def __init__(self, flask, verbose_messages): hippo.CanvasBox.__init__(self) self.props.spacing = style.DEFAULT_SPACING flask.connect('verbose', self.__verbose_cb) flask.connect('progress', self.__progress_cb) flask.connect('key_confirm', self.__key_confirm_cb) self._page = None self._key = None # verbose self._verbose = gtk.TextView() self._verbose.props.wrap_mode = gtk.WRAP_WORD self._verbose.props.editable = False self._verbose.props.buffer.props.text = verbose_messages scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled.add(self._verbose) scrolled.show_all() expander = gtk.Expander(_('Details')) expander.add(scrolled) self.append(hippo.CanvasWidget(widget=expander), hippo.PACK_EXPAND) # progress page self._progress_page = hippo.CanvasBox( spacing=style.DEFAULT_SPACING, orientation=hippo.ORIENTATION_VERTICAL) self._progress = gtk.ProgressBar() self._progress.set_size_request(-1, style.SMALL_ICON_SIZE) self._progress.modify_bg(gtk.STATE_INSENSITIVE, style.COLOR_WHITE.get_gdk_color()) self._progress_page.append(hippo.CanvasWidget(widget=self._progress)) cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL) cancel_button.connect('clicked', self.__cancel_button_clicked_cb, flask) self._progress_page.append(hippo.CanvasWidget( widget=cancel_button, xalign=hippo.ALIGNMENT_CENTER)) # confirm page self._confirm_page = hippo.CanvasBox( spacing=style.DEFAULT_SPACING, orientation=hippo.ORIENTATION_HORIZONTAL, xalign=hippo.ALIGNMENT_CENTER) self._confirm_caption = hippo.CanvasText() self._confirm_page.append(self._confirm_caption) self._accept_button = gtk.Button(stock=gtk.STOCK_YES) self._accept_button.connect('clicked', self.__accept_button_clicked_cb, flask) self._confirm_page.append(hippo.CanvasWidget( widget=self._accept_button)) deny_button = gtk.Button(stock=gtk.STOCK_NO) deny_button.connect('clicked', self.__deny_button_clicked_cb, flask) self._confirm_page.append(hippo.CanvasWidget(widget=deny_button)) # complete page self._complete_page = hippo.CanvasBox( spacing=style.DEFAULT_SPACING, orientation=hippo.ORIENTATION_VERTICAL) stop_button = gtk.Button(stock=gtk.STOCK_STOP) stop_button.connect('clicked', lambda button: self.emit('stop')) self._complete_page.append(hippo.CanvasWidget( widget=stop_button, xalign=hippo.ALIGNMENT_CENTER)) # error page self._error_page = hippo.CanvasBox( spacing=style.DEFAULT_SPACING, orientation=hippo.ORIENTATION_VERTICAL) stop_button = gtk.Button(stock=gtk.STOCK_DIALOG_ERROR) stop_button.connect('clicked', lambda button: self.emit('stop')) self._error_page.append(hippo.CanvasWidget( widget=stop_button, xalign=hippo.ALIGNMENT_CENTER))
def initui(self): """ Create the window and all of the UI widgets, and make them visible. """ ## Creating the objects # Create a window with custom accelerators accels = gtk.AccelGroup() self.window = gtk.Window() self.window.set_title('DVI Display: %s' % self.path) self.window.set_icon_name('display') self.window.connect('destroy', self.destroy) self.window.add_accel_group(accels) # Use a table for the main layout. # In it are rulers, a scrolling window for the image, and a toolbar. self.table = gtk.Table(rows=3, columns=2) self.hruler = gtk.HRuler() self.vruler = gtk.VRuler() self.scrollwindow = gtk.ScrolledWindow() self.scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrollwindow.get_hadjustment().connect('value-changed', self.update_rulers) self.scrollwindow.get_vadjustment().connect('value-changed', self.update_rulers) self.scrollwindow.connect('size-allocate', self.update_rulers) # gtk.Image cannot scroll by itself, so we wrap it in a gtk.Viewport. self.imageviewport = gtk.Viewport() # Request mouse events self.imageviewport.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK) self.imageviewport.connect('motion-notify-event', self.image_mouse_move) self.imageviewport.connect( 'button-press-event', lambda w, event: self.image_mouse_button(event.button, True)) self.imageviewport.connect( 'button-release-event', lambda w, event: self.image_mouse_button(event.button, False)) self.imagedisplay = gtk.Image() self.imagedisplay.set_alignment(0, 0) # The toolbar is a simple H-box self.toolbar = gtk.HBox() # A button to display the mouse coordinates and copy them to clipboard self.coordinates = gtk.Button('') self.coordinates.get_child().set_markup( '<span face="mono"> %4s %4s </span>' % ('', '')) self.coordinates.connect('clicked', self.coordinates_clicked) # Other toolbar widgets: previous, next, save, save all, progress self.prevbutton = gtk.Button(stock=gtk.STOCK_MEDIA_PREVIOUS) self.prevbutton.connect('clicked', lambda b: self.display_image(self.index - 1)) self.nextbutton = gtk.Button(stock=gtk.STOCK_MEDIA_NEXT) self.nextbutton.connect('clicked', lambda b: self.display_image(self.index + 1)) self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE) self.savebutton.connect('clicked', lambda b: self.save_image(False)) self.saveallbutton = gtk.Button("Save _All") self.saveallbutton.set_image( gtk.image_new_from_stock(gtk.STOCK_SAVE, gtk.ICON_SIZE_BUTTON)) self.saveallbutton.connect('clicked', lambda b: self.save_image(True)) self.progress = gtk.ProgressBar() # Update the toolbar, setting sensitivities and text self.update_bar() ## Defining extra accelerators self.nextbutton.add_accelerator('clicked', accels, ord('n'), 0, 0) self.nextbutton.add_accelerator('clicked', accels, ord('j'), 0, 0) self.nextbutton.add_accelerator('clicked', accels, ord('l'), 0, 0) self.nextbutton.add_accelerator('clicked', accels, ord('.'), 0, 0) self.nextbutton.add_accelerator('clicked', accels, ord('>'), 0, 0) self.prevbutton.add_accelerator('clicked', accels, ord('p'), 0, 0) self.prevbutton.add_accelerator('clicked', accels, ord('k'), 0, 0) self.prevbutton.add_accelerator('clicked', accels, ord('h'), 0, 0) self.prevbutton.add_accelerator('clicked', accels, ord(','), 0, 0) self.prevbutton.add_accelerator('clicked', accels, ord('<'), 0, 0) self.savebutton.add_accelerator('clicked', accels, ord('s'), gtk.gdk.CONTROL_MASK, 0) self.coordinates.add_accelerator('clicked', accels, ord('c'), gtk.gdk.CONTROL_MASK, 0) ## Making the widget hierarchy self.imageviewport.add(self.imagedisplay) self.scrollwindow.add(self.imageviewport) self.table.attach(self.hruler, 1, 2, 0, 1, xoptions=gtk.FILL, yoptions=gtk.FILL) self.table.attach(self.vruler, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=gtk.FILL) self.table.attach(self.scrollwindow, 1, 2, 1, 2) self.toolbar.pack_start(self.prevbutton, expand=False) self.toolbar.pack_start(self.coordinates, expand=False) self.toolbar.pack_start(self.progress) self.toolbar.pack_start(self.saveallbutton, expand=False) self.toolbar.pack_start(self.savebutton, expand=False) self.toolbar.pack_start(self.nextbutton, expand=False) self.table.attach(self.toolbar, 0, 2, 2, 3, yoptions=gtk.FILL) self.window.add(self.table) ## Show everything self.window.show_all()
def __init__(self, app, parent, title=None, images=None, color='blue', bg='#c0c0c0', height=25, show_text=1, norm=1): self.parent = parent self.percent = 0 self.steps_sum = 0 self.norm = norm self.top = makeToplevel(parent, title=title) self.top.set_position(gtk.WIN_POS_CENTER) self.top.set_resizable(False) self.top.connect("delete_event", self.wmDeleteWindow) # hbox hbox = gtk.HBox(spacing=5) hbox.set_border_width(10) hbox.show() self.top.table.attach(hbox, 0, 1, 0, 1, 0, 0, 0, 0) # hbox-1: image if images and images[0]: im = gtk.Image() im.set_from_pixbuf(images[0].pixbuf) hbox.pack_start(im, expand=False, fill=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) # hbox-2:vbox vbox = gtk.VBox() vbox.show() hbox.pack_start(vbox, False, False) # hbox-2:vbox:pbar self.pbar = gtk.ProgressBar() self.pbar.show() vbox.pack_start(self.pbar, True, False) self.pbar.realize() # ~ self.pbar.set_show_text(show_text) self.pbar.set_text(str(show_text)+'%') w, h = self.pbar.size_request() self.pbar.set_size_request(max(w, 300), max(h, height)) # hbox-3:image if images and images[1]: im = gtk.Image() im.set_from_pixbuf(images[1].pixbuf) hbox.pack_end(im, expand=False) im.show() im.set_property('xpad', 10) im.set_property('ypad', 5) # set icon # if app: # try: # name = app.dataloader.findFile('pysol.xpm') # bg = self.top.get_style().bg[gtk.STATE_NORMAL] # pixmap, mask = create_pixmap_from_xpm(self.top, bg, name) # self.top.set_icon(pixmap, mask) # except: pass setTransient(self.top, parent) self.top.show() self.top.window.set_cursor(gdk.Cursor(gdk.WATCH)) self.update(percent=0)
def __init__ (self): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_border_width (6) self.set_resizable (False) self.set_title ('') # defaults to center location self.set_position (gtk.WIN_POS_CENTER) self.connect ("delete-event", self.__on_close) # main container main = gtk.VBox (spacing = 12) main.set_spacing (12) main.set_border_width (6) main.show() self.add (main) # primary text alg = gtk.Alignment () alg.set_padding (0, 6, 0, 0) alg.show() main.pack_start (alg, False, False) lbl = hig_label() lbl.set_selectable (False) lbl.show() self.__primary_label = lbl alg.add (lbl) # secondary text lbl = hig_label() lbl.set_selectable (False) lbl.show() main.pack_start (lbl, False, False) self.__secondary_label = lbl # Progress bar vbox = gtk.VBox() vbox.show() main.pack_start (vbox, False, False) prog = gtk.ProgressBar () prog.show() self.__progress_bar = prog vbox.pack_start (prog, expand = False) lbl = hig_label () lbl.set_selectable (False) lbl.show () self.__sub_progress_label = lbl vbox.pack_start (lbl, False, False) # Buttons box bbox = gtk.HButtonBox () bbox.set_layout (gtk.BUTTONBOX_END) bbox.show () # Cancel Button cancel = gtk.Button (gtk.STOCK_CANCEL) cancel.set_use_stock (True) cancel.show () self.__cancel = cancel bbox.add (cancel) main.add (bbox) # Close button, which is hidden by default close = gtk.Button (gtk.STOCK_CLOSE) close.set_use_stock (True) close.hide () bbox.add (close) self.__close = close
pygtk.require('2.0') import gtk import subprocess import time def timer(widget): time.sleep(1) gtk.main_quit() if __name__ == "__main__": volumen = subprocess.check_output("/usr/libexec/i3blocks/volume") s = ''.join(x for x in volumen if x.isdigit()) progressbar = gtk.ProgressBar(adjustment=None) progressbar.set_fraction(int(s) / 100.0) progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT) message = gtk.Dialog( parent=None, flags=gtk.DIALOG_MODAL, ) color = gtk.gdk.color_parse('#6c71c4') message.modify_bg(gtk.STATE_NORMAL, color) #progressbar.modify_style progressbar.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse("red")) label = gtk.Label() label.set_markup( '<span fgcolor="#eee8d5" font_desc="FontAwesome 30"></span>')
gtk.gdk.threads_init() slideshow_window = gtk.Window() slideshow_window.set_title("Ubiquity Slideshow with Webkit") slideshow_window.connect('destroy', gtk.main_quit) slideshow_container = gtk.VBox() slideshow_container.set_spacing(8) slideshow_window.add(slideshow_container) slideshow = SlideshowViewer(options.path, locale=options.locale, rtl=options.rtl, controls=options.controls) install_progressbar = gtk.ProgressBar() install_progressbar.set_size_request(-1, 30) install_progressbar.set_text("Pretending to install. Please wait...") install_progressbar.set_fraction(0) slideshow_container.add(slideshow) slideshow_container.add(install_progressbar) slideshow_container.set_child_packing(install_progressbar, True, False, 0, 0) slideshow_window.show_all() install_timer = gobject.timeout_add_seconds(2, progress_increment, install_progressbar, 0.01) gtk.main()
def build_ui(self): self.clear_ui() self.box = gtk.VBox(False, 20) self.configure_window() self.window.add(self.box) if 'error' in self.gui: # labels self.label = gtk.Label(self.gui_message) self.label.set_line_wrap(True) self.box.pack_start(self.label, True, True, 0) self.label.show() # button box self.button_box = gtk.HButtonBox() self.button_box.set_layout(gtk.BUTTONBOX_SPREAD) self.box.pack_start(self.button_box, True, True, 0) self.button_box.show() if self.gui != 'error': # yes button yes_image = gtk.Image() yes_image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON) self.yes_button = gtk.Button("Yes") self.yes_button.set_image(yes_image) if self.gui == 'error_try_stable': self.yes_button.connect("clicked", self.try_stable, None) elif self.gui == 'error_try_default_mirror': self.yes_button.connect("clicked", self.try_default_mirror, None) elif self.gui == 'error_try_forcing_english': self.yes_button.connect("clicked", self.try_forcing_english, None) elif self.gui == 'error_try_tor': self.yes_button.connect("clicked", self.try_tor, None) self.button_box.add(self.yes_button) self.yes_button.show() # exit button exit_image = gtk.Image() exit_image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON) self.exit_button = gtk.Button("Exit") self.exit_button.set_image(exit_image) self.exit_button.connect("clicked", self.destroy, None) self.button_box.add(self.exit_button) self.exit_button.show() elif self.gui == 'task': # label self.label = gtk.Label(self.gui_message) self.label.set_line_wrap(True) self.box.pack_start(self.label, True, True, 0) self.label.show() # progress bar self.progressbar = gtk.ProgressBar(adjustment=None) self.progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT) self.progressbar.set_pulse_step(0.01) self.box.pack_start(self.progressbar, True, True, 0) # button box self.button_box = gtk.HButtonBox() self.button_box.set_layout(gtk.BUTTONBOX_SPREAD) self.box.pack_start(self.button_box, True, True, 0) self.button_box.show() # start button start_image = gtk.Image() start_image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON) self.start_button = gtk.Button(_("Start")) self.start_button.set_image(start_image) self.start_button.connect("clicked", self.start, None) self.button_box.add(self.start_button) if not self.gui_autostart: self.start_button.show() # exit button exit_image = gtk.Image() exit_image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON) self.exit_button = gtk.Button(_("Cancel")) self.exit_button.set_image(exit_image) self.exit_button.connect("clicked", self.destroy, None) self.button_box.add(self.exit_button) self.exit_button.show() self.box.show() self.window.show() if self.gui_autostart: self.start(None)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_resizable(True) self.window.connect("destroy", self.destroy_progress) self.window.set_title("ProgressBar") self.window.set_border_width(0) vbox = gtk.VBox(False, 5) vbox.set_border_width(10) self.window.add(vbox) vbox.show() # Create a centering alignment object align = gtk.Alignment(0.5, 0.5, 0, 0) vbox.pack_start(align, False, False, 5) align.show() # Create the ProgressBar self.pbar = gtk.ProgressBar() align.add(self.pbar) self.pbar.show() # Add a timer callback to update the value of the progress bar self.timer = gobject.timeout_add(100, progress_timeout, self) separator = gtk.HSeparator() vbox.pack_start(separator, False, False, 0) separator.show() # rows, columns, homogeneous table = gtk.Table(2, 2, False) vbox.pack_start(table, False, True, 0) table.show() # Add a check button to select displaying of the trough text check = gtk.CheckButton("Show text") table.attach(check, 0, 1, 0, 1, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 5, 5) check.connect("clicked", self.toggle_show_text) check.show() # Add a check button to toggle activity mode self.activity_check = check = gtk.CheckButton("Activity mode") table.attach(check, 0, 1, 1, 2, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 5, 5) check.connect("clicked", self.toggle_activity_mode) check.show() # Add a check button to toggle orientation check = gtk.CheckButton("Right to Left") table.attach(check, 0, 1, 2, 3, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 5, 5) check.connect("clicked", self.toggle_orientation) check.show() # Add a button to exit the program button = gtk.Button("close") button.connect("clicked", self.destroy_progress) vbox.pack_start(button, False, False, 0) # This makes it so the button is the default. button.set_flags(gtk.CAN_DEFAULT) # This grabs this button to be the default button. Simply hitting # the "Enter" key will cause this button to activate. button.grab_default() button.show() self.window.show()
def __init__(self): filename = os.path.join(paths.lib_dir(), 'bauble.glade') self.widgets = utils.load_widgets(filename) self.window = self.widgets.main_window self.window.hide() # restore the window size geometry = prefs[self.window_geometry_pref] if geometry is not None: self.window.set_default_size(*geometry) self.window.connect('delete-event', self.on_delete_event) self.window.connect("destroy", self.on_quit) self.window.set_title(self.title) try: pixbuf = gtk.gdk.pixbuf_new_from_file(bauble.default_icon) self.window.set_icon(pixbuf) except Exception: logger.warning( _('Could not load icon from %s' % bauble.default_icon)) logger.warning(traceback.format_exc()) menubar = self.create_main_menu() self.widgets.menu_box.pack_start(menubar) combo = self.widgets.main_comboentry model = gtk.ListStore(str) combo.set_model(model) self.populate_main_entry() main_entry = combo.child main_entry.connect('activate', self.on_main_entry_activate) accel_group = gtk.AccelGroup() main_entry.add_accelerator("grab-focus", accel_group, ord('L'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) self.window.add_accel_group(accel_group) go_button = self.widgets.go_button go_button.connect('clicked', self.on_go_button_clicked) query_button = self.widgets.query_button query_button.connect('clicked', self.on_query_button_clicked) self.set_default_view() # add a progressbar to the status bar # Warning: this relies on gtk.Statusbar internals and could break in # future versions of gtk statusbar = self.widgets.statusbar statusbar.set_spacing(10) statusbar.set_has_resize_grip(True) self._cids = [] def on_statusbar_push(sb, cid, txt): if cid not in self._cids: self._cids.append(cid) statusbar.connect('text-pushed', on_statusbar_push) # remove label from frame frame = statusbar.get_children()[0] #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF0000')) label = frame.get_children()[0] frame.remove(label) # replace label with hbox and put label and progress bar in hbox hbox = gtk.HBox(False, 5) frame.add(hbox) hbox.pack_start(label, True, True, 0) vbox = gtk.VBox(True, 0) hbox.pack_end(vbox, False, True, 15) self.progressbar = gtk.ProgressBar() vbox.pack_start(self.progressbar, False, False, 0) self.progressbar.set_size_request(-1, 10) vbox.show() hbox.show() from pyparsing import StringStart, Word, alphanums, restOfLine, \ StringEnd cmd = StringStart() + ':' + Word(alphanums + '-_').setResultsName('cmd') arg = restOfLine.setResultsName('arg') self.cmd_parser = (cmd + StringEnd()) | (cmd + '=' + arg) | arg combo.grab_focus()
def set_os_list(self, os_list, os_match): # Creating the main widgets for this section self.os_expander.set_use_markup(True) self.os_expander.set_expanded(True) self.os_table, self.os_hbox = self.create_table_hbox() self.os_progress = gtk.ProgressBar() # Setting the current match's details in the widgets if len(os_list) > 1: self.os_list = gtk.combo_box_new_text() model = self.os_list.get_model() [ model.append([os['name']]) for os in os_list if os.has_key("name") ] self.os_list.set_active(0) # In case we have the os selection changed, we need to change the # icon and the current accuracy. Also, we need to save the selection # in the usr result. self.os_list.connect("changed", self.os_selection_changed) else: self.os_list = HIGEntryLabel(os_match.get("name", "Not Available")) self.os_table.attach(HIGEntryLabel(_('Name:')), 0, 1, 0, 1) self.os_table.attach(self.os_list, 1, 2, 0, 1) # Setting current os_match accuracy if os_match.get("accuracy", ''): self.os_progress.set_fraction(float(os_match['accuracy']) / 100.0) self.os_progress.set_text(os_match['accuracy'] + '%') self.os_progress.set_sensitive(True) else: self.os_progress.set_sensitive(False) self.os_progress.set_text(_('Not Available')) self.os_table.attach(HIGEntryLabel(_('Accuracy:')), 0, 1, 1, 2) self.os_table.attach(self.os_progress, 1, 2, 1, 2) ################### ## Setting the list of matches and the list of ports used in the scan if os_match.has_key("portsused"): self.set_ports_used(os_match["portsused"]) self.portsused_expander.set_sensitive(True) else: # In case we don't have any port, we still show the expander widget # but in a non-sensitive manner self.portsused_expander.set_sensitive(False) self.portsused_expander.set_use_markup(True) self.os_table.attach(self.portsused_expander, 0, 2, 2, 3) if os_match.has_key('osclass'): self.set_osclass(os_match['osclass']) self.osclass_expander.set_sensitive(True) else: self.osclass_expander.set_sensitive(False) self.osclass_expander.set_use_markup(True) self.os_table.attach(self.osclass_expander, 0, 2, 3, 4) self.os_expander.add(self.os_hbox) self._pack_noexpand_nofill(self.os_expander) # Saving os_list and os_match for latter access self.current_os_list = os_list self.current_os_match = os_match
def on_detect_connections(self, widget, data=None): ''' Auto-detect adjacent electrodes in device; prompt to save updated SVG. .. versionchanged:: X.X.X Prompt for output file location instead of forcefully overwriting source device SVG file. ''' app = get_app() svg_source = ph.path(app.dmf_device.svg_filepath) # Reference to parent window for dialogs. parent_window = app.main_window_controller.view dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, parent=parent_window) dialog.set_title('Detecting connections between electrodes') dialog.props.text = markdown2pango( 'Detecting connections between electrodes ' 'in `%s`...' % svg_source).strip() dialog.props.use_markup = True dialog.props.destroy_with_parent = True dialog.props.window_position = gtk.WIN_POS_MOUSE # Disable `X` window close button. dialog.props.deletable = False content_area = dialog.get_content_area() progress = gtk.ProgressBar() content_area.pack_start(progress, fill=True, expand=True, padding=5) content_area.show_all() progress.props.can_focus = True progress.props.has_focus = True @gtk_threadsafe def on_finished(future): # Retrieve auto-detected connection results from background task. connections_svg = future.result() # Remove existing "Connections" layer and merge new "Connections" # layer with original SVG. output_svg =\ sm.merge.merge_svg_layers([sm.remove_layer(svg_source, 'Connections'), connections_svg]) try: default_path = DEVICES_DIR.joinpath(svg_source.name) output_path = \ select_device_output_path(title='Please select location to' ' save device', default_path=default_path, parent=parent_window) except IOError: _L().debug('No output path was selected.') else: with open(output_path, 'w') as output: output.write(output_svg.getvalue()) # Load new device. self.load_device(output_path) with ThreadPoolExecutor() as executor: # Use background thread to auto-detect adjacent electrodes from SVG # paths and polygons from `Device` layer. future = executor.submit( sm.detect_connections.auto_detect_adjacent_shapes, svg_source, shapes_xpath=ELECTRODES_XPATH) def update_progress(): while not future.done(): gtk_threadsafe(progress.pulse)() time.sleep(.25) gtk_threadsafe(dialog.destroy)() # Launch dialog with pulsing progress indicator. threads = [threading.Thread(target=f) for f in (update_progress, )] for t in threads: t.daemon = True t.start() future.add_done_callback(on_finished) dialog.run()
def renumber_annotations(self, m, at): """Renumber all annotations of a given type. """ d = gtk.Dialog(title=_("Renumbering annotations of type %s") % self.get_title(at), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) l=gtk.Label() l.set_markup(_("<b>Renumber all annotations according to their order.</b>\n\n<i>Note that this action cannot be undone.</i>\nReplace the first numeric value of the annotation content with the new annotation number.\nIf no numeric value is found and the annotation is structured, it will insert the number.\nIf no numeric value is found and the annotation is of type text/plain, it will overwrite the annotation content.\nThe offset parameter allows you to renumber from a given annotation.")) l.set_line_wrap(True) l.show() d.vbox.add(l) hb=gtk.HBox() l=gtk.Label(_("Offset")) hb.pack_start(l, expand=False) s=gtk.SpinButton() s.set_range(-5, len(at.annotations)) s.set_value(1) s.set_increments(1, 5) hb.add(s) d.vbox.pack_start(hb, expand=False) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res=d.run() if res == gtk.RESPONSE_OK: re_number=re.compile('(\d+)') re_struct=re.compile('^num=(\d+)$', re.MULTILINE) offset=s.get_value_as_int() - 1 l=at.annotations l.sort(key=lambda a: a.fragment.begin) l=l[offset:] size=float(len(l)) dial=gtk.Dialog(_("Renumbering %d annotations") % size, None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) prg=gtk.ProgressBar() dial.vbox.pack_start(prg, expand=False) dial.show_all() for i, a in enumerate(l[offset:]): prg.set_text(_("Annotation #%d") % i) prg.set_fraction( i / size ) while gtk.events_pending(): gtk.main_iteration() if a.type.mimetype == 'application/x-advene-structured': if re_struct.search(a.content.data): # A 'num' field is present. Update it. data=re_struct.sub("num=%d" % (i+1), a.content.data) else: # Insert the num field data=("num=%d\n" % (i+1)) + a.content.data elif re_number.search(a.content.data): # There is a number. Simply substitute the new one. data=re_number.sub(str(i+1), a.content.data) elif a.type.mimetype == 'text/plain': # Overwrite the contents data=str(i+1) else: data=None if data is not None and a.content.data != data: a.content.data=data self.controller.notify('PackageActivate', package=self.controller.package) dial.destroy() d.destroy() return True
def __init__(self): # the window itself self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.destroy) self.window.set_border_width(10) self.window.set_title("RegexpRenamer") # general layout self.vbox1 = gtk.VBox(False) self.window.add(self.vbox1) self.vbox1.set_property("spacing", 2) # toolbar self.toolbar = gtk.Toolbar() self.vbox1.pack_start(self.toolbar, False, True, 0) iconw = gtk.Image() iconw.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) self.toolbar.append_item("Add file", "Add another file to be renamed.", "Private info", iconw, self.on_add_file) iconw = gtk.Image() iconw.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON) self.toolbar.append_item("Remove file", "Remove selected file from list.", "Private info", iconw, self.on_remove_file) # tree-view with scroller self.tvscroll = gtk.ScrolledWindow() self.vbox1.pack_start(self.tvscroll, True, True, 0) self.tv = gtk.TreeView() self.tvscroll.add(self.tv) self.tv.connect("drag_data_received", self.on_drag_data_received) self.tv.enable_model_drag_dest([("text/uri-list",0,80)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY) # bottom "navigation" self.inputgrid = gtk.HBox(False) self.vbox1.pack_start(self.inputgrid, False, False) self.labelbox = gtk.VBox(2) self.labelbox.set_border_width(5) self.txtbox = gtk.VBox(2) self.txtbox.set_border_width(5) self.inputgrid.pack_start(self.labelbox, False, False) self.inputgrid.pack_start(self.txtbox, True, True) # labels self.lblregexp = gtk.Label("Regexp:") self.labelbox.pack_start(self.lblregexp, False, False) self.lblregexp.set_alignment(0,0.5) self.lblreplacement = gtk.Label("Replacement:") self.labelbox.pack_start(self.lblreplacement, False, False) self.lblreplacement.set_alignment(0,0.5) # input fields self.txtregex = gtk.Entry() self.txtbox.pack_start(self.txtregex, True, True) self.txtregex.set_text("(.*)") self.txtregex.connect("focus-out-event", self.onpreview) self.txtreplacement = gtk.Entry() self.txtbox.pack_start(self.txtreplacement, True, True) self.txtreplacement.set_text("\\1") self.txtreplacement.connect("focus-out-event", self.onpreview) # button self.btnRename = gtk.Button("Rename") self.vbox1.pack_start(self.btnRename, False, False) self.btnRename.connect("pressed",self.onrename) # the liststore self.liststore = gtk.ListStore(str, str, str, str) self.tv.set_model(self.liststore) cellpb = gtk.CellRendererPixbuf() colorigname = gtk.TreeViewColumn("Original name", text=0) cellt = gtk.CellRendererText() self.tv.append_column(colorigname) colorigname.pack_start(cellpb, False) colorigname.pack_start(cellt) colorigname.set_attributes(cellt, text=0) colorigname.set_attributes(cellpb, icon_name=3) self.tv.append_column( gtk.TreeViewColumn("New name", gtk.CellRendererText(), text=1)) self.tv.append_column( gtk.TreeViewColumn("Directory", gtk.CellRendererText(), text=2)) # statusbar self.statusbar = gtk.Statusbar() self.statusbar.set_property("has-resize-grip", False) self.vbox1.pack_end(self.statusbar, False, True) self.pb = gtk.ProgressBar() self.statusbar.pack_start(self.pb) cid = self.statusbar.get_context_id("Renamer") self.statusbar.push(cid, "Renamer") # show window with all its widgets self.window.resize(400,300) self.window.show_all()
def apply(self, interface, testing=False): try: qubes_users = self.admin.enumerateUsersByGroup('qubes') if len(qubes_users) < 1: self._showErrorMessage( _("You must create a user account to create default VMs.")) return RESULT_FAILURE else: self.qubes_user = qubes_users[0] for choice in QubesChoice.instances: choice.store_selected() choice.widget.set_sensitive(False) self.check_advanced.set_sensitive(False) interface.nextButton.set_sensitive(False) interface.backButton.set_sensitive(False) if self.progress is None: self.progress = gtk.ProgressBar() self.progress.set_pulse_step(0.06) self.vbox.pack_start(self.progress, True, False) self.progress.show() if testing: return RESULT_SUCCESS if self.check_advanced.get_active(): return RESULT_SUCCESS errors = [] # Finish template(s) installation, because it wasn't fully possible # from anaconda (it isn't possible to start a VM there). # This is specific to firstboot, not general configuration. for template in os.listdir('/var/lib/qubes/vm-templates'): try: self.configure_template(template) except Exception as e: errors.append((self.stage, str(e))) self.configure_default_template() self.configure_qubes() self.configure_network() if self.choice_usb.get_selected() \ and not self.choice_usb_with_net.get_selected(): # Workaround for #1464 (so qvm.start from salt can't be used) self.run_command_in_thread( ['systemctl', 'start', '*****@*****.**']) try: self.configure_default_dvm() except Exception as e: errors.append((self.stage, str(e))) if errors: msg = "" for (stage, error) in errors: msg += "{} failed:\n{}\n\n".format(stage, error) self.stage = "firstboot" raise Exception(msg) interface.nextButton.set_sensitive(True) return RESULT_SUCCESS except Exception as e: md = gtk.MessageDialog(interface.win, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, self.stage + " failure!\n\n" + str(e)) md.run() md.destroy() self.show_stage("Failure...") self.progress.hide() self.check_advanced.set_active(True) interface.nextButton.set_sensitive(True) return RESULT_FAILURE
def probBacnet(self, treeview, treeStore, device_net): window = gtk.Window(gtk.WINDOW_TOPLEVEL) #window.connect("delete_event", self.delete) #window.connect("destroy", self.delete) window.set_border_width(10) window.set_title('OPC and Bacnet Loading...') window.set_position(gtk.WIN_POS_CENTER_ALWAYS ) # set window to center posiotion whwn startup window.set_default_size(550, 100) window.set_destroy_with_parent(True) vbox = gtk.VBox(False, 5) hbox = gtk.HBox(False, 2) hbox.show() vbox.pack_start(hbox, False, False, 5) # Create the ProgressBar self.pbar = gtk.ProgressBar() self.pbar.show() self.pbar.set_text('Finding device...') hbox.add(self.pbar) #hbox = gtk.HBox(True, 2) #hbox.show() label = gtk.Label('Browe device on network: ') label.show() #hbox.add(label) bbox = gtk.HButtonBox() vbox.pack_start(bbox, False, False, 5) layout = gtk.BUTTONBOX_START bbox.set_layout(layout) bbox.set_spacing(5) bbox.add(label) bbox.show() bbox = gtk.HButtonBox() vbox.pack_start(bbox, False, False, 0) layout = gtk.BUTTONBOX_SPREAD bbox.set_layout(layout) bbox.set_spacing(10) buttonClose = gtk.Button(stock='gtk-close') #vbox.pack_start(buttonClose, True, True, 5) def close_dialog(self, window): #itemPropertySelect.window = None window.destroy() buttonClose.connect("clicked", close_dialog, window) bbox.add(buttonClose) buttonClose.show() bbox.show() txt_load = "" self.finish = False state = False #timer = gobject.timeout_add (1200, progress_timeout, pbar,label,self.finish) window.add(vbox) vbox.show() window.set_modal(True) window.show() # Widget pack send to other class device_found = [] widgetPack = { 'finish': True, 'progress': self.pbar, 'label': label, 'getDevice': device_found } widgetPack['treeview'] = treeview widgetPack['treestore'] = treeStore widgetPack[ 'device_net'] = device_net # device_net[device_name[i]]['device_id'] timer = gobject.timeout_add(100, self.pulse_progress, label, widgetPack) #timer1 = gobject.timeout_add (1200, self.getBacnetDevice, label,self.pbar) getDevcie = BacnetThread(widgetPack) getDevcie.start() print 'return devcie is ', widgetPack['getDevice'] return widgetPack['getDevice'] # return list of deivce
def __init__(self, src, dst, actions): self.__progress = None self.cancel = False self.txt_operation = _("Copying files") self.label_under = None self.num_items = 1 # force copying of non-local objects if (actions & gtk.gdk.ACTION_LINK): if src[0].get_path() is None: actions = gtk.gdk.ACTION_COPY if not (actions & gtk.gdk.ACTION_LINK): if (actions & gtk.gdk.ACTION_MOVE): self.txt_operation = _("Moving files") elif (actions == 0): self.txt_operation = _("Deleting files") self.dialog = gtk.Dialog(title=self.txt_operation, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) self.dialog.set_border_width(12) self.dialog.set_has_separator(False) self.dialog.vbox.set_spacing(2) hbox_copy = gtk.HBox(False, 0) label_copy = gtk.Label("") label_copy.set_markup("<big><b>%s</b></big>\n" % self.txt_operation) hbox_copy.pack_start(label_copy, False, False, 0) self.dialog.vbox.add(hbox_copy) hbox_info = gtk.HBox(False, 0) label_fromto = gtk.Label("") label_fromto.set_justify(gtk.JUSTIFY_RIGHT) hbox_info.pack_start(label_fromto, False, False, 0) srcdir = src[0].get_parent().get_uri() if len(dst) > 0: label_fromto.set_markup("<b>From:</b>\n<b>To:</b>") dstdir = dst[0].get_parent().get_uri() else: dstdir = "" label_fromto.set_markup("<b>From:</b>\n") label_srcdst = gtk.Label("") label_srcdst.set_alignment(0.0, 0.5) label_srcdst.set_ellipsize(pango.ELLIPSIZE_START) label_srcdst.set_markup("%s\n%s" % (srcdir, dstdir)) hbox_info.pack_start(label_srcdst, True, True, 4) self.dialog.vbox.add(hbox_info) self.progress_bar = gtk.ProgressBar() self.dialog.vbox.add(self.progress_bar) hbox_under = gtk.HBox(False, 0) self.label_under = gtk.Label("") self.label_under.set_justify(gtk.JUSTIFY_LEFT) self.label_under.set_ellipsize(pango.ELLIPSIZE_MIDDLE) self.label_under.xalign = 0.0 hbox_under.pack_start(self.label_under, True, True, 0) self.dialog.vbox.add(hbox_under) self.status_label = gtk.Label() self.dialog.vbox.add(self.status_label) self.dialog.set_size_request(400,-1) self.dialog.connect("response", self._dialog_response) self.cancellable = gio.Cancellable() def _copy_callback(file, result, items): try: if file is None or file.copy_finish(result): if len(items) > 0: source, dest = items.pop() self.label_under.set_markup( "<i>%s %s</i>" % (self.txt_operation, str(source.get_basename()))) self.progress_bar.set_text(self.txt_operation + " " + _("%d of %d") % (self.num_items - len(items), self.num_items)) source.copy_async(dest, _copy_callback, _copy_progress, cancellable=self.cancellable, user_data=items) else: self._finish() else: print "copy failed" except gio.Error: self._finish() def _copy_progress(current, total): if self.dialog: if current > 0 and total > 0: fraction = float(current)/total self.progress_bar.set_fraction(fraction) def _delete_cb(src, result): try: en = src.enumerate_children_finish(result) fi = en.next_file(None) while fi != None: child = en.get_container().get_child(fi.get_name()) child.trash(None) fi = en.next_file(None) en.close(None) self._finish() except gio.Error: self._finish() if actions == 0: # remove the contents of directory print "We're deleting %s" % src[0] src[0].enumerate_children_async("standard::name", _delete_cb, cancellable=self.cancellable) elif (actions & gtk.gdk.ACTION_MOVE): # why the hell isn't there gio.File.move_async() ?? for item in zip(src, dst): source, dest = item source.move(dest, cancellable=self.cancellable) self._finish() elif (actions & gtk.gdk.ACTION_LINK): for item in zip(src, dst): source, dest = item dest.make_symbolic_link(source.get_path()) self._finish() else: # gtk.gdk.ACTION_COPY items = zip(src, dst) items.reverse() self.num_items = len(items) _copy_callback(None, None, items) # show dialog after 1 sec gobject.timeout_add(1000, self._dialog_show)
cbut = gtk.Button("Cancel") def callback (button, *args): cbut.set_sensitive(False) worker.cancel() cbut.connect("clicked", callback) vbox.add(cbut) gbut = gtk.Button("Get") def callback (button, *args): gbut.set_sensitive(False) print "Found:", worker.get() gbut.connect("clicked", callback) vbox.add(gbut) prog = gtk.ProgressBar() def callback (worker, progress): prog.set_fraction(progress) worker.connect("progressed", callback) vbox.add(prog) field = gtk.Entry() def process (worker, primes): field.set_text(str(primes[-1])) worker.connect("published", process) vbox.add(field) def done (worker): print "Finished, Cancelled:", worker.isCancelled() worker.connect("done", done)
def __init__(self, command, stdoutfile, width=400, height=400, standalone=False, ignore_command=False, title=None): self.standalone = standalone self.command = command self.ignore_command = ignore_command self.stdout = stdoutfile self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_border_width(5) if title is None: self.window.set_title('Command Output') else: self.window.set_title(title) self.window.connect("delete_event", self.quit) self.window.set_default_size(width, height) self.window.set_icon(get_icon()) self.quit_already = False self.find_current = None self.find_current_iter = None self.search_warning_done = False sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) sw.show() self.textview = gtk.TextView() self.textview.set_editable(False) self.textview.set_wrap_mode(gtk.WRAP_WORD) # Use a monospace font. This is safe - by testing - setting an # illegal font description has no effect. self.textview.modify_font(pango.FontDescription("monospace")) tb = self.textview.get_buffer() self.textview.show() self.ftag = tb.create_tag(None, background="#70FFA9") vbox = gtk.VBox() vbox.show() if not self.ignore_command: self.progress_bar = gtk.ProgressBar() self.progress_bar.set_text(command) self.progress_bar.set_pulse_step(0.04) self.progress_bar.show() vbox.pack_start(self.progress_bar, expand=False) self.command_label = gtk.Label(self.command) if self.ignore_command: self.command_label.show() vbox.pack_start(self.command_label, expand=False) sw.add(self.textview) frame = gtk.Frame() frame.add(sw) frame.show() vbox.add(frame) save_button = gtk.Button("Save As") save_button.connect("clicked", self.save, self.textview) save_button.show() hbox = gtk.HBox() hbox.pack_start(save_button, False) hbox.show() output_label = gtk.Label('output : ' + stdoutfile.name) output_label.show() hbox.pack_start(output_label, expand=True) self.freeze_button = gtk.ToggleButton("_Disconnect") self.freeze_button.set_active(False) self.freeze_button.connect("toggled", self.freeze) self.freeze_button.show() searchbox = gtk.HBox() searchbox.show() entry = gtk.Entry() entry.show() entry.connect("activate", self.enter_clicked) searchbox.pack_start(entry, True) b = gtk.Button("Find Next") b.connect_object('clicked', self.on_find_clicked, entry) b.show() searchbox.pack_start(b, False) searchbox.pack_start(self.freeze_button, False) close_button = gtk.Button("_Close") close_button.connect("clicked", self.quit, None, None) close_button.show() hbox.pack_end(close_button, False) vbox.pack_start(searchbox, False) vbox.pack_start(hbox, False) self.window.add(vbox) close_button.grab_focus() self.window.show()
def _add_progress_bar(self): layout = self.get_content_area() self.cur_prog_bar = gtk.ProgressBar() self.cur_prog_bar.set_pulse_step(0.01) layout.pack_start(self.cur_prog_bar, expand=False) layout.show_all()
break progress.set_fraction(0.0) progress.set_text("") progress.grab_remove() dialog = gtk.Dialog("Modal Trick", None, 0, (gtk.STOCK_EXECUTE, gtk.RESPONSE_APPLY, gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) dialog.connect("response", response) dialog.connect("destroy", gtk.main_quit) box = dialog.get_child() widget = gtk.CheckButton("Check me!") box.pack_start(widget, False, False, 0) widget = gtk.Entry() box.pack_start(widget, False, False, 0) adj = gtk.Adjustment(0.0, 0.0, 100.0, 1.0, 10.0, 0.0) widget = gtk.HScale(adj) box.pack_start(widget, False, False, 0) widget = gtk.ProgressBar() box.pack_start(widget, False, False, 0) dialog.set_data("progress", widget) dialog.show_all() gtk.main()
def __init__(self, img): #layout self.contenitore_gen = gtk.VBox() box_gen = gtk.VBox() box_tab = gtk.VBox() self.contenitore_gen.pack_start(box_gen, False, False, 0) #window self.win = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win.connect("destroy", self.destroy) self.win.set_title("Win-Iconizer 1.0") self.win.set_position(gtk.WIN_POS_CENTER) self.win.set_default_size(400, 400) self.win.set_resizable(False) self.win.set_border_width(2) self.icon = self.win.render_icon(gtk.STOCK_NO, gtk.ICON_SIZE_BUTTON) self.win.set_icon(self.icon) self.label = gtk.Label( "Select the formats you would like to create:\n") self.win.add(self.contenitore_gen) box_gen.pack_start(box_tab, True, True, 1) box_tab.pack_start(self.label, True, True, 1) tooltips = gtk.Tooltips() table = gtk.Table(8, 5, False) table.set_col_spacings(5) table.attach(gtk.Label(""), 0, 1, 0, 1) table.attach(gtk.Label("16"), 1, 2, 0, 1) table.attach(gtk.Label("24"), 2, 3, 0, 1) table.attach(gtk.Label("32"), 3, 4, 0, 1) table.attach(gtk.Label("48"), 4, 5, 0, 1) table.attach(gtk.Label("64"), 5, 6, 0, 1) table.attach(gtk.Label("128"), 6, 7, 0, 1) table.attach(gtk.Label("256"), 7, 8, 0, 1) table.attach(gtk.Label("512"), 8, 9, 0, 1) #1-bit 2 colors self.c_1b_16p = gtk.CheckButton("") self.c_1b_16p.set_size_request(20, 20) self.c_1b_24p = gtk.CheckButton("") self.c_1b_24p.set_size_request(20, 20) self.c_1b_32p = gtk.CheckButton("") self.c_1b_32p.set_size_request(20, 20) self.c_1b_48p = gtk.CheckButton("") self.c_1b_48p.set_size_request(20, 20) self.c_1b_64p = gtk.CheckButton("") self.c_1b_64p.set_size_request(20, 20) self.c_1b_128p = gtk.CheckButton("") self.c_1b_128p.set_size_request(20, 20) self.c_1b_256p = gtk.CheckButton("") self.c_1b_256p.set_size_request(20, 20) self.c_1b_512p = gtk.CheckButton("") self.c_1b_512p.set_size_request(20, 20) l_mono = gtk.Label("Mono") table.attach(l_mono, 0, 1, 1, 2) tooltips.set_tip(l_mono, "Mono - 1-bit") table.attach(self.c_1b_16p, 1, 2, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_24p, 2, 3, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_32p, 3, 4, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_48p, 4, 5, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_64p, 5, 6, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_128p, 6, 7, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_256p, 7, 8, 1, 2, xoptions=gtk.EXPAND) table.attach(self.c_1b_512p, 8, 9, 1, 2, xoptions=gtk.EXPAND) #4-bit 16 colors self.c_16c_16p = gtk.CheckButton("") self.c_16c_16p.set_size_request(20, 20) self.c_16c_24p = gtk.CheckButton("") self.c_16c_24p.set_size_request(20, 20) self.c_16c_32p = gtk.CheckButton("") self.c_16c_32p.set_size_request(20, 20) self.c_16c_48p = gtk.CheckButton("") self.c_16c_48p.set_size_request(20, 20) self.c_16c_64p = gtk.CheckButton("") self.c_16c_64p.set_size_request(20, 20) self.c_16c_128p = gtk.CheckButton("") self.c_16c_128p.set_size_request(20, 20) self.c_16c_256p = gtk.CheckButton("") self.c_16c_256p.set_size_request(20, 20) self.c_16c_512p = gtk.CheckButton("") self.c_16c_512p.set_size_request(20, 20) l_16c = gtk.Label("16 Colors") table.attach(l_16c, 0, 1, 2, 3) tooltips.set_tip(l_16c, "16 Colors - 4-bits") table.attach(self.c_16c_16p, 1, 2, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_24p, 2, 3, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_32p, 3, 4, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_48p, 4, 5, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_64p, 5, 6, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_128p, 6, 7, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_256p, 7, 8, 2, 3, xoptions=gtk.EXPAND) table.attach(self.c_16c_512p, 8, 9, 2, 3, xoptions=gtk.EXPAND) #8-bit 256 colors self.c_256c_16p = gtk.CheckButton("") self.c_256c_16p.set_size_request(20, 20) self.c_256c_24p = gtk.CheckButton("") self.c_256c_24p.set_size_request(20, 20) self.c_256c_32p = gtk.CheckButton("") self.c_256c_32p.set_size_request(20, 20) self.c_256c_48p = gtk.CheckButton("") self.c_256c_48p.set_size_request(20, 20) self.c_256c_64p = gtk.CheckButton("") self.c_256c_64p.set_size_request(20, 20) self.c_256c_128p = gtk.CheckButton("") self.c_256c_128p.set_size_request(20, 20) self.c_256c_256p = gtk.CheckButton("") self.c_256c_256p.set_size_request(20, 20) self.c_256c_512p = gtk.CheckButton("") self.c_256c_512p.set_size_request(20, 20) l_256c = gtk.Label("256 Colors") table.attach(l_256c, 0, 1, 3, 4) tooltips.set_tip(l_256c, "256 Colors - 8-bits") table.attach(self.c_256c_16p, 1, 2, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_24p, 2, 3, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_32p, 3, 4, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_48p, 4, 5, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_64p, 5, 6, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_128p, 6, 7, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_256p, 7, 8, 3, 4, xoptions=gtk.EXPAND) table.attach(self.c_256c_512p, 8, 9, 3, 4, xoptions=gtk.EXPAND) #32-bit 4.2 billion colors RGBA self.c_32b_16p = gtk.CheckButton("") self.c_32b_16p.set_size_request(20, 20) self.c_32b_24p = gtk.CheckButton("") self.c_32b_24p.set_size_request(20, 20) self.c_32b_32p = gtk.CheckButton("") self.c_32b_32p.set_size_request(20, 20) self.c_32b_48p = gtk.CheckButton("") self.c_32b_48p.set_size_request(20, 20) self.c_32b_64p = gtk.CheckButton("") self.c_32b_64p.set_size_request(20, 20) self.c_32b_128p = gtk.CheckButton("") self.c_32b_128p.set_size_request(20, 20) self.c_32b_256p = gtk.CheckButton("") self.c_32b_256p.set_size_request(20, 20) self.c_32b_512p = gtk.CheckButton("") self.c_32b_512p.set_size_request(20, 20) l_rgba = gtk.Label("RGB/A") table.attach(l_rgba, 0, 1, 4, 5) tooltips.set_tip(l_rgba, "RGB/A - 32-bits") table.attach(self.c_32b_16p, 1, 2, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_24p, 2, 3, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_32p, 3, 4, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_48p, 4, 5, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_64p, 5, 6, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_128p, 6, 7, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_256p, 7, 8, 4, 5, xoptions=gtk.EXPAND) table.attach(self.c_32b_512p, 8, 9, 4, 5, xoptions=gtk.EXPAND) box_tab.pack_start(table, True, True, 1) #icon type box_type = gtk.VBox(True, 5) default = gtk.RadioButton(None, "Default") default.connect("toggled", self.Set_Icon_Type, "default") default.set_active(False) tooltips.set_tip( default, "48x48 (256 colors, 16 colors)\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)" ) box_type.pack_start(default, False, False, 0) win_vista = gtk.RadioButton(default, "Win Vista") win_vista.connect("toggled", self.Set_Icon_Type, "win_vista") tooltips.set_tip( win_vista, "Recommended:\n256x256 (RGB/A)\n64x64 (RGB/A)\n48x48 (RGB/A, 256 colors, 16 colors)\n32x32 (RGB/A, 256 colors, 16 colors)\n24x24 (RGB/A, 256 colors, 16 colors)\n16x16 (RGB/A, 256 colors, 16 colors)\nMinimum:\n256x256 (RGB/A)\n48x48 (RGB/A, 256 colors)\n32x32 (RGB/A, 256 colors)\n16x16 (RGB/A, 256 colors)\nOptional:\n256x256 (256 colors, 16 colors)\n64x64 (256 colors, 16 colors)" ) box_type.pack_start(win_vista, False, False, 0) win_xp = gtk.RadioButton(default, "Win XP") win_xp.connect("toggled", self.Set_Icon_Type, "win_xp") tooltips.set_tip( win_xp, "Recommended:\n48x48 (RGB/A, 256 colors, 16 colors)\n32x32 (RGB/A, 256 colors, 16 colors)\n24x24 (RGB/A, 256 colors, 16 colors)\n16x16 (RGB/A, 256 colors, 16 colors)\nMinimum:\n32x32 (RGB/A, 256 colors, 16 colors),\n16x16 (RGB/A, 256 colors, 16 colors)\nOptional:\n128x128 (RGB/A)" ) box_type.pack_start(win_xp, False, False, 0) win_95 = gtk.RadioButton(default, "Win 95 - Win 98 - Win ME - Win 2000") win_95.connect("toggled", self.Set_Icon_Type, "win_95") tooltips.set_tip( win_95, "Recommended:\n48x48 (256 colors, 16 colors)\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)\nMinimum:\n32x32 (256 colors, 16 colors)\n16x16 (256 colors, 16 colors)" ) box_type.pack_start(win_95, False, False, 0) favico = gtk.RadioButton(default, "Favico") favico.connect("toggled", self.Set_Icon_Type, "favico") tooltips.set_tip( favico, "Recommended:\n32x32 (256 colors)\n16x16 (256 colors)") box_type.pack_start(favico, False, False, 0) custom = gtk.RadioButton(default, "Custom") custom.connect("toggled", self.Set_Icon_Type, "custom") tooltips.set_tip(custom, "Create your own icon") box_type.pack_start(custom, False, False, 0) box_gen.pack_start(gtk.Label(""), True, True, 1) box_gen.pack_start(box_type, True, True, 1) box_gen.pack_start(gtk.Label(""), True, True, 1) b_exe = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON) b_exe.set_image(image) b_exe.set_label("Create") b_exe.set_size_request(80, 35) b_exe.connect("clicked", self.Create_Icon, img) #progress bar self.pbar = gtk.ProgressBar() self.pbar.set_text("0 %") box_gen.pack_start(self.pbar, True, True, 5) box_gen.pack_start(b_exe, False, False, 1) #set default self.Set_Icon_Type(self, "default") self.win.show_all()
def __init__(self): self.fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL) self.fenetre.set_resizable( False) # Interdire le redimensionnement de la fenêtre self.fenetre.set_title( "worldmap - Installation Wizard") # Titre de la fenêtre #self.fenetre.set_decorated(False) # Cacher les contours de la fenêtre self.fenetre.set_icon_from_file("%s/images/icone.png" % WORLDMAP_PATH) # Spécifier une icône self.fenetre.set_position( gtk.WIN_POS_CENTER) # Centrer la fenêtre au lancement self.fenetre.set_border_width(0) # Largueur de la bordure intérieur # self.fenetre.set_size_request(430, 400) # Taille de la fenêtre self.fenetre.connect("delete_event", self.quitDialog) # Alerte de fermeture self.fenetre.show() self.boite_all = gtk.VBox(False, 5) self.boite_all.show() self.fixed_img = gtk.Fixed() self.fixed_img.set_size_request(430, 150) self.fixed_img.show() self.img_a_propos = gtk.Image() self.img_a_propos.set_from_file("%s/images/a_propos.png" % WORLDMAP_PATH) self.img_a_propos.show() self.fixed_img.put(self.img_a_propos, 0, 0) self.version = gtk.Label("v%s" % VERSION) self.version.show() self.fixed_img.put(self.version, 20, 80) self.boite_all.pack_start(self.fixed_img, False, False, 0) # self.boite_modules self.boite_modules = gtk.VBox(False, 5) self.boite_modules.set_border_width(10) self.boite_modules.show() # label1_modules label1_modules = gtk.Label("Install dependencies :") label1_modules.set_alignment(0, 0) self.boite_modules.pack_start(label1_modules, True, True, 0) label1_modules.show() # scrollbar_entree self.scrolled_modules = gtk.ScrolledWindow() self.scrolled_modules.set_size_request(250, 200) self.boite_modules.pack_start(self.scrolled_modules, False, False, 0) self.scrolled_modules.show() self.boite_site_modules = gtk.HBox(False, 0) self.scrolled_modules.add_with_viewport(self.boite_site_modules) self.scrolled_modules.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.boite_site_modules.show() self.boite_col1_modules = gtk.VBox(False, 0) self.boite_site_modules.pack_start(self.boite_col1_modules, True, True, 0) self.boite_col1_modules.show() self.boite2_modules = gtk.HBox(False, 5) self.boite_modules.pack_start(self.boite2_modules, False, False, 5) self.boite2_modules.show() # self.progressbar_modules self.progressbar_modules = gtk.ProgressBar() self.boite2_modules.pack_start(self.progressbar_modules, True, True, 0) self.progressbar_modules.show() # self.self.btn_modules self.btn_modules = gtk.Button("ok") self.btn_modules.set_size_request( int(self.btn_modules.size_request()[0] * 1.2), self.btn_modules.size_request()[1]) self.btn_modules.connect("clicked", self.quitDialog) self.boite2_modules.pack_start(self.btn_modules, False, False, 0) self.btn_modules.show() json_data = open('%s/core/modules.json' % WORLDMAP_PATH) data = simplejson.load(json_data) json_data.close() # for cathegorie in data.keys(): # print "cathegorie : %s" % cathegorie # for module in data[cathegorie]: # print "module : %s" % module['name'] # for dependance in module['dependency']: # if dependance['name']: # print "dependance : %s" % dependance['name'] i = 0 missingDep = 0 self.expanders = dict() self.vboxs = dict() self.hboxs = dict() self.labels = dict() self.btns = dict() for category in data.keys(): self.expanders[category] = gtk.Expander("<b>%s</b>" % category) self.expanders[category].props.use_markup = True self.expanders[category].set_expanded(True) self.boite_col1_modules.pack_start(self.expanders[category], False, False, 0) self.expanders[category].show() self.vboxs[category] = gtk.VBox(False, 0) self.expanders[category].add(self.vboxs[category]) self.vboxs[category].show() for module in data[category]: i += 1 self.labels[module['name']] = gtk.Label('%s :' % module['name']) self.vboxs[category].pack_start(self.labels[module['name']], False, False, 0) # self.labels[module['name']].set_active(True) # self.labels[module['name']].set_sensitive(False) self.labels[module['name']].set_alignment(0, 0.5) self.labels[module['name']].show() for dependency in module['dependency']: if dependency['name']: self.hboxs['%s - %s' % (dependency['name'], module['name'])] = gtk.HBox() self.vboxs[category].pack_start( self.hboxs['%s - %s' % (dependency['name'], module['name'])], fill=False) self.hboxs['%s - %s' % (dependency['name'], module['name'])].show() if self.checkDep(dependency['name'], dependency['type']): self.btns['%s - %s' % (dependency['name'], module['name'])] = gtk.Button( dependency['name']) else: self.btns['%s - %s' % ( dependency['name'], module['name'])] = gtk.Button( '<i><span foreground="red">%s</span></i>' % dependency['name']) self.btns['%s - %s' % (dependency['name'], module['name'] )].child.set_use_markup(True) missingDep += 1 self.btns['%s - %s' % ( dependency['name'], module['name'] )].set_size_request( int(self.btns['%s - %s' % (dependency['name'], module['name'])].size_request()[0] * 1.2), self.btns['%s - %s' % (dependency['name'], module['name'])].size_request()[1]) self.btns['%s - %s' % (dependency['name'], module['name'])].connect( "clicked", self.installDep, dependency, data) self.hboxs['%s - %s' % (dependency['name'], module['name'])].pack_start( self.btns['%s - %s' % (dependency['name'], module['name'])], False, False, 0) self.btns['%s - %s' % (dependency['name'], module['name'])].show() if missingDep: self.btn_modules.set_sensitive(False) self.progressbar_modules.set_text( "%d dependenc%s to install" % (missingDep, 'ies' if missingDep > 1 else 'y')) else: self.progressbar_modules.set_text( "nothing to install, you can continue") # self.separateur_modules self.separateur_modules = gtk.HSeparator() self.boite_modules.pack_start(self.separateur_modules, False, False, 0) self.separateur_modules.show() # self.label_entree_modules self.label_entree_modules = gtk.Label( "GNU General Public License v3.0") self.label_entree_modules.set_alignment(1, 0) self.boite_modules.pack_start(self.label_entree_modules, False, False, 0) self.label_entree_modules.show() self.boite_all.pack_start(self.boite_modules, False, False, 0) self.fenetre.add(self.boite_all) # self.fenetre.show_all() gtk.main()
def __init__(self, application, thread): self._window = gtk.Window(type=gtk.WINDOW_TOPLEVEL) self._paused = False self._application = application self._thread = thread self._size_format = '{0} / {1}' self._count_format = '{0} / {1}' self._has_source_destination = False self._has_current_file = False self._has_details = False self._size_format_type = self._application.options.get('size_format') self._hide_on_minimize = application.options.section('operations').get( 'hide_on_minimize') self._total_size = 0L self._total_count = 0L self._current_size = 0L self._current_count = 0L # aggregate speeds to provide accurate time prediction self._speeds = [] self._total_checkpoint = 0 # set window properties self._window.set_title('Operation Dialog') self._window.set_default_size(500, 10) self._window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self._window.set_resizable(True) self._window.set_skip_taskbar_hint(False) self._window.set_transient_for(application) self._window.set_wmclass('Sunflower', 'Sunflower') # connect signals self._window.connect('destroy', self._destroy) self._window.connect('delete-event', self._cancel_click) self._window.connect('window-state-event', self._window_state) # set icon self._application.icon_manager.set_window_icon(self._window) # create interface self._vbox = gtk.VBox(False, 5) # operation items self._operation_label = gtk.Label() self._operation_label.set_alignment(0, 0.5) self._operation_progress = gtk.ProgressBar() self._operation_image = gtk.Image() self._set_operation_image() vbox_operation = gtk.VBox(False, 0) vbox_operation.pack_start(self._operation_label, False, False, 0) vbox_operation.pack_start(self._operation_progress, False, False, 0) self._operation_item = self._application.add_operation( vbox_operation, self._operation_click) self._operation_item.set_image(self._operation_image) self._operation_item.show_all() # pack interface self._window.add(self._vbox)
def create_status_bar(self): self.bar = gtk.ProgressBar() self.vbox.pack_end(self.bar, expand=False)
class Application: def __init__(self): self.Dead = False self.ActiveProfile = None # Figure out our installation paths self.DATADIR = os.path.join( os.path.dirname(os.path.abspath(sys.argv[0])), "share").decode(FNENC) if not os.path.exists(self.DATADIR): self.DATADIR = os.path.join(os.path.normpath(sys.prefix), "share/xpd").decode(FNENC) if not os.path.exists(self.DATADIR): self.DATADIR = os.path.join( os.path.normpath( os.path.join( os.path.dirname(os.path.abspath(sys.argv[0])), "..")), "share/xpd").decode(FNENC) if not os.path.exists(self.DATADIR): raise SystemExit, _("FATAL: Could not find data directory") self.CONFIGDIR = os.path.join(glib.get_user_data_dir(), "xpd").decode('utf-8') if not os.access(self.CONFIGDIR, os.F_OK): os.makedirs(self.CONFIGDIR, 0700) def Initialize(self, textdomain): # Load the widgets from the GtkBuilder file self.builder = gtk.Builder() self.builder.set_translation_domain(textdomain) try: self.builder.add_from_file(self.DATADIR + "/gui.xml") except RuntimeError, e: raise SystemExit(str(e)) # Cache most used widgets into variables for widget in "MainWindow", "AboutDialog", "StatusBar", "SerialPortsList", \ "ProfileList", "EditProfileDialog", "ProfileName", "ParamDescLabel", \ "ParamVBox", "ControllerFamily", "UserChoice", "UserHints" : setattr(self, widget, self.builder.get_object(widget)) # Due to a bug in libglade we can't embed controls into the status bar self.ButtonCancelUpload = gtk.Button(stock="gtk-cancel") self.StatusBar.pack_end(self.ButtonCancelUpload, False, True, 0) self.ButtonCancelUpload.connect("clicked", self.on_ButtonCancelUpload_clicked) alignment = gtk.Alignment(0.5, 0.5) self.StatusBar.pack_end(alignment, False, True, 0) alignment.show() self.ProgressBar = gtk.ProgressBar() alignment.add(self.ProgressBar) self.StatusCtx = self.StatusBar.get_context_id("") self.builder.connect_signals(self) self.InitProfileList() self.LoadProfiles() self.FillFamilies() # Dynamic serial port list update worker self.SerialPortsHash = None self.UpdateSerialPorts() glib.timeout_add_seconds(1, self.RefreshSerialPorts) # Enable image buttons on Windows; on Linux you can change it via preferences if os.name == "nt": settings = gtk.settings_get_default() settings.set_property("gtk-button-images", True) self.MainWindow.show() self.SetStatus(_("Ready"))
def __init__(self, parent, profile_store, profiles, callback): self.profiles = profiles self.current_database = None self.old_profile, self.current_profile = None, None self.db_cache = None self.updating_db = False # GTK Stuffs self.parent = parent self.dialog = gtk.Dialog(title=_(u'Profile Editor'), parent=parent, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) self.ok_button = self.dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_icon(TRYTON_ICON) hpaned = gtk.HPaned() vbox_profiles = gtk.VBox(homogeneous=False, spacing=6) self.cell = gtk.CellRendererText() self.cell.set_property('editable', True) self.cell.connect('editing-started', self.edit_started) self.profile_tree = gtk.TreeView() self.profile_tree.set_model(profile_store) self.profile_tree.insert_column_with_attributes(-1, _(u'Profile'), self.cell, text=0) self.profile_tree.connect('cursor-changed', self.profile_selected) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(self.profile_tree) self.add_button = gtk.Button(_(u'_Add'), use_underline=True) self.add_button.connect('clicked', self.profile_create) add_image = gtk.Image() add_image.set_from_stock('gtk-add', gtk.ICON_SIZE_BUTTON) self.add_button.set_image(add_image) self.remove_button = gtk.Button(_(u'_Remove'), use_underline=True) self.remove_button.connect('clicked', self.profile_delete) remove_image = gtk.Image() remove_image.set_from_stock('gtk-remove', gtk.ICON_SIZE_BUTTON) self.remove_button.set_image(remove_image) vbox_profiles.pack_start(scroll, expand=True, fill=True) vbox_profiles.pack_start(self.add_button, expand=False, fill=True) vbox_profiles.pack_start(self.remove_button, expand=False, fill=True) hpaned.add1(vbox_profiles) table = gtk.Table(4, 2, homogeneous=False) table.set_row_spacings(3) table.set_col_spacings(3) host = gtk.Label(_(u'Host:')) host.set_alignment(1, 0.5) host.set_padding(3, 3) self.host_entry = gtk.Entry() self.host_entry.connect('focus-out-event', self.display_dbwidget) self.host_entry.connect('changed', self.update_profiles, 'host') self.host_entry.set_activates_default(True) host.set_mnemonic_widget(self.host_entry) table.attach(host, 0, 1, 1, 2, yoptions=False, xoptions=gtk.FILL) table.attach(self.host_entry, 1, 2, 1, 2, yoptions=False) database = gtk.Label(_(u'Database:')) database.set_alignment(1, 0.5) database.set_padding(3, 3) self.database_entry = gtk.Entry() self.database_entry.connect('changed', self.dbentry_changed) self.database_entry.connect('changed', self.update_profiles, 'database') self.database_entry.set_activates_default(True) self.database_label = gtk.Label() self.database_label.set_use_markup(True) self.database_label.set_alignment(0, 0.5) self.database_combo = gtk.ComboBox() dbstore = gtk.ListStore(gobject.TYPE_STRING) cell = gtk.CellRendererText() self.database_combo.pack_start(cell, True) self.database_combo.add_attribute(cell, 'text', 0) self.database_combo.set_model(dbstore) self.database_combo.connect('changed', self.dbcombo_changed) self.database_progressbar = gtk.ProgressBar() self.database_progressbar.set_text(_(u'Fetching databases list')) image = gtk.Image() image.set_from_stock('tryton-new', gtk.ICON_SIZE_BUTTON) db_box = gtk.VBox(homogeneous=True) db_box.pack_start(self.database_entry) db_box.pack_start(self.database_combo) db_box.pack_start(self.database_label) db_box.pack_start(self.database_progressbar) # Compute size_request of box in order to prevent "form jumping" width, height = 0, 0 for child in db_box.get_children(): cwidth, cheight = child.size_request() width, height = max(width, cwidth), max(height, cheight) db_box.set_size_request(width, height) table.attach(database, 0, 1, 2, 3, yoptions=False, xoptions=gtk.FILL) table.attach(db_box, 1, 2, 2, 3, yoptions=False) username = gtk.Label(_(u'Username:'******'changed', self.update_profiles, 'username') username.set_mnemonic_widget(self.username_entry) self.username_entry.set_activates_default(True) table.attach(username, 0, 1, 3, 4, yoptions=False, xoptions=gtk.FILL) table.attach(self.username_entry, 1, 2, 3, 4, yoptions=False) hpaned.add2(table) hpaned.set_position(250) self.dialog.vbox.pack_start(hpaned) self.dialog.set_default_size(640, 350) self.dialog.set_default_response(gtk.RESPONSE_ACCEPT) self.dialog.connect('close', lambda *a: False) self.dialog.connect('response', self.response) self.callback = callback
def ProgressWindow(text, title, q_window, q_bar, q_msg, term=False, q_terminal='', fcancel=False, pcancel=()): dialog = gtk.Dialog() dialog.set_title(title) dialogarea = dialog.get_content_area() dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) if term: dialog.set_size_request(window_width, window_height) else: dialog.set_size_request(window_width * 3 / 4, window_height / 4) dialog.set_resizable(False) box = gtk.VBox() box.set_border_width(borderwidth) label = gtk.Label() label.set_markup(text) label.set_justify(gtk.JUSTIFY_CENTER) progress = gtk.ProgressBar() if term: scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) terminal = vte.Terminal() terminal.set_cursor_blinks(True) terminal.set_emulation('xterm') terminal.set_scrollback_lines(1000) terminal.set_audible_bell(True) terminal.set_visible_bell(False) scroll.add(terminal) box.pack_start(label, False, False, 5) box.pack_start(progress, False, False, 0) if term: box.pack_start(gtk.HSeparator(), False, False, 0) box.pack_start(scroll, True, True, 0) button = gtk.Button(stock=gtk.STOCK_CANCEL) button.connect_object("clicked", gtk.Window.destroy, dialog) if fcancel: button.connect("clicked", fcancel, *pcancel) box.pack_start(gtk.HSeparator(), False, False, 0) box.pack_start(button, False, False, 0) dialogarea.add(box) dialog.show_all() q_window.put(dialog) q_bar.put(progress) q_msg.put(label) if term: q_terminal.put(terminal) return dialog
def __init__(self, parent, config, info=None): """""" gtk.Dialog.__init__(self) ServiceUpdate.__init__(self, config) self.set_transient_for(parent) self.parent_widget = parent self.installing = False self.checking_version = False self.remote_info = info self.set_icon_from_file(media.ICON_UPDATE) self.set_title(("Update Manager")) self.set_size_request(400, 300) # treeview frame = gtk.Frame() self.vbox.pack_start(frame) frame.set_size_request(200, -1) frame.set_border_width(10) label = gtk.Label() label.set_markup("<b>%s</b>" % ("Update Services")) frame.set_label_widget(label) scroll = gtk.ScrolledWindow() frame.add(scroll) scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.treeview = gtk.TreeView( gtk.ListStore(gtk.gdk.Pixbuf, str, bool, str, gobject.TYPE_PYOBJECT)) scroll.add(self.treeview) self.treeview.set_rules_hint(True) self.treeview.set_headers_visible(False) tree_icon = gtk.TreeViewColumn('Icon') icon_cell = gtk.CellRendererPixbuf() tree_icon.pack_start(icon_cell, True) tree_icon.add_attribute(icon_cell, 'pixbuf', 0) tree_icon.set_property('min-width', 100) self.treeview.append_column(tree_icon) tree_name = gtk.TreeViewColumn('Name') name_cell = gtk.CellRendererText() tree_name.pack_start(name_cell, True) tree_name.add_attribute(name_cell, 'text', 1) tree_name.set_property('min-width', 200) self.treeview.append_column(tree_name) tree_add = gtk.TreeViewColumn('Add') add_cell = gtk.CellRendererToggle() add_cell.connect("toggled", self.toggled) tree_add.pack_start(add_cell, True) tree_add.add_attribute(add_cell, 'active', 2) self.treeview.append_column(tree_add) #status hbox = gtk.HBox() self.vbox.pack_start(hbox, False, False, 5) self.status_icon = gtk.image_new_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU) hbox.pack_start(self.status_icon, False, False, 10) self.status_label = gtk.Label("Checking for updates.") hbox.pack_start(self.status_label, False, False, 5) self.progress = gtk.ProgressBar() hbox.pack_start(self.progress, True, True, 20) #action area cancel_button = gtk.Button(None, gtk.STOCK_CANCEL) add_button = gtk.Button(None, gtk.STOCK_ADD) self.action_area.pack_start(cancel_button) self.action_area.pack_start(add_button) cancel_button.connect("clicked", self.close) add_button.connect("clicked", self.install) self.connect("response", self.close) self.show_all() self.progress.hide() gobject.timeout_add(200, self.load_updates) self.run()
def __init__(self, cmd_args, description=None, title=None, stock_id=gtk.STOCK_EXECUTE, hide_progress=False, modal=True, event_queue=None): window = get_dialog_parent() self.dialog = gtk.Dialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), parent=window) self.dialog.set_modal(modal) self.dialog.set_default_size(*DIALOG_SIZE_PROCESS) self._is_destroyed = False self.dialog.set_icon( self.dialog.render_icon(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)) self.cmd_args = cmd_args self.event_queue = event_queue str_cmd_args = [rose.gtk.util.safe_str(a) for a in cmd_args] if description is not None: str_cmd_args = [description] if title is None: self.dialog.set_title(" ".join(str_cmd_args[0:2])) else: self.dialog.set_title(title) if callable(cmd_args[0]): self.label = gtk.Label(self.DIALOG_FUNCTION_LABEL) else: self.label = gtk.Label(self.DIALOG_PROCESS_LABEL) self.label.set_use_markup(True) self.label.show() self.image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_DIALOG) self.image.show() image_vbox = gtk.VBox() image_vbox.pack_start(self.image, expand=False, fill=False) image_vbox.show() top_hbox = gtk.HBox() top_hbox.pack_start(image_vbox, expand=False, fill=False, padding=DIALOG_PADDING) top_hbox.show() hbox = gtk.HBox() hbox.pack_start(self.label, expand=False, fill=False, padding=DIALOG_PADDING) hbox.show() main_vbox = gtk.VBox() main_vbox.show() main_vbox.pack_start(hbox, expand=False, fill=False, padding=DIALOG_SUB_PADDING) cmd_string = str_cmd_args[0] if str_cmd_args[1:]: if callable(cmd_args[0]): cmd_string += "(" + " ".join(str_cmd_args[1:]) + ")" else: cmd_string += " " + " ".join(str_cmd_args[1:]) self.cmd_label = gtk.Label() self.cmd_label.set_markup("<b>" + cmd_string + "</b>") self.cmd_label.show() cmd_hbox = gtk.HBox() cmd_hbox.pack_start(self.cmd_label, expand=False, fill=False, padding=DIALOG_PADDING) cmd_hbox.show() main_vbox.pack_start(cmd_hbox, expand=False, fill=True, padding=DIALOG_SUB_PADDING) # self.dialog.set_modal(True) self.progress_bar = gtk.ProgressBar() self.progress_bar.set_pulse_step(0.1) self.progress_bar.show() hbox = gtk.HBox() hbox.pack_start(self.progress_bar, expand=True, fill=True, padding=DIALOG_PADDING) hbox.show() main_vbox.pack_start(hbox, expand=False, fill=False, padding=DIALOG_SUB_PADDING) top_hbox.pack_start(main_vbox, expand=True, fill=True, padding=DIALOG_PADDING) if self.event_queue is None: self.dialog.vbox.pack_start(top_hbox, expand=True, fill=True) else: text_view_scroll = gtk.ScrolledWindow() text_view_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) text_view_scroll.show() text_view = gtk.TextView() text_view.show() self.text_buffer = text_view.get_buffer() self.text_tag = self.text_buffer.create_tag() self.text_tag.set_property("scale", pango.SCALE_SMALL) text_view.connect('size-allocate', self._handle_scroll_text_view) text_view_scroll.add(text_view) text_expander = gtk.Expander(self.DIALOG_LOG_LABEL) text_expander.set_spacing(DIALOG_SUB_PADDING) text_expander.add(text_view_scroll) text_expander.show() top_pane = gtk.VPaned() top_pane.pack1(top_hbox, resize=False, shrink=False) top_pane.show() self.dialog.vbox.pack_start(top_pane, expand=True, fill=True, padding=DIALOG_SUB_PADDING) top_pane.pack2(text_expander, resize=True, shrink=True) if hide_progress: progress_bar.hide() self.ok_button = self.dialog.get_action_area().get_children()[0] self.ok_button.hide() for child in self.dialog.vbox.get_children(): if isinstance(child, gtk.HSeparator): child.hide() self.dialog.show()
try: val = float(line) except (ValueError, TypeError): pass else: # actualizar la barra pbar.set_fraction(val / 100) return True # llamar otra vez if __name__ == '__main__': import pygtk pygtk.require('2.0') import gtk, gobject main = gtk.Window(gtk.WINDOW_TOPLEVEL) main.connect('destroy', lambda *x: gtk.mainquit()) pbar = gtk.ProgressBar() main.add(pbar) # leer en idle poll = select.poll() poll.register(0, select.POLLIN) # el 0 es del stdin gobject.idle_add(step, poll, pbar) main.show_all() gtk.main()