hackloper775

Grid Gtk

Oct 22nd, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. from gi.repository import Gtk
  2.  
  3. class Ejemplo(Gtk.Window):
  4.  
  5.     def __init__(self):
  6.         Gtk.Window.__init__(self, title="Ejemplo")
  7.  
  8.         grid = Gtk.Grid()
  9.         self.add(grid) # Añadimos el grid a la ventana
  10.  
  11.         self.btn = Gtk.Button(label="Boton 1")
  12.         self.btn2 = Gtk.Button(label="Boton 2")
  13.         self.btn3 = Gtk.Button(label="Boton 3")
  14.  
  15.         grid.add(self.btn) # Añadimos el boton a la grid
  16.         grid.attach_next_to(self.btn2, self.btn, Gtk.PositionType.BOTTOM, 1, 1) # Añadimos el boton dos abajo del boton 1
  17.         grid.attach_next_to(self.btn3, self.btn, Gtk.PositionType.LEFT, 1,2) # Añadimos el boton tres al lado izquierdo del boton uno con tamaño de dos botones en altura.
  18.  
  19. ejem = Ejemplo()
  20. ejem.connect("delete-event", Gtk.main_quit)
  21. ejem.show_all()
  22. Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment