def _setup_layout(self): hpaned = HPaned() label = Label(_("Are you sure you want to install/remove those packages?")) label.show() inst_frame = Frame(_("Packages to install")) rem_frame = Frame(_("Packages to remove")) 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.install_tree) rem_scroll.add(self.remove_tree) inst_frame.add(inst_scroll) rem_frame.add(rem_scroll) hpaned.pack1(inst_frame, False, False) hpaned.pack2(rem_frame, False, False) hpaned.show_all() self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(hpaned, True, True, 0) self.set_default_size(600,300) return
def __init__(self, message, name='Dialog'): _GenDialog.__init__(self, name=name) self.set_name(name) self.label = Label(message) self.vbox.pack_start(self.label, FALSE, TRUE, 0) self.vbox.set_homogeneous(FALSE) self.label.show()
def __init__(self, value=None): super(MDSplusMethodWidget, self).__init__(rows=4, columns=2, homogeneous=False) self.device = Entry() self.method = Entry() self.args = list() self.argTable = Table(rows=8, columns=2, homogeneous=False) for i in range(8): self.args.append(Entry()) self.argTable.attach(Label("Arg %d: " % (i + 1, )), 0, 1, i, i + 1, 0, 0) self.argTable.attach(self.args[i], 1, 2, i, i + 1, EXPAND | FILL, 0) self.scrolledWindow = ScrolledWindow() self.scrolledWindow.add_with_viewport(self.argTable) self.scrolledWindow.set_policy(POLICY_NEVER, POLICY_ALWAYS) adj = self.scrolledWindow.get_vadjustment() adj.connect("changed", adj_changed) self.timeout = Entry() self.attach(Label("Device:"), 0, 1, 0, 1, 0, 0) self.attach(self.device, 1, 2, 0, 1, EXPAND | FILL, 0) self.attach(Label("Method:"), 0, 1, 1, 2, 0, 0) self.attach(self.method, 1, 2, 1, 2, EXPAND | FILL, 0) self.attach(self.scrolledWindow, 0, 2, 2, 3) self.attach(Label("Timeout:"), 0, 1, 3, 4, 0, 0) self.attach(self.timeout, 1, 2, 3, 4, EXPAND | FILL, 0) self.set_row_spacings(5) self.value = value
def __init__(self, bus): VBox.__init__(self) self.bus = bus logger.debug('Running...') self.label = Label('Looking for Presence Service...') self.errors = ListStore(str) errors_tree = TreeView(model=self.errors) errors_tree.insert_column_with_attributes(0, 'Log', CellRendererText(), text=0) scroller = ScrolledWindow() scroller.add(errors_tree) self.paned = VPaned() self.paned.pack1(scroller) self.pack_start(self.label, False, False) self.pack_end(self.paned) bus.watch_name_owner(PS_NAME, self.on_name_owner_change) self.ps_watcher = Label('-') self.paned.pack2(self.ps_watcher) self.show_all()
class _DownloadStatus(HBox): def __init__(self, queue): HBox.__init__(self) self.thread = DlWorker(queue, self.progress, self.set_url) self.label = Label('hello') self.pbar = ProgressBar() self.pack_start(self.label, FALSE, FALSE, 0) self.pack_end(self.pbar, FALSE, FALSE, 0) self.label.show() self.pbar.show() self.show() self._done = False self._started = False def progress(self, dt, dd, ut, ud): threads_enter() print 'in progress', dt, dd, ut, ud if dt == 0: self._done += 0.1 if self._done >= 1: self._done = 0 else: self._done = float(dd) / float(dt) print '_done', self._done self.pbar.set_fraction(self._done) threads_leave() def set_url(self, url): self.label.set_text(url) def start(self, *args): if not self._started: self.thread.start() self._started = True
class _DownloadStatus(HBox): def __init__(self, queue): HBox.__init__(self) self.thread = DlWorker(queue, self.progress, self.set_url) self.label = Label("hello") self.pbar = ProgressBar() self.pack_start(self.label, FALSE, FALSE, 0) self.pack_end(self.pbar, FALSE, FALSE, 0) self.label.show() self.pbar.show() self.show() self._done = False self._started = False def progress(self, dt, dd, ut, ud): threads_enter() print "in progress", dt, dd, ut, ud if dt == 0: self._done += 0.1 if self._done >= 1: self._done = 0 else: self._done = float(dd) / float(dt) print "_done", self._done self.pbar.set_fraction(self._done) threads_leave() def set_url(self, url): self.label.set_text(url) def start(self, *args): if not self._started: self.thread.start() self._started = True
def __init__(self): HBox.__init__(self) self.set_spacing(3) #hour spin self.__hour_spin = SpinButton() self.__hour_spin.set_range(00, 99) self.__hour_spin.set_width_chars(2) self.__hour_spin.set_increments(1, 1) self.__hour_spin.set_numeric(True) self.__hour_spin.set_update_policy(UPDATE_IF_VALID) self.__hour_spin.set_snap_to_ticks(True) self.__hour_spin.connect("output", self._on_spin_output) self.__hour_spin_handler = (self.__hour_spin.connect("value-changed", self.hour_spin_changed)) self.pack_start(self.__hour_spin) self.__hour_spin.show() #separator sep = Label(":") self.pack_start(sep, expand=False) sep.show() #minute spin self.__minute_spin = SpinButton() self.__minute_spin.set_range(00, 59) self.__minute_spin.set_width_chars(2) self.__minute_spin.set_increments(1, 1) self.__minute_spin.set_numeric(True) self.__minute_spin.set_wrap(True) self.__minute_spin.set_update_policy(UPDATE_IF_VALID) self.__minute_spin.set_snap_to_ticks(True) self.__minute_spin.connect("output", self._on_spin_output) self.__minute_spin.connect("wrapped", self._on_minute_wrap) self.__minute_spin_handler = (self.__minute_spin.connect("value-changed", self.minute_spin_changed)) self.pack_start(self.__minute_spin) self.__minute_spin.show() #separator self.__second_sep = Label(":") self.pack_start(self.__second_sep, expand=False) self.__second_sep.show() #seconds spin self.__second_spin = SpinButton() self.__second_spin.set_range(00, 59) self.__second_spin.set_width_chars(2) self.__second_spin.set_increments(1, 1) self.__second_spin.set_numeric(True) self.__second_spin.set_wrap(True) self.__second_spin.set_update_policy(UPDATE_IF_VALID) self.__second_spin.set_snap_to_ticks(True) self.__second_spin.connect("output", self._on_spin_output) self.__second_spin.connect("wrapped", self._on_second_wrap) self.__second_spin_handler = (self.__second_spin.connect("value-changed", self.second_spin_changed)) self.pack_start(self.__second_spin) self.__second_spin.show()
class Dialog(_GenDialog): def __init__(self, message, name='Dialog'): _GenDialog.__init__(self, name=name) self.set_name(name) self.label = Label(message) self.vbox.pack_start(self.label, FALSE, TRUE, 0) self.vbox.set_homogeneous(FALSE) self.label.show()
def _setup_layout(self): label = Label(_("This packages requires one of the packages you've selected for removal.\nDo you want to remove them all?")) label.show() self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(self.tree, True, True, 0) return
def __init__(self): VBox.__init__(self) self.status_label = Label('blank') self.source_label = Label('blank') self.pack_start(self.status_label, FALSE, FALSE, 0) self.pack_end(self.source_label, FALSE, FALSE, 0) self.status_label.show() self.source_label.show() self.show()
def create_encoding_box(combobox): from i18n import msg0157 from gtk import Label, HBox label = Label(msg0157) label.set_use_underline(True) hbox = HBox(homogeneous=False, spacing=10) hbox.pack_start(label, False, False, 0) hbox.pack_start(combobox, True, True, 0) return hbox
def __init__(self, item, name='ItemLabel'): HBox.__init__(self) self.set_name(name) self._key_, self._val_ = item self.label = Label(self._key_) self.vlabel = Label(self._val_) self.pack_start(self.label, 0, 0, 0) self.pack_end(self.vlabel, 0, 0, 0) map(lambda x: x.show(), [self.label, self.vlabel]) self.show()
class upgrade_confirm_dialog(Dialog): def __init__(self, parent, to_upgrade, icon): Dialog.__init__(self, _("Confirm Upgrade"), parent, DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT, (STOCK_OK, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT)) self.set_icon(pixbuf_new_from_file(icon)) self._setup_tree(to_upgrade) self._setup_layout() 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.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) self.tree.show() def _setup_layout(self): self.label = Label(_("Are you sure yo want to upgrade those packages?\n")) self.label.show() self.set_default_size (300, 300) scr = ScrolledWindow() scr.set_policy("automatic", "automatic") scr.add(self.tree) scr.show() self.vbox.pack_start(self.label, False, False, 0) self.vbox.pack_start(scr, True, True, 0) def run(self): retcode = Dialog.run(self) self.destroy() if retcode == RESPONSE_ACCEPT: return True else: return False
def __init__(self, name, default=None): HBox.__init__(self) self.set_name(name) self.label = Label(name) self.entry = Entry() self.pack_start(self.label, TRUE, TRUE, 0) self.add(self.entry) self.label.show() self.entry.show() if default: self.set(default) self.show()
def __init__(self, queue): HBox.__init__(self) self.thread = DlWorker(queue, self.progress, self.set_url) self.label = Label('hello') self.pbar = ProgressBar() self.pack_start(self.label, FALSE, FALSE, 0) self.pack_end(self.pbar, FALSE, FALSE, 0) self.label.show() self.pbar.show() self.show() self._done = False self._started = False
class PresenceServiceNameWatcher(VBox): def __init__(self, bus): VBox.__init__(self) self.bus = bus logger.debug('Running...') self.label = Label('Looking for Presence Service...') self.errors = ListStore(str) errors_tree = TreeView(model=self.errors) errors_tree.insert_column_with_attributes(0, 'Log', CellRendererText(), text=0) scroller = ScrolledWindow() scroller.add(errors_tree) self.paned = VPaned() self.paned.pack1(scroller) self.pack_start(self.label, False, False) self.pack_end(self.paned) bus.watch_name_owner(PS_NAME, self.on_name_owner_change) self.ps_watcher = Label('-') self.paned.pack2(self.ps_watcher) self.show_all() def log(self, format, *args): self.errors.append((format % args, )) def on_name_owner_change(self, owner): try: if owner: self.label.set_text( 'Presence Service running: unique name %s' % owner) if self.ps_watcher is not None: self.paned.remove(self.ps_watcher) self.ps_watcher = PresenceServiceWatcher( self.bus, owner, self.log) self.paned.pack2(self.ps_watcher) self.show_all() else: self.label.set_text('Presence Service not running') if self.ps_watcher is not None: self.paned.remove(self.ps_watcher) self.ps_watcher = Label('-') self.paned.pack2(self.ps_watcher) except Exception, e: self.log('ERROR: %s', e)
def __init__(self,value=None): super(MDSplusWindowWidget,self).__init__(rows=3,columns=2,homogeneous=False) self.startIdx=Entry() self.endIdx=Entry() self.timeAt0=Entry() self.attach(Label("StartIdx: "),0,1,0,1,0,0) self.attach(self.startIdx,1,2,0,1,EXPAND|FILL,0) self.attach(Label("EndIdx: "),0,1,1,2,0,0) self.attach(self.endIdx,1,2,1,2,EXPAND|FILL,0) self.attach(Label("TimeAt0:"),0,1,2,3,0,0) self.attach(self.timeAt0,1,2,2,3,EXPAND|FILL,0) self.set_row_spacings(5) self.value=value
def __init__(self,value=None): super(MDSplusRangeWidget,self).__init__(rows=3,columns=2,homogeneous=False) self.begin=Entry() self.ending=Entry() self.delta=Entry() self.attach(Label("Begin: "),0,1,0,1,0,0) self.attach(self.begin,1,2,0,1,EXPAND|FILL,0) self.attach(Label("Ending: "),0,1,1,2,0,0) self.attach(self.ending,1,2,1,2,EXPAND|FILL,0) self.attach(Label("Delta:"),0,1,2,3,0,0) self.attach(self.delta,1,2,2,3,EXPAND|FILL,0) self.set_row_spacings(5) self.value=value
def __init__(self, parent, backend): self.backend = backend self.dialog = GtkAboutDialog() self.dialog.set_transient_for(parent) self.dialog.set_modal(True) self.dialog.set_name(_("Subscription Manager")) self.dialog.set_license(LICENSE) self.dialog.set_wrap_license(True) self.dialog.set_website("https://fedorahosted.org/subscription-manager/") self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc.")) self.dialog.set_logo(gdk.pixbuf_new_from_file_at_size(LOGO_PATH, 100, 100)) rhsm_version_label = Label() backend_version_label = Label() context_box = self.dialog.vbox.get_children()[0] context_box.pack_end(rhsm_version_label) context_box.pack_end(backend_version_label) # Set the component versions. server_versions = get_server_versions(self.backend.uep) client_versions = get_client_versions() self.dialog.set_version(client_versions['subscription-manager']) rhsm_version_label.set_markup(_("<b>python-rhsm version:</b> %s" % \ client_versions['python-rhsm'])) backend_version_label.set_markup(_("<b>subscription management service version:</b> %s" % \ server_versions['candlepin'])) self.dialog.connect("response", self._handle_response) self.dialog.show_all()
def __init__(self, item, name='ItemEntry'): if len(item) != 2: raise Error, 'ItemEntry needs item not %s' % item field, value = item HBox.__init__(self) self.set_name(name) self.label = Label(field) self.pack_start(self.label, FALSE, FALSE, 0) self.entry = Entry() self.set(str(value)) self.pack_end(self.entry, TRUE, TRUE, 0) self.label.show() self.entry.show() self.show()
def create_menuitem(string, stock_id=None): from gtk import MenuItem, Image, HBox, Label hbox = HBox(spacing=7) hbox.set_property("border-width", 2) if stock_id: image = Image() image.set_property("stock", stock_id) hbox.pack_start(image, False, False, 0) label = Label(string) label.set_property("use-underline", True) hbox.pack_start(label, False, False, 0) menuitem = MenuItem() menuitem.add(hbox) return menuitem
def create_button(stock_id, string): from gtk import HBox, Image, Label, ICON_SIZE_BUTTON, Alignment alignment = Alignment() alignment.set_property("xalign", 0.5) alignment.set_property("yalign", 0.5) hbox = HBox(False, 3) if stock_id: image = Image() image.set_from_stock(stock_id, ICON_SIZE_BUTTON) hbox.pack_start(image, False, False, 0) label = Label(string) label.set_property("use-underline", True) hbox.pack_start(label, False, False, 0) alignment.add(hbox) return alignment
def _setup_layout(self): self.set_default_size(-1,250) label = Label(_("This packages requires one of the packages you've selected for removal.\nDo you want to remove them all?")) label.show() scr = ScrolledWindow() scr.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) scr.add(self.tree) self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(scr, True, True, 0) self.vbox.show_all() return
class _FieldEntry(HBox): def __init__(self, name, default=None): HBox.__init__(self) self.set_name(name) self.label = Label(name) self.entry = Entry() self.pack_start(self.label, TRUE, TRUE, 0) self.add(self.entry) self.label.show() self.entry.show() if default: self.set(default) self.show() def set(self, value): self.entry.set_text(value)
def add(self, child, label=None): if label == None: label = 'New Document ' + str(self.documentCount) self.documentCount += 1 self.append_page(child, Label(label)) self.show_all()
class _FieldEntry(HBox): def __init__(self, name, default=None): HBox.__init__(self) self.set_name(name) self.label = Label(name) self.entry = Entry() self.pack_start(self.label, True, True, 0) self.add(self.entry) self.label.show() self.entry.show() if default: self.set(default) self.show() def set(self, value): self.entry.set_text(value)
def __init__(self, message, name='Dialog'): _GenDialog.__init__(self, name=name) self.set_name(name) self.label = Label(message) self.vbox.pack_start(self.label, False, True, 0) self.vbox.set_homogeneous(False) self.label.show()
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, url, path): VBox.__init__(self) self.label = Label(path) self.label.show() self.pack_start(self.label, FALSE, FALSE, 0) self.pbar = ProgressBar() self.pack_end(self.pbar, FALSE, FALSE, 0) self.pbar.show() self.show() self._done = 0 #self.thread = DownloadThread(url, path, self.progress) self.thread = DownloadThread(url, path, self.progress) #self.button = Button('start') #self.button.connect('clicked', self.start) #self.button.show() #self.pack_end(self.button, FALSE, FALSE, 0) self._started = False
def __init__(self, value=None): super(MDSplusSequentialWidget, self).__init__( rows=4, columns=2, homogeneous=False) self.ident = Entry() self.phase = Entry() self.sequence = Entry() self.event = Entry() self.attach(Label("Server: "), 0, 1, 0, 1, 0, 0) self.attach(self.ident, 1, 2, 0, 1, EXPAND | FILL, 0) self.attach(Label("Phase: "), 0, 1, 1, 2, 0, 0) self.attach(self.phase, 1, 2, 1, 2, EXPAND | FILL, 0) self.attach(Label("Sequence:"), 0, 1, 2, 3, 0, 0) self.attach(self.sequence, 1, 2, 2, 3, EXPAND | FILL, 0) self.attach(Label("Event: "), 0, 1, 3, 4, 0, 0) self.attach(self.event, 1, 2, 3, 4, EXPAND | FILL, 0) self.set_row_spacings(5) self.value = value
def setupChannels(self): for child in self.table.get_children(): child.destroy() if self.incNidOffset > -1: columns = 6 else: columns = 5 self.table.resize(self.numChannels + 1, columns) self.table.attach(Label(""), 0, 1, 0, 1, 0, 0, 10, 0) self.table.attach(Label("On"), 1, 2, 0, 1, 0, 0, 10, 0) self.table.attach(Label("StartIdx"), 2, 3, 0, 1, EXPAND | FILL, 0, 10, 0) self.table.attach(Label("EndIdx"), 3, 4, 0, 1, EXPAND | FILL, 0, 10, 0) if self.incNidOffset > -1: self.table.attach(Label("Increment"), 4, 5, 0, 1, EXPAND | FILL, 0, 10, 0) self.table.attach(Label("Path"), columns - 1, columns, 0, 1, 0, 0, 10, 0) self.channels = list() for chan in range(self.numChannels): channel = dict() self.channels.append(channel) channel['number'] = Label("%d" % (chan + 1, )) self.table.attach(channel['number'], 0, 1, chan + 1, chan + 2, 0, 0, 10, 0) channel['on'] = CheckButton('') self.table.attach(channel['on'], 1, 2, chan + 1, chan + 2, 0, 0, 10, 0) channel['startIdx'] = Entry() self.table.attach(channel['startIdx'], 2, 3, chan + 1, chan + 2, EXPAND | FILL, 0, 10, 0) channel['endIdx'] = Entry() self.table.attach(channel['endIdx'], 3, 4, chan + 1, chan + 2, EXPAND | FILL, 0, 10, 0) if self.incNidOffset > -1: channel['inc'] = Entry() self.table.attach(channel['inc'], 4, 5, chan + 1, chan + 2, EXPAND | FILL, 0, 10, 0) channel['path'] = Label(' ') self.table.attach(channel['path'], columns - 1, columns, chan + 1, chan + 2, 0, 0, 10, 0) self.show_all() if not guibuilder: for chan in range(self.numChannels): chanNidOffset = self.node.nid + chan * self.nodesPerChannel channel = self.channels[chan] channel['dataNode'] = TreeNode( chanNidOffset + self.dataNidOffset, self.node.tree) channel['startIdxNode'] = TreeNode( chanNidOffset + self.startIdxNidOffset, self.node.tree) channel['endIdxNode'] = TreeNode( chanNidOffset + self.endIdxNidOffset, self.node.tree) if self.incNidOffset > -1: channel['incNode'] = TreeNode( chanNidOffset + self.incNidOffset, self.node.tree)
def _setup_layout(self, conflict): self.set_default_size(-1,250) if not conflict: label = Label(_("These packages are required by package(s) you've selected for removal.\nDo you want to remove them all?")) else: label = Label("Package(s) that are about to be installed conflicts \nwith package(s) that are already installed.\nDo you want to remove them?") label.show() scr = ScrolledWindow() scr.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) scr.add(self.tree) self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(scr, True, True, 0) self.vbox.show_all() return
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 _setup_layout(self): hpaned = HPaned() label = Label(_("Are you sure you want to install/remove those packages?")) label.show() inst_frame = Frame(_("Packages to install")) rem_frame = Frame(_("Packages to remove")) inst_frame.add(self.install_tree) rem_frame.add(self.remove_tree) hpaned.add1(inst_frame) hpaned.add2(rem_frame) hpaned.show_all() self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(hpaned, True, True, 0) return
def __init__(self, item, name='ItemEntry'): HBox.__init__(self) self.set_name(name) self._key_, self._val_ = item self.label = Label(self._key_) self.entry = Entry() self.entry.set_text(self._val_) self.pack_start(self.label, 0, 0, 0) self.pack_end(self.entry, 0, 0, 0) map(lambda x: x.show(), [self.label, self.entry]) self.show()
def add_tab(self, widget, tab_name, label): """Adds a tab object to the notebook.""" log.debug('add tab: %s', tab_name) self.tabs[tab_name] = widget scrolled = ScrolledWindow() scrolled.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) scrolled.add(widget) self.notebook.insert_page(scrolled, Label(label), -1) scrolled.show_all() self.after_update()
def __init__(self, queue): HBox.__init__(self) self.thread = DlWorker(queue, self.progress, self.set_url) self.label = Label("hello") self.pbar = ProgressBar() self.pack_start(self.label, FALSE, FALSE, 0) self.pack_end(self.pbar, FALSE, FALSE, 0) self.label.show() self.pbar.show() self.show() self._done = False self._started = False
def __init__(self, name, default=None): HBox.__init__(self) self.set_name(name) self.label = Label(name) self.entry = Entry() self.pack_start(self.label, True, True, 0) self.add(self.entry) self.label.show() self.entry.show() if default: self.set(default) 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, parent, backend): self.backend = backend self.dialog = GtkAboutDialog() self.dialog.set_transient_for(parent) self.dialog.set_modal(True) self.dialog.set_name(_("Subscription Manager")) self.dialog.set_license(LICENSE) self.dialog.set_wrap_license(True) self.dialog.set_website("https://fedorahosted.org/subscription-manager/") self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc.")) self.dialog.set_logo(gdk.pixbuf_new_from_file_at_size(LOGO_PATH, 100, 100)) rhsm_version_label = Label() backend_version_label = Label() context_box = self.dialog.vbox.get_children()[0] context_box.pack_end(rhsm_version_label) context_box.pack_end(backend_version_label) # Set the component versions. versions = get_version_dict(self.backend.uep) self.dialog.set_version(versions['subscription manager']) rhsm_version_label.set_markup(_("<b>python-rhsm version:</b> %s" % \ versions['python-rhsm'])) backend_version_label.set_markup(_("<b>remote entitlement server version:</b> %s" % \ versions['candlepin'])) self.dialog.connect("response", self._handle_response) self.dialog.show_all()
def __init__(self): HBox.__init__(self) self.set_spacing(3) #hour spin self.__hour_spin = SpinButton() self.__hour_spin.set_range(00, 99) self.__hour_spin.set_width_chars(2) self.__hour_spin.set_increments(1, 1) self.__hour_spin.set_numeric(True) self.__hour_spin.set_update_policy(UPDATE_IF_VALID) self.__hour_spin.set_snap_to_ticks(True) self.__hour_spin.connect("output", self._on_spin_output) self.__hour_spin_handler = (self.__hour_spin.connect( "value-changed", self.hour_spin_changed)) self.pack_start(self.__hour_spin) self.__hour_spin.show() #separator sep = Label(":") self.pack_start(sep, expand=False) sep.show() #minute spin self.__minute_spin = SpinButton() self.__minute_spin.set_range(00, 59) self.__minute_spin.set_width_chars(2) self.__minute_spin.set_increments(1, 1) self.__minute_spin.set_numeric(True) self.__minute_spin.set_wrap(True) self.__minute_spin.set_update_policy(UPDATE_IF_VALID) self.__minute_spin.set_snap_to_ticks(True) self.__minute_spin.connect("output", self._on_spin_output) self.__minute_spin.connect("wrapped", self._on_minute_wrap) self.__minute_spin_handler = (self.__minute_spin.connect( "value-changed", self.minute_spin_changed)) self.pack_start(self.__minute_spin) self.__minute_spin.show() #separator self.__second_sep = Label(":") self.pack_start(self.__second_sep, expand=False) self.__second_sep.show() #seconds spin self.__second_spin = SpinButton() self.__second_spin.set_range(00, 59) self.__second_spin.set_width_chars(2) self.__second_spin.set_increments(1, 1) self.__second_spin.set_numeric(True) self.__second_spin.set_wrap(True) self.__second_spin.set_update_policy(UPDATE_IF_VALID) self.__second_spin.set_snap_to_ticks(True) self.__second_spin.connect("output", self._on_spin_output) self.__second_spin.connect("wrapped", self._on_second_wrap) self.__second_spin_handler = (self.__second_spin.connect( "value-changed", self.second_spin_changed)) self.pack_start(self.__second_spin) self.__second_spin.show()
def __init__(self, item, name='ItemEntry'): if len(item) != 2: raise Error, 'ItemEntry needs item not %s' %item field, value = item HBox.__init__(self) self.set_name(name) self.label = Label(field) self.pack_start(self.label, FALSE, FALSE, 0) self.entry = Entry() self.set(str(value)) self.pack_end(self.entry, TRUE, TRUE, 0) self.label.show() self.entry.show() self.show()
def _setup_layout(self): self.label = Label(_("Are you sure yo want to upgrade those packages?\n")) self.label.show() self.set_default_size (300, 300) scr = ScrolledWindow() scr.set_policy("automatic", "automatic") scr.add(self.tree) scr.show() self.vbox.pack_start(self.label, False, False, 0) self.vbox.pack_start(scr, True, True, 0)
class DownloadStatus(VBox): def __init__(self, url, path): VBox.__init__(self) self.label = Label(path) self.label.show() self.pack_start(self.label, FALSE, FALSE, 0) self.pbar = ProgressBar() self.pack_end(self.pbar, FALSE, FALSE, 0) self.pbar.show() self.show() self._done = 0 # self.thread = DownloadThread(url, path, self.progress) self.thread = DownloadThread(url, path, self.progress) # self.button = Button('start') # self.button.connect('clicked', self.start) # self.button.show() # self.pack_end(self.button, FALSE, FALSE, 0) self._started = False def progress(self, dt, dd, ut, ud): threads_enter() print "in progress", dt, dd, ut, ud if dt == 0: self._done += 0.1 if self._done >= 1: self._done = 0 else: self._done = float(dd) / float(dt) print "_done", self._done self.pbar.set_fraction(self._done) threads_leave() def start(self, *args): if not self._started: self.thread.start() self._started = True
def __init__(self, info): Table.__init__(self, 4, 1) self.info = info self.objs = ( image_new_from_file("img/found/%s.png" % (str(self.info['found']), )), image_new_from_file("img/wpt/%s.png" % (self.info['type'][0], )), Label(self.info['id']), Label("%s by %s" % (self.info['name'], self.info['creator'])) ) self.objs[0].set_tooltip_text("Found" if self.info['found'] else "Not found") self.objs[1].set_tooltip_text(self.info['type'][1]) self.objs[2].set_size_request(80, 32) self.objs[3].set_justify(JUSTIFY_LEFT) self.objs[3].set_ellipsize(ELLIPSIZE_END) self.attach(self.objs[0], 0, 1, 0, 1, FILL, FILL) self.attach(self.objs[1], 1, 2, 0, 1, FILL, FILL) self.attach(self.objs[2], 2, 3, 0, 1, FILL, FILL, FILL, FILL) self.attach(self.objs[3], 3, 4, 0, 1)
class DownloadStatus(VBox): def __init__(self, url, path): VBox.__init__(self) self.label = Label(path) self.label.show() self.pack_start(self.label, FALSE, FALSE, 0) self.pbar = ProgressBar() self.pack_end(self.pbar, FALSE, FALSE, 0) self.pbar.show() self.show() self._done = 0 #self.thread = DownloadThread(url, path, self.progress) self.thread = DownloadThread(url, path, self.progress) #self.button = Button('start') #self.button.connect('clicked', self.start) #self.button.show() #self.pack_end(self.button, FALSE, FALSE, 0) self._started = False def progress(self, dt, dd, ut, ud): threads_enter() print 'in progress', dt, dd, ut, ud if dt == 0: self._done += 0.1 if self._done >= 1: self._done = 0 else: self._done = float(dd) / float(dt) print '_done', self._done self.pbar.set_fraction(self._done) threads_leave() def start(self, *args): if not self._started: self.thread.start() self._started = True
class ItemEntry(HBox): def __init__(self, item, name='ItemEntry'): if len(item) != 2: raise RuntimeError, 'ItemEntry needs item not %s' %item field, value = item HBox.__init__(self) self.set_name(name) self.label = Label(field) self.pack_start(self.label, False, False, 0) self.entry = Entry() self.set(str(value)) self.pack_end(self.entry, True, True, 0) self.label.show() self.entry.show() self.show() def get(self): return self.entry.get_text() def set(self, value): self.entry.set_text(value) def fieldname(self): return self.label.get_text()
def __init__(self, parent, backend): self.backend = backend self.dialog = GtkAboutDialog() self.dialog.set_transient_for(parent) self.dialog.set_modal(True) self.dialog.set_name(_("Subscription Manager")) self.dialog.set_license(LICENSE) self.dialog.set_wrap_license(True) if not get_running_as_firstboot(): self.dialog.set_website( "https://fedorahosted.org/subscription-manager/") self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc.")) self.dialog.set_logo_icon_name("subscription-manager") self.dialog.set_icon_name("subscription-manager") next_update_label = Label() rhsm_version_label = Label() backend_version_label = Label() context_box = self.dialog.vbox.get_children()[0] context_box.pack_end(next_update_label) context_box.pack_end(rhsm_version_label) context_box.pack_end(backend_version_label) self._set_next_update(next_update_label) # Set the component versions. server_versions = get_server_versions( self.backend.cp_provider.get_consumer_auth_cp()) client_versions = get_client_versions() self.dialog.set_version(client_versions['subscription-manager']) rhsm_version_label.set_markup( _("<b>%s version:</b> %s") % ("python-rhsm", client_versions['python-rhsm'])) backend_version_label.set_markup( _("<b>subscription management service version:</b> %s") % server_versions['candlepin']) self.dialog.connect("response", self._handle_response) self.dialog.show_all()
def __init__(self, parent, backend): self.backend = backend self.dialog = GtkAboutDialog() self.dialog.set_transient_for(parent) self.dialog.set_modal(True) self.dialog.set_name(_("Subscription Manager")) self.dialog.set_license(LICENSE) self.dialog.set_wrap_license(True) if not get_running_as_firstboot(): self.dialog.set_website("https://fedorahosted.org/subscription-manager/") self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc.")) self.dialog.set_logo_icon_name("subscription-manager") self.dialog.set_icon_name("subscription-manager") next_update_label = Label() python_rhsm_version_label = Label() sub_man_version_label = Label() backend_version_label = Label() context_box = self.dialog.vbox.get_children()[0] context_box.pack_end(next_update_label) context_box.pack_end(python_rhsm_version_label) context_box.pack_end(sub_man_version_label) context_box.pack_end(backend_version_label) self._set_next_update(next_update_label) # Set the component versions. server_versions = get_server_versions(self.backend.cp_provider.get_consumer_auth_cp()) client_versions = get_client_versions() python_rhsm_version_label.set_markup(_("<b>%s version:</b> %s") % ("python-rhsm", client_versions['python-rhsm'])) sub_man_version_label.set_markup(_("<b>%s version:</b> %s") % ("subscription manager", client_versions['subscription-manager'])) backend_version_label.set_markup(_("<b>subscription management service version:</b> %s") % server_versions['candlepin']) self.dialog.connect("response", self._handle_response) self.dialog.show_all()
def __init__(self, url, path): VBox.__init__(self) self.label = Label(path) self.label.show() self.pack_start(self.label, FALSE, FALSE, 0) self.pbar = ProgressBar() self.pack_end(self.pbar, FALSE, FALSE, 0) self.pbar.show() self.show() self._done = 0 # self.thread = DownloadThread(url, path, self.progress) self.thread = DownloadThread(url, path, self.progress) # self.button = Button('start') # self.button.connect('clicked', self.start) # self.button.show() # self.pack_end(self.button, FALSE, FALSE, 0) self._started = False
def on_name_owner_change(self, owner): try: if owner: self.label.set_text( 'Presence Service running: unique name %s' % owner) if self.ps_watcher is not None: self.paned.remove(self.ps_watcher) self.ps_watcher = PresenceServiceWatcher( self.bus, owner, self.log) self.paned.pack2(self.ps_watcher) self.show_all() else: self.label.set_text('Presence Service not running') if self.ps_watcher is not None: self.paned.remove(self.ps_watcher) self.ps_watcher = Label('-') self.paned.pack2(self.ps_watcher) except Exception, e: self.log('ERROR: %s', e)
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 __init__(self, trans, transid, plugin, gui_parent, change_register_function, book, display_mode=TRANSACTION_ALL_EDIT_FIRST_TIME, transaction_edit_finished_function=null_function): self.trans = trans self.transid = transid self.plugin = plugin self.gui_parent = gui_parent self.change_register_function = change_register_function self.book = book self.display_mode = display_mode self.transaction_edit_finished_function = ( null_function if display_mode not in HEADLESS_MODES else transaction_edit_finished_function ) self.hide_parent = Window() self.hide_parent.hide() self.mainvbox = VBox() self.hide_parent.add(self.mainvbox) config = self.trans.get_configuration_and_provide_on_load_hook() config_module_name = self.plugin.config_module_name if not config_valid(config): # even in the case of a broken config, we should still # display all of the data we have available... self.mainvbox.pack_start(Label("no configuration")) elif not self.trans.can_safely_proceed_with_config_module(config): # should display all data that's available instead of just # this label # # and should give # user an overide option where they either pick an old config # for one time use or just blow out the memory of having used # a different config... # # should also print the checksum itself so they know # what they need... # # perhaps eventually we even put in place some archival support # for saving old glade and config files and then code into the # the transaction -- hey, code you need to be editable is # over here.. # # now hopefully there is no marking of this transaction dirty # in this mode and the extra safegaurds we put into # MultipageGladeTransaction don't get activated self.mainvbox.pack_start( Label("out of date configuration. data is read only here for " "the safety of your old information, last adler " "CRC was %s" % self.trans.config_crc_cache )) else: # if the safety cache was relied on before we need to tell the # backend that the transaction is actually dirty, # and now that we know that we have a workable config, # there's a chance that we'll actually be able to avoid # relying on the cache this time if self.trans.get_safety_cache_was_used(): self.change_register_function() self.page_label = Label("") (x_align, y_align) = self.page_label.get_alignment() self.page_label.set_alignment(0.0, y_align) self.mainvbox.pack_start(self.page_label, expand=False) # establish maincontainer, which is where the actual glade # pages are put by attach_current_page # # The order of placement here is important, we place this # after page_label has already been added to main # and we also need to do this prior to attach_current_page # being called, as it depends on self.maincontainer being # there # # when we're in headless mode the maincontainer can just be # the mainvbox itself # # but, outside headless mode we save screen real-estate and # place a scrolled window (which becomes the maincontainer) # inside the mainvbox and the glade by glade pages end up # in there instead (again, in attach_current_page) if display_mode in HEADLESS_MODES: self.maincontainer = self.mainvbox else: self.maincontainer = Viewport() sw = ScrolledWindow() sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) sw.add( self.maincontainer) self.mainvbox.pack_start(sw) self.glade_pages = [ self.__setup_page(glade_file, top_glade_element) for glade_file, top_glade_element in config.pages ] self.glade_pages_by_ident_index = dict( ( (key, self.glade_pages[i]) for i, key in enumerate(config.pages) ) # end generator expression ) # end dict self.__setup_auto_widgets() self.current_page = 0 self.attach_current_page() button_hbox = HBox() self.mainvbox.pack_end(button_hbox, expand=False) self.nav_buts = dict( (Button(), i) for i in range(2) ) for but, i in self.nav_buts.iteritems(): but.set_property('use-stock', True) but.set_label( STOCK_GO_BACK if i == GLADE_BACK_NAV else STOCK_GO_FORWARD ) button_hbox.pack_start(but, expand=False) but.connect("clicked", self.nav_but_clicked) config.gui_initialization_hook( self, self.trans, self.plugin, self.book) self.mainvbox.show_all() self.mainvbox.reparent(self.gui_parent)
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()
def __init__(self, bus, unique_name, log): VBox.__init__(self) self.bus = bus self.unique_name = unique_name self.proxy = bus.get_object(unique_name, PS_PATH) self.iface = dbus.Interface(self.proxy, PS_IFACE) self.log = log self.activities = None self.iface.connect_to_signal('ActivityAppeared', self._on_activity_appeared) self.iface.connect_to_signal('ActivityDisappeared', self._on_activity_disappeared) self.iface.GetActivities(reply_handler=self._on_get_activities_success, error_handler=self._on_get_activities_failure) self.buddies = None self.iface.connect_to_signal('BuddyAppeared', self._on_buddy_appeared) self.iface.connect_to_signal('BuddyDisappeared', self._on_buddy_disappeared) self.iface.GetBuddies(reply_handler=self._on_get_buddies_success, error_handler=self._on_get_buddies_failure) # keep this in sync with the ACT_COL_ constants self.activities_list_store = ListStore( str, # object path int, # weight (bold if new) bool, # strikethrough (dead) str, # ID str, # color str, # type str, # name str, # conn str, # channels str, # buddies ) self.pack_start(Label('Activities:'), False, False) self.activities_list = TreeView(self.activities_list_store) c = self.activities_list.insert_column_with_attributes( 0, 'Object path', CellRendererText(), text=ACT_COL_PATH, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_PATH) c = self.activities_list.insert_column_with_attributes( 1, 'ID', CellRendererText(), text=ACT_COL_ID, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_ID) c = self.activities_list.insert_column_with_attributes( 2, 'Color', CellRendererText(), text=ACT_COL_COLOR, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_COLOR) c = self.activities_list.insert_column_with_attributes( 3, 'Type', CellRendererText(), text=ACT_COL_TYPE, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_TYPE) c = self.activities_list.insert_column_with_attributes( 4, 'Name', CellRendererText(), text=ACT_COL_NAME, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_NAME) c = self.activities_list.insert_column_with_attributes( 5, 'Connection', CellRendererText(), text=ACT_COL_CONN, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(ACT_COL_CONN) c = self.activities_list.insert_column_with_attributes( 6, 'Channels', CellRendererText(), text=ACT_COL_CHANNELS, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) c = self.activities_list.insert_column_with_attributes( 7, 'Buddies', CellRendererText(), text=ACT_COL_BUDDIES, weight=ACT_COL_WEIGHT, strikethrough=ACT_COL_STRIKE) c.set_resizable(True) scroller = ScrolledWindow() scroller.add(self.activities_list) self.pack_start(scroller) # keep this in sync with the BUDDY_COL_ constants self.buddies_list_store = ListStore(str, int, bool, str, bool, str, str, str, str, str, str) self.pack_start(Label('Buddies:'), False, False) self.buddies_list = TreeView(self.buddies_list_store) c = self.buddies_list.insert_column_with_attributes( 0, 'Object path', CellRendererText(), text=BUDDY_COL_PATH, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_PATH) c = self.buddies_list.insert_column_with_attributes( 1, 'Pubkey', CellRendererText(), text=BUDDY_COL_KEY_ID, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_KEY_ID) c = self.buddies_list.insert_column_with_attributes( 2, 'Nick', CellRendererText(), text=BUDDY_COL_NICK, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_NICK) c = self.buddies_list.insert_column_with_attributes( 3, 'Owner', CellRendererToggle(), active=BUDDY_COL_OWNER) c = self.buddies_list.insert_column_with_attributes( 4, 'Color', CellRendererText(), text=BUDDY_COL_COLOR, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_OWNER) c = self.buddies_list.insert_column_with_attributes( 5, 'IPv4', CellRendererText(), text=BUDDY_COL_IP4, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_IP4) c = self.buddies_list.insert_column_with_attributes( 6, 'CurAct', CellRendererText(), text=BUDDY_COL_CUR_ACT, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_CUR_ACT) c = self.buddies_list.insert_column_with_attributes( 7, 'Activities', CellRendererText(), text=BUDDY_COL_ACTIVITIES, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_ACTIVITIES) c = self.buddies_list.insert_column_with_attributes( 8, 'Handles', CellRendererText(), text=BUDDY_COL_HANDLES, weight=BUDDY_COL_WEIGHT, strikethrough=BUDDY_COL_STRIKE) c.set_resizable(True) c.set_sort_column_id(BUDDY_COL_HANDLES) scroller = ScrolledWindow() scroller.add(self.buddies_list) self.pack_start(scroller) self.iface.connect_to_signal('ActivityInvitation', self._on_activity_invitation) self.iface.connect_to_signal('PrivateInvitation', self._on_private_invitation)
def __init__(self): Label.__init__(self) self.useFullPath=False
class HourEntry(HBox): __gtype_name__ = 'HourEntry' __gproperties__ = { 'hour' : (TYPE_PYOBJECT, 'Hour', 'The hour currently selected', PARAM_READWRITE), 'minute' : (TYPE_PYOBJECT, 'Minute', 'The minute currently selected', PARAM_READWRITE), 'second' : (TYPE_PYOBJECT, 'Second', 'The second currently selected', PARAM_READWRITE), } __gsignals__ = { 'time_changed' : (SIGNAL_RUN_LAST, TYPE_NONE, ()), } hour = 00 minute = 00 second = 00 lock = False def __init__(self): HBox.__init__(self) self.set_spacing(3) #hour spin self.__hour_spin = SpinButton() self.__hour_spin.set_range(00, 99) self.__hour_spin.set_width_chars(2) self.__hour_spin.set_increments(1, 1) self.__hour_spin.set_numeric(True) self.__hour_spin.set_update_policy(UPDATE_IF_VALID) self.__hour_spin.set_snap_to_ticks(True) self.__hour_spin.connect("output", self._on_spin_output) self.__hour_spin_handler = (self.__hour_spin.connect("value-changed", self.hour_spin_changed)) self.pack_start(self.__hour_spin) self.__hour_spin.show() #separator sep = Label("hh:") self.pack_start(sep, expand=False) sep.show() #minute spin self.__minute_spin = SpinButton() self.__minute_spin.set_range(00, 59) self.__minute_spin.set_width_chars(2) self.__minute_spin.set_increments(1, 1) self.__minute_spin.set_numeric(True) self.__minute_spin.set_wrap(True) self.__minute_spin.set_update_policy(UPDATE_IF_VALID) self.__minute_spin.set_snap_to_ticks(True) self.__minute_spin.connect("output", self._on_spin_output) self.__minute_spin.connect("wrapped", self._on_minute_wrap) self.__minute_spin_handler = (self.__minute_spin.connect("value-changed", self.minute_spin_changed)) self.pack_start(self.__minute_spin) self.__minute_spin.show() #separator self.__second_sep = Label("mn:") self.pack_start(self.__second_sep, expand=False) self.__second_sep.show() #seconds spin self.__second_spin = SpinButton() self.__second_spin.set_range(00, 59) self.__second_spin.set_width_chars(2) self.__second_spin.set_increments(1, 1) self.__second_spin.set_numeric(True) self.__second_spin.set_wrap(True) self.__second_spin.set_update_policy(UPDATE_IF_VALID) self.__second_spin.set_snap_to_ticks(True) self.__second_spin.connect("output", self._on_spin_output) self.__second_spin.connect("wrapped", self._on_second_wrap) self.__second_spin_handler = (self.__second_spin.connect("value-changed", self.second_spin_changed)) self.pack_start(self.__second_spin) self.__second_spin.show() self.__ss_sep = Label("ss") self.pack_start(self.__ss_sep, expand=False) self.__ss_sep.show() def set_hour(self, hour): self.__hour_spin.set_value(hour) self.hour = int(self.__hour_spin.get_value()) def set_minute(self, minute): self.__minute_spin.set_value(minute) self.minute = int(self.__minute_spin.get_value()) def set_second(self, second): self.__second_spin.set_value(second) self.second = int(self.__second_spin.get_value()) def set_time(self, hour, minute): self.__hour_spin.handler_block(self.__hour_spin_handler) self.__minute_spin.handler_block(self.__minute_spin_handler) self.__second_spin.handler_block(self.__second_spin_handler) self.__hour_spin.set_value(hour) self.hour = int(self.__hour_spin.get_value()) self.__minute_spin.set_value(minute) self.minute = int(self.__minute_spin.get_value()) self.__second_spin.set_value(00) self.second = int(self.__second_spin.get_value()) self.__hour_spin.handler_unblock(self.__hour_spin_handler) self.__minute_spin.handler_unblock(self.__minute_spin_handler) self.__second_spin.handler_unblock(self.__second_spin_handler) self.emit("time_changed") def get_time(self): return self.hour, self.minute # get_properties def do_get_property(self, property): data = {"hour":self.hour, "minute":self.minute} if data.has_key(property.name): return data[property.name] else: raise AttributeError, 'unknown property %s' % property.name def do_set_property(self, property, value): if property.name == 'hour': self.set_hour(value) elif property.name == 'minute': self.set_minute(value) else: raise AttributeError, 'unknown property %s' % property.name def _on_minute_wrap(self, obj): self.lock = True if obj.get_value() == 59: value = self.__hour_spin.get_value_as_int() - 1 else: value = self.__hour_spin.get_value_as_int() + 1 self.__hour_spin.set_value(value) self.lock = False self.emit("time_changed") def _on_second_wrap(self, obj): self.lock = True minute_value = self.__minute_spin.get_value_as_int() second_value = obj.get_value_as_int() hour_value = None if minute_value == 59 and second_value == 0: hour_value = self.__hour_spin.get_value_as_int() + 1 elif minute_value == 0 and second_value == 59: hour_value = self.__hour_spin.get_value_as_int() - 1 if not(hour_value is None): self.__hour_spin.set_value(hour_value) if second_value == 59: minute_value -= 1 elif second_value == 0: minute_value += 1 if minute_value == 60: minute_value = 0 elif minute_value == -1: minute_value = 59 self.__minute_spin.set_value(minute_value) self.lock = False self.emit("time_changed") def _on_spin_output(self, obj): obj.set_text("%02d" % obj.get_adjustment().get_value()) return True def hour_spin_changed(self, obj): self.hour = obj.get_value_as_int() if not self.lock: self.emit("time_changed") def minute_spin_changed(self, obj): self.minute = obj.get_value_as_int() if not self.lock: self.emit("time_changed") def second_spin_changed(self, obj): self.second = obj.get_value_as_int() if not self.lock: self.emit("time_changed") def set_second_visible(self, s): if s: self.__second_spin.show() self.__second_sep.show() else: self.__second_spin.hide() self.__second_sep.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 __init__(self): super(HelloWorld, self).__init__() self.set_title("Time Tracker") self.set_size_request(600, 480) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(6400, 6400, 6440)) self.set_position(gtk.WIN_POS_CENTER) #self.set_border_width(20) total_hours = [] total_minutes = [] total_seconds = [] prev_hours = "Hours: \n" prev_minutes = "Minutes: \n" prev_seconds = "Seconds: \n" vbox = gtk.VBox(False, 2) mb = gtk.MenuBar() filemenu = gtk.Menu() filem = gtk.MenuItem("File") filem.set_submenu(filemenu) exit = gtk.MenuItem("Exit") exit.connect("activate", gtk.main_quit) filemenu.append(exit) mb.append(filem) vbox.pack_start(mb, False, False, 0) table = gtk.Table(5, 6, True) button = gtk.ToggleButton(label = "Start") button2 = Button("Test") text = Label("Hello World") text.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) prev_hours_label = Label(prev_hours) prev_hours_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) prev_minutes_label = Label(prev_minutes) prev_minutes_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) prev_seconds_label = Label(prev_seconds) prev_seconds_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) total = Label("Total: \n") total.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFF')) table.attach(button, 0, 3, 1, 2) table.attach(text, 0, 3, 0, 1) table.attach(prev_hours_label, 0, 1, 2, 6) table.attach(prev_minutes_label, 1, 2, 2, 6) table.attach(prev_seconds_label, 2, 3, 2, 6) table.attach(total, 3, 4, 2, 6) vbox.pack_end(table, True, True, 0) self.connect("destroy", self.destroy) button.connect("toggled", self.timer) # Assign relative self variable so all methods have access self.text = text self.button = button self.prev_hours_label = prev_hours_label self.prev_minutes_label = prev_minutes_label self.prev_seconds_label = prev_seconds_label self.prev_hours = prev_hours self.prev_minutes = prev_minutes self.prev_seconds = prev_seconds self.total_hours = total_hours self.total_minutes = total_minutes self.total_seconds = total_seconds self.total = total self.add(vbox) self.show_all()