class command_dialog(Window): def __init__(self, icon): Window.__init__(self, WINDOW_TOPLEVEL) self.set_property("skip-taskbar-hint", True) self.set_property("destroy-with-parent", True) self.set_modal(True) self.set_position(WIN_POS_CENTER) self.vbox = VBox(False, 0) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.terminal.show() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.vbox.pack_start(self.terminal, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.vbox.show() self.add(self.vbox) self.set_icon(pixbuf_new_from_file(icon)) def run(self, command): self.show() self.terminal.fork_command() self.terminal.feed_child("pacman --noconfirm -%s;exit\n" %command)
class DirCombo(HBox): def __init__(self, dir=None): HBox.__init__(self, False, 2) buttonImage = Image() buttonImage.set_from_stock(STOCK_REFRESH, ICON_SIZE_MENU) self.combo = ComboBox() self.refreshButton = Button() self.refreshButton.set_image(buttonImage) self.refreshButton.connect('clicked', self.refreshButton_clicked, None) self.model = ListStore(str) self.combo.set_model(self.model) self.dir = dir self.pack_start(self.combo, False, False, 0) self.pack_start(self.refreshButton, False, False, 0) if self.dir != None and exists(self.dir): self.refresh() def refresh(self): self.combo.clear() self.model.clear() list = listdir(self.dir) cell = CellRendererText() self.combo.pack_start(cell, True) self.combo.add_attribute(cell, 'text', 0) for i in list: if i[0] != '.' and isdir(join(self.dir, i)) == True: self.model.append([i]) def refreshButton_clicked(self, widget, data): self.refresh()
def __init__(self): ''' Constructor ''' cellRendererText = CellRendererText() treeViewColumn = TreeViewColumn() treeViewColumn.pack_start(cellRendererText) treeView = TreeView() treeView.append_column(treeViewColumn) scrolledWindow = ScrolledWindow() scrolledWindow.add(treeView) btnAdd_Alternative = Button() btnDel_Alternative = Button() hButtonBox = HButtonBox() hButtonBox.pack_start(btnAdd_Alternative) hButtonBox.pack_start(btnDel_Alternative) vBox = VBox() vBox.pack_start(scrolledWindow) vBox.pack_start(hButtonBox) self.add(vBox)
def __init__(self, item, name='ItemButton'): HBox.__init__(self) self.set_name(name) self._key_, self._val_ = item self.label = Label(self._key_) self.button = Button(label=self._val_) self.pack_start(self.label, 0, 0, 0) self.pack_end(self.button, 1, 1, 5) map(lambda x: x.show(), [self.label, self.button]) self.show()
def __init__(self, name='UDBar'): HBox.__init__(self) self.set_name(name) self.ubutton = Button('update') self.dbutton = Button('diff') self.pack_start(self.ubutton, 0, 0, 0) self.pack_end(self.dbutton, 0, 0, 0) self.ubutton.show() self.dbutton.show() self.show()
def __init__(self): HBox.__init__(self) MDSplusWidget.__init__(self) HBox.set_homogeneous(self, False) self.node_state = CheckButton('') self.button = Button() HBox.pack_start(self, self.node_state, False, False, 0) HBox.pack_start(self, self.button, False, False, 0) HBox.pack_start(self, Label(''), True, False, 0) if not guibuilder: self.button.connect("clicked", self.popupXd) self.button.connect("realize", self.setButtonLabel)
def __init__(self, name='TraitBar'): HBox.__init__(self) self.set_name(name) self.lcombo = MyCombo() self.rcombo = MyCombo() self.lcombo.set('') self.rcombo.set('') self.cbutton = Button('clear') self.cbutton.show() self.pack_start(self.lcombo, 0, 0, 0) self.pack_end(self.rcombo, 0, 0, 0) self.add(self.cbutton) self.show()
def __init__(self, name='GenDialog'): gtkDialog.__init__(self) self.set_name(name) self.ok_button = Button('ok', 'gtk-ok') self.ok_button.set_name(name) self.cancel_button = Button('cancel', 'gtk-cancel') self.cancel_button.set_name(name) self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0) self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0) self.ok_button.show() self.cancel_button.show() self.cancel_button.connect('clicked', lambda *x: self.destroy()) self._buttons_ = {} self.show()
def __init__(self, name='GenDialog'): gtkDialog.__init__(self) self.set_name(name) self.ok_button = Button('ok', 'gtk-ok') self.ok_button.set_name(name) self.cancel_button = Button('cancel', 'gtk-cancel') self.cancel_button.set_name(name) self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0) self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0) self.ok_button.show() self.cancel_button.show() self.cancel_button.connect('clicked', lambda *x : self.destroy()) self._buttons_ = {} self.show()
class TraitBar(HBox): def __init__(self, name='TraitBar'): HBox.__init__(self) self.set_name(name) self.lcombo = MyCombo() self.rcombo = MyCombo() self.lcombo.set('') self.rcombo.set('') self.cbutton = Button('clear') self.cbutton.show() self.pack_start(self.lcombo, 0, 0, 0) self.pack_end(self.rcombo, 0, 0, 0) self.add(self.cbutton) self.show()
class ItemButton(HBox): def __init__(self, item, name='ItemButton'): HBox.__init__(self) self.set_name(name) self._key_, self._val_ = item self.label = Label(self._key_) self.button = Button(label=self._val_) self.pack_start(self.label,0,0,0) self.pack_end(self.button,1,1,5) map(lambda x: x.show(), [self.label, self.button]) self.show() def set(self, text): self._val_ = text self.button.set_label(self._val_)
def __init__(self): from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator self.window = Window(WINDOW_TOPLEVEL) self.window.set_title("Slideshow") self.window.connect("delete_event", self.delete_event) self.window.set_border_width(10) self.vbox = VBox(False, 0) self.window.add(self.vbox) self.hbox1 = HBox(False, 0) self.vbox.pack_start(self.hbox1, True, True, 1) self.hbox = HBox(False, 0) self.vbox.pack_start(self.hbox, False, False, 1) self.hbox2 = HBox(False, 0) self.vbox.pack_start(self.hbox2, True, True, 1) self.label = Label('Identifikační číslo:') self.hbox.pack_start(self.label, False, False, 1) self.label.show() self.editable = Entry() self.editable.connect('key_press_event', self.key_press_event) self.hbox.pack_start(self.editable, True, True, 1) self.editable.show() self.button = Button("Začít") self.button.connect("clicked", self.callback) self.button.set_receives_default(True) self.button.set_can_focus(True) self.hbox.pack_start(self.button, False, False, 1) self.button.show() self.hbox1.show() self.hbox.show() self.hbox2.show() self.vbox.show() self.window.show()
def __init__(self, suites, name='SuiteBar'): HBox.__init__(self) self.set_name(name) self.lcombo = MyCombo(suites) self.lcombo.set(suites[0]) self.rcombo = MyCombo(suites) self.rcombo.set(suites[0]) self.ubutton = Button('update') self.dbutton = Button('diff') self.pack_start(self.lcombo, 0, 0, 0) self.pack_end(self.rcombo, 0, 0, 0) self.add(self.ubutton) self.add(self.dbutton) self.ubutton.show() self.dbutton.show() self.show()
def _setup_layout(self): self.vbox = VBox(False, 0) self.vbox.show() self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = expander_new_with_mnemonic(_("_Terminal")) self.expander.set_expanded(False) self.expander.add(self.terminal) self.expander.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) scr = ScrolledWindow() scr.set_policy ("automatic", "automatic") scr.add (self.tree) scr.show() vpaned = VPaned() vpaned.add1(scr) vpaned.add2(self.expander) vpaned.set_position (260) vpaned.show() self.vbox.pack_start(vpaned, True, True, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox) return
def _setup_layout(self): self.hpaned = HPaned() self.hpaned.add1(self.inst_tree) self.hpaned.add2(self.rem_tree) self.hpaned.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = Expander(_("Terminal")) self.expander.connect("notify::expanded", self._set_size) self.expander.show() self.vbox = VBox(False, 0) self.vbox.show() self.vbox.pack_start(self.hpaned, False, False, 0) self.vbox.pack_start(self.expander, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox)
def __init__(self, dir=None): HBox.__init__(self, False, 2) buttonImage = Image() buttonImage.set_from_stock(STOCK_REFRESH, ICON_SIZE_MENU) self.combo = ComboBox() self.refreshButton = Button() self.refreshButton.set_image(buttonImage) self.refreshButton.connect('clicked', self.refreshButton_clicked, None) self.model = ListStore(str) self.combo.set_model(self.model) self.dir = dir self.pack_start(self.combo, False, False, 0) self.pack_start(self.refreshButton, False, False, 0) if self.dir != None and exists(self.dir): self.refresh()
def __init__(self): Table.__init__(self, 1, 5) self.entry1 = Entry() self.entry2 = Entry() self.button = Button("Search") self.attach(self.entry1, 0, 1, 0, 1) self.attach(self.entry2, 1, 2, 0, 1) self.attach(self.button, 2, 3, 0, 1) self.entry1.set_width_chars(12) self.entry2.set_width_chars(12) self.entry1.set_text("59.666042") self.entry2.set_text("16.481794") self.button.connect('clicked', self.clicked)
def __init__(self): HBox.__init__(self) MDSplusWidget.__init__(self) HBox.set_homogeneous(self,False) self.node_state=CheckButton('') self.button=Button() HBox.pack_start(self,self.node_state,False,False,0) HBox.pack_start(self,self.button,False,False,0) HBox.pack_start(self,Label(''),True,False,0) if not guibuilder: self.button.connect("clicked",self.popupXd) self.button.connect("realize",self.setButtonLabel)
def __init__(self, title=TITLE, level=WINDOW_TOPLEVEL, on_exit=None): self.title = title self.grabbing = False self.events = [] self.rgb = WHITE_RGB self.on_exit = on_exit self.window = Window(level) self.window.set_title(title) self.window.set_resizable(True) self.window.add_events(POINTER_MOTION_MASK) self.window.set_default_size(350, 150) self.colors = [] grab_btn = Button('Grab') grab_btn.connect_object('clicked', self.toggle_grab, self.window) self.grab_btn = grab_btn exit_btn = Button('Exit') exit_btn.connect_object('clicked', self.destroy, self.window) drawing = DrawingArea() drawing.connect_object('expose_event', self.do_expose, self.window) self.drawing = drawing label = Label(rgb_to_string(WHITE_RGB)) self.label = label table = Table(2, 2, True) table.attach(self.drawing, 0, 1, 0, 1) table.attach(label, 0, 1, 1, 2) table.attach(grab_btn, 1, 2, 0, 1) table.attach(exit_btn, 1, 2, 1, 2) self.window.add(table)
def initXdbox(self): self.xdbox=Window() try: self.xdbox.set_title(str(self.node)) except: pass vbox=VBox() self.xdbox.expr=MDSplusExprWidget() vbox.pack_start(self.xdbox.expr,True,True,20) close=Button(stock=STOCK_CLOSE) close.connect("clicked",self.xdbox_close) redo=Button(stock=STOCK_REDO) redo.connect("clicked",self.xdbox_redo) cancel=Button(stock=STOCK_CANCEL) cancel.connect("clicked",self.xdbox_cancel) hbox=HBox() hbox.pack_start(close,False,False,20) hbox.pack_start(redo,False,False,20) hbox.pack_start(cancel,False,False,20) vbox.pack_start(hbox,False,False,20) self.xdbox.add(vbox) self.xdbox.expr.set_text(self.node_value())
def __init__(self): Window.__init__(self) self.model = ListStore(str, str) self.aboutWindow = None self.helper = Helper(None) self.set_title('Gnome Custom Shortcuts') self.set_icon_from_file(join(data_path, 'icon.svg')) self.set_border_width(5) self.set_size_request(400, 400) list = TreeView() list.append_column(TreeViewColumn('')) list.append_column(TreeViewColumn('Command')) list.append_column(TreeViewColumn('Shortcut')) closeButton = Button(None, STOCK_CLOSE) aboutButton = Button(None, STOCK_ABOUT) buttonsBox = HButtonBox() buttonsBox.pack_start(aboutButton, False, False, 0) buttonsBox.pack_start(Label(''), True, True, 0) buttonsBox.pack_start(closeButton, False, False, 0) box = VBox(False, 5) box.pack_start(list, True, True, 0) box.pack_start(buttonsBox, False, False, 0) self.connect('destroy', main_quit, None) closeButton.connect('clicked', main_quit, None) aboutButton.connect('clicked', self.show_about, None) self.add(box) self.show_all()
def _setup_layout(self): self.set_default_size(600,200) self.hpaned = HPaned() inst_scroll = ScrolledWindow() inst_scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) rem_scroll = ScrolledWindow() rem_scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) inst_scroll.add(self.inst_tree) rem_scroll.add(self.rem_tree) self.hpaned.pack1(inst_scroll, False, False) self.hpaned.pack2(rem_scroll, False, False) self.hpaned.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = Expander(_("Terminal")) self.expander.connect("notify::expanded", self._set_size) self.expander.show() self.vbox = VBox(False, 0) self.vbox.show() self.vbox.pack_start(self.hpaned, True, True, 0) self.vbox.pack_start(self.expander, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox)
def __init__(self,node=None,value=None): Window.__init__(self) MDSplusWidget.__init__(self) if node is not None: self.node=node else: self.value=value hbtop=HBox(homogeneous=False) self.on=CheckButton(label="On") self.parent_on=CheckButton(label="Parent") self.parent_on.set_sensitive(False) self.path=MDSplusPathWidget() if node is not None: self.path._node=self._node hbtags=HBox(homogeneous=False) self.tags=Entry() self.tags.set_width_chars(60) expression_menu=self.dtype_menu(tuple(),varname='dtype_expression',no_show=True) axis_menu=self.dtype_menu(('Range',),varname='dtype_axis',no_show=True) window_menu=self.dtype_menu(('Window',),varname='dtype_window',no_show=True) dispatch_menu=self.dtype_menu(('Dispatch',),varname='dtype_dispatch',no_show=True) action_menu=self.dtype_menu(('Action',),varname='dtype_action',no_show=True) task_menu=self.dtype_menu(('Method','Routine'),varname='dtype_task',no_show=True) any_menu=self.dtype_menu(('Range','Window','Dispatch','Action','Method','Routine'),varname='dtype_any',no_show=True) menus=(self.dtype_expression,self.dtype_axis,self.dtype_dispatch,self.dtype_action,self.dtype_task,self.dtype_window,self.dtype_any) hbtop.pack_start(self.on,False,False,10) hbtop.pack_start(self.parent_on,False,False,10) hbtop.pack_start(self.path,False,False,0) hbtags.pack_start(Label("Tags:"),False,False,10) hbtags.pack_start(self.tags,False,False,0) self.action=MDSplusActionWidget() self.windoww=MDSplusWindowWidget() self.sequential=MDSplusSequentialWidget() self.expression=MDSplusExpressionWidget() self.method=MDSplusMethodWidget() self.routine=MDSplusRoutineWidget() self.dispatch=MDSplusDispatchWidget() self.range=MDSplusRangeWidget() self.widgets=(self.action,self.sequential,self.expression,self.method,self.routine,self.dispatch,self.range,self.windoww) self.ok=Button(stock=STOCK_OK) self.cancel=Button(stock=STOCK_CANCEL) self.redo=Button(stock=STOCK_REDO) self.ok.connect("clicked",self.do_ok) self.cancel.connect("clicked",self.do_cancel) self.redo.connect("clicked",self.do_redo) hb2=HBox() hb2.add(self.ok) hb2.add(self.redo) hb2.add(self.cancel) vb=VBox(homogeneous=False) vb.set_border_width(10) vb.pack_start(hbtop,False,False,0) vb.pack_start(hbtags,False,False,0) vb.pack_start(expression_menu,False,False,0) vb.pack_start(axis_menu,False,False,0) vb.pack_start(window_menu,False,False,0) vb.pack_start(dispatch_menu,False,False,0) vb.pack_start(action_menu,False,False,0) vb.pack_start(task_menu,False,False,0) vb.pack_start(any_menu,False,False,0) for w in self.widgets: w.set_no_show_all(True) vb.pack_start(w,False,False,0) vb.pack_start(hb2,False,False,20) self.add(vb) self.do_redo(self.redo) self.putOnApply = True self.nidOffset = -1
class MDSplusXdBox(props,MDSplusDtypeSelWidget,MDSplusWidget,Window): __gtype_name__ = 'MDSplusXdBox' def inHBox(self,w): hb=HBox() hb.pack_start(w,False,False,0) return hb def __init__(self,node=None,value=None): Window.__init__(self) MDSplusWidget.__init__(self) if node is not None: self.node=node else: self.value=value hbtop=HBox(homogeneous=False) self.on=CheckButton(label="On") self.parent_on=CheckButton(label="Parent") self.parent_on.set_sensitive(False) self.path=MDSplusPathWidget() if node is not None: self.path._node=self._node hbtags=HBox(homogeneous=False) self.tags=Entry() self.tags.set_width_chars(60) expression_menu=self.dtype_menu(tuple(),varname='dtype_expression',no_show=True) axis_menu=self.dtype_menu(('Range',),varname='dtype_axis',no_show=True) window_menu=self.dtype_menu(('Window',),varname='dtype_window',no_show=True) dispatch_menu=self.dtype_menu(('Dispatch',),varname='dtype_dispatch',no_show=True) action_menu=self.dtype_menu(('Action',),varname='dtype_action',no_show=True) task_menu=self.dtype_menu(('Method','Routine'),varname='dtype_task',no_show=True) any_menu=self.dtype_menu(('Range','Window','Dispatch','Action','Method','Routine'),varname='dtype_any',no_show=True) menus=(self.dtype_expression,self.dtype_axis,self.dtype_dispatch,self.dtype_action,self.dtype_task,self.dtype_window,self.dtype_any) hbtop.pack_start(self.on,False,False,10) hbtop.pack_start(self.parent_on,False,False,10) hbtop.pack_start(self.path,False,False,0) hbtags.pack_start(Label("Tags:"),False,False,10) hbtags.pack_start(self.tags,False,False,0) self.action=MDSplusActionWidget() self.windoww=MDSplusWindowWidget() self.sequential=MDSplusSequentialWidget() self.expression=MDSplusExpressionWidget() self.method=MDSplusMethodWidget() self.routine=MDSplusRoutineWidget() self.dispatch=MDSplusDispatchWidget() self.range=MDSplusRangeWidget() self.widgets=(self.action,self.sequential,self.expression,self.method,self.routine,self.dispatch,self.range,self.windoww) self.ok=Button(stock=STOCK_OK) self.cancel=Button(stock=STOCK_CANCEL) self.redo=Button(stock=STOCK_REDO) self.ok.connect("clicked",self.do_ok) self.cancel.connect("clicked",self.do_cancel) self.redo.connect("clicked",self.do_redo) hb2=HBox() hb2.add(self.ok) hb2.add(self.redo) hb2.add(self.cancel) vb=VBox(homogeneous=False) vb.set_border_width(10) vb.pack_start(hbtop,False,False,0) vb.pack_start(hbtags,False,False,0) vb.pack_start(expression_menu,False,False,0) vb.pack_start(axis_menu,False,False,0) vb.pack_start(window_menu,False,False,0) vb.pack_start(dispatch_menu,False,False,0) vb.pack_start(action_menu,False,False,0) vb.pack_start(task_menu,False,False,0) vb.pack_start(any_menu,False,False,0) for w in self.widgets: w.set_no_show_all(True) vb.pack_start(w,False,False,0) vb.pack_start(hb2,False,False,20) self.add(vb) self.do_redo(self.redo) self.putOnApply = True self.nidOffset = -1 def set_dtype(self): if hasattr(self,'_node'): try: exec 'self.dtype=self.dtype_%s' % (self.node.usage.lower(),) except Exception,e: self.dtype=self.dtype_expression else:
class MDSplusOnOffXdBoxWidget(props,MDSplusWidget,HBox): __gtype_name__ = 'MDSplusOnOffXdBoxWidget' __gproperties__= props.__gproperties__ def reset(self): self.node_state.set_active(self.node.on) self.node_state.set_label('') if hasattr(self,'xdbox'): self.xdbox.reset() def apply(self): if self.putOnApply: if self.node.on != self.node_state.get_active(): try: self.node.on=self.node_state.get_active() except Exception: if self.node_state.get_active(): state='on' else: state='off' MDSplusErrorMsg('Error setting node on/off state','Error turning node %s %s\n\n%s' % (self.node.minpath,state,sys.exc_info()[1])) raise if hasattr(self,'xdbox'): try: if self.node.compare(self.xdbox.value) != 1: self.node.record=self.xdbox.value self.reset() except Exception: MDSplusErrorMsg('Error storing value','Error storing value in to %s\n\n%s' % (self.node.minpath,sys.exc_info()[1])) def xd_state_changed(self,button): self.node_state.set_active(self.xdbox.on.get_active()) def node_state_changed(self,button): self.xdbox.on.set_active(self.node_state.get_active()) def popupXd(self,button): if not hasattr(self,'xdbox'): self.xdbox=MDSplusXdBox(self.node) self.xdbox.putOnApply=False self.xdbox.on.connect('toggled',self.xd_state_changed) self.node_state.connect('toggled',self.node_state_changed) self.xdbox.node=self.getNode() self.xdbox.set_title(self.buttonLabel) self.xdbox.on.set_active(self.node_state.get_active()) self.xdbox.show() def setButtonLabel(self,button): self.button.set_label(self.buttonLabel) def __init__(self): HBox.__init__(self) MDSplusWidget.__init__(self) HBox.set_homogeneous(self,False) self.node_state=CheckButton('') self.button=Button() HBox.pack_start(self,self.node_state,False,False,0) HBox.pack_start(self,self.button,False,False,0) HBox.pack_start(self,Label(''),True,False,0) if not guibuilder: self.button.connect("clicked",self.popupXd) self.button.connect("realize",self.setButtonLabel) def show(self): self.show_all()
def initXdbox(self): self.xdbox = Window() try: self.xdbox.set_title(str(self.node)) except: pass vbox = VBox() self.xdbox.expr = MDSplusExprWidget() vbox.pack_start(self.xdbox.expr, True, True, 20) close = Button(stock=STOCK_CLOSE) close.connect("clicked", self.xdbox_close) redo = Button(stock=STOCK_REDO) redo.connect("clicked", self.xdbox_redo) cancel = Button(stock=STOCK_CANCEL) cancel.connect("clicked", self.xdbox_cancel) hbox = HBox() hbox.pack_start(close, False, False, 20) hbox.pack_start(redo, False, False, 20) hbox.pack_start(cancel, False, False, 20) vbox.pack_start(hbox, False, False, 20) self.xdbox.add(vbox) self.xdbox.expr.set_text(self.node_value())
class Base(object): def __init__(self): from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator self.window = Window(WINDOW_TOPLEVEL) self.window.set_title("Slideshow") self.window.connect("delete_event", self.delete_event) self.window.set_border_width(10) self.vbox = VBox(False, 0) self.window.add(self.vbox) self.hbox1 = HBox(False, 0) self.vbox.pack_start(self.hbox1, True, True, 1) self.hbox = HBox(False, 0) self.vbox.pack_start(self.hbox, False, False, 1) self.hbox2 = HBox(False, 0) self.vbox.pack_start(self.hbox2, True, True, 1) self.label = Label('Identifikační číslo:') self.hbox.pack_start(self.label, False, False, 1) self.label.show() self.editable = Entry() self.editable.connect('key_press_event', self.key_press_event) self.hbox.pack_start(self.editable, True, True, 1) self.editable.show() self.button = Button("Začít") self.button.connect("clicked", self.callback) self.button.set_receives_default(True) self.button.set_can_focus(True) self.hbox.pack_start(self.button, False, False, 1) self.button.show() self.hbox1.show() self.hbox.show() self.hbox2.show() self.vbox.show() self.window.show() def delete_event(self, widget, event, data=None): gtk.main_quit() return False def key_press_event(self, widget, event): from gtk.gdk import keyval_from_name,keyval_name if event.keyval in (keyval_from_name('Return'),keyval_from_name('KP_Enter')): self.callback(widget) def _getFilePaths(self, fileTypes, recursive=True): import os import re from sys import argv pt = re.compile(r'.*([%(0)s][^%(0)s]*)'%{'0':os.path.extsep}) path = [a for m,a in ((pt.match(os.path.basename(a)),a) for a in argv[1:]) if m and m.group(1) in fileTypes] if not path: path = '/home/pi/img/*.jpg' if isinstance(path, str): ## Returns list containing paths of files in /path/ that are of a file type in /fileTypes/, ## if /recursive/ is False subdirectories are not checked. paths = [] if recursive: for root, folders, files in os.walk(path, followlinks=True): for file in files: for fileType in fileTypes: if file.endswith(fileType): paths.append(os.path.join(root, file)) else: for item in os.listdir(path): for fileType in fileTypes: if item.endswith(fileType): paths.append(os.path.join(root, item)) return paths elif iterable(path): return path else: return [] def _init_cb(self,trans): from threading import Thread if not iterable(trans): trans = trans, callbacks = [] for name,cb in trans: t = Thread(target=cb, name='%sThread'%name) t.daemon = True t.start() callbacks.append(cb.enqueue) def wrap(msg): for cb in callbacks: if not cb(msg): return False return True return wrap def callback(self, widget): from slideshow import SlideShow from trans import Message,GpioTransceiver,JsonTransceiver if not self.editable.get_text(): return False img_cbs = self._init_cb([('ImgGpioCallback',GpioTransceiver(24)),('ImgJsonCallback',JsonTransceiver('img.json'))]) kp_cbs = self._init_cb([('KpGpioCallback',GpioTransceiver(26,bcd=False)),('KpJsonCallback',JsonTransceiver('kp.json'))]) def ordfnc(path): from numpy.random import permutation gray = path[0] result = [] for p in permutation(path[1:]): result.append(p) result.append(gray) return result slide = SlideShow( path=self._getFilePaths(('.jpg', '.jpeg', '.png')), transition='None', fullscreen=True, delay=5, order=ordfnc, principal=self.editable.get_text(), img_callback = img_cbs, kp_callback = kp_cbs, ) self.editable.set_text('') slide() def __call__(self): gtk.main()
class MDSplusXdBox(props, MDSplusDtypeSelWidget, MDSplusWidget, Window): __gtype_name__ = "MDSplusXdBox" def inHBox(self, w): hb = HBox() hb.pack_start(w, False, False, 0) return hb def __init__(self, node=None, value=None): Window.__init__(self) MDSplusWidget.__init__(self) if node is not None: self.node = node else: self.value = value hbtop = HBox(homogeneous=False) self.on = CheckButton(label="On") self.parent_on = CheckButton(label="Parent") self.parent_on.set_sensitive(False) self.path = MDSplusPathWidget() if node is not None: self.path._node = self._node hbtags = HBox(homogeneous=False) self.tags = Entry() self.tags.set_width_chars(60) expression_menu = self.dtype_menu(tuple(), varname="dtype_expression", no_show=True) axis_menu = self.dtype_menu(("Range",), varname="dtype_axis", no_show=True) window_menu = self.dtype_menu(("Window",), varname="dtype_window", no_show=True) dispatch_menu = self.dtype_menu(("Dispatch",), varname="dtype_dispatch", no_show=True) action_menu = self.dtype_menu(("Action",), varname="dtype_action", no_show=True) task_menu = self.dtype_menu(("Method", "Routine"), varname="dtype_task", no_show=True) any_menu = self.dtype_menu( ("Range", "Window", "Dispatch", "Action", "Method", "Routine"), varname="dtype_any", no_show=True ) menus = ( self.dtype_expression, self.dtype_axis, self.dtype_dispatch, self.dtype_action, self.dtype_task, self.dtype_window, self.dtype_any, ) hbtop.pack_start(self.on, False, False, 10) hbtop.pack_start(self.parent_on, False, False, 10) hbtop.pack_start(self.path, False, False, 0) hbtags.pack_start(Label("Tags:"), False, False, 10) hbtags.pack_start(self.tags, False, False, 0) self.action = MDSplusActionWidget() self.windoww = MDSplusWindowWidget() self.sequential = MDSplusSequentialWidget() self.expression = MDSplusExpressionWidget() self.method = MDSplusMethodWidget() self.routine = MDSplusRoutineWidget() self.dispatch = MDSplusDispatchWidget() self.range = MDSplusRangeWidget() self.widgets = ( self.action, self.sequential, self.expression, self.method, self.routine, self.dispatch, self.range, self.windoww, ) self.ok = Button(stock=STOCK_OK) self.cancel = Button(stock=STOCK_CANCEL) self.redo = Button(stock=STOCK_REDO) self.ok.connect("clicked", self.do_ok) self.cancel.connect("clicked", self.do_cancel) self.redo.connect("clicked", self.do_redo) hb2 = HBox() hb2.add(self.ok) hb2.add(self.redo) hb2.add(self.cancel) vb = VBox(homogeneous=False) vb.set_border_width(10) vb.pack_start(hbtop, False, False, 0) vb.pack_start(hbtags, False, False, 0) vb.pack_start(expression_menu, False, False, 0) vb.pack_start(axis_menu, False, False, 0) vb.pack_start(window_menu, False, False, 0) vb.pack_start(dispatch_menu, False, False, 0) vb.pack_start(action_menu, False, False, 0) vb.pack_start(task_menu, False, False, 0) vb.pack_start(any_menu, False, False, 0) for w in self.widgets: w.set_no_show_all(True) vb.pack_start(w, False, False, 0) vb.pack_start(hb2, False, False, 20) self.add(vb) self.do_redo(self.redo) self.putOnApply = True self.nidOffset = -1 def set_dtype(self): if hasattr(self, "_node"): try: exec("self.dtype=self.dtype_%s" % (self.node.usage.lower(),)) except Exception: self.dtype = self.dtype_expression else: self.dtype = self.dtype_any self.dtype.set_no_show_all(False) def do_ok(self, button): try: value = self.value if not self.putOnApply: self.hide() elif hasattr(self, "_node"): try: self.node.record = value self.hide() except Exception: self.popupError(sys.exc_info()) else: self.value = value self.hide() except: pass def do_redo(self, button): if not hasattr(self, "_node"): self.value = _value self.set_dtype() else: self.path.reset() self.on.set_active(self.node.disabled == False) self.parent_on.set_active(self.node.parent_disabled == False) tags = self.node.tags if tags is None: self.tags.set_text("") else: taglist = "" for tag in tags: if taglist == "": taglist = tag else: taglist = taglist + "," + tag self.tags.set_text(taglist) self.set_dtype() try: self.value = self.record except: self.value = None self.reset() def do_cancel(self, button): self.hide()
def __init__(self, objectives, new): Expander.__init__(self) self.connect("enter-notify-event", self.onEnterNotifyEvent) self.connect("leave-notify-event", self.onLeaveNotifyEvent) vBox = VBox() self.add(vBox) # Data model self.model = ListStore(str, float) # Title bar hBox = HBox() self.set_property("label-widget", hBox) self.title = Label() hBox.pack_start(self.title) # Alternatives treeView = TreeView(self.model) # treeView.set_headers_visible(False) vBox.pack_start(treeView) listStore_objectives = ListStore(str) for name in objectives: listStore_objectives.append((name, )) def combo_changed(_, path, text, model): model[path][0] = text cellRenderer = CellRendererCombo() cellRenderer.connect("edited", combo_changed, self.model) cellRenderer.set_property("text-column", 0) cellRenderer.set_property("editable", True) cellRenderer.set_property("has-entry", True) cellRenderer.set_property("model", listStore_objectives) treeViewColumn = TreeViewColumn("Alternative", cellRenderer, text=0) # treeViewColumn = TreeViewColumn(None,cellRenderer,text=0) treeView.append_column(treeViewColumn) def spin_changed(_, path, value, model): model[path][1] = float(value.replace(",", ".")) cellRenderer = CellRendererSpin() cellRenderer.connect("edited", spin_changed, self.model) cellRenderer.set_property("adjustment", Adjustment(1, 0, 100, 1, 10, 0)) cellRenderer.set_property("editable", True) cellRenderer.set_property("digits", 2) treeViewColumn = TreeViewColumn(None, cellRenderer, text=1) treeView.append_column(treeViewColumn) # Add/remove alternative button box # hButtonBox = HButtonBox() # vBox.pack_start(hButtonBox, False) # Add alternative button = Button("gtk-add") button.connect("clicked", self.on_btnAdd_Alternative_clicked) button.set_use_stock(True) # hButtonBox.pack_start(button) vBox.pack_start(button, False) # # Remove alternative # button = Button("gtk-remove") # button.connect("clicked",self.on_btnDel_Alternative_clicked) # button.set_use_stock(True) # hButtonBox.pack_start(button) # Expand the requeriment and add an alternative if it's new if new: self.set_expanded(True) self.model.append((None, 1.0)) # Show requeriment self.show_all() # Delete requeriment button (default is hidden) self.imgRemove = Image() self.imgRemove.connect("button-press-event", self.onDelRequeriment) self.imgRemove.set_from_stock("gtk-cancel", ICON_SIZE_MENU) hBox.pack_start(self.imgRemove)
def __on_plugin_directories_button_click(self, button): """Present a dialog to the user for selecting extra plugin directories and process the request.""" dia = Dialog('Plugin Directories', None, DIALOG_MODAL, (STOCK_OK, RESPONSE_OK, STOCK_CANCEL, RESPONSE_CANCEL ) ) dia.resize(500, 300) dia.vbox.set_spacing(8) # Setup the tree view of plugin directories. model = ListStore(str) # each row contains a single string tv = TreeView(model) cell = CellRendererText() column = TreeViewColumn('Directory', cell, text = 0) tv.append_column(column) dia.vbox.pack_start(tv) # Populate the tree view. plugin_directories = \ get_plugins_directories_from_config(self.config, self.config_path) for plugin_directory in plugin_directories: row = (plugin_directory,) model.append(row) modify_box = HBox(spacing = 8) # Setup the remove directory button. remove_button = Button('Remove') remove_button.set_sensitive(False) # no directory selected initially remove_button.connect('clicked', self.__on_remove, tv) modify_box.pack_end(remove_button, expand = False) tv.connect('cursor-changed', self.__on_select, remove_button) # Setup the add directory button. add_button = Button('Add') add_button.connect('clicked', self.__on_add, tv) modify_box.pack_end(add_button, expand = False) dia.vbox.pack_start(modify_box, expand = False) # Setup the "already included directories" label. included_label = Label('Plugins in the PYTHONPATH are already ' + 'available to BoKeep.') # Use a horizontal box to left-justify the label. For some reason, # the label's set_justification property doesn't work for me. label_box = HBox() label_box.pack_start(included_label, expand = False) dia.vbox.pack_start(label_box, expand = False) dia.show_all() dia_result = dia.run() if dia_result == RESPONSE_OK: # Remove the old plugin directories from the program's path. plugin_directories = \ get_plugins_directories_from_config(self.config, self.config_path) for plugin_directory in plugin_directories: path.remove(plugin_directory) # Get the new plugin directories from the dialog. plugin_directories = [] for row in model: plugin_directory = row[0] plugin_directories.append(plugin_directory) # Update the BoKeep PYTHONPATH so that new plugins can be loaded and # populate the list of possible new plugins. for plugin_directory in plugin_directories: path.append(plugin_directory) self.__populate_possible_plugins() # Save the new plugin directories in the configuration file. set_plugin_directories_in_config(self.config, self.config_path, plugin_directories) dia.destroy()
class _GenDialog(gtkDialog): def __init__(self, name='GenDialog'): gtkDialog.__init__(self) self.set_name(name) self.ok_button = Button('ok', 'gtk-ok') self.ok_button.set_name(name) self.cancel_button = Button('cancel', 'gtk-cancel') self.cancel_button.set_name(name) self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0) self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0) self.ok_button.show() self.cancel_button.show() self.cancel_button.connect('clicked', lambda *x : self.destroy()) self._buttons_ = {} self.show() def set_ok(self, ok_fun): self.ok_button.connect('clicked', ok_fun) def set_cancel(self, cancel_fun): self.cancel_button.connect('clicked', cancel_fun) self.connect('destroy', cancel_fun) def add_button(self, name, func, label='foo'): if name not in self._buttons_.keys(): self._buttons_[name] = Button(label) self._buttons_[name].show() self._buttons_[name].connect('clicked', func) self.action_area.add(self._buttons_[name])
class _GenDialog(gtkDialog): def __init__(self, name='GenDialog'): gtkDialog.__init__(self) self.set_name(name) self.ok_button = Button('ok', 'gtk-ok') self.ok_button.set_name(name) self.cancel_button = Button('cancel', 'gtk-cancel') self.cancel_button.set_name(name) self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0) self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0) self.ok_button.show() self.cancel_button.show() self.cancel_button.connect('clicked', lambda *x: self.destroy()) self._buttons_ = {} self.show() def set_ok(self, ok_fun): self.ok_button.connect('clicked', ok_fun) def set_cancel(self, cancel_fun): self.cancel_button.connect('clicked', cancel_fun) self.connect('destroy', cancel_fun) def add_button(self, name, func, label='foo'): if name not in self._buttons_.keys(): self._buttons_[name] = Button(label) self._buttons_[name].show() self._buttons_[name].connect('clicked', func) self.action_area.add(self._buttons_[name])
def __get_button(self): from gtk import Button button = Button() button.set_property("focus-on-click", False) button.set_property("can-default", False) button.set_property("can-focus", False) button.set_property("has-default", False) button.set_property("is-focus", False) button.set_property("receives-default", False) button.set_property("receives-default", False) return button
def add_button(self, name, func, label='foo'): if name not in self._buttons_.keys(): self._buttons_[name] = Button(label) self._buttons_[name].show() self._buttons_[name].connect('clicked', func) self.action_area.add(self._buttons_[name])
def __init__(self): tip=Tooltips() ok=Button(stock=STOCK_OK) ok.connect("clicked",self.ok_pressed) apply=Button(stock=STOCK_APPLY) apply.connect("clicked",self.apply_pressed) reset=Button(stock=STOCK_REDO) reset.connect("clicked",self.reset_pressed) cancel=Button(stock=STOCK_CANCEL) cancel.connect("clicked",self.cancel_pressed) self.add(ok) self.add(apply) self.add(reset) self.add(cancel)
class upgrade_dialog(Window): def __init__(self, to_upgrade, icon): Window.__init__(self, WINDOW_TOPLEVEL) self.set_property("skip-taskbar-hint", True) self.set_property("modal", True) self.set_property("destroy-with-parent", True) self.set_position(WIN_POS_CENTER) self.set_default_size (300, 300) self.set_icon(pixbuf_new_from_file(icon)) self._setup_tree(to_upgrade) self._setup_layout() def _setup_layout(self): self.vbox = VBox(False, 0) self.vbox.show() self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = expander_new_with_mnemonic(_("_Terminal")) self.expander.set_expanded(False) self.expander.add(self.terminal) self.expander.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) scr = ScrolledWindow() scr.set_policy ("automatic", "automatic") scr.add (self.tree) scr.show() vpaned = VPaned() vpaned.add1(scr) vpaned.add2(self.expander) vpaned.set_position (260) vpaned.show() self.vbox.pack_start(vpaned, True, True, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox) return def _setup_tree(self, pacs): self.model = ListStore(str, str, str) for pac in pacs: self.model.append(["yellow", pac.name, pac.version]) continue self.tree = TreeView() self.tree.show() self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id = 0) self.tree.insert_column_with_attributes(-1, "Package", CellRendererText(), text = 1) self.tree.insert_column_with_attributes(-1, "Version", CellRendererText(), text = 2) self.tree.set_model(self.model) return def run(self): self.show() self.terminal.do_upgrade()
class MDSplusXdBox(props,MDSplusDtypeSelWidget,MDSplusWidget,Window): __gtype_name__ = 'MDSplusXdBox' def inHBox(self,w): hb=HBox() hb.pack_start(w,False,False,0) return hb def __init__(self,node=None,value=None): Window.__init__(self) MDSplusWidget.__init__(self) if node is not None: self.node=node else: self.value=value hbtop=HBox(homogeneous=False) self.on=CheckButton(label="On") self.parent_on=CheckButton(label="Parent") self.parent_on.set_sensitive(False) self.path=MDSplusPathWidget() if node is not None: self.path._node=self._node hbtags=HBox(homogeneous=False) self.tags=Entry() self.tags.set_width_chars(60) expression_menu=self.dtype_menu(tuple(),varname='dtype_expression',no_show=True) axis_menu=self.dtype_menu(('Range',),varname='dtype_axis',no_show=True) window_menu=self.dtype_menu(('Window',),varname='dtype_window',no_show=True) dispatch_menu=self.dtype_menu(('Dispatch',),varname='dtype_dispatch',no_show=True) action_menu=self.dtype_menu(('Action',),varname='dtype_action',no_show=True) task_menu=self.dtype_menu(('Method','Routine'),varname='dtype_task',no_show=True) any_menu=self.dtype_menu(('Range','Window','Dispatch','Action','Method','Routine'),varname='dtype_any',no_show=True) menus=(self.dtype_expression,self.dtype_axis,self.dtype_dispatch,self.dtype_action,self.dtype_task,self.dtype_window,self.dtype_any) hbtop.pack_start(self.on,False,False,10) hbtop.pack_start(self.parent_on,False,False,10) hbtop.pack_start(self.path,False,False,0) hbtags.pack_start(Label("Tags:"),False,False,10) hbtags.pack_start(self.tags,False,False,0) self.action=MDSplusActionWidget() self.windoww=MDSplusWindowWidget() self.sequential=MDSplusSequentialWidget() self.expression=MDSplusExpressionWidget() self.method=MDSplusMethodWidget() self.routine=MDSplusRoutineWidget() self.dispatch=MDSplusDispatchWidget() self.range=MDSplusRangeWidget() self.widgets=(self.action,self.sequential,self.expression,self.method,self.routine,self.dispatch,self.range,self.windoww) self.ok=Button(stock=STOCK_OK) self.cancel=Button(stock=STOCK_CANCEL) self.redo=Button(stock=STOCK_REDO) self.ok.connect("clicked",self.do_ok) self.cancel.connect("clicked",self.do_cancel) self.redo.connect("clicked",self.do_redo) hb2=HBox() hb2.add(self.ok) hb2.add(self.redo) hb2.add(self.cancel) vb=VBox(homogeneous=False) vb.set_border_width(10) vb.pack_start(hbtop,False,False,0) vb.pack_start(hbtags,False,False,0) vb.pack_start(expression_menu,False,False,0) vb.pack_start(axis_menu,False,False,0) vb.pack_start(window_menu,False,False,0) vb.pack_start(dispatch_menu,False,False,0) vb.pack_start(action_menu,False,False,0) vb.pack_start(task_menu,False,False,0) vb.pack_start(any_menu,False,False,0) for w in self.widgets: w.set_no_show_all(True) vb.pack_start(w,False,False,0) vb.pack_start(hb2,False,False,20) self.add(vb) self.do_redo(self.redo) self.putOnApply = True self.nidOffset = -1 def set_dtype(self): if hasattr(self,'_node'): try: exec('self.dtype=self.dtype_%s' % (self.node.usage.lower(),)) except Exception: self.dtype=self.dtype_expression else: self.dtype=self.dtype_any self.dtype.set_no_show_all(False) def do_ok(self,button): try: value=self.value if not self.putOnApply: self.hide() elif hasattr(self,'_node'): try: self.node.record=value self.hide() except Exception: self.popupError(sys.exc_info()[1]) else: self.value=value self.hide() except: pass def do_redo(self,button): if not hasattr(self,'_node'): self.value=_value self.set_dtype() else: self.path.reset() self.on.set_active(self.node.disabled==False) self.parent_on.set_active(self.node.parent_disabled==False) tags = self.node.tags if tags is None: self.tags.set_text('') else: taglist='' for tag in tags: if taglist == '': taglist=tag else: taglist=taglist+','+tag self.tags.set_text(taglist) self.set_dtype() try: self.value=self.record except: self.value=None self.reset() def do_cancel(self,button): self.hide()
class GeoForm(Table): __gsignals__ = { 'search': (SIGNAL_ACTION, TYPE_NONE, (TYPE_FLOAT, TYPE_FLOAT)) } def __init__(self): Table.__init__(self, 1, 5) self.entry1 = Entry() self.entry2 = Entry() self.button = Button("Search") self.attach(self.entry1, 0, 1, 0, 1) self.attach(self.entry2, 1, 2, 0, 1) self.attach(self.button, 2, 3, 0, 1) self.entry1.set_width_chars(12) self.entry2.set_width_chars(12) self.entry1.set_text("59.666042") self.entry2.set_text("16.481794") self.button.connect('clicked', self.clicked) def get_lat_long(self): s1 = self.entry1.get_text() s2 = self.entry2.get_text() re1 = FMT1.match(s1) re2 = FMT1.match(s2) if re1 and re2: return float(re1.group(0)), float(re2.group(0)) re1 = FMT2.match(s1) re2 = FMT3.match(s2) if re1 and re2: c1 = re1.group(3), re1.group(1), re1.group(2) c2 = re2.group(3), re2.group(1), re2.group(2) return geo2dec(c1, c2) re1 = FMT4.match(s1) re2 = FMT5.match(s2) if re1 and re1: c1 = re1.group(1), re1.group(2), re1.group(3) c2 = re2.group(1), re2.group(2), re2.group(3) return geo2dec(c1, c2) raise SyntaxError() def clicked(self, event): try: self.emit('search', *self.get_lat_long()) except SyntaxError: pass
def __init__(self): Button.__init__(self) MDSplusWidget.__init__(self) if not guibuilder: self.connect("clicked",self.popupXd)
gtk.main_quit() def life_cb(widget, event): gtk.main_quit() def other_cb(widget, event): gtk.main_quit() window = Window(gtk.WINDOW_TOPLEVEL) window.connect("destroy", gtk.main_quit) box = gtk.VBox(False, 0) stamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') btn_same = Button("SAME") btn_same.connect_object("button_press_event", same_cb, window) box.pack_start(btn_same, True, True, 0) btn_project = Button("project") btn_project.connect_object("button_press_event", project_cb, window) box.pack_start(btn_project, True, True, 0) btn_study = Button("study") btn_study.connect_object("button_press_event", study_cb, window) box.pack_start(btn_study, True, True, 0) btn_life = Button("life") btn_life.connect_object("button_press_event", life_cb, window) box.pack_start(btn_life, True, True, 0)
def __init__(self, node=None, value=None): Window.__init__(self) MDSplusWidget.__init__(self) if node is not None: self.node = node else: self.value = value hbtop = HBox(homogeneous=False) self.on = CheckButton(label="On") self.parent_on = CheckButton(label="Parent") self.parent_on.set_sensitive(False) self.path = MDSplusPathWidget() if node is not None: self.path._node = self._node hbtags = HBox(homogeneous=False) self.tags = Entry() self.tags.set_width_chars(60) expression_menu = self.dtype_menu(tuple(), varname="dtype_expression", no_show=True) axis_menu = self.dtype_menu(("Range",), varname="dtype_axis", no_show=True) window_menu = self.dtype_menu(("Window",), varname="dtype_window", no_show=True) dispatch_menu = self.dtype_menu(("Dispatch",), varname="dtype_dispatch", no_show=True) action_menu = self.dtype_menu(("Action",), varname="dtype_action", no_show=True) task_menu = self.dtype_menu(("Method", "Routine"), varname="dtype_task", no_show=True) any_menu = self.dtype_menu( ("Range", "Window", "Dispatch", "Action", "Method", "Routine"), varname="dtype_any", no_show=True ) menus = ( self.dtype_expression, self.dtype_axis, self.dtype_dispatch, self.dtype_action, self.dtype_task, self.dtype_window, self.dtype_any, ) hbtop.pack_start(self.on, False, False, 10) hbtop.pack_start(self.parent_on, False, False, 10) hbtop.pack_start(self.path, False, False, 0) hbtags.pack_start(Label("Tags:"), False, False, 10) hbtags.pack_start(self.tags, False, False, 0) self.action = MDSplusActionWidget() self.windoww = MDSplusWindowWidget() self.sequential = MDSplusSequentialWidget() self.expression = MDSplusExpressionWidget() self.method = MDSplusMethodWidget() self.routine = MDSplusRoutineWidget() self.dispatch = MDSplusDispatchWidget() self.range = MDSplusRangeWidget() self.widgets = ( self.action, self.sequential, self.expression, self.method, self.routine, self.dispatch, self.range, self.windoww, ) self.ok = Button(stock=STOCK_OK) self.cancel = Button(stock=STOCK_CANCEL) self.redo = Button(stock=STOCK_REDO) self.ok.connect("clicked", self.do_ok) self.cancel.connect("clicked", self.do_cancel) self.redo.connect("clicked", self.do_redo) hb2 = HBox() hb2.add(self.ok) hb2.add(self.redo) hb2.add(self.cancel) vb = VBox(homogeneous=False) vb.set_border_width(10) vb.pack_start(hbtop, False, False, 0) vb.pack_start(hbtags, False, False, 0) vb.pack_start(expression_menu, False, False, 0) vb.pack_start(axis_menu, False, False, 0) vb.pack_start(window_menu, False, False, 0) vb.pack_start(dispatch_menu, False, False, 0) vb.pack_start(action_menu, False, False, 0) vb.pack_start(task_menu, False, False, 0) vb.pack_start(any_menu, False, False, 0) for w in self.widgets: w.set_no_show_all(True) vb.pack_start(w, False, False, 0) vb.pack_start(hb2, False, False, 20) self.add(vb) self.do_redo(self.redo) self.putOnApply = True self.nidOffset = -1
class MDSplusOnOffXdBoxWidget(props, MDSplusWidget, HBox): __gtype_name__ = 'MDSplusOnOffXdBoxWidget' __gproperties__ = props.__gproperties__ def reset(self): self.node_state.set_active(self.node.on) self.node_state.set_label('') if hasattr(self, 'xdbox'): self.xdbox.reset() def apply(self): if self.putOnApply: if self.node.on != self.node_state.get_active(): try: self.node.on = self.node_state.get_active() except Exception: if self.node_state.get_active(): state = 'on' else: state = 'off' MDSplusErrorMsg( 'Error setting node on/off state', 'Error turning node %s %s\n\n%s' % (self.node.minpath, state, sys.exc_info())) raise if hasattr(self, 'xdbox'): try: if self.node.compare(self.xdbox.value) != 1: self.node.record = self.xdbox.value self.reset() except Exception: MDSplusErrorMsg( 'Error storing value', 'Error storing value in to %s\n\n%s' % (self.node.minpath, sys.exc_info())) def xd_state_changed(self, button): self.node_state.set_active(self.xdbox.on.get_active()) def node_state_changed(self, button): self.xdbox.on.set_active(self.node_state.get_active()) def popupXd(self, button): if not hasattr(self, 'xdbox'): self.xdbox = MDSplusXdBox(self.node) self.xdbox.putOnApply = False self.xdbox.on.connect('toggled', self.xd_state_changed) self.node_state.connect('toggled', self.node_state_changed) self.xdbox.node = self.getNode() self.xdbox.set_title(self.buttonLabel) self.xdbox.on.set_active(self.node_state.get_active()) self.xdbox.show() def setButtonLabel(self, button): self.button.set_label(self.buttonLabel) def __init__(self): HBox.__init__(self) MDSplusWidget.__init__(self) HBox.set_homogeneous(self, False) self.node_state = CheckButton('') self.button = Button() HBox.pack_start(self, self.node_state, False, False, 0) HBox.pack_start(self, self.button, False, False, 0) HBox.pack_start(self, Label(''), True, False, 0) if not guibuilder: self.button.connect("clicked", self.popupXd) self.button.connect("realize", self.setButtonLabel) def show(self): self.show_all()
def __init__(self): Button.__init__(self) MDSplusWidget.__init__(self) if not guibuilder: self.connect("clicked", self.popupXd)
def __init__(self): tip = Tooltips() ok = Button(stock=STOCK_OK) ok.connect("clicked", self.ok_pressed) apply = Button(stock=STOCK_APPLY) apply.connect("clicked", self.apply_pressed) reset = Button(stock=STOCK_REDO) reset.connect("clicked", self.reset_pressed) cancel = Button(stock=STOCK_CANCEL) cancel.connect("clicked", self.cancel_pressed) self.add(ok) self.add(apply) self.add(reset) self.add(cancel)
def start_stock_button(stock_code): but = Button() but.set_property('use-stock', True) but.set_label(stock_code) return but
class do_dialog(Window): def __init__(self, queues, icon): Window.__init__(self, WINDOW_TOPLEVEL) self.set_property("skip-taskbar-hint", True) self.set_property("destroy-with-parent", True) self.set_modal(True) self.connect("delete-event", self._stop_closing) self.set_position(WIN_POS_CENTER) self.set_icon(pixbuf_new_from_file(icon)) self._setup_trees(queues) self._setup_layout() self.queues = queues def _setup_trees(self, queues): self._setup_install_tree(queues["add"]) self._setup_remove_tree(queues["remove"]) def _setup_install_tree(self, add_queue): self.inst_model = ListStore(str, str, str) for pac in add_queue: if pac.isold: image = "yellow" elif pac.installed: image = "green" else: image = "red" self.inst_model.append([image, pac.name, pac.version]) continue self.inst_tree = TreeView() self.inst_tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id = 0) self.inst_tree.insert_column_with_attributes(-1, _("Package"), CellRendererText(), text = 1) self.inst_tree.insert_column_with_attributes(-1, _("Version"), CellRendererText(), text = 2) self.inst_tree.set_model(self.inst_model) def _setup_remove_tree(self, remove_queue): self.rem_model = ListStore(str, str, str) for pac in remove_queue: if pac.isold: image = "yellow" elif pac.installed: image = "green" else: image = "red" self.rem_model.append([image, pac.name, pac.inst_ver]) continue self.rem_tree = TreeView() self.rem_tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id = 0) self.rem_tree.insert_column_with_attributes(-1, _("Package"), CellRendererText(), text = 1) self.rem_tree.insert_column_with_attributes(-1, _("Installed Version"), CellRendererText(), text = 2) self.rem_tree.set_model(self.rem_model) def _set_size (self, widget, event, data=None): if self.expander.get_expanded(): self.size = self.get_size() self.expander.add(self.terminal) self.terminal.show() else: self.expander.remove(self.terminal) self.resize(self.size[0], self.size[1]) self.show_all() def _setup_layout(self): self.hpaned = HPaned() self.hpaned.add1(self.inst_tree) self.hpaned.add2(self.rem_tree) self.hpaned.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = Expander(_("Terminal")) self.expander.connect("notify::expanded", self._set_size) self.expander.show() self.vbox = VBox(False, 0) self.vbox.show() self.vbox.pack_start(self.hpaned, False, False, 0) self.vbox.pack_start(self.expander, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox) def run(self): self.show() self.terminal.do(self.queues) return def _stop_closing(self, widget, event): self.stop_emission("delete-event") return True