def _set_details(dialog, details): vbox1 = gtk.VBox() vbox2 = dialog.vbox vbox2.pack_start(vbox1) align1 = gtk.Alignment(0.0, 0.0, 0.0, 0.0) align1.set_property("border-width", 6) align1.show() vbox2.pack_start(align1) align2 = gtk.Alignment(0.0, 0.0, 0.0, 0.0) align2.set_property("border-width", 6) align2.show() details = details.rstrip() expander = gtk.expander_new_with_mnemonic( _("_Details (%d lines)") % len(details.splitlines())) expander.show() viewport = gtk.ScrolledWindow() viewport.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) viewport.show() lbl = LogView() lbl.append(details) lbl.show() nil, height = lbl.get_size_request() width, nil = vbox2.get_size_request() viewport.set_size_request(width, min(height, 480)) viewport.add_with_viewport(lbl) expander.add(viewport) align2.add(expander) vbox1.show() vbox1.pack_start(align2)
def enabled(self): self.expander = gtk.expander_new_with_mnemonic(_('_Lyrics')) self.expander.set_expanded(True) self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window.set_size_request(-1, 200) self.adjustment = self.scrolled_window.get_vadjustment() self.textview = gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textview.set_editable(False) self.textview.set_cursor_visible(False) self.textview.set_wrap_mode(gtk.WRAP_WORD) self.textview.set_justification(gtk.JUSTIFY_CENTER) self.textview.connect('key-press-event', self.key_press_event_cb) self.scrolled_window.add_with_viewport(self.textview) self.textview.show() self.expander.add(self.scrolled_window) self.scrolled_window.show() # Newer Quod Libet, we can't pack into songpane. # So we pack into the window itself, throwing in some padding. self.expander.set_border_width(6) app.window.child.pack_start(self.expander, expand=False, fill=True)
def __init__(self, parent, flags, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE): if not type in _IMAGE_TYPES: raise TypeError("type must be one of: %s", ', '.join(_IMAGE_TYPES.keys())) if not buttons in _BUTTON_TYPES: raise TypeError("buttons be one of: %s", ', '.join(_BUTTON_TYPES.keys())) gtk.Dialog.__init__(self, '', parent, flags) self.set_border_width(5) self.set_resizable(False) self.set_has_separator(False) # Some window managers (ION) displays a default title (???) if # the specified one is empty, workaround this by setting it # to a single space instead self.set_title(" ") self.set_skip_taskbar_hint(True) self.vbox.set_spacing(14) # It seems like get_accessible is not available on windows, go figure if hasattr(self, 'get_accessible'): self.get_accessible().set_role(atk.ROLE_ALERT) self._primary_label = gtk.Label() self._secondary_label = gtk.Label() self._details_label = gtk.Label() self._image = gtk.image_new_from_stock(_IMAGE_TYPES[type], gtk.ICON_SIZE_DIALOG) self._image.set_alignment(0.5, 0.0) self._primary_label.set_use_markup(True) for label in (self._primary_label, self._secondary_label, self._details_label): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) hbox = gtk.HBox(False, 12) hbox.set_border_width(5) hbox.pack_start(self._image, False, False) vbox = gtk.VBox(False, 0) hbox.pack_start(vbox, False, False) vbox.pack_start(self._primary_label, False, False) vbox.pack_start(self._secondary_label, False, False) self._expander = gtk.expander_new_with_mnemonic( _("Show more _details")) self._expander.set_spacing(6) self._expander.add(self._details_label) vbox.pack_start(self._expander, False, False) self.vbox.pack_start(hbox, False, False) hbox.show_all() self._expander.hide() self.add_buttons(*_BUTTON_TYPES[buttons]) self.label_vbox = vbox
def _setup_layout(self): self.vbox = VBox(False, 0) self.vbox.show() self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = expander_new_with_mnemonic(_("_Terminal")) self.expander.set_expanded(False) self.expander.add(self.terminal) self.expander.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) scr = ScrolledWindow() scr.set_policy ("automatic", "automatic") scr.add (self.tree) scr.show() vpaned = VPaned() vpaned.add1(scr) vpaned.add2(self.expander) vpaned.set_position (260) vpaned.show() self.vbox.pack_start(vpaned, True, True, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox) return
def msg_dialog(parent, title, text, seconary_text='', details='', dlg_type=gtk.MESSAGE_ERROR): dialog = gtk.MessageDialog(parent, flags=gtk.DIALOG_MODAL, type=dlg_type, buttons=gtk.BUTTONS_OK, message_format=text) if seconary_text: dialog.format_secondary_text(seconary_text) if details: expander = gtk.expander_new_with_mnemonic("_Additional details") text_buffer = gtk.TextBuffer() text_buffer.set_text(details) editor = gtk.TextView(text_buffer); editor.set_editable(False) editor.set_wrap_mode(True) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(editor) expander.add(sw) dialog.vbox.pack_start(expander, True) expander.show_all() dialog.set_title(title) dialog.run() dialog.destroy()
def __init__(self, deferred, message, parent=None, details=None, timeout=None): # timeout is 5 minutes """ @param deferred: L{Deferred} @param message: str or unicode @param details: str or unicode. @param timeout: lifetime in seconds. If set to None, disables it. """ #FIXME: error_dialog should be an attribute of this class self.deferredResult = deferred error_dialog = gtk.MessageDialog( parent=parent, flags=0, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format=message) if details is not None: error_dialog.vbox.set_spacing(14) # TODO: i18n ! expander = gtk.expander_new_with_mnemonic("Show more details") expander.set_spacing(6) details_label = gtk.Label() details_label.set_selectable(True) details_label.set_text(details) expander.add(details_label) error_dialog.vbox.pack_start(expander, False, False) pass #print("Added details in the error dialog: %s" % (details)) self._delayed_id = None if timeout is not None: self._delayed_id = reactor.callLater(timeout, self._timeout, error_dialog) error_dialog.set_modal(True) error_dialog.connect("close", self.on_close) error_dialog.connect("response", self.on_response) error_dialog.show_all()
def msg_dialog(parent, title, text, seconary_text='', details='', dlg_type=gtk.MESSAGE_ERROR): dialog = gtk.MessageDialog(parent, flags=gtk.DIALOG_MODAL, type=dlg_type, buttons=gtk.BUTTONS_OK, message_format=text) if seconary_text: dialog.format_secondary_text(seconary_text) if details: expander = gtk.expander_new_with_mnemonic("_Additional details") text_buffer = gtk.TextBuffer() text_buffer.set_text(details) editor = gtk.TextView(text_buffer) editor.set_editable(False) editor.set_wrap_mode(True) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(editor) expander.add(sw) dialog.vbox.pack_start(expander, True) expander.show_all() dialog.set_title(title) dialog.run() dialog.destroy()
def __init__(self, parent, flags, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE): if not type in _IMAGE_TYPES: raise TypeError( "type must be one of: %s", ', '.join(_IMAGE_TYPES.keys())) if not buttons in _BUTTON_TYPES: raise TypeError( "buttons be one of: %s", ', '.join(_BUTTON_TYPES.keys())) gtk.Dialog.__init__(self, '', parent, flags) self.set_deletable(False) self.set_border_width(5) self.set_resizable(False) self.set_has_separator(False) # Some window managers (ION) displays a default title (???) if # the specified one is empty, workaround this by setting it # to a single space instead self.set_title(" ") self.set_skip_taskbar_hint(True) self.vbox.set_spacing(14) # It seems like get_accessible is not available on windows, go figure if hasattr(self, 'get_accessible'): self.get_accessible().set_role(atk.ROLE_ALERT) self._primary_label = gtk.Label() self._secondary_label = gtk.Label() self._details_label = gtk.Label() self._image = gtk.image_new_from_stock(_IMAGE_TYPES[type], gtk.ICON_SIZE_DIALOG) self._image.set_alignment(0.5, 0.0) self._primary_label.set_use_markup(True) for label in (self._primary_label, self._secondary_label, self._details_label): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) hbox = gtk.HBox(False, 12) hbox.set_border_width(5) hbox.pack_start(self._image, False, False) vbox = gtk.VBox(False, 0) hbox.pack_start(vbox, False, False) vbox.pack_start(self._primary_label, False, False) vbox.pack_start(self._secondary_label, False, False) self._expander = gtk.expander_new_with_mnemonic( _("Show more _details")) self._expander.set_spacing(6) self._expander.add(self._details_label) vbox.pack_start(self._expander, False, False) self.vbox.pack_start(hbox, False, False) hbox.show_all() self._expander.hide() self.add_buttons(*_BUTTON_TYPES[buttons]) self.label_vbox = vbox
def __init__(self, parent, flags, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE, ): #XXX: better errors assert type in image_types, 'not a valid type' assert buttons in button_types, 'not a valid set of buttons' gtk.Dialog.__init__(self, ' ', parent, flags) self.set_border_width(5) self.set_has_separator(False) self.set_resizable(False) self.set_skip_taskbar_hint(True) self.primary = gtk.Label() self.secondary = gtk.Label() self.details = gtk.Label() self.image = gtk.image_new_from_stock( image_types[type], gtk.ICON_SIZE_DIALOG ) self.image.set_alignment(0.0, 0.5) self.primary.set_use_markup(True) for label in (self.primary, self.secondary, self.details): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) hbox = gtk.HBox(False, 12) hbox.set_border_width(5) hbox.pack_start(self.image, False, False) self.label_vbox = vbox = gtk.VBox(False, 0) hbox.pack_start(vbox, False, False) vbox.pack_start(self.primary, False, False) vbox.pack_start(self.secondary, False, False) self.expander = gtk.expander_new_with_mnemonic( 'show more _details' ) self.expander.set_spacing(5) self.expander.add(self.details) vbox.pack_start(self.expander, False, False) self.vbox.pack_start(hbox, False, False) hbox.show_all() self.expander.hide() self._buttons = button_types[buttons] self.add_buttons(*self._buttons)
def set_details(self, details): if details == "": return #TRANSLATORS: expander label in the error dialog expander = gtk.expander_new_with_mnemonic(_("_Details")) expander.set_spacing(6) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) textview = gtk.TextView() buffer = textview.get_buffer() buffer.insert_at_cursor(details) scrolled.add(textview) expander.add(scrolled) box = self.label.get_parent() box.add(expander) expander.show_all()
def set_details(self, details): if details == None: return #TRANSLATORS: expander label in the error dialog expander = gtk.expander_new_with_mnemonic(_("_Details")) expander.set_spacing(6) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) textview = gtk.TextView() buffer = textview.get_buffer() buffer.insert_at_cursor(details) scrolled.add(textview) expander.add(scrolled) box = self.label.get_parent() box.add(expander) expander.show_all()
def __init__(self, parser, max_tree_depth): self.parser = parser self._max_tree_depth = max_tree_depth self.search_thread = None self.search_lock = threading.Lock() self.name_entry = name_entry = gtk.Entry() name_entry.connect('activate', self.on_name_entry_activate) search_button = self.search_button = gtk.Button(stock=gtk.STOCK_FIND) search_button.connect('clicked', self.on_search) search_button.set_no_show_all(True) search_button.show() stop_button = self.stop_button = gtk.Button(stock=gtk.STOCK_STOP) stop_button.connect('clicked', self.stop_search) stop_button.set_no_show_all(True) self.progress = progress = gtk.ProgressBar() progress.set_size_request(-1, 8) name_box = gtk.HBox(spacing=8) name_box.set_border_width(8) name_box.pack_start(name_entry, True, True) name_box.pack_start(search_button, False) name_box.pack_start(stop_button, False) self.store = gtk.TreeStore(str, str, str, str) # name, icon, fnstyle, info self.treeview = treeview = self._create_treeview(self.store) scroller = gtk.ScrolledWindow() scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroller.add(treeview) settings_view = SettingsView(max_depth_value=max_tree_depth) settings_view.on_max_depth_changed = self.on_max_depth_changed extension = gtk.expander_new_with_mnemonic('_Settings') extension.add(settings_view.view) vbox = gtk.VBox() vbox.pack_start(name_box, False) vbox.pack_start(progress, False) vbox.pack_start(scroller, True, True) vbox.pack_start(extension, False) self.window = window = gtk.Window() window.set_title(Application.title) window.set_default_size(800, 600) window.set_icon(Application.get_icon()) window.add(vbox)
def __init__(self, deferred, message, parent=None, details=None, timeout=None): # timeout is 5 minutes """ @param deferred: L{Deferred} @param message: str or unicode @param details: str or unicode. @param timeout: lifetime in seconds. If set to None, disables it. """ #FIXME: error_dialog should be an attribute of this class self.deferredResult = deferred error_dialog = gtk.MessageDialog(parent=parent, flags=0, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format=message) if details is not None: error_dialog.vbox.set_spacing(14) # TODO: i18n ! expander = gtk.expander_new_with_mnemonic("Show more details") expander.set_spacing(6) details_label = gtk.Label() details_label.set_selectable(True) details_label.set_text(details) expander.add(details_label) error_dialog.vbox.pack_start(expander, False, False) pass #print("Added details in the error dialog: %s" % (details)) self._delayed_id = None if timeout is not None: self._delayed_id = reactor.callLater(timeout, self._timeout, error_dialog) error_dialog.set_modal(True) error_dialog.connect("close", self.on_close) error_dialog.connect("response", self.on_response) error_dialog.show_all()
def _msg_dialog(parent_win, title, text, secondary_text='', details='', dlg_type=gtk.MESSAGE_ERROR, buttons=[(gtk.STOCK_OK, gtk.RESPONSE_OK)]): dialog = gtk.MessageDialog(parent_win, flags=gtk.DIALOG_MODAL, type=dlg_type, message_format=text) dialog.set_title(title) for button in buttons: dialog.add_button(button[0], button[1]) dialog.set_default_response(buttons[-1][1]) if secondary_text: dialog.format_secondary_text(secondary_text) if details: expander = gtk.expander_new_with_mnemonic(details[0]) text_buffer = gtk.TextBuffer() text_buffer.set_text(details[1]) editor = gtk.TextView(text_buffer); editor.set_editable(False) editor.set_wrap_mode(True) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(editor) expander.add(sw) dialog.vbox.pack_start(expander, True) expander.show_all() dialog.set_title(title) ret = dialog.run() dialog.destroy() return ret
def show_error_window(error_string, add_apport_button=False): """Displays an error dialog, and returns the response ID. error_string -- the error's output (usually a traceback) add_apport_button -- whether to add a 'report with apport' button Returns the response ID of the dialog, 1 for ignore, 2 for close and 3 for apport. """ # initialize dialog title = _("An error has occurred") global APP_NAME if APP_NAME: title = APP_NAME global dialog dialog = gtk.Dialog(title) # title Label label = gtk.Label() label.set_markup("<b>" + _("It looks like an error has occurred.") + "</b>") label.set_alignment(0, 0.5) dialog.get_content_area().pack_start(label, False) # message Label global MESSAGE text_label = gtk.Label() text_label.set_markup(MESSAGE) text_label.set_alignment(0, 0.5) text_label.set_line_wrap(True) def text_label_size_allocate(widget, rect): """Lets label resize correctly while wrapping text.""" widget.set_size_request(rect.width, -1) text_label.connect("size-allocate", text_label_size_allocate) if not MESSAGE == "": dialog.get_content_area().pack_start(text_label, False) # TextView with error_string buffer = gtk.TextBuffer() buffer.set_text(error_string) textview = gtk.TextView() textview.set_buffer(buffer) textview.set_editable(False) try: textview.modify_font(pango.FontDescription("monospace 8")) except Exception: print >> sys.stderr, "gtkcrashhandler: modify_font raised an exception" # allow scrolling of textview scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add_with_viewport(textview) # hide the textview in an Expander widget expander = gtk.expander_new_with_mnemonic(_("_Details")) expander.add(scrolled) expander.connect('activate', on_expanded) dialog.get_content_area().pack_start(expander, True) # add buttons if add_apport_button: dialog.add_button(_("_Report this problem..."), 3) # If we're have multiple threads, or if we're in a GTK callback, # execution can continue normally in other threads, so add button if gtk.main_level() > 0 or threading.activeCount() > 1: dialog.add_button(_("_Ignore the error"), 1) dialog.add_button(("_Close the program"), 2) dialog.set_default_response(2) # set dialog aesthetic preferences dialog.set_border_width(12) dialog.get_content_area().set_spacing(4) dialog.set_resizable(False) # show the dialog and act on it dialog.show_all() res = dialog.run() dialog.destroy() if res < 0: res = 2 return res
def __init__(self, box, conf, ind): self.conf = conf self.ind = ind for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] table = gtk.Table(4, 2, False) label = gtk.Label("Line 1 :") label.set_alignment(0, 0.5) self.line1_format = gtk.Entry() self.line1_format.set_width_chars(10) self.line1_format.set_text(self.settings['line1']) map = label.get_colormap() colour = map.alloc_color(self.settings['line1_color']) self.line1_color = gtk.ColorButton(colour) self.line1_font = gtk.FontButton(self.settings['line1_font']) table.attach(label, 0, 1, 0, 1) table.attach(self.line1_format, 1, 2, 0, 1) table.attach(self.line1_color, 2, 3, 0, 1) table.attach(self.line1_font, 3, 4, 0, 1) label = gtk.Label("Line 2 :") label.set_alignment(0, 0.5) self.line2_format = gtk.Entry() self.line2_format.set_width_chars(10) self.line2_format.set_text(self.settings['line2']) colour = map.alloc_color(self.settings['line2_color']) self.line2_color = gtk.ColorButton(colour) self.line2_font = gtk.FontButton(self.settings['line2_font']) table.attach(label, 0, 1, 1, 2) table.attach(self.line2_format, 1, 2, 1, 2) table.attach(self.line2_color, 2, 3, 1, 2) table.attach(self.line2_font, 3, 4, 1, 2) label = gtk.Label(_("Tooltip :")) label.set_alignment(0, 0.5) self.tooltip_format = gtk.Entry() self.tooltip_format.set_width_chars(10) self.tooltip_format.set_text(self.settings['tooltip']) table.attach(label, 0, 1, 2, 3) table.attach(self.tooltip_format, 1, 2, 2, 3) box.pack_start(table, True) text_line1format = gtk.TextView() text_line1format.set_wrap_mode(gtk.WRAP_WORD) text_line1format.set_border_width(2) txt_buffer = text_line1format.get_buffer() txt_buffer.set_text(INFO) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(text_line1format) expander = gtk.expander_new_with_mnemonic("_Info") expander.add(sw) box.pack_start(table, False, False) box.pack_start(expander, True, True)
def __init__(self, echo, expander, enable_tooltips): gtk.VBox.__init__(self, spacing=4) self._watch = None self.echo = echo self.set_border_width(4) self.serial = SerialSender.SerialSender() self.serial.connect("serial-connected", self._on_serial_connected) sc = SerialChooser.SerialChooser( sender=self.serial, ports=libserial.get_ports(), speeds=libserial.get_speeds()) self.pack_start(sc, expand=False, fill=False) self.terminal = vte.Terminal() self.terminal.connect("commit", self._on_text_entered_in_terminal) self.pack_start(self.terminal, expand=True, fill=True) #tell vte to not get in the way of backspace/delete # #python-vte bindings don't appear to support this constant, #so the magic values are being assumed from the C enum :/ if self.BACKSPACE: #backbind = vte.ERASE_ASCII_BACKSPACE backbind = 2 else: #backbind = vte.ERASE_AUTO_BACKSPACE backbind = 1 if self.DELETE: #delbind = vte.ERASE_DELETE_SEQUENCE delbind = 3 else: #delbind = vte.ERASE_AUTO delbind = 0 self.terminal.set_backspace_binding (backbind) self.terminal.set_delete_binding (delbind) hb = gtk.HBox(spacing=2) self.pack_start(hb, expand=False, fill=True) entry = RawEntry.MyEntry(enable_tooltips) entry.connect("activate", self._on_entry_activate) hb.pack_start(entry, expand=True, fill=True) lbl = gtk.Label("0B") lbl.set_width_chars(4) lbl.set_justify(gtk.JUSTIFY_RIGHT) hb.pack_start(lbl, expand=False, fill=False) if enable_tooltips: lbl.props.has_tooltip = True lbl.connect("query-tooltip", self._on_lbl_tooltip, entry) entry.connect("changed", self._on_entry_changed, lbl) #store the hex view in an expander #only create said viewwhen revealed the first time if expander: exp = gtk.expander_new_with_mnemonic("_Hex View") exp.connect("notify::expanded", self._expander_callback) self.pack_start(exp, expand=False, fill=False) self.hexview = None self._hexbuf = ""
def build_interface( self ): """ Builds the interface Arguments: - self: The main object pointer """ self.setWindowsIcon() accelGroup = gtk.AccelGroup() self.add_accel_group( accelGroup ) self.accelGroup = accelGroup self.set_title( "MouseTrap" ) self.connect( "destroy", self.close) self.setWindowsIcon() self.vBox = gtk.VBox() self.buttonsBox = gtk.HButtonBox() #self.buttonsBox = gtk.HBox(False,0) self.prefButton = gtk.Button(stock=gtk.STOCK_PREFERENCES) self.prefButton.connect("clicked", self._show_settings_gui) self.buttonsBox.pack_start( self.prefButton, True, True ) self.closeButton = gtk.Button(stock=gtk.STOCK_QUIT) self.closeButton.connect("clicked", self.close) self.buttonsBox.pack_start( self.closeButton, True, True ) self.helpButton = gtk.Button(stock=gtk.STOCK_HELP) self.helpButton.connect("clicked", self._loadHelp) self.buttonsBox.pack_start( self.helpButton, True, True ) self.vBox.pack_start( self.buttonsBox, False, False ) self.adds_vbox = gtk.VBox() self.adds_vbox.show_all() self.vBox.pack_start( self.adds_vbox, False, False ) self.cap_image = gtk.Image() if self.cfg.getboolean("gui", "showCapture"): self.cap_expander = gtk.expander_new_with_mnemonic("_Camera Image") self.cap_expander.add(self.cap_image) self.cap_expander.set_expanded(True) #expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.cap_expander) if self.cfg.getboolean("gui", "showPointMapper"): self.map_expander = gtk.expander_new_with_mnemonic("_Script Mapper") self.map_expander.add(self.script) self.map_expander.set_expanded(True) #expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.map_expander) # # flipButton = gtk.Button( _("Flip Image") ) # flipButton.connect("clicked", self.recalcPoint, "flip" ) # hBox.pack_start( flipButton, False, False ) # # recalcButton = gtk.Button( _("Recalc Point") ) # recalcButton.connect("clicked", self.recalcPoint ) # hBox.pack_start( recalcButton, False, False ) # # self.vBox.pack_end(hBox, False, False ) # # self.buttonsBox.show_all() self.statusbar = gtk.Statusbar() self.statusbar_id = self.statusbar.get_context_id("statusbar") self.vBox.pack_start(self.statusbar, True, True) self.vBox.show_all() self.add(self.vBox) self.show() debug.debug("ui.main", "Interface Built")
def show_error_window(error_string, add_apport_button=False): """Displays an error dialog, and returns the response ID. error_string -- the error's output (usually a traceback) add_apport_button -- whether to add a 'report with apport' button Returns the response ID of the dialog, 1 for ignore, 2 for close and 3 for apport. """ # initialize dialog title = _("An error has occurred") global APP_NAME if APP_NAME: title = APP_NAME global dialog # Do not allow more than one error window if dialog is not None: return 1 dialog = gtk.Dialog(title) # title Label label = gtk.Label() label.set_markup("<b>%s</b>" % _("It looks like an error has occurred.")) label.set_alignment(0, 0.5) dialog.get_content_area().pack_start(label, False) # message Label global MESSAGE text_label = gtk.Label() text_label.set_markup(MESSAGE) text_label.set_alignment(0, 0.5) text_label.set_line_wrap(True) def text_label_size_allocate(widget, rect): """Lets label resize correctly while wrapping text.""" widget.set_size_request(rect.width, -1) text_label.connect("size-allocate", text_label_size_allocate) if not MESSAGE == "": dialog.get_content_area().pack_start(text_label, False) # TextView with error_string buffer = gtk.TextBuffer() buffer.set_text(error_string) textview = gtk.TextView() textview.set_buffer(buffer) textview.set_editable(False) try: textview.modify_font(pango.FontDescription("monospace 8")) except Exception: print >> sys.stderr, "gtkcrashhandler: modify_font raised an exception" # allow scrolling of textview scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add_with_viewport(textview) # hide the textview in an Expander widget expander = gtk.expander_new_with_mnemonic(_("_Details")) expander.add(scrolled) expander.connect('activate', on_expanded) dialog.get_content_area().pack_start(expander, True) # add buttons if add_apport_button: dialog.add_button(_("_Report this problem..."), 3) # If we're have multiple threads, or if we're in a GTK callback, # execution can continue normally in other threads, so add button if gtk.main_level() > 0 or threading.activeCount() > 1: dialog.add_button(_("_Ignore the error"), 1) dialog.add_button(("_Close the program"), 2) dialog.set_default_response(2) # set dialog aesthetic preferences dialog.set_border_width(12) dialog.get_content_area().set_spacing(4) dialog.set_resizable(False) # show the dialog and act on it dialog.show_all() res = dialog.run() dialog.destroy() if res < 0: res = 2 return res
def build_interface(self): """ Builds the interface Arguments: - self: The main object pointer """ self.setWindowsIcon() accelGroup = gtk.AccelGroup() self.add_accel_group(accelGroup) self.accelGroup = accelGroup self.set_title("MouseTrap") self.connect("destroy", self.close) self.setWindowsIcon() self.vBox = gtk.VBox() self.buttonsBox = gtk.HButtonBox() #self.buttonsBox = gtk.HBox(False,0) self.prefButton = gtk.Button(stock=gtk.STOCK_PREFERENCES) self.prefButton.connect("clicked", self._show_settings_gui) self.buttonsBox.pack_start(self.prefButton, True, True) self.closeButton = gtk.Button(stock=gtk.STOCK_QUIT) self.closeButton.connect("clicked", self.close) self.buttonsBox.pack_start(self.closeButton, True, True) self.helpButton = gtk.Button(stock=gtk.STOCK_HELP) self.helpButton.connect("clicked", self._loadHelp) self.buttonsBox.pack_start(self.helpButton, True, True) self.vBox.pack_start(self.buttonsBox, False, False) self.adds_vbox = gtk.VBox() self.adds_vbox.show_all() self.vBox.pack_start(self.adds_vbox, False, False) self.cap_image = gtk.Image() if self.cfg.getboolean("gui", "showCapture"): self.cap_expander = gtk.expander_new_with_mnemonic("_Camera Image") self.cap_expander.add(self.cap_image) self.cap_expander.set_expanded(True) #expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.cap_expander) if self.cfg.getboolean("gui", "showPointMapper"): self.map_expander = gtk.expander_new_with_mnemonic( "_Script Mapper") self.map_expander.add(self.script) self.map_expander.set_expanded(True) #expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.map_expander) # # flipButton = gtk.Button( _("Flip Image") ) # flipButton.connect("clicked", self.recalcPoint, "flip" ) # hBox.pack_start( flipButton, False, False ) # # recalcButton = gtk.Button( _("Recalc Point") ) # recalcButton.connect("clicked", self.recalcPoint ) # hBox.pack_start( recalcButton, False, False ) # # self.vBox.pack_end(hBox, False, False ) # # self.buttonsBox.show_all() self.statusbar = gtk.Statusbar() self.statusbar_id = self.statusbar.get_context_id("statusbar") self.vBox.pack_start(self.statusbar, True, True) self.vBox.show_all() self.add(self.vBox) self.show() debug.debug("ui.main", "Interface Built")
def __init__(self): self.jpeg_quality = 80 self.delete_orig = True self.icon_size = gtk.ICON_SIZE_BUTTON self.window = None self.info_label = gtk.Label('Drag image here') self.info_img = gtk.image_new_from_stock( gtk.STOCK_INFO, self.icon_size) self.display_img = gtk.image_new_from_stock( gtk.STOCK_DND, gtk.ICON_SIZE_LARGE_TOOLBAR) self.img_pbuf = None self.img_giofile = None self.button = gtk.Button('_Convert') self.adv_expander = gtk.expander_new_with_mnemonic('_Advanced Options') self.adv_delete_orig_checkbox = gtk.CheckButton('Move original to the _Trash after successful conversion') self.adv_jpeg_quality_adjust = gtk.Adjustment( value = self.jpeg_quality, lower = 0, upper = 100, step_incr = 1, page_incr = 10) self.adv_jpeg_quality_slider = gtk.HScale(self.adv_jpeg_quality_adjust) # Use our own magic data file, as we don't want to require one be pre # installed. self.magic = magic.Magic( mime=True, magic_file=os.path.join('.', 'share', 'misc', 'magic') ) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title('Convert to JPEG') self.window.set_border_width(10) self.window.set_position(gtk.WIN_POS_CENTER) # Figure out window size def_width = 450 def_height = 550 max_scale = 0.9 def_ratio = float(def_width) / def_height sc_width = gtk.gdk.screen_width() sc_height = gtk.gdk.screen_height() max_width = int(sc_width * max_scale) max_height = int(sc_height * max_scale) if def_width > def_height: if max_width < def_width: def_width = int(max_width) def_height = int(def_width * def_ratio) else: if max_height < def_height: def_height = int(max_height) def_width = int(def_height / def_ratio) self.window.set_default_size(def_width, def_height) self.adv_delete_orig_checkbox.set_active(self.delete_orig) hbox = gtk.HBox(spacing=3) hbox.set_border_width(3) hbox.pack_start( gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON), expand=False, fill=False) label = gtk.Label('_Convert') label.set_use_underline(True) label.set_mnemonic_widget(self.button) hbox.pack_start(label, expand=False, fill=True) self.button.remove( self.button.get_child() ) self.button.add(hbox) self.window.connect('destroy', lambda w: gtk.main_quit()) self.window.connect_after('realize', self.on_realize) self.adv_jpeg_quality_adjust.connect_after( 'value-changed', self.on_jpeg_quality_changed) self.adv_delete_orig_checkbox.connect_after( 'toggled', self.on_delete_orig_toggled) self.button.connect('clicked', self.on_convert_clicked) # Drag-and-Drop self.window.drag_dest_set( gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_HIGHLIGHT, [('text/uri-list', 0, 0)], gtk.gdk.ACTION_COPY) self.window.connect('drag_drop', self.on_drop) self.window.connect('drag_data_received', self.on_drop_recv_data) self.adv_jpeg_quality_slider.set_digits(0) self.adv_jpeg_quality_slider.set_value_pos(gtk.POS_RIGHT) self.adv_jpeg_quality_slider.add_mark(0, gtk.POS_BOTTOM, 'lower quality') self.adv_jpeg_quality_slider.add_mark(0, gtk.POS_TOP, 'smaller file') self.adv_jpeg_quality_slider.add_mark(100, gtk.POS_BOTTOM, 'highest quality') self.adv_jpeg_quality_slider.add_mark(100, gtk.POS_TOP, 'larger file') self.info_label.set_single_line_mode(False) self.adv_expander.set_expanded(False) self.button.set_sensitive(False) # Layout main_vbox = gtk.VBox(spacing=3) info_hbox = gtk.HBox(spacing=3) info_hbox.pack_start( gtk.Label('') ) # spacer info_hbox.pack_start(self.info_img, expand=False, fill=False) info_hbox.pack_start(self.info_label, expand=False, fill=False) info_hbox.pack_start( gtk.Label('') ) # spacer jpeg_quality_label = gtk.Label('JPEG _Quality') jpeg_quality_label.set_use_underline(True) jpeg_quality_label.set_mnemonic_widget(self.adv_jpeg_quality_slider) jpeg_quality_hbox = gtk.HBox(spacing=8) jpeg_quality_hbox.pack_start(jpeg_quality_label, expand=False, fill=False) jpeg_quality_hbox.pack_start(self.adv_jpeg_quality_slider, expand=True, fill=True) adv_vbox = gtk.VBox(spacing=3) adv_vbox.pack_start(self.adv_delete_orig_checkbox) adv_vbox.pack_start(jpeg_quality_hbox) #adv_vbox.pack_end(gtk.HSeparator(), expand=False, fill=False) alignment = gtk.Alignment(xscale=1.0, yscale=1.0) alignment.set_padding(0, 0, 20, 0) alignment.add(adv_vbox) self.adv_expander.add(alignment) bbox = gtk.HButtonBox() bbox.set_layout(gtk.BUTTONBOX_END) bbox.pack_end(self.button, fill=False, expand=False) main_vbox.pack_start(info_hbox, expand=False) main_vbox.pack_start(gtk.HSeparator(), expand=False, fill=False) main_vbox.pack_start(self.display_img, expand=True, fill=True) main_vbox.pack_start(gtk.HSeparator(), expand=False, fill=False) main_vbox.pack_end(bbox, expand=False, fill=False) main_vbox.pack_end(self.adv_expander, expand=False, fill=False) self.window.add(main_vbox) self.window.show_all() self.unload_image()
def __init__(self, echo, expander, enable_tooltips): gtk.VBox.__init__(self, spacing=4) self._watch = None self.echo = echo self.set_border_width(4) self.serial = SerialSender.SerialSender() self.serial.connect("serial-connected", self._on_serial_connected) sc = SerialChooser.SerialChooser(sender=self.serial, ports=libserial.get_ports(), speeds=libserial.get_speeds()) self.pack_start(sc, expand=False, fill=False) self.terminal = vte.Terminal() self.terminal.connect("commit", self._on_text_entered_in_terminal) self.pack_start(self.terminal, expand=True, fill=True) #tell vte to not get in the way of backspace/delete # #python-vte bindings don't appear to support this constant, #so the magic values are being assumed from the C enum :/ if self.BACKSPACE: #backbind = vte.ERASE_ASCII_BACKSPACE backbind = 2 else: #backbind = vte.ERASE_AUTO_BACKSPACE backbind = 1 if self.DELETE: #delbind = vte.ERASE_DELETE_SEQUENCE delbind = 3 else: #delbind = vte.ERASE_AUTO delbind = 0 self.terminal.set_backspace_binding(backbind) self.terminal.set_delete_binding(delbind) hb = gtk.HBox(spacing=2) self.pack_start(hb, expand=False, fill=True) entry = RawEntry.MyEntry(enable_tooltips) entry.connect("activate", self._on_entry_activate) hb.pack_start(entry, expand=True, fill=True) lbl = gtk.Label("0B") lbl.set_width_chars(4) lbl.set_justify(gtk.JUSTIFY_RIGHT) hb.pack_start(lbl, expand=False, fill=False) if enable_tooltips: lbl.props.has_tooltip = True lbl.connect("query-tooltip", self._on_lbl_tooltip, entry) entry.connect("changed", self._on_entry_changed, lbl) #store the hex view in an expander #only create said viewwhen revealed the first time if expander: exp = gtk.expander_new_with_mnemonic("_Hex View") exp.connect("notify::expanded", self._expander_callback) self.pack_start(exp, expand=False, fill=False) self.hexview = None self._hexbuf = ""
class config(): def __init__(self, box, conf, ind): self.conf = conf self.ind = ind framebox = gtk.VBox(False, 0) framebox.set_border_width(5) framebox.set_spacing(10) box.pack_start(framebox) for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] # make new array from string # because when you save the array, it looks like a string: [{'text':'\xd0\xa3\xd0\xa0\xd0\x90'}] # but when the load value, adeskbar takes it as a string type alarmlist_dict = {} alarmlist_str = self.settings['alarmlist'] settings['alarmlist'] = [] if str(alarmlist_str) != '[]': q = [] try: q = alarmlist_str[2:-2].split("}, {") except Exception, e: q.append(alarmlist_str[2:-2]) for a in q: paras = a[1:-1].split("', '") for line in paras: k, v = line.split("': '") alarmlist_dict[k] = v settings['alarmlist'].append(alarmlist_dict) alarmlist_dict = {} table = gtk.Table(4, 2, False) label = gtk.Label(_("Time :")) label.set_alignment(0, 0.5) self.time_format = gtk.Entry() self.time_format.set_width_chars(10) self.time_format.set_text(self.settings['time']) map = label.get_colormap() colour = map.alloc_color(self.settings['time_color']) self.time_color = gtk.ColorButton(colour) self.time_font = gtk.FontButton(self.settings['time_font']) table.attach(label, 0, 1, 0, 1) table.attach(self.time_format, 1, 2, 0, 1) table.attach(self.time_color, 2, 3, 0, 1) table.attach(self.time_font, 3, 4, 0, 1) label = gtk.Label(_("Date :")) label.set_alignment(0, 0.5) self.date_format = gtk.Entry() self.date_format.set_width_chars(10) self.date_format.set_text(self.settings['date']) colour = map.alloc_color(self.settings['date_color']) self.date_color = gtk.ColorButton(colour) self.date_font = gtk.FontButton(self.settings['date_font']) table.attach(label, 0, 1, 1, 2) table.attach(self.date_format, 1, 2, 1, 2) table.attach(self.date_color, 2, 3, 1, 2) table.attach(self.date_font, 3, 4, 1, 2) label = gtk.Label(_("Tooltip :")) label.set_alignment(0, 0.5) self.tooltip_format = gtk.Entry() self.tooltip_format.set_width_chars(10) self.tooltip_format.set_text(self.settings['tooltip']) table.attach(label, 0, 1, 2, 3) table.attach(self.tooltip_format, 1, 2, 2, 3) framebox.pack_start(table, True) text_timeformat = gtk.TextView() text_timeformat.set_wrap_mode(gtk.WRAP_WORD) text_timeformat.set_border_width(2) buffer = text_timeformat.get_buffer() buffer.set_text(INFO) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(text_timeformat) expander = gtk.expander_new_with_mnemonic(_("_Info")) expander.add(sw) framebox.pack_start(expander, True) self.mouseover_checkbox = gtk.CheckButton(_('Show on mouseover')) self.mouseover_checkbox.set_active(int( conf.launcher[ind]['mouseover'])) framebox.pack_end(self.mouseover_checkbox, False, False) bBox = gtk.VBox(False, 0) bBox.set_spacing(10) bBox.set_border_width(4) BoxListControls = gtk.HBox(False, 0) # ListStore self.view = View(self) self.view.connect("row-activated", self.edit_item) index = 0 if settings['alarmlist'] != []: for alarm in settings['alarmlist']: date_d = alarm['date_d'] date_m = alarm['date_m'] date_y = alarm['date_y'] time_h = alarm['time_h'] time_m = alarm['time_m'] day1 = alarm['day1'] day2 = alarm['day2'] day3 = alarm['day3'] day4 = alarm['day4'] day5 = alarm['day5'] day6 = alarm['day6'] day7 = alarm['day7'] soundfile = alarm['soundfile'] cmd = alarm['cmd'] text = alarm['text'] notify = alarm['notify'] remind = alarm['remind'] index = alarm['index'] self.view.add_launcher(date_d, date_m, date_y, time_h, time_m, day1, day2, day3, day4, day5, day6, day7, soundfile, cmd, text, notify, remind, index) self.view.model.connect("row-deleted", self.view.row_deleted) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add(self.view) scrolled.set_size_request(550, 100) frame = gtk.Frame() frame.add(scrolled) ## Control buttons for list # Add Launcher button = core.image_button(_('add new task'), './images/conf/add_custom.png', 24) button.connect("clicked", self.new_item_custom) BoxListControls.pack_start(button, False, False) # Remove button = core.image_button(_('remove'), './images/conf/remove.png', 24) button.connect("clicked", self.remove_item) BoxListControls.pack_start(button, False, False) bBox.pack_start(BoxListControls, False, False) bBox.pack_start(frame, False, False) framebox.pack_start(bBox, False, False)
def build_interface(self): """ Builds the interface Arguments: - self: The main object pointer """ self.connect("key-press-event", self.handleKeyboardInput) self.set_resizable(False) self.setWindowsIcon() accelGroup = gtk.AccelGroup() self.add_accel_group(accelGroup) self.accelGroup = accelGroup self.add_events(gtk.gdk.KEY_PRESS_MASK) self.set_title("MouseTrap") self.connect("destroy", self.close) self.setWindowsIcon() self.vBox = gtk.VBox() self.buttonsBox = gtk.HButtonBox() # self.buttonsBox = gtk.HBox(False,0) self.prefButton = gtk.Button(stock=gtk.STOCK_PREFERENCES) self.prefButton.connect("clicked", self._show_settings_gui) self.buttonsBox.pack_start(self.prefButton, True, True) self.closeButton = gtk.Button(stock=gtk.STOCK_QUIT) self.closeButton.connect("clicked", self.close) self.buttonsBox.pack_start(self.closeButton, True, True) self.helpButton = gtk.Button(stock=gtk.STOCK_HELP) self.helpButton.connect("clicked", self._loadHelp) self.buttonsBox.pack_start(self.helpButton, True, True) self.vBox.pack_start(self.buttonsBox, False, False) self.adds_vbox = gtk.VBox() self.adds_vbox.show_all() self.vBox.pack_start(self.adds_vbox, False, False) self.cap_image = gtk.Image() if self.cfg.getboolean("gui", "showCapture"): self.cap_expander = gtk.expander_new_with_mnemonic("_Camera Image") self.cap_expander.add(self.cap_image) # expander.connect('notify::expanded', self.expanded_cb) self.cap_expander.set_expanded(True) self.vBox.pack_start(self.cap_expander) if self.cfg.get("main", "algorithm") == "color": self.pal_expander = gtk.expander_new_with_mnemonic("Color _Picker") # Create a vertical box inside the color picker expander for layout self.pickerBox = gtk.VBox(spacing=10) self.picker = gtk.ColorSelection() self.picker.set_has_palette(True) self.pickerBox.pack_start(self.picker) self.saveColorButton = gtk.Button(stock=gtk.STOCK_SAVE) self.saveColorButton.connect("clicked", self._changeColors) # Weird config file hack. See Module.update_hue_range() docs if self.cfg.getboolean("main", "startCam"): self.saveColorButton.connect("clicked", self.ctr.idm.update_hue_range) self.pickerBox.pack_start(self.saveColorButton) self.pal_expander.add(self.pickerBox) self.vBox.pack_start(self.pal_expander) if self.cfg.getboolean("gui", "showPointMapper"): self.map_expander = gtk.expander_new_with_mnemonic("_Script Mapper") self.map_expander.add(self.script) self.map_expander.set_expanded(True) # expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.map_expander) # # flipButton = gtk.Button( _("Flip Image") ) # flipButton.connect("clicked", self.recalcPoint, "flip" ) # hBox.pack_start( flipButton, False, False ) # # recalcButton = gtk.Button( _("Recalc Point") ) # recalcButton.connect("clicked", self.recalcPoint ) # hBox.pack_start( recalcButton, False, False ) # # self.vBox.pack_end(hBox, False, False ) # # self.buttonsBox.show_all() self.statusbar = gtk.Statusbar() self.statusbar_id = self.statusbar.get_context_id("statusbar") self.vBox.pack_start(self.statusbar, True, True) self.vBox.show_all() self.add(self.vBox) self.show() debug.debug("ui.main", "Interface Built")