Simple windowed application: Difference between revisions

Content added Content deleted
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;
}</c>
}</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:
}
}
}
}
</csharp>
</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);
}</d>
}</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();
}
}
}</d>
}</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
</delphi>
</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:
}
}
}</java>
}</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();</perl>
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;</perl>
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()</python>
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()</python>
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()</python>
app.exec_loop()</lang>


{{libheader|wxPython}}
{{libheader|wxPython}}