def __init__(self, dg=Delegate(), ds=DataSource()): # setting the delegate and datasource self.dg = dg self.ds = ds # calling the super class's constructor gtk.ScrolledWindow.__init__(self) # building the ui self._list = gtk.List() # set to single selection self._list.set_selection_mode(1) # add a selection signal handler self._list.connect('button_release_event', self.item_clicked) # add list to scrolled window self.add_with_viewport(self._list)
def __init__(self): #Fenster erstellen self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("SVN Manager") self.window.connect("destroy", self.destroy_event, None) self.window.set_border_width(10) #VBox erstellen vbox = gtk.HBox(spacing=5, homogeneous=False) #Liste mit Repos erstellen self.repoList = gtk.List() i1 = gtk.ListItem("test") i1.show() i2 = gtk.ListItem("test2") i2.show() self.repoList.append_items([i1, i2]) self.repoList.show() vbox.add(self.repoList) #Controls erstellen control_box = gtk.VBox() add_button = gtk.Button("Add") add_button.show() add_button.connect("button-press-event", self.add_clicked, None) del_button = gtk.Button("Del") del_button.show() del_button.connect("button-press-event", self.del_clicked, None) control_box.add(add_button) control_box.add(del_button) control_box.show() remove_button = gtk.Button("Del") remove_button.show() remove_button.connect("button-press-event", self.del_clicked, None) control_box.add(remove_button) control_box.show() vbox.add(control_box) vbox.show() #Fenster anzeigen self.window.add(vbox) self.window.show() print "Test"
def __mk_left_vbox(self): self.left_vbox = gtk.VBox(homogeneous=False, spacing=0) self.new_sprite_button = gtk.Button("New sprite from selection") self.new_sprite_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.new_sprite_click, args)) self.left_vbox.pack_start(self.new_sprite_button, expand=False, fill=False, padding=0) self.add_to_selected_sprite_button = gtk.Button( "Add to selected sprite") self.add_to_selected_sprite_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.add_to_selected_sprite_click, args)) self.left_vbox.pack_start(self.add_to_selected_sprite_button, expand=False, fill=False, padding=0) self.load_image_button = gtk.Button("Load image") self.load_image_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.load_image_click, args)) self.left_vbox.pack_start(self.load_image_button, expand=False, fill=False, padding=0) self.images_label = gtk.Label("Source images") self.scrolled_window = gtk.ScrolledWindow() self.gtklist = gtk.List() self.gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.image_list_selection_changed, args)) self.scrolled_window.add_with_viewport(self.gtklist) self.left_vbox.pack_start(self.images_label, expand=False, fill=False, padding=0) self.left_vbox.pack_start(self.scrolled_window, expand=True, fill=True, padding=0) self.image_delete_button = gtk.Button("Delete image") self.image_delete_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.delete_image_button_click, None)) self.left_vbox.pack_start(self.image_delete_button, expand=False, fill=False, padding=0) self.sprites_label = gtk.Label("Sprites") self.sp_scrolled_window = gtk.ScrolledWindow() self.sp_gtklist = gtk.List() self.sp_gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.sprites_selection_changed, args)) self.sp_scrolled_window.add_with_viewport(self.sp_gtklist) self.left_vbox.pack_start(self.sprites_label, expand=False, fill=False, padding=0) self.left_vbox.pack_start(self.sp_scrolled_window, expand=True, fill=True, padding=0) self.sprite_delete_button = gtk.Button("Delete sprite") self.sprite_delete_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.sprite_delete_button_click, None)) self.left_vbox.pack_start(self.sprite_delete_button, expand=False, fill=False, padding=0)
def __mk_right_vbox(self): self.right_vbox = gtk.VBox(homogeneous=False, spacing=0) self.sprite_label = gtk.Label("Sprite images") self.sprite_window = gtk.ScrolledWindow() self.sprite_gtklist = gtk.List() self.sprite_gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.sprite_elements_list_selection_changed, args)) self.sprite_window.add_with_viewport(self.sprite_gtklist) self.sprite_updown_hbox = gtk.HBox(homogeneous=False, spacing=0) self.sprite_up_button = gtk.Button(u"▲") self.sprite_down_button = gtk.Button(u"▼") self.sprite_up_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.sprite_image_up_click, args)) self.sprite_down_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.sprite_image_down_click, args)) self.sprite_updown_hbox.pack_start(self.sprite_up_button, expand=True, fill=True, padding=0) self.sprite_updown_hbox.pack_start(self.sprite_down_button, expand=True, fill=True, padding=0) self.right_vbox.pack_start(self.sprite_label, expand=False, fill=False, padding=0) self.right_vbox.pack_start(self.sprite_window, expand=True, fill=True, padding=0) self.right_vbox.pack_start(self.sprite_updown_hbox, expand=False, fill=False, padding=0) self.sprite_image_remove_button = gtk.Button( "Remove image from sprite") self.sprite_image_remove_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.sprite_image_remove_button_click, None)) self.right_vbox.pack_start(self.sprite_image_remove_button, expand=False, fill=False, padding=0) self.tool_label = gtk.Label("General settings") self.right_vbox.pack_start(self.tool_label, expand=False, fill=False, padding=0) settings_lst = state.get_settings_list() if settings_lst != None: print settings_lst for s in settings_lst: dct = {} if s.type == "int": w = self.__mk_labeled_spin(dct, s.display_name, s, None, s.default, s.min, s.max) self.right_vbox.pack_start(w, expand=False, fill=False, padding=0) self.settings_vb = gtk.VBox(homogeneous=False, spacing=0) self.right_vbox.pack_start(self.settings_vb, expand=False, fill=False, padding=0)
def del_clicked(self, widget, event, data=None): sel = self.repoList.get_selection() self.repoList.remove_items(sel) gtk.List() print "Delete clicked"
def __mk_left_vbox(self): self.left_vbox = gtk.VBox(homogeneous=False, spacing=0) self.sprites_label = gtk.Label("Sprites") self.sp_scrolled_window = gtk.ScrolledWindow() self.sp_gtklist = gtk.List() self.sp_gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.sprites_selection_changed, args)) self.sp_scrolled_window.add_with_viewport(self.sp_gtklist) self.left_vbox.pack_start(self.sprites_label, expand=False, fill=False, padding=0) self.left_vbox.pack_start(self.sp_scrolled_window, expand=True, fill=True, padding=0) self.sprite_put_button = gtk.Button("Put sprite") self.sprite_put_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.sprite_put_button_click, None)) self.sprite_put_button.set_sensitive(False) self.left_vbox.pack_start(self.sprite_put_button, expand=False, fill=False, padding=0) self.layer_label = gtk.Label("Layers") self.l_scrolled_window = gtk.ScrolledWindow() self.l_gtklist = gtk.List() self.l_gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.general_selection_changed, { "lst": args, "callback": ep.layers_selection_changed, "enumerable": state.get_layers() })) self.l_scrolled_window.add_with_viewport(self.l_gtklist) self.left_vbox.pack_start(self.layer_label, expand=False, fill=False, padding=0) self.left_vbox.pack_start(self.l_scrolled_window, expand=True, fill=True, padding=0) self.layer_add_button = gtk.Button("Add layer") self.layer_add_button.connect( "clicked", lambda *args: ep.push_event(EVEnum.layer_add_button_click, None)) self.left_vbox.pack_start(self.layer_add_button, expand=False, fill=False, padding=0) self.layer_remove_button = gtk.Button("Delete layer") self.layer_remove_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.layer_delete_button_click, None)) self.left_vbox.pack_start(self.layer_remove_button, expand=False, fill=False, padding=0)
def __mk_right_vbox(self): self.right_vbox = gtk.VBox(homogeneous=False, spacing=0) self.general_settings_vb = gtk.VBox(homogeneous=False, spacing=0) self.update_general_settings() self.right_vbox.pack_start(self.general_settings_vb, expand=False, fill=False, padding=0) self.settings_vb = gtk.VBox(homogeneous=False, spacing=0) self.right_vbox.pack_start(self.settings_vb, expand=False, fill=False, padding=0) self.layer_objects_label = gtk.Label("Layer objects") self.lo_scrolled_window = gtk.ScrolledWindow() self.lo_gtklist = gtk.List() self.lo_gtklist.connect( "selection_changed", lambda *args: ep.push_event( EVEnum.general_selection_changed, { "lst": args, "callback": ep.layer_objects_selection_changed, "enumerable": state.get_active_layer().get_proxy_lst() })) self.lo_scrolled_window.add_with_viewport(self.lo_gtklist) self.right_vbox.pack_start(self.layer_objects_label, expand=False, fill=False, padding=0) self.right_vbox.pack_start(self.lo_scrolled_window, expand=True, fill=True, padding=0) self.layer_object_add_button = gtk.Button("Add meta") self.layer_object_add_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.layer_object_add_meta_button_click, None)) self.layer_object_add_button.set_sensitive(False) self.right_vbox.pack_start(self.layer_object_add_button, expand=False, fill=False, padding=0) self.layer_set_child_button = gtk.Button("Set child") self.layer_set_child_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.layer_set_child_button_click, None)) self.layer_set_child_button.set_sensitive(False) self.right_vbox.pack_start(self.layer_set_child_button, expand=False, fill=False, padding=0) self.layer_delete_object_button = gtk.Button("Delete object") self.layer_delete_object_button.connect( "clicked", lambda *args: ep.push_event( EVEnum.layer_delete_object_button_click, None)) self.right_vbox.pack_start(self.layer_delete_object_button, expand=False, fill=False, padding=0)
def __init__(self): self.logger = logging.getLogger('openmwmm.manager') # Create the main window. self.window = gtk.Window() self.window.set_title('OpenMW Mods') self.window.connect('destroy', gtk.main_quit) mb = gtk.MenuBar() # Create a file menu. filemenu = gtk.Menu() filem = gtk.MenuItem('File') filem.set_submenu(filemenu) importm = gtk.MenuItem('Import mod...') importm.connect('activate', self.on_import) filemenu.append(importm) exitm = gtk.MenuItem('Exit') exitm.connect('activate', gtk.main_quit) filemenu.append(exitm) mb.append(filem) # Create a mod menu. modmenu = gtk.Menu() modm = gtk.MenuItem('Mod') modm.set_submenu(modmenu) installm = gtk.MenuItem('Install...') installm.connect('activate', self.on_install) modmenu.append(installm) removem = gtk.MenuItem('Remove...') removem.connect('activate', self.on_remove) modmenu.append(removem) mb.append(modm) # Create the available mods list. self.mods_available = gtk.List() self.mods_available.connect('selection_changed', self.on_mod_selection) mods_available_scroller = gtk.ScrolledWindow() mods_available_scroller.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC mods_available_scroller.add_with_viewport(self.mods_available) # Create the installed mods list. self.mods_installed = gtk.List() mods_installed_scroller = gtk.ScrolledWindow() mods_installed_scroller.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC mods_installed_scroller.add_with_viewport(self.mods_installed) hbox = gtk.HBox(False, 2) hbox.pack_start(mods_available_scroller, True, True, 0) hbox.pack_start(mods_installed_scroller, True, True, 0) # TODO: Allow loading data dir from menu or config. self.datadir = openmwmm.datadir.DataDir( os.path.join(os.path.expanduser('~'), '.config', 'openmw')) self.show_mods() vbox = gtk.VBox(False, 2) vbox.pack_start(mb, False, False, 0) vbox.pack_start(hbox, True, True, 0) self.window.add(vbox) self.window.show_all() gtk.main()
def __init__(self, extension): super(List, self).__init__(extension) self.widget = gtk.List()