Advertisement
hackloper775

toggle gtk

Oct 22nd, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. from gi.repository import Gtk
  2.  
  3. class Ejemplo(Gtk.Window):
  4.     def __init__(self):
  5.         Gtk.Window.__init__(self,title="Que sistema usas?")
  6.         self.set_border_width(10)
  7.         hbox = Gtk.Box(spacing=6)
  8.         self.add(hbox)
  9.        
  10.         rb1 = Gtk.RadioButton(label="Ubuntu",group=None)
  11.         rb1.connect("toggled", self.clic, "Ubuntu")
  12.         hbox.pack_start(rb1, False, False, 0)
  13.        
  14.         rb2 = Gtk.RadioButton.new_from_widget(rb1)
  15.         rb2.set_label("Windows")
  16.         rb2.connect("toggled", self.clic, "Windows")        
  17.         hbox.pack_start(rb2, False, False, 0)
  18.        
  19.         rb3 = Gtk.RadioButton.new_from_widget(rb1)
  20.         rb3.set_label("MacOSX")
  21.         rb3.connect("toggled", self.clic, "MacOSX")
  22.         hbox.pack_start(rb3, False, False, 0)
  23.        
  24.         rb3 = Gtk.RadioButton.new_from_widget(rb1)
  25.         rb3.set_label("Ninguno")
  26.         rb3.connect("toggled", self.clic, "ninguno")
  27.         hbox.pack_start(rb3, False, False, 0)
  28.    
  29.     def clic(self,boton,sistema):
  30.         if boton.get_active():
  31.             if sistema == "ninguno":
  32.                 print "No usas ninguno"
  33.             else:
  34.                 print "Usas " + sistema + " :O"
  35.  
  36. ejem =  Ejemplo()
  37.  
  38. ejem.connect("delete-event",Gtk.main_quit)
  39.  
  40. ejem.show_all()
  41.  
  42. Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement