Python-Ref > GUI programming with PyGTK > Widgets > Stock buttons
 
 

<-^^->
Klíčová slova
Moduly
Knihovní funkce

Stock buttons

How to use built-in buttons.
There are many built-in items in the GTK that can be used when building a GUI. Usage of such items makes your GUI more visually compatible with the rest of the GTK applications and also allows user defined styling because the individual stock items are themable.
Expand/Shrink
Rozdíl proti: gtk4-1.py
@@ -28,12 +28,12 @@
     self.button_box = gtk.HBox()
     self.mainbox.pack_end( self.button_box)
     # first button
-    button = gtk.Button( "Press me")
+    button = gtk.Button( stock=gtk.STOCK_OK) 
     button.connect( "clicked", self.button1_clicked)
     self.button_box.pack_start( button)
     button.show()
     # second button
-    button = gtk.Button( "Big red button")
+    button = gtk.Button( stock=gtk.STOCK_STOP) 
     button.connect( "clicked", self.red_button_clicked)
     self.button_box.pack_start( button)
     button.show()
@@ -56,5 +56,5 @@
 if __name__ == "__main__":
-  m = MyGUI( "Buttons")
+  m = MyGUI( "Buttons II.")
   m.main()
stdout:
Good bye...
Screenshot:
Program screenshot gtk-buttons2-1.png
Doba běhu: 3695.5 ms
For an overview of available stock items see Image.