if position == gtk.POS_TOP or position == gtk.POS_BOTTOM: box = gtk.VBox() else: box = gtk.HBox() if position == gtk.POS_TOP or position == gtk.POS_LEFT: box.pack_start(img, False) if label: box.pack_start(lbl, False) elif position == gtk.POS_BOTTOM or position == gtk.POS_RIGTH: if label: box.pack_start(lbl, False) box.pack_start(img, False) self.add(box) self.show_all() if __name__ == "__main__": from test import TestWindow import os path = os.path.join(os.path.dirname(__file__), "cancel.png") imagebtn = ImageButton(path) imagebtn2 = ImageButton(path, label="Cancelar") win = TestWindow() hbox = gtk.HBox() hbox.pack_start(imagebtn) hbox.pack_start(imagebtn2) win.add(hbox) win.start()
self.add(self.__treeview) def get_selected(self): treeselection = self.__treeview.get_selection() (model, pathlist) = treeselection.get_selected_rows() return pathlist def select(self, index): """ selecciona el indice recibido """ treeselection = self.__treeview.get_selection() treeselection.select_path((index,)) def unselect_all(self): treeselection = self.__treeview.get_selection() treeselection.unselect_all() if __name__ == "__main__": from test import TestWindow list = [] for i in range(15):list.append("item %s"%i) win = TestWindow() select = SelectMultiple(list) win.add(select) win.start()
""" conecta una senial con la funcion obtenida """ self.__treeview.connect(signal, callback) def set_focus(self): """ pone el focus en el treeview """ self.__treeview.grab_focus() if __name__ == "__main__": from test import TestWindow sample_list = ( ("Texto 1", 100), ("Texto2", 300), ("Entero", 100, gobject.TYPE_INT), ("Flotante", 50, gobject.TYPE_FLOAT), ) row = ("texto 1", "Texto 2", 5, 300.5) win = TestWindow() datalist = DataList(sample_list) datalist.add_row(row) win.add(datalist) win.start()
def connect_signal(self, signal, callback): """ conecta una senial con la funcion obtenida """ self.__treeview.connect(signal, callback) def set_focus(self): """ pone el focus en el treeview """ self.__treeview.grab_focus() if __name__ == "__main__": from test import TestWindow sample_list = ( ("Texto 1", 100), ("Texto2", 300), ("Entero", 100, gobject.TYPE_INT), ("Flotante", 50, gobject.TYPE_FLOAT), ) row = ("texto 1", "Texto 2", 5, 300.5) win = TestWindow() datalist = DataList(sample_list) datalist.add_row(row) win.add(datalist) win.start()