def __init__(self, layout): super(OcPage, self).__init__(False, 10) self.oc_widgets = {} for ir, item_row in enumerate(layout[2]): hbox = gtk.HBox(False) if ir == (len(layout[2]) - 1): hbox.pack_start(gtk.Label(), True, False) for i, item in enumerate(item_row): # check to create item via gtk basic class # or via comstum functions which is callable if callable(item['type']): if item.get('params'): _item = item['type'](item['params']) else: _item = item['type']() item['type'] = 'custom' else: _item = self._create_item(item) _item.get_conf = item.get('get_conf', None) _item.get_conf_args = item.get('get_conf_args', None) _item.set_conf = item.get('set_conf', None) _item.conf_path = item.get('conf_path', None) new_attr(self, item['name'] + '_' + item['type'], _item) self.oc_widgets['%s_%s' % (item['name'], item['type'])] = _item if isinstance(_item, DetailedList): hbox.set_size_request(OC_DEFAULT, OC_DETAILEDLIST_HEIGHT) if item.get('vhelp'): hbox.set_size_request(OC_DEFAULT, item['vhelp']) # We need to set 'DOUBLE ALIGMENT HERE:' # first sets the alignment of text inside the hbox label. # then, sets the the alignment of label inside the hbox. # and finally, pack the widget into the hbox. if hasattr(_item, 'set_alignment'): if isinstance(_item, gtk.Entry): _item.set_alignment(OC_ALIGNMENT_CONTENT_X) else: _item.set_alignment(OC_ALIGNMENT_CONTENT_X, OC_ALIGNMENT_CONTENT_Y) alig = gtk.Alignment() alig.add(_item) if item.get('title'): alig.set_padding(0, 0, OC_PADDING_TITLE, 0) else: if i == 0: alig.set_padding(0, 0, OC_PADDING_CONTENT_FIRST, 0) else: alig.set_padding(0, 0, OC_PADDING_CONTENT_NEXT, 0) if isinstance(_item, (gtk.CheckButton, DetailedList)): alig.set(0, 0, 1, 1) alig.set_padding(0, 0, OC_PADDING_LIST, OC_PADDING_LIST) hbox.pack_start(alig, True, True) else: hbox.pack_start(alig, False, False) self.pack_start(hbox, False, False, padding=OC_PAGE_WIDGET_HPADDING)
def __init__(self, layout): super(OcPage, self).__init__(False, 10) self.oc_widgets = {} for ir, item_row in enumerate(layout[2]): hbox = gtk.HBox(False) if ir == (len(layout[2]) - 1): hbox.pack_start(gtk.Label(), True, False) for i, item in enumerate(item_row): # check to create item via gtk basic class # or via comstum functions which is callable if callable(item['type']): if item.get('params'): _item = item['type'](item['params']) else: _item = item['type']() item['type'] = 'custom' else: _item = self._create_item(item) _item.get_conf = item.get('get_conf', None) _item.get_conf_args = item.get('get_conf_args', None) _item.set_conf = item.get('set_conf', None) _item.conf_path = item.get('conf_path', None) new_attr(self, item['name'] + '_' + item['type'], _item) self.oc_widgets['%s_%s' % (item['name'], item['type'])] = _item if isinstance(_item, DetailedList): hbox.set_size_request(OC_DEFAULT, OC_DETAILEDLIST_HEIGHT) if item.get('vhelp'): hbox.set_size_request(OC_DEFAULT, item['vhelp']) # We need to set 'DOUBLE ALIGMENT HERE:' # first sets the alignment of text inside the hbox label. # then, sets the the alignment of label inside the hbox. # and finally, pack the widget into the hbox. if hasattr(_item, 'set_alignment'): if isinstance(_item, gtk.Entry): _item.set_alignment(OC_ALIGNMENT_CONTENT_X) else: _item.set_alignment(OC_ALIGNMENT_CONTENT_X, OC_ALIGNMENT_CONTENT_Y) alig = gtk.Alignment() alig.add(_item) if item.get('title'): alig.set_padding(0, 0, OC_PADDING_TITLE, 0) else: if i == 0: alig.set_padding(0, 0, OC_PADDING_CONTENT_FIRST, 0) else: alig.set_padding(0, 0, OC_PADDING_CONTENT_NEXT, 0) if isinstance(_item, (gtk.CheckButton, DetailedList)): alig.set(0, 0, 1, 1) alig.set_padding(0, 0, OC_PADDING_LIST, OC_PADDING_LIST) hbox.pack_start(alig, True, True) else: hbox.pack_start(alig, False, False) self.pack_start( hbox, False, False, padding=OC_PAGE_WIDGET_HPADDING)
def __init__(self, obj, path, row): super(NetworkDetailWindows, self).__init__(gtk.WINDOW_TOPLEVEL) self.set_position(gtk.WIN_POS_CENTER) self.set_default_size(OC_WIDTH, OC_HEIGHT) from ocsetup_ui import NetworkDetail page_layout = NetworkDetail(obj.treeview_datas[path[0]]) page = OcPage(page_layout) new_attr(self, 'page_' + page_layout[0], page) self.add(page) datautil.datas_refresh(page.oc_widgets) self.show_all()
def __init__(self, pages): self.window = gtk.Window() self.window.set_default_size(OC_WIDTH, OC_HEIGHT) self.window.set_position(gtk.WIN_POS_CENTER) self.vbox = gtk.VBox(False, 1) self.notebook = gtk.Notebook() self.notebook.set_tab_pos(gtk.POS_LEFT) self.notebook.connect(GTK_SIGNAL_SWITCH_PAGE, self._handle_switch_page) self.notebook.set_size_request(OC_NOTEBOOK_WIDTH, OC_NOTEBOOK_HEIGHT) self.notebook.set_show_border(False) self.shell = ShellWindow( self.window, confirm=True, confirm_msg="Are you sure to use shell?") self.logger = LogWindow(self.window) self.pages = {} # Get Plugins from path `OVIRT_PLUGINS_PATH` #sys.path.append(OVIRT_PLUGINS_PATH) for plugins in os.walk(OVIRT_PLUGINS_PATH): for plugin_filename in plugins[2]: if plugin_filename.endswith('.py'): try: plugin = __import__(plugin_filename[:-3]).get_plugin() if plugin: pages.append(plugin) except: pass for page in pages: tab = gtk.Label(page[1]) new_attr(self, 'tab_' + page[0], tab) tab.set_size_request(OC_NOTEBOOK_TAB_WIDTH, OC_NOTEBOOK_TAB_HEIGHT) # we need to call _create_page to create self.xxx_page _page = new_attr(self, 'page_' + page[0], self._create_page(page)) self.notebook.append_page(_page, tab) header_img = ColorLabel('', OC_HEADER_BG) header_img.set_size_request(OC_WIDTH, OC_HEADER_HEIGHT) footer_img = ColorLabel('', OC_FOOTER_BG) footer_img.set_size_request(OC_WIDTH, OC_FOOTER_HEIGHT) self.vbox.pack_start(header_img, False, False) self.vbox.pack_start(self.notebook, False, False) self.vbox.pack_start(footer_img, True, True) self.window.add(self.vbox) self.window.connect(GTK_SIGNAL_DESTROY, lambda w: gtk.main_quit()) self.window.show_all()
def __init__(self, pages): self.window = gtk.Window() self.window.set_default_size(OC_WIDTH, OC_HEIGHT) self.window.set_position(gtk.WIN_POS_CENTER) self.vbox = gtk.VBox(False, 1) self.notebook = gtk.Notebook() self.notebook.set_tab_pos(gtk.POS_LEFT) self.notebook.connect(GTK_SIGNAL_SWITCH_PAGE, self._handle_switch_page) self.notebook.set_size_request(OC_NOTEBOOK_WIDTH, OC_NOTEBOOK_HEIGHT) self.notebook.set_show_border(False) self.shell = ShellWindow(self.window, confirm=True, confirm_msg="Are you sure to use shell?") self.logger = LogWindow(self.window) self.pages = {} # Get Plugins from path `OVIRT_PLUGINS_PATH` #sys.path.append(OVIRT_PLUGINS_PATH) for plugins in os.walk(OVIRT_PLUGINS_PATH): for plugin_filename in plugins[2]: if plugin_filename.endswith('.py'): try: plugin = __import__(plugin_filename[:-3]).get_plugin() if plugin: pages.append(plugin) except: pass for page in pages: tab = gtk.Label(page[1]) new_attr(self, 'tab_' + page[0], tab) tab.set_size_request(OC_NOTEBOOK_TAB_WIDTH, OC_NOTEBOOK_TAB_HEIGHT) # we need to call _create_page to create self.xxx_page _page = new_attr(self, 'page_' + page[0], self._create_page(page)) self.notebook.append_page(_page, tab) header_img = ColorLabel('', OC_HEADER_BG) header_img.set_size_request(OC_WIDTH, OC_HEADER_HEIGHT) footer_img = ColorLabel('', OC_FOOTER_BG) footer_img.set_size_request(OC_WIDTH, OC_FOOTER_HEIGHT) self.vbox.pack_start(header_img, False, False) self.vbox.pack_start(self.notebook, False, False) self.vbox.pack_start(footer_img, True, True) self.window.add(self.vbox) self.window.connect(GTK_SIGNAL_DESTROY, lambda w: gtk.main_quit()) self.window.show_all()