Simple windowed application: Difference between revisions
Content added Content deleted
(→{{header|Python}}: wxPython) |
No edit summary |
||
Line 79: | Line 79: | ||
{{libheader|GTK+}} |
{{libheader|GTK+}} |
||
<c>#include <stdio.h> |
<lang c>#include <stdio.h> |
||
#include <gtk/gtk.h> |
#include <gtk/gtk.h> |
||
Line 118: | Line 118: | ||
gtk_main(); |
gtk_main(); |
||
return 0; |
return 0; |
||
}</ |
}</lang> |
||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
{{works with|C sharp|C#|2.0+}} |
{{works with|C sharp|C#|2.0+}} |
||
{{libheader|System.Windows.Forms}} |
{{libheader|System.Windows.Forms}} |
||
<csharp> |
<lang csharp> |
||
using System.Windows.Forms; |
using System.Windows.Forms; |
||
Line 160: | Line 160: | ||
} |
} |
||
} |
} |
||
</ |
</lang> |
||
=={{header|D}}== |
=={{header|D}}== |
||
Line 166: | Line 166: | ||
{{works with|D|1}} |
{{works with|D|1}} |
||
{{libheader|DFL}} |
{{libheader|DFL}} |
||
<d>module winapp ; |
<lang d>module winapp ; |
||
import dfl.all ; |
import dfl.all ; |
||
import std.string ; |
import std.string ; |
||
Line 196: | Line 196: | ||
void main() { |
void main() { |
||
Application.run(new MainForm); |
Application.run(new MainForm); |
||
}</ |
}</lang> |
||
===Hybrid=== |
===Hybrid=== |
||
Line 218: | Line 218: | ||
} |
} |
||
SimpleWindow.d: |
SimpleWindow.d: |
||
<d>module SimpleWindow; |
<lang d>module SimpleWindow; |
||
import tango.text.convert.Integer; |
import tango.text.convert.Integer; |
||
import tango.core.Thread; // For Thread.yield |
import tango.core.Thread; // For Thread.yield |
||
Line 253: | Line 253: | ||
Thread.yield(); |
Thread.yield(); |
||
} |
} |
||
}</ |
}</lang> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 263: | Line 263: | ||
'''NOTE:''' The project name here must match the name of the file. |
'''NOTE:''' The project name here must match the name of the file. |
||
<delphi> |
<lang delphi> |
||
-- begin file -- |
-- begin file -- |
||
Line 351: | Line 351: | ||
end. // Program |
end. // Program |
||
</ |
</lang> |
||
=={{header|E}}== |
=={{header|E}}== |
||
Line 485: | Line 485: | ||
{{libheader|AWT}} |
{{libheader|AWT}} |
||
{{libheader|Swing}} |
{{libheader|Swing}} |
||
<java>import java.awt.BorderLayout; |
<lang java>import java.awt.BorderLayout; |
||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||
Line 519: | Line 519: | ||
} |
} |
||
}</ |
}</lang> |
||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
Line 538: | Line 538: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
<perl> use Tk; |
<lang perl> use Tk; |
||
$main = MainWindow->new; |
$main = MainWindow->new; |
||
Line 547: | Line 547: | ||
-command => sub { $l->configure(-text => 'Number of clicks: '.(++$count).'.'); }, |
-command => sub { $l->configure(-text => 'Number of clicks: '.(++$count).'.'); }, |
||
)->pack; |
)->pack; |
||
MainLoop();</ |
MainLoop();</lang> |
||
{{libheader|GTK}} |
{{libheader|GTK}} |
||
<perl> use Gtk '-init'; |
<lang perl> use Gtk '-init'; |
||
# Window. |
# Window. |
||
Line 576: | Line 576: | ||
# Main loop. |
# Main loop. |
||
Gtk->main;</ |
Gtk->main;</lang> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{libheader|Tkinter}} |
{{libheader|Tkinter}} |
||
<python>from Tkinter import Tk, Label, Button |
<lang python>from Tkinter import Tk, Label, Button |
||
def update_label(): |
def update_label(): |
||
Line 593: | Line 593: | ||
l.pack() |
l.pack() |
||
Button(w, text="click me", command=update_label).pack() |
Button(w, text="click me", command=update_label).pack() |
||
w.mainloop()</ |
w.mainloop()</lang> |
||
===The same in OO manner=== |
===The same in OO manner=== |
||
<python>#!/usr/bin/env python |
<lang python>#!/usr/bin/env python |
||
from Tkinter import Button, Frame, Label, Pack |
from Tkinter import Button, Frame, Label, Pack |
||
Line 616: | Line 616: | ||
if __name__=="__main__": |
if __name__=="__main__": |
||
ClickCounter().mainloop()</ |
ClickCounter().mainloop()</lang> |
||
{{libheader|PyQt}} |
{{libheader|PyQt}} |
||
<python>import sys |
<lang python>import sys |
||
from qt import * |
from qt import * |
||
Line 637: | Line 637: | ||
win.show() |
win.show() |
||
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) |
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) |
||
app.exec_loop()</ |
app.exec_loop()</lang> |
||
{{libheader|wxPython}} |
{{libheader|wxPython}} |