23 avril 2008
PyGTK : Windows : Creation of a basic window
The class used to create windows is :
gtk.Window(windows_type)
Attirbute windows_type can take two values :
gtk.WINDOW_TOPLEVEL
Create a complete window composed of the active party, the bar of title, of the borders
gtk.WINDOW_POPUP
In the opposite, this parameter means that alone active part will be visible
Code :
#!/usr/bin/env python
# -*- Encoding: Latin-1 -*-
import pygtk
pygtk.require('2.0')
import gtk
def fenetre():
fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL)
fenetre.set_default_size(400, 200)
fenetre.show_all()
gtk.main()
if __name__ == '__main__':
fenetre()
Result :
Quelques explications :
fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL)
This line allows to call the class gtk.Window()
fenetre.set_default_size(400, 200)
Here, method set_default_size (width, height) allows to give a width and a height (in pixels) in the window
fenetre.show_all()
Method show_all() allows to show the widget (here, the window) and all widgets children
In order to do that, it is necessary that the parent is a container
Commentaires
Poster un commentaire
Rétroliens
URL pour faire un rétrolien vers ce message :
http://www.canalblog.com/cf/fe/tb/?bid=287253&pid=8923322
Liens vers des weblogs qui référencent ce message :






