def __init__(self, view, attrs): super(Many2Many, self).__init__(view, attrs) self.widget = gtk.Frame() self.widget.set_shadow_type(gtk.SHADOW_NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = gtk.VBox(homogeneous=False, spacing=5) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 hbox = gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = gtk.Label(attrs.get('string', '')) self.title.set_alignment(0.0, 0.5) hbox.pack_start(self.title, expand=True, fill=True) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) tooltips = common.Tooltips() self.wid_text = PlaceholderEntry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', lambda *a: self._focus_out()) self.focus_out = True hbox.pack_start(self.wid_text, expand=True, fill=True) if int(self.attrs.get('completion', 1)): self.wid_completion = get_completion( create=self.attrs.get('create', True) and common.MODELACCESS[self.attrs['relation']]['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) else: self.wid_completion = None self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add existing record')) self.but_add.connect('clicked', self._sig_add) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) img_add.set_alignment(0.5, 0.5) self.but_add.add(img_add) self.but_add.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_add, expand=False, fill=False) self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove selected record <Del>')) self.but_remove.connect('clicked', self._sig_remove) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) img_remove.set_alignment(0.5, 0.5) self.but_remove.add(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_remove, expand=False, fill=False) hbox.set_focus_chain([self.wid_text]) tooltips.enable() frame = gtk.Frame() frame.add(hbox) frame.set_shadow_type(gtk.SHADOW_OUT) vbox.pack_start(frame, expand=False, fill=True) self.screen = Screen(attrs['relation'], view_ids=attrs.get('view_ids', '').split(','), mode=['tree'], views_preload=attrs.get('views', {}), row_activate=self._on_activate, limit=None) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True) self.screen.widget.connect('key_press_event', self.on_keypress) self.wid_text.connect('key_press_event', self.on_keypress)
def codebox_insert(self, iter_insert, codebox_dict, codebox_justification=None, text_buffer=None, cursor_pos=0): """Insert Code Box""" if not text_buffer: text_buffer = self.dad.curr_buffer anchor = text_buffer.create_child_anchor(iter_insert) self.curr_codebox_anchor = anchor anchor.frame_width = codebox_dict['frame_width'] anchor.frame_height = codebox_dict['frame_height'] anchor.width_in_pixels = codebox_dict['width_in_pixels'] anchor.syntax_highlighting = codebox_dict['syntax_highlighting'] anchor.highlight_brackets = codebox_dict['highlight_brackets'] anchor.show_line_numbers = codebox_dict['show_line_numbers'] anchor.sourcebuffer = gtksourceview2.Buffer() anchor.sourcebuffer.set_style_scheme( self.dad.sourcestyleschememanager.get_scheme( self.dad.style_scheme)) if anchor.syntax_highlighting != cons.PLAIN_TEXT_ID: self.dad.set_sourcebuffer_syntax_highlight( anchor.sourcebuffer, anchor.syntax_highlighting) anchor.sourcebuffer.set_highlight_matching_brackets( anchor.highlight_brackets) anchor.sourcebuffer.connect('insert-text', self.dad.on_text_insertion) anchor.sourcebuffer.connect('delete-range', self.dad.on_text_removal) anchor.sourcebuffer.connect('modified-changed', self.dad.on_modified_changed) if codebox_dict['fill_text']: anchor.sourcebuffer.set_text(codebox_dict['fill_text']) anchor.sourcebuffer.place_cursor( anchor.sourcebuffer.get_iter_at_offset(cursor_pos)) anchor.sourcebuffer.set_modified(False) anchor.sourceview = gtksourceview2.View(anchor.sourcebuffer) anchor.sourceview.set_smart_home_end( gtksourceview2.SMART_HOME_END_AFTER) anchor.sourceview.set_highlight_current_line( self.dad.pt_highl_curr_line) if self.dad.pt_show_white_spaces: anchor.sourceview.set_draw_spaces(DRAW_SPACES_FLAGS) if anchor.syntax_highlighting == cons.PLAIN_TEXT_ID: anchor.sourceview.modify_font( pango.FontDescription(self.dad.pt_font)) else: anchor.sourceview.modify_font( pango.FontDescription(self.dad.code_font)) anchor.sourceview.set_show_line_numbers(anchor.show_line_numbers) anchor.sourceview.set_insert_spaces_instead_of_tabs( self.dad.spaces_instead_tabs) anchor.sourceview.set_tab_width(self.dad.tabs_width) anchor.sourceview.connect('populate-popup', self.on_sourceview_populate_popup_codebox, anchor) anchor.sourceview.connect('key_press_event', self.on_key_press_sourceview_codebox, anchor) anchor.sourceview.connect('key_release_event', self.on_key_release_sourceview_codebox, anchor) anchor.sourceview.connect('button-press-event', self.on_mouse_button_clicked_codebox, anchor) anchor.sourceview.connect("event-after", self.on_sourceview_event_after_codebox, anchor) anchor.sourceview.connect( "motion-notify-event", self.on_sourceview_motion_notify_event_codebox) anchor.sourceview.connect("copy-clipboard", self.dad.clipboard_handler.copy, True) anchor.sourceview.connect("cut-clipboard", self.dad.clipboard_handler.cut, True) if self.dad.line_wrapping: anchor.sourceview.set_wrap_mode(gtk.WRAP_WORD) else: anchor.sourceview.set_wrap_mode(gtk.WRAP_NONE) anchor.scrolledwindow = gtk.ScrolledWindow() anchor.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) anchor.scrolledwindow.add(anchor.sourceview) anchor.scrolledwindow.get_vscrollbar().connect( 'event-after', self.on_vscrollbar_event_after, anchor) anchor.scrolledwindow.get_hscrollbar().connect( 'event-after', self.on_hscrollbar_event_after, anchor) anchor.frame = gtk.Frame() self.codebox_apply_width_height(anchor) anchor.frame.add(anchor.scrolledwindow) anchor.frame.set_shadow_type(gtk.SHADOW_NONE) anchor.eventbox = gtk.EventBox() anchor.eventbox.add(anchor.frame) self.dad.sourceview.add_child_at_anchor(anchor.eventbox, anchor) anchor.eventbox.show_all() self.dad.widget_set_colors(anchor.sourceview, self.dad.rt_def_fg, self.dad.rt_def_bg, True) for win in [ gtk.TEXT_WINDOW_LEFT, gtk.TEXT_WINDOW_RIGHT, gtk.TEXT_WINDOW_TOP, gtk.TEXT_WINDOW_BOTTOM ]: anchor.sourceview.set_border_window_size(win, 1) if codebox_justification: text_iter = text_buffer.get_iter_at_child_anchor(anchor) self.dad.state_machine.apply_object_justification( text_iter, codebox_justification, text_buffer) elif self.dad.user_active: # if I apply a justification, the state is already updated self.dad.state_machine.update_state()
def make_preferences_dialog(self): # TODO: switch to something declarative or at least clean-up the following mess self.prefs = prefs = gtk.Dialog(APP_NAME, None, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) prefs.connect("response", self.on_preferences_changed) prefs.connect("delete-event", self.on_preferences_changed) def on_sb_time_changed(widget, data=None): self.options.timeout = widget.get_value() self.logger.debug("Timeout value changed: %f." % self.options.timeout) def on_cbox_sizes_changed(widget, data=None): index = widget.get_active() self.options.font_size = FONT_SIZES.keys()[index] self.update_geometry() self.logger.debug("Window size changed: %s." % self.options.font_size) def on_cbox_modes_changed(widget, data=None): index = widget.get_active() self.options.key_mode = KEY_MODES.keys()[index] self.on_change_mode() self.logger.debug("Key mode changed: %s." % self.options.key_mode) def on_cbox_bak_changed(widget, data=None): index = widget.get_active() self.options.bak_mode = BAK_MODES.keys()[index] self.on_change_mode() self.logger.debug("Bak mode changed: %s." % self.options.bak_mode) def on_cbox_mods_changed(widget, data=None): index = widget.get_active() self.options.mods_mode = MODS_MODES.keys()[index] self.on_change_mode() self.logger.debug("Mods mode changed: %s." % self.options.mods_mode) def on_cbox_modsonly_changed(widget, data=None): self.options.mods_only = widget.get_active() self.on_change_mode() self.logger.debug("Modifiers only changed: %s." % self.options.mods_only) def on_cbox_visshift_changed(widget, data=None): self.options.vis_shift = widget.get_active() self.on_change_mode() self.logger.debug("Visible Shift changed: %s." % self.options.vis_shift) def on_cbox_visspace_changed(widget, data=None): self.options.vis_space = widget.get_active() self.on_change_mode() self.logger.debug("Show Whitespace changed: %s." % self.options.vis_space) def on_cbox_position_changed(widget, data=None): index = widget.get_active() new_position = POSITIONS.keys()[index] if self.options.position != 'fixed' and new_position == 'fixed': new_geom = on_btn_sel_geom(widget) if not new_geom: self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) return self.options.position = new_position self.update_geometry() self.logger.debug("Window position changed: %s." % self.options.position) def on_cbox_screen_changed(widget, data=None): self.options.screen = widget.get_active() self.set_active_monitor(self.options.screen) self.logger.debug("Screen changed: %d." % self.options.screen) def on_cbox_persist_changed(widget, data=None): self.options.persist = widget.get_active() if not self.get_property('visible'): self.show() else: self.on_label_change(self.label.get_text()) self.logger.debug("Persistent changed: %s." % self.options.persist) def on_sb_compr_changed(widget, data=None): self.options.compr_cnt = widget.get_value_as_int() self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_cbox_compr_changed(widget, data=None): compr_enabled = widget.get_active() self.sb_compr.set_sensitive(compr_enabled) self.options.compr_cnt = self.sb_compr.get_value_as_int( ) if compr_enabled else 0 self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_btn_sel_geom(widget, data=None): try: ret = subprocess.check_output(['slop', '-f', '%x %y %w %h %i']) except subprocess.CalledProcessError: return False except OSError: msg = gtk.MessageDialog( parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format="Error running \"slop\"") msg.format_secondary_markup( "\"slop\" is required for interactive selection. " "See <a href=\"https://github.com/naelstrof/slop\">" "https://github.com/naelstrof/slop</a>") msg.run() msg.destroy() return False data = map(int, ret.split(' ')) self.options.geometry = data[0:4] self.options.window = data[4] if not self.options.window or \ self.options.window == self.get_screen().get_root_window().xid: # region selected, switch to fixed self.options.window = None self.options.position = 'fixed' self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) self.update_geometry() self.btn_reset_geom.set_sensitive(True) return True def on_btn_reset_geom(widget, data=None): self.options.geometry = None if self.options.position == 'fixed': self.options.position = 'bottom' self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) self.update_geometry() widget.set_sensitive(False) def on_adj_opacity_changed(widget, data=None): self.options.opacity = widget.get_value() self.update_colors() def on_font_color_changed(widget, data=None): self.options.font_color = widget.get_color().to_string() self.update_colors() def on_bg_color_changed(widget, data=None): self.options.bg_color = widget.get_color().to_string() self.update_colors() def on_btn_font(widget, data=None): self.options.font_desc = widget.get_font_name() self.font = pango.FontDescription(self.options.font_desc) self.update_label() frm_main = gtk.Frame(_("Preferences")) frm_main.set_border_width(6) frm_time = gtk.Frame("<b>%s</b>" % _("Time")) frm_time.set_border_width(4) frm_time.get_label_widget().set_use_markup(True) frm_time.set_shadow_type(gtk.SHADOW_NONE) vbox_time = gtk.VBox(spacing=6) hbox_time = gtk.HBox() lbl_time1 = gtk.Label(_("Display for")) lbl_time2 = gtk.Label(_("seconds")) sb_time = gtk.SpinButton(digits=1) sb_time.set_increments(0.5, 1.0) sb_time.set_range(0.5, 10.0) sb_time.set_numeric(True) sb_time.set_update_policy(gtk.UPDATE_IF_VALID) sb_time.set_value(self.options.timeout) sb_time.connect("value-changed", on_sb_time_changed) hbox_time.pack_start(lbl_time1, expand=False, fill=False, padding=6) hbox_time.pack_start(sb_time, expand=False, fill=False, padding=4) hbox_time.pack_start(lbl_time2, expand=False, fill=False, padding=4) vbox_time.pack_start(hbox_time) chk_persist = gtk.CheckButton(_("Persistent window")) chk_persist.connect("toggled", on_cbox_persist_changed) chk_persist.set_active(self.options.persist) vbox_time.pack_start(chk_persist) frm_time.add(vbox_time) frm_time.show_all() frm_position = gtk.Frame("<b>%s</b>" % _("Position")) frm_position.set_border_width(4) frm_position.get_label_widget().set_use_markup(True) frm_position.set_shadow_type(gtk.SHADOW_NONE) vbox_position = gtk.VBox(spacing=6) lbl_screen = gtk.Label(_("Screen")) cbox_screen = gtk.combo_box_new_text() scr = self.get_screen() for n in range(scr.get_n_monitors()): cbox_screen.insert_text( n, '%d: %s' % (n, scr.get_monitor_plug_name(n))) cbox_screen.set_active(self.monitor) cbox_screen.connect("changed", on_cbox_screen_changed) hbox0_position = gtk.HBox() hbox0_position.pack_start(lbl_screen, expand=False, fill=False, padding=6) hbox0_position.pack_start(cbox_screen, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox0_position) lbl_positions = gtk.Label(_("Position")) self.cbox_positions = cbox_positions = gtk.combo_box_new_text() cbox_positions.set_name('position') for key, value in enumerate(POSITIONS): cbox_positions.insert_text(key, value) cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) cbox_positions.connect("changed", on_cbox_position_changed) self.btn_reset_geom = btn_reset_geom = gtk.Button(_("Reset")) btn_reset_geom.connect("clicked", on_btn_reset_geom) btn_reset_geom.set_sensitive(self.options.geometry is not None) hbox1_position = gtk.HBox() hbox1_position.pack_start(lbl_positions, expand=False, fill=False, padding=6) hbox1_position.pack_start(cbox_positions, expand=False, fill=False, padding=4) hbox1_position.pack_start(btn_reset_geom, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox1_position) btn_sel_geom = gtk.Button(_("Select window/region")) btn_sel_geom.connect("clicked", on_btn_sel_geom) vbox_position.pack_start(btn_sel_geom) frm_aspect = gtk.Frame("<b>%s</b>" % _("Font")) frm_aspect.set_border_width(4) frm_aspect.get_label_widget().set_use_markup(True) frm_aspect.set_shadow_type(gtk.SHADOW_NONE) vbox_aspect = gtk.VBox(spacing=6) frm_position.add(vbox_position) hbox0_font = gtk.HBox() lbl_font = gtk.Label(_("Font")) btn_font = gtk.FontButton(self.options.font_desc) btn_font.set_use_size(False) btn_font.set_show_size(False) btn_font.connect("font-set", on_btn_font) hbox0_font.pack_start(lbl_font, expand=False, fill=False, padding=6) hbox0_font.pack_start(btn_font, expand=False, fill=False, padding=4) hbox2_aspect = gtk.HBox() lbl_sizes = gtk.Label(_("Size")) cbox_sizes = gtk.combo_box_new_text() cbox_sizes.set_name('size') for key, value in enumerate(FONT_SIZES): cbox_sizes.insert_text(key, value) cbox_sizes.set_active(FONT_SIZES.keys().index(self.options.font_size)) cbox_sizes.connect("changed", on_cbox_sizes_changed) hbox2_aspect.pack_start(lbl_sizes, expand=False, fill=False, padding=6) hbox2_aspect.pack_start(cbox_sizes, expand=False, fill=False, padding=4) vbox_aspect.pack_start(hbox0_font) vbox_aspect.pack_start(hbox2_aspect) frm_aspect.add(vbox_aspect) frm_kbd = gtk.Frame("<b>%s</b>" % _("Keys")) frm_kbd.set_border_width(4) frm_kbd.get_label_widget().set_use_markup(True) frm_kbd.set_shadow_type(gtk.SHADOW_NONE) vbox_kbd = gtk.VBox(spacing=6) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Keyboard mode")) cbox_modes = gtk.combo_box_new_text() cbox_modes.set_name('mode') for key, value in enumerate(KEY_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(KEY_MODES.keys().index(self.options.key_mode)) cbox_modes.connect("changed", on_cbox_modes_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Backspace mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(BAK_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(BAK_MODES.keys().index(self.options.bak_mode)) cbox_modes.connect("changed", on_cbox_bak_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Modifiers mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(MODS_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(MODS_MODES.keys().index(self.options.mods_mode)) cbox_modes.connect("changed", on_cbox_mods_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) chk_kbd = gtk.CheckButton(_("Show Modifier sequences only")) chk_kbd.connect("toggled", on_cbox_modsonly_changed) chk_kbd.set_active(self.options.mods_only) vbox_kbd.pack_start(chk_kbd) chk_kbd = gtk.CheckButton(_("Always show Shift")) chk_kbd.connect("toggled", on_cbox_visshift_changed) chk_kbd.set_active(self.options.vis_shift) vbox_kbd.pack_start(chk_kbd) chk_vspace = gtk.CheckButton(_("Show Whitespace characters")) chk_vspace.set_active(self.options.vis_space) chk_vspace.connect("toggled", on_cbox_visspace_changed) vbox_kbd.pack_start(chk_vspace) hbox_compr = gtk.HBox() chk_compr = gtk.CheckButton(_("Compress repeats after")) chk_compr.set_active(self.options.compr_cnt > 0) chk_compr.connect("toggled", on_cbox_compr_changed) self.sb_compr = sb_compr = gtk.SpinButton(digits=0) sb_compr.set_increments(1, 1) sb_compr.set_range(1, 100) sb_compr.set_numeric(True) sb_compr.set_update_policy(gtk.UPDATE_IF_VALID) sb_compr.set_value(self.options.compr_cnt or 3) sb_compr.connect("value-changed", on_sb_compr_changed) hbox_compr.pack_start(chk_compr, expand=False, fill=False) hbox_compr.pack_start(sb_compr, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_compr) frm_kbd.add(vbox_kbd) frm_color = gtk.Frame("<b>%s</b>" % _("Color")) frm_color.set_border_width(4) frm_color.get_label_widget().set_use_markup(True) frm_color.set_shadow_type(gtk.SHADOW_NONE) vbox_color = gtk.VBox(spacing=6) hbox3_font_color = gtk.HBox() lbl_font_color = gtk.Label(_("Font color")) btn_font_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.font_color)) btn_font_color.set_title(_("Text color")) btn_font_color.connect("color-set", on_font_color_changed) hbox3_font_color.pack_start(lbl_font_color, expand=False, fill=False, padding=6) hbox3_font_color.pack_start(btn_font_color, expand=False, fill=False, padding=4) hbox4_bg_color = gtk.HBox() lbl_bg_color = gtk.Label(_("Background color")) btn_bg_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.bg_color)) btn_bg_color.set_title(_("Background color")) btn_bg_color.connect("color-set", on_bg_color_changed) hbox4_bg_color.pack_start(lbl_bg_color, expand=False, fill=False, padding=6) hbox4_bg_color.pack_start(btn_bg_color, expand=False, fill=False, padding=4) hbox5_opacity = gtk.HBox() lbl_opacity = gtk.Label(_("Opacity")) adj_opacity = gtk.Adjustment(self.options.opacity, 0, 1.0, 0.1, 0, 0) adj_opacity.connect("value-changed", on_adj_opacity_changed) adj_scale = gtk.HScale(adj_opacity) hbox5_opacity.pack_start(lbl_opacity, expand=False, fill=False, padding=6) hbox5_opacity.pack_start(adj_scale, expand=True, fill=True, padding=4) vbox_color.pack_start(hbox3_font_color) vbox_color.pack_start(hbox4_bg_color) vbox_color.pack_start(hbox5_opacity) frm_color.add(vbox_color) hbox_main = gtk.HBox() vbox_main = gtk.VBox() vbox_main.pack_start(frm_time, False, False, 6) vbox_main.pack_start(frm_position, False, False, 6) vbox_main.pack_start(frm_aspect, False, False, 6) hbox_main.pack_start(vbox_main) vbox_main = gtk.VBox() vbox_main.pack_start(frm_kbd, False, False, 6) vbox_main.pack_start(frm_color, False, False, 6) hbox_main.pack_start(vbox_main) frm_main.add(hbox_main) prefs.vbox.pack_start(frm_main) prefs.set_destroy_with_parent(True) prefs.set_resizable(False) prefs.set_has_separator(False) prefs.set_default_response(gtk.RESPONSE_CLOSE) prefs.vbox.show_all()
def __init__(self, obj, name, notebook): self.notebook = notebook self.obj = obj self.name = name # vpane self.page = gtk.HPaned() # left view, navigation left_view = gtk.VBox() nav_frame = gtk.Frame('Navigation') self.treeview = gtk.TreeView() self.treeview.connect("cursor-changed", self.on_cursor_changed) self.treeview.connect("row-activated", self.on_row_activated) self.treeview.set_headers_visible(False) self.treeview.set_enable_tree_lines(True) col_name = gtk.TreeViewColumn('Name', gtk.CellRendererText(), markup=0) self.treeview.append_column(col_name) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolledwindow.add_with_viewport(self.treeview) nav_frame.add(scrolledwindow) left_view.pack_start(nav_frame, True, True) np_frame = gtk.Frame('Navigation path') self.path_label = gtk.Entry() self.path_label.set_editable(False) np_frame.add(self.path_label) left_view.pack_start(np_frame, False, False) no_frame = gtk.Frame('Navigation options') no_hbox = gtk.HBox() self.b_hide_builtin = gtk.CheckButton(label='Hide Builtin') self.b_hide_builtin.set_active(True) self.b_hide_builtin.connect("clicked", self.on_button_hide_builtin_toggle) no_hbox.pack_start(self.b_hide_builtin, False, False) b_refresh = gtk.Button(label='Refresh') b_refresh.connect("clicked", self.on_button_refresh_click) no_hbox.pack_end(b_refresh, False, False) no_frame.add(no_hbox) left_view.pack_end(no_frame, expand=False, fill=False, padding=5) self.page.add1(left_view) # Right view (sources) right_view = gtk.VBox() sd_frame = gtk.Frame('Definition') self.source_def = gtk.Entry() self.source_def.set_editable(False) sd_frame.add(self.source_def) right_view.pack_start(sd_frame, False, False) source_frame = gtk.Frame('Source code') source_scroll = gtk.ScrolledWindow() source_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) lang = python_lang.lang self.source_content = CodeBuffer(lang=lang) source_tv = gtk.TextView(self.source_content) source_tv.set_editable(False) source_scroll.add_with_viewport(source_tv) source_frame.add(source_scroll) right_view.pack_start(source_frame, True, True) sfp_frame = gtk.Frame('Source file path') self.source_file = gtk.Entry() self.source_file.set_editable(False) sfp_frame.add(self.source_file) right_view.pack_start(sfp_frame, False, False) self.page.add2(right_view) self.tree_model = model.ObjectModel(self.obj, self.name, self.b_hide_builtin.get_active()) self.treeview.set_model(self.tree_model) self.page.show_all() # Notebook tab Label control nbt_view = gtk.HBox() nbt_label = gtk.Label(name) nbt_view.pack_start(nbt_label, False, False) #nbt_close_btn = gtk.Button('x') image_close = gtk.Image() nbt_close_btn = gtk.Button() nbt_close_btn.set_relief(gtk.RELIEF_NONE) nbt_close_btn.set_focus_on_click(False) nbt_close_btn.set_tooltip_text("Close Tab") image_close.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) #nbt_close_btn.get_settings() nbt_close_btn.add(image_close) nbt_close_btn.connect("style-set", self.on_style_set) #set_relief(button,gtk.RELIEF_NONE) #nbt_close_btn = gtk.Button(None, gtk.STOCK_CLOSE) nbt_close_btn.connect("clicked", self.on_close_btn_clicked) nbt_view.pack_end(nbt_close_btn, False, False) nbt_view.show_all() notebook.append_page(self.page, nbt_view) notebook.set_tab_reorderable(self.page, True) self.check_show_tab()
def _has_valid_weighting(self): if self._weight_func == self._default_weight_func: return self._weight_column >= 0 return True def _default_weight_func(self, model, _iter): return model.get_value(_iter, self._weight_column) if __name__ == '__main__': win = gtk.Window() win.set_title('Cairo TreeMap') win.set_default_size(640, 480) win.props.border_width = 24 win.connect('delete-event', lambda *_: gtk.main_quit()) f = gtk.Frame() f.set_shadow_type(gtk.SHADOW_NONE) win.add(f) f.show() treemap = TreeMap() f.add(treemap) treemap.show() model = gtk.TreeStore(str, int) i = model.append(None, row=('Item 1', 6)) model.append(i, row=('Item 1.1', 5)) j = model.append(i, row=('Item 1.2', 13)) model.append(j, row=('Item 1.2.1', 8)) model.append(j, row=('Item 1.2.2', 7)) model.append(j, row=('Item 1.2.3', 3)) k = model.append(j, row=('Item 1.2.4', 8)) model.append(k, row=('Item 1.2.4.1', 2))
def __init_gui(self): ''' പൂമുഖം തുറന്ന്, ദര്ശനം നല്കാം... ''' gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title(title) self.set_default_size(340, 160) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.connect("destroy", self.__quit) # ലേബലടിക്ക്. ascii_lbl = gtk.Label(_("ASCII File : ")) mapping_lbl = gtk.Label(_("Mapping File : ")) unicode_lbl = gtk.Label(_("Unicode File : ")) # പ്രമാണോം പത്രോം ആധാരോം എടുക്ക്വാ.. #ascii_btn = gtk.FileChooserButton(_("Select the ASCII File (.txt,.pdf)")) ascii_btn = gtk.Button("ASCII File...", None) ascii_btn.connect("clicked", self.__choose_ascii_file) unicode_btn = gtk.Button("Unicode File...", None) unicode_btn.connect("clicked", self.__choose_unicode_file) mapping_btn = gtk.FileChooserButton( _("Select the ASCII-Unicode Mapping File")) #unicode_btn = gtk.FileChooserButton(_("Select Output Unicode File")) # ആസ്കി-യൂണിക്കോഡ് ആണോ, അതോ യൂണിക്കോഡ്-ആസ്കിയോ? a2u_radio = gtk.RadioButton(None, (_("ASCII-to-Unicode"))) u2a_radio = gtk.RadioButton(a2u_radio, (_("Unicode-to-ASCII"))) # മാപ്പ്, സാധാരണ എവിടെ കിട്ടും? അല്ല, എവിടെ കിട്ടും? mapping_dir = sys.prefix + "/share/payyans/maps/" mapping_btn.set_current_folder(mapping_dir) # Define the Actions. Lets get some action, baby! convert_btn = gtk.Button(_("Convert"), gtk.STOCK_CONVERT) convert_btn.connect("clicked", self.__convert_file) cancel_btn = gtk.Button(_("Quit"), gtk.STOCK_QUIT) cancel_btn.connect("clicked", self.__quit) about_btn = gtk.Button(_("About"), gtk.STOCK_ABOUT) about_btn.connect("clicked", self.__show_about) self.a2u_radio = a2u_radio self.u2a_radio = u2a_radio self.ascii_btn = ascii_btn self.mapping_btn = mapping_btn self.unicode_btn = unicode_btn # Pack the widgets. പാക്കു ചെയ്യ്, പാക്കു വെട്ട്. hbox1 = gtk.HBox() hbox1.set_border_width(4) hbox1.pack_start(ascii_lbl) hbox1.pack_end(ascii_btn) hbox2 = gtk.HBox() hbox2.set_border_width(4) hbox2.pack_start(mapping_lbl) hbox2.pack_end(mapping_btn) hbox3 = gtk.HBox() hbox3.set_border_width(4) hbox3.pack_start(unicode_lbl) hbox3.pack_end(unicode_btn) radio_box = gtk.HBox() radio_box.set_border_width(12) radio_box.pack_start(a2u_radio) radio_box.pack_start(u2a_radio) btn_box = gtk.HButtonBox() btn_box.set_border_width(4) btn_box.pack_start(convert_btn) btn_box.pack_start(about_btn) btn_box.pack_start(cancel_btn) vbox1 = gtk.VBox() vbox1.set_border_width(4) vbox1.pack_start(hbox1) vbox1.pack_start(hbox2) vbox1.pack_start(hbox3) vbox1.pack_start(radio_box) vbox1.pack_end(btn_box) frame = gtk.Frame() frame.set_border_width(5) frame.add(vbox1) self.add(frame) self.show_all()
def __init__(self, label='', **kwargs): if '_concreteWidget' not in self.__dict__: self._innerWidget = self._outerWidget = \ self._concreteWidget = gtk.Frame() super(Frame, self).__init__(**kwargs) self.label = label
def build_dialog(self): # Our parent creates widgets in a Analyze Color Range frame, # we add to that a dialog window we build. analysis_frame = color_analyzer.build_dialog(self) HOMOGENEOUS = True NOT_HOMOGENEOUS = False EXPAND = True NOT_EXPAND = False FILL = True NOT_FILL = False WINDOW_BORDER = 5 V_SPACE = 3 H_PAD = 3 TABLE_X_SPACE = 3 TABLE_Y_SPACE = 3 TBL_BTN_SEC_H_SPACE = 30 # Between right of table and Btn section row_labels = ('Mid Vals:', 'Thresholds:') color_labels = (' Red', ' Green', ' Blue') empty_labels = ('', ) * 3 spinner_labels = color_labels, empty_labels self.mid_val_thresh_adj_lst = [] self.range_thresh_adj_lst = [] thresh_adj_lst = [ self.mid_val_thresh_adj_lst, self.range_thresh_adj_lst ] self.diag_window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.diag_window.set_title('Analyze & Select by Color Range') self.diag_window.set_border_width(WINDOW_BORDER) self.diag_window.connect('destroy', self.delete_event) # Here we just set a handler for delete_event that immediately # exits GTK. # self.diag_window.connect('delete_event', self.delete_event) uber_box = gtk.VBox(NOT_HOMOGENEOUS, V_SPACE) self.diag_window.add(uber_box) uber_box.pack_start(analysis_frame, NOT_EXPAND, NOT_FILL, 0) # ==== Build the 'Specify Selection' section. tooltips = gtk.Tooltips() frame = gtk.Frame('Specify color range to select') # frame.set_label_align(0.0, 1.0) uber_box.pack_start(frame, NOT_EXPAND, NOT_FILL, 0) vbox = gtk.VBox(NOT_HOMOGENEOUS, V_SPACE) frame.add(vbox) # Build row of Selection Mode options hbox = gtk.HBox(NOT_HOMOGENEOUS, 0) vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0) lbl = gtk.Label('Selection Mode: ') hbox.pack_start(lbl, NOT_EXPAND, NOT_FILL, H_PAD) rbtn_lbl = ['Replace', 'Add', 'Subtract', 'Intersect'] rbtn_data = [ CHANNEL_OP_REPLACE, CHANNEL_OP_ADD, CHANNEL_OP_SUBTRACT, CHANNEL_OP_INTERSECT ] rbtn = None for c in range(4): rbtn = gtk.RadioButton(rbtn, rbtn_lbl[c]) rbtn.connect('toggled', self.sel_mode_callback, rbtn_data[c]) hbox.pack_start(rbtn, NOT_EXPAND, NOT_FILL, H_PAD) if c == 0: rbtn_actv = rbtn rbtn.set_active(True) # get toggled msg sent out rbtn_actv.set_active(True) # so callback() inits vars # Build row of Selection Context Options hbox = gtk.HBox(NOT_HOMOGENEOUS, 0) vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0) context_opt_lbl = self.context_opt_lbl for c in range(4): chk_btn = gtk.CheckButton(context_opt_lbl[c]) chk_btn.connect("toggled", self.sel_ctxt_callback, c) hbox.pack_start(chk_btn, NOT_EXPAND, NOT_FILL, H_PAD) # Build 'Feather Radius' threshold widgets hbox = gtk.HBox(NOT_HOMOGENEOUS, 0) vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, 0) lbl = gtk.Label('Feather Radius') thresh_adj = gtk.Adjustment(pdb.gimp_context_get_feather_radius()[0], 0, 100, .1, 1) spinner = gtk.SpinButton(thresh_adj, 1, 1) spinner.set_wrap(True) spinner.set_numeric(True) spinner.set_snap_to_ticks(True) self.f_radius_thresh_adj = thresh_adj self.f_radius_spinner = spinner hbox.pack_start(spinner, NOT_EXPAND, NOT_FILL, H_PAD) hbox.pack_start(lbl, NOT_EXPAND, NOT_FILL, 0) self.f_radius_box = hbox # Build Table for Mid Pt. Color and Threshold widgets hbox = gtk.HBox(NOT_HOMOGENEOUS, TBL_BTN_SEC_H_SPACE) vbox.pack_start(hbox, NOT_EXPAND, NOT_FILL, V_SPACE) table = gtk.Table(len(row_labels), 1 + (len(spinner_labels[0]) * 2), NOT_HOMOGENEOUS) table.set_row_spacings(TABLE_Y_SPACE) table.set_col_spacings(TABLE_X_SPACE) hbox.pack_start(table, NOT_EXPAND, NOT_FILL, H_PAD) row = 0 # R, G & B threshold widgets for r_lbl in row_labels: col = 0 lbl = gtk.Label(r_lbl) table.attach(lbl, col, col + 1, row, row + 1, gtk.FILL, gtk.FILL) # fill so justify method works lbl.set_alignment(0, .5) #Left just. & Vert center col += 1 for spin_lbl in spinner_labels[row]: if '' != spin_lbl: lbl = gtk.Label() lbl.set_markup('<tt>' + spin_lbl + '</tt>') table.attach(lbl, col, col + 1, row, row + 1, 0, 0) col += 1 thresh_adj = gtk.Adjustment(0, 0, 255, 0.5) spinner = gtk.SpinButton(thresh_adj, 0.5, 1) spinner.set_wrap(True) spinner.set_numeric(True) spinner.set_snap_to_ticks(True) thresh_adj_lst[row] += [thresh_adj] table.attach(spinner, col, col + 1, row, row + 1, 0, 0) col += 1 row += 1 # Add [Select] btn to lower right corner of Select Frame vbox = gtk.VBox(NOT_HOMOGENEOUS, 0) hbox.pack_end(vbox, NOT_EXPAND, NOT_FILL, H_PAD) bbox = gtk.HButtonBox() bbox.set_layout(gtk.BUTTONBOX_END) bbox.set_spacing(0) vbox.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0) btn = gtk.Button('Select') btn.connect('clicked', self.select_callback) bbox.add(btn) # Add [Load Vals] btn above Select] btn bbox = gtk.HButtonBox() bbox.set_layout(gtk.BUTTONBOX_END) bbox.set_spacing(0) vbox.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0) btn = gtk.Button('Load Vals') btn.connect('clicked', self.load_callback) bbox.add(btn) tooltips.set_tip(btn, 'Load Mid Vals & Thresholds\nfrom Analysis') # Build last section, [Close] btn bbox = gtk.HButtonBox() bbox.set_layout(gtk.BUTTONBOX_END) bbox.set_spacing(0) uber_box.pack_end(bbox, NOT_EXPAND, NOT_FILL, 0) btn = gtk.Button('Close') btn.connect('clicked', self.delete_event) bbox.add(btn) self.diag_window.show_all() self.f_radius_box.hide() return uber_box
def make_filter(self): self.tourneyTypes = {} #self.tourneys = {} self.sites = {} self.seats = {} self.siteid = {} self.heroes = {} self.boxes = {} self.toggles = {} for site in self.conf.get_supported_sites(): #Get db site id for filtering later self.cursor.execute(self.sql.query['getSiteId'], (site, )) result = self.db.cursor.fetchall() if len(result) == 1: self.siteid[site] = result[0][0] else: log.debug( _("Either 0 or more than one site matched for %s") % site) # For use in date ranges. self.start_date = gtk.Entry(max=12) self.end_date = gtk.Entry(max=12) self.start_date.set_property('editable', False) self.end_date.set_property('editable', False) # For use in groups etc #self.sbGroups = {} self.numTourneys = 0 playerFrame = gtk.Frame() playerFrame.set_label_align(0.0, 0.0) vbox = gtk.VBox(False, 0) self.fillPlayerFrame(vbox, self.display) playerFrame.add(vbox) sitesFrame = gtk.Frame() sitesFrame.set_label_align(0.0, 0.0) vbox = gtk.VBox(False, 0) self.fillSitesFrame(vbox) sitesFrame.add(vbox) # Tourney types tourneyTypesFrame = gtk.Frame() tourneyTypesFrame.set_label_align(0.0, 0.0) tourneyTypesFrame.show() vbox = gtk.VBox(False, 0) self.fillTourneyTypesFrame(vbox) tourneyTypesFrame.add(vbox) # Seats seatsFrame = gtk.Frame() seatsFrame.show() vbox = gtk.VBox(False, 0) self.sbSeats = {} self.fillSeatsFrame(vbox, self.display) seatsFrame.add(vbox) # Date dateFrame = gtk.Frame() dateFrame.set_label_align(0.0, 0.0) dateFrame.show() vbox = gtk.VBox(False, 0) self.fillDateFrame(vbox) dateFrame.add(vbox) # Buttons #self.Button1=gtk.Button("Unnamed 1") #self.Button1.set_sensitive(False) self.Button2 = gtk.Button("Unnamed 2") self.Button2.set_sensitive(False) expand = False self.mainVBox.pack_start(playerFrame, expand) self.mainVBox.pack_start(sitesFrame, expand) self.mainVBox.pack_start(seatsFrame, expand) self.mainVBox.pack_start(dateFrame, expand) self.mainVBox.pack_start(gtk.VBox(False, 0)) #self.mainVBox.pack_start(self.Button1, expand) self.mainVBox.pack_start(self.Button2, expand) self.mainVBox.show_all() # Should do this cleaner if "Heroes" not in self.display or self.display["Heroes"] == False: playerFrame.hide() if "Sites" not in self.display or self.display["Sites"] == False: sitesFrame.hide() if "Seats" not in self.display or self.display["Seats"] == False: seatsFrame.hide() if "Dates" not in self.display or self.display["Dates"] == False: dateFrame.hide() #if "Button1" not in self.display or self.display["Button1"] == False: # self.Button1.hide() if "Button2" not in self.display or self.display["Button2"] == False: self.Button2.hide() #if 'button1' in self.label and self.label['button1']: # self.Button1.set_label( self.label['button1'] ) if 'button2' in self.label and self.label['button2']: self.Button2.set_label(self.label['button2']) #if 'button1' in self.callback and self.callback['button1']: # self.Button1.connect("clicked", self.callback['button1'], "clicked") # self.Button1.set_sensitive(True) if 'button2' in self.callback and self.callback['button2']: self.Button2.connect("clicked", self.callback['button2'], "clicked") self.Button2.set_sensitive(True) # make sure any locks on db are released: self.db.rollback()
def __init__(self): oofGUI.MainPage.__init__(self, name="Pin Nodes", ordering=120.1, tip='Pin and unpin nodes') mainbox = gtk.VBox(spacing=2) self.gtk.add(mainbox) align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(spacing=3) align.add(centerbox) self.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'), callback=self.select_skeletonCB) label = gtk.Label('Microstructure=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.skelwidget.gtk[0], expand=0, fill=0) label = gtk.Label('Skeleton=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.skelwidget.gtk[1], expand=0, fill=0) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') # Pinned nodes status in the left half of the main pane pnsframe = gtk.Frame("Pinned Nodes Status") pnsframe.set_shadow_type(gtk.SHADOW_IN) self.datascroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.datascroll, "StatusScroll") pnsframe.add(self.datascroll) self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.psdata = fixedwidthtext.FixedWidthTextView() self.psdata.set_editable(False) self.psdata.set_wrap_mode(gtk.WRAP_WORD) self.psdata.set_cursor_visible(False) self.datascroll.add_with_viewport(self.psdata) mainpane.pack1(pnsframe, resize=1, shrink=0) # Pin nodes method modframe = gtk.Frame("Pin Nodes Methods") gtklogger.setWidgetName(modframe, 'Modify') modframe.set_shadow_type(gtk.SHADOW_IN) modbox = gtk.VBox() # will have "methods" and "buttons" modframe.add(modbox) self.pinModFactory = regclassfactory.RegisteredClassFactory( pinnodesmodifier.PinNodesModifier.registry, title="Method:", scope=self, name="Method") modbox.pack_start(self.pinModFactory.gtk, expand=1, fill=1, padding=2) # buttons hbox1 = gtk.HBox() modbox.pack_start(hbox1, expand=0, fill=0, padding=2) self.okbutton = gtk.Button(stock=gtk.STOCK_OK) gtklogger.setWidgetName(self.okbutton, 'OK') gtklogger.connect(self.okbutton, "clicked", self.okCB) tooltips.set_tooltip_text(self.okbutton, "Pin nodes with the selected method.") self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) gtklogger.setWidgetName(self.undobutton, 'Undo') gtklogger.connect(self.undobutton, "clicked", self.undoCB) tooltips.set_tooltip_text(self.undobutton, "Undo the latest action.") self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.connect(self.redobutton, "clicked", self.redoCB) tooltips.set_tooltip_text(self.redobutton, "Redo the latest undone action.") hbox1.pack_start(self.undobutton, expand=0, fill=1, padding=2) hbox1.pack_start(self.okbutton, expand=1, fill=1, padding=2) hbox1.pack_end(self.redobutton, expand=0, fill=1, padding=2) hbox2 = gtk.HBox(homogeneous=1) modbox.pack_start(hbox2, expand=0, fill=0, padding=2) self.unpinallbutton = gtk.Button("Unpin All") gtklogger.setWidgetName(self.unpinallbutton, 'Unpin All') gtklogger.connect(self.unpinallbutton, "clicked", self.unpinallCB) tooltips.set_tooltip_text(self.unpinallbutton, "Unpin all the pinned nodes.") self.invertbutton = gtk.Button("Invert") gtklogger.setWidgetName(self.invertbutton, 'Invert') gtklogger.connect(self.invertbutton, "clicked", self.invertCB) tooltips.set_tooltip_text( self.invertbutton, "Invert - pin the unpinned and unpin the pinned.") hbox2.pack_start(self.unpinallbutton, expand=1, fill=1, padding=2) hbox2.pack_start(self.invertbutton, expand=1, fill=1, padding=2) mainpane.pack2(modframe, resize=0, shrink=0) # Switchboard callbacks switchboard.requestCallbackMain(('who changed', 'Skeleton'), self.changeSkeleton) switchboard.requestCallbackMain(('new who', 'Microstructure'), self.newMS) switchboard.requestCallbackMain("new pinned nodes", self.newNodesPinned) switchboard.requestCallbackMain(self.skelwidget, self.skel_update) switchboard.requestCallbackMain("made reservation", self.reservationChanged) switchboard.requestCallbackMain("cancelled reservation", self.reservationChanged)
def ofd(fname = None): dialog = gtk.Dialog("pyedit: Open File", None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_default_response(gtk.RESPONSE_ACCEPT) dialog.connect("key-press-event", area_key, dialog) dialog.connect("key-release-event", area_key, dialog) dialog.set_default_size(800, 600) # Spacers label1 = gtk.Label(" "); label2 = gtk.Label(" ") label3 = gtk.Label(" "); label4 = gtk.Label(" ") label5 = gtk.Label(" "); label6 = gtk.Label(" ") label7 = gtk.Label(" "); label8 = gtk.Label(" ") label10 = gtk.Label(" "); dialog.label11 = gtk.Label(" ") dialog.label12 = gtk.Label(" ") dialog.pbox = gtk.HBox() fill_path(dialog) dialog.vbox.pack_start(label4, False) dialog.vbox.pack_start(dialog.pbox, False) dialog.vbox.pack_start(label10, False) warnings.simplefilter("ignore") dialog.entry = gtk.Entry(); warnings.simplefilter("default") dialog.entry.set_activates_default(True) dialog.entry.set_text(fname) hbox2 = gtk.HBox() hbox2.pack_start(label6, False) hbox2.pack_start(dialog.entry) hbox2.pack_start(label7, False) dialog.vbox.pack_start(hbox2, False) dialog.vbox.pack_start(label8, False) dialog.ts = gtk.ListStore(str, str, str, str) tview = create_ftree(dialog.ts) scroll = gtk.ScrolledWindow() tview.connect("row-activated", tree_sel, dialog) tview.connect("cursor-changed", tree_sel_row, dialog) dialog.tview = tview scroll.add(tview) frame2 = gtk.Frame(); frame2.add(scroll) hbox3 = gtk.HBox() hbox3.pack_start(label1, False) hbox3.pack_start(frame2) hbox3.pack_start(label2, False) dialog.vbox.pack_start(hbox3) dialog.vbox.pack_start(label3, False) dialog.show_all() populate(dialog) dialog.set_focus(tview) #dialog.set_focus(dialog.entry) response = dialog.run() if response == gtk.RESPONSE_ACCEPT: res = os.path.realpath(dialog.entry.get_text()) else: res = "" #print "response", response, "res", res dialog.destroy() return res
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, medal, activity): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, self.get_colormap().alloc_color('#ffffff')) self.medal = medal self.activity = activity # Load the image. medal_type = medal['type'] bundle = sugar.activity.activity.get_bundle_path() images = { 'bronze': bundle + '/images/bronze-medal.svg', 'silver': bundle + '/images/silver-medal.svg', 'gold': bundle + '/images/gold-medal.svg' } medalpixbuf = gtk.gdk.pixbuf_new_from_file(images[medal_type]) medalpixbuf = medalpixbuf.scale_simple(350, 350, gtk.gdk.INTERP_BILINEAR) medalimage = gtk.Image() medalimage.set_from_pixbuf(medalpixbuf) # Certifications section. title = gtk.Label() title.set_markup( _("<span font_desc='Serif Bold Italic 28'>Certificate of Achievement</span>" )) text0 = gtk.Label() text0.set_markup( _("<span font_desc='Sans 16'>This certifies that</span>")) text1 = gtk.Label() text1.set_markup( _("<span font_desc='Sans 16'><b><u><i>%(nick)s</i></u></b></span>") % medal) text2 = gtk.Label() text2.set_markup( _("<span font_desc='Sans 16'>earned a %(type)s medal in </span>") % medal) text3 = gtk.Label() text3.set_markup( _("<span font_desc='Sans 16'>in <b><u><i>%(lesson)s</i></u></b></span>" ) % medal) text4 = gtk.Label() text4.set_markup( _("<span font_desc='Sans 16'>on <b><u><i>%(date)s</i></u></b>.</span>" ) % medal) textbox = gtk.VBox() textbox.pack_start(text0) textbox.pack_start(text1) textbox.pack_start(text2) textbox.pack_start(text3) textbox.pack_start(text4) medalbox = gtk.HBox() medalbox.pack_start(textbox) medalbox.pack_end(medalimage) # Stats section. statbox = gtk.HBox() if medal.has_key('wpm'): stat1 = gtk.Label() stat1.set_markup("<span size='18000'>" + (_('<b>Words Per Minute:</b> %(wpm)d') % medal) + "</span>") statbox.pack_start(stat1, True) stat2 = gtk.Label() stat2.set_markup("<span size='18000'>" + (_('<b>Accuracy:</b> %(accuracy)d%%') % medal) + "</span>") statbox.pack_start(stat2, True) elif medal.has_key('score'): stat1 = gtk.Label() stat1.set_markup("<span size='18000'>" + (_('<b>SCORE:</b> %(score)d') % medal) + "</span>") statbox.pack_start(stat1, True) oklabel = gtk.Label() oklabel.set_markup("<span size='10000'>" + _('Press the ENTER key to continue.') + '</span>') self.okbtn = gtk.Button() self.okbtn.add(oklabel) self.okbtn.connect('clicked', self.ok_cb) btnbox = gtk.HBox() btnbox.pack_start(self.okbtn, True, True, 100) vbox = gtk.VBox() vbox.pack_start(title, False, False, 0) vbox.pack_start(medalbox, True, False, 0) vbox.pack_start(gtk.HSeparator(), False, False, 20) vbox.pack_start(statbox, False, False, 0) frame = gtk.Frame() frame.add(vbox) frame.set_border_width(10) box = gtk.VBox() box.pack_start(frame, True, True) box.pack_start(btnbox, False, False, 40) self.add(box) self.show_all() self.connect('realize', self.realize_cb)
def __init__(self): gtk.Frame.__init__(self, "Lattice") self.set_label_align (0.5, 0.5); TypeBox = gtk.VBox() HBox = gtk.HBox() TypeFrame = gtk.Frame ("Type") ParamFrame = gtk.Frame ("Parameters") self.CubicRadio = gtk.RadioButton (None, "Simple Cubic") self.TetraRadio = gtk.RadioButton (self.CubicRadio, "Tetragonal") self.FCCRadio = gtk.RadioButton (self.CubicRadio, "FCC") self.BCCRadio = gtk.RadioButton (self.CubicRadio, "BCC") self.OrthoRadio = gtk.RadioButton (self.CubicRadio, "Orthorhombic") self.ArbRadio = gtk.RadioButton (self.CubicRadio, "Arbitrary") self.CubicRadio.connect ("toggled", self.RadioCallback, "Cubic") self.FCCRadio.connect ("toggled", self.RadioCallback, "FCC") self.BCCRadio.connect ("toggled", self.RadioCallback, "BCC") self.OrthoRadio.connect ("toggled", self.RadioCallback, "Ortho") self.ArbRadio.connect ("toggled", self.RadioCallback, "Arb") TypeBox.pack_start (self.CubicRadio) TypeBox.pack_start (self.FCCRadio) TypeBox.pack_start (self.BCCRadio) TypeBox.pack_start (self.OrthoRadio) TypeBox.pack_start (self.ArbRadio) TypeFrame.add (TypeBox) # Setup the lattice vector table VectorTable=gtk.Table(3, 4, False) a0label = gtk.Label(); a0label.set_markup("a<small><sub>0</sub></small>") a1label = gtk.Label(); a1label.set_markup("a<small><sub>1</sub></small>") a2label = gtk.Label(); a2label.set_markup("a<small><sub>2</sub></small>") VectorTable.attach(a0label, 0, 1, 0, 1, gtk.SHRINK, gtk.SHRINK, 5); VectorTable.attach(a1label, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK, 5); VectorTable.attach(a2label, 0, 1, 2, 3, gtk.SHRINK, gtk.SHRINK, 5); self.SpinButtons = [] for row in range(0,3): spinlist = [] for col in range(1,4): spin = gtk.SpinButton(\ gtk.Adjustment(0.0, -1.0e5, 1.00e5, 0.01, 0.1)) spinlist.append(spin) spin.set_digits(5) spin.set_width_chars(8) VectorTable.attach (spin, col, col+1, row, row+1) self.SpinButtons.append(spinlist) VectorFrame = gtk.Frame ("Lattice Vectors"); VectorFrame.add(VectorTable) # Setup the parameters ParamBox = gtk.VBox() # Cubic parameters ParamTable = gtk.Table(6,4) self.aButton = gtk.SpinButton\ (gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1)) self.aButton.set_digits(5); self.aButton.set_width_chars(8); self.bButton = gtk.SpinButton(gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1)); self.bButton.set_digits(5); self.bButton.set_width_chars(8); self.cButton = gtk.SpinButton(gtk.Adjustment(1.0, 0.0, 1e5, 0.01, 0.1)); self.cButton.set_digits(5); self.cButton.set_width_chars(8); self.alphaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1)); self.alphaButton.set_digits(3) self.betaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1)); self.betaButton.set_digits(3) self.gammaButton = gtk.SpinButton(gtk.Adjustment(90.0, 0.0, 180.0, 0.01, 0.1)); self.gammaButton.set_digits(3) # Set parameters changing callback self.aButton.connect ("value_changed", self.parameters_callback) self.bButton.connect ("value_changed", self.parameters_callback) self.cButton.connect ("value_changed", self.parameters_callback) self.alphaButton.connect("value_changed", self.parameters_callback) self.betaButton.connect ("value_changed", self.parameters_callback) self.gammaButton.connect("value_changed", self.parameters_callback) ParamTable.attach(gtk.Label("a"), 0, 1, 0, 1) ParamTable.attach(gtk.Label("b"), 0, 1, 1, 2) ParamTable.attach(gtk.Label("c"), 0, 1, 2, 3) alphaLabel = gtk.Label(); alphaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">α</span>") betaLabel = gtk.Label(); betaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">β</span>") gammaLabel = gtk.Label(); gammaLabel.set_markup("<span foreground=\"blue\" font_family=\"Standard Symbols L\">γ</span>") ParamTable.attach(alphaLabel, 2, 3, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(betaLabel , 2, 3, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(gammaLabel, 2, 3, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.aButton, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.bButton, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.cButton, 1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.alphaButton, 3, 4, 0, 1, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.betaButton, 3, 4, 1, 2, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamTable.attach(self.gammaButton, 3, 4, 2, 3, gtk.SHRINK, gtk.SHRINK, 5, 2) ParamBox.pack_start(ParamTable) ParamFrame.add (ParamBox) # Pack the main Lattice box HBox.pack_start (TypeFrame, False, False, 3) HBox.pack_start (ParamFrame, False, False, 3) HBox.pack_start (VectorFrame, False, False, 3) self.set_cubic() self.lattice_sensitive(False) self.params_sensitive([True, False, False, False, False, False]) self.add (HBox)
def __init__(self, parent=None): gtk.Window.__init__(self) try: self.set_screen(parent.get_screen()) except AttributeError: self.connect('destroy', lambda *w: gtk.main_quit()) self.set_title(self.__class__.__name__) self.set_default_size(-1, 500) self.set_border_width(8) hbox = gtk.HBox(False, 8) self.add(hbox) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) hbox.pack_start(sw, False, False, 0) model = self.__create_model() treeview = gtk.TreeView(model) sw.add(treeview) column = gtk.TreeViewColumn() column.set_title("Macro") cell_renderer = gtk.CellRendererPixbuf() column.pack_start(cell_renderer, False) column.set_attributes(cell_renderer, stock_id=1) cell_renderer = gtk.CellRendererText() column.pack_start(cell_renderer, True) column.set_cell_data_func(cell_renderer, macro_set_func_text) treeview.append_column(column) cell_renderer = gtk.CellRendererText() treeview.insert_column_with_data_func(-1, "Label", cell_renderer, label_set_func) cell_renderer = gtk.CellRendererText() treeview.insert_column_with_data_func(-1, "Accel", cell_renderer, accel_set_func) cell_renderer = gtk.CellRendererText() treeview.insert_column_with_data_func(-1, "ID", cell_renderer, id_set_func) align = gtk.Alignment(0.5, 0.0, 0.0, 0.0) hbox.pack_end(align, False, False, 0) frame = gtk.Frame("Selected Item") align.add(frame) vbox = gtk.VBox(False, 8) vbox.set_border_width(4) frame.add(vbox) display = StockItemDisplay() treeview.set_data("stock-display", display) display.type_label = gtk.Label() display.macro_label = gtk.Label() display.id_label = gtk.Label() display.label_accel_label = gtk.Label() display.icon_image = gtk.Image() # empty image vbox.pack_start(display.type_label, False, False, 0) vbox.pack_start(display.icon_image, False, False, 0) vbox.pack_start(display.label_accel_label, False, False, 0) vbox.pack_start(display.macro_label, False, False, 0) vbox.pack_start(display.id_label, False, False, 0) selection = treeview.get_selection() selection.set_mode(gtk.SELECTION_SINGLE) selection.connect("changed", self.on_selection_changed) self.show_all()
def StartGUI(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", gtk.main_quit) self.window.set_border_width(10) self.window.set_default_size(400, 800) self.window.set_title("Reference Model Builder") self.vbox = gtk.VBox() # this is the main container ################################################################################# # --- PDB file selection --- # checking for pdb files in reference directory referenceFiles = [] for files in glob.glob( os.path.join(self.reference_directory, '*-ground-state.pdb')): pdbFile = files[files.rfind('/') + 1:] referenceFiles.append(pdbFile) frame = gtk.Frame(label='Select PDB file') hbox = gtk.HBox() self.cb_select_pdb = gtk.combo_box_new_text() # self.cb_select_pdb.connect("changed", self.set_selection_mode) for pdbFile in referenceFiles: self.cb_select_pdb.append_text(pdbFile) hbox.add(self.cb_select_pdb) frame.add(hbox) self.vbox.pack_start(frame) self.load_pdb_file_button = gtk.Button(label="Load") # self.load_pdb_file_button.connect("clicked",self.get_samples_to_look_at) self.load_pdb_file_button.connect("clicked", self.load_pdb_file) hbox.add(self.load_pdb_file_button) frame.add(hbox) self.vbox.pack_start(frame) # SPACER self.vbox.add(gtk.Label(' ')) frame = gtk.Frame(label='MTZ file to refine against') hbox = gtk.HBox() self.mtzFree = '' self.mtzFree_label = gtk.Label() hbox.add(self.mtzFree_label) frame.add(hbox) self.vbox.pack_start(frame) # SPACER self.vbox.add(gtk.Label(' ')) frame = gtk.Frame(label='MTZ file after refinement') hbox = gtk.HBox() self.mtzRefine_label = gtk.Label() hbox.add(self.mtzRefine_label) frame.add(hbox) self.vbox.pack_start(frame) # SPACER self.vbox.add(gtk.Label(' \n ')) ################################################################################# # --- ground state mean map --- # checking for ground state mean map in reference folder # self.meanMaps = {} # for dirs in glob.glob(os.path.join(self.reference_directory,'pandda_*')): # panddaDir=dirs.split('/')[len(dirs.split('/'))-1] # for files in glob.glob(os.path.join(dirs,'processed_datasets','*','*ground-state-mean-map.native.ccp4')): # if os.path.isfile(files): # self.meanMaps[panddaDir]=files # break # frame = gtk.Frame(label='Load ground-state-mean-map files') # hbox=gtk.HBox() # self.cb_select_mean_map = gtk.combo_box_new_text() # for item in self.meanMaps: # self.cb_select_mean_map.append_text(item) # hbox.add(self.cb_select_mean_map) # self.load_ground_state_map_button = gtk.Button(label="Load") # self.load_ground_state_map_button.connect("clicked",self.load_ground_state_map) # hbox.add(self.load_ground_state_map_button) # frame.add(hbox) # self.vbox.pack_start(frame) # frame = gtk.Frame() # hbox=gtk.HBox() # self.cb_select_mean_map_by_resolution = gtk.combo_box_new_text() # self.cb_select_mean_map_by_resolution.connect("changed", self.show_selected_mean_map) # hbox.add(self.cb_select_mean_map_by_resolution) ## self.show_highres_ground_state_map_button = gtk.Button(label="Show Highest\nResolution Map") ## self.show_highres_ground_state_map_button.connect("clicked",self.show_highres_ground_state_map) ## hbox.add(self.show_highres_ground_state_map_button) ## self.show_all_ground_state_map_button = gtk.Button(label="Show All Maps") ## self.show_all_ground_state_map_button.connect("clicked",self.show_all_ground_state_map) ## hbox.add(self.show_all_ground_state_map_button) # frame.add(hbox) # self.vbox.pack_start(frame) # SPACER # self.vbox.add(gtk.Label(' \n ')) ################################################################################# # --- Refinement History --- frame = gtk.Frame(label='Refinement History') self.hbox_for_info_graphics = gtk.HBox() self.canvas = FigureCanvas(self.update_plot([0], [0], [0])) self.canvas.set_size_request(190, 190) self.hbox_for_info_graphics.add(self.canvas) frame.add(self.hbox_for_info_graphics) self.vbox.pack_start(frame) ################################################################################# # --- status window --- frame = gtk.Frame(label='Status') vbox = gtk.VBox() self.spinnerBox = gtk.VBox() self.refinementRunning = gtk.Spinner() vbox.add(self.spinnerBox) # hbox.add(self.refinementRunning) self.status_label = gtk.Label() vbox.add(self.status_label) frame.add(vbox) self.status_label.set_text('idle') # frame.add(self.status_label) self.vbox.pack_start(frame) ################################################################################# # --- Refinement Statistics --- # next comes a section which displays some global quality indicators # a combination of labels and textview widgets, arranged in a table RRfreeLabel_frame = gtk.Frame() self.RRfreeLabel = gtk.Label('R/Rfree') RRfreeLabel_frame.add(self.RRfreeLabel) self.RRfreeValue = gtk.Label(self.QualityIndicators['Rcryst'] + '/' + self.QualityIndicators['Rfree']) RRfreeBox_frame = gtk.Frame() self.RRfreeBox = gtk.EventBox() self.RRfreeBox.add(self.RRfreeValue) RRfreeBox_frame.add(self.RRfreeBox) ResolutionLabel_frame = gtk.Frame() self.ResolutionLabel = gtk.Label('Resolution') ResolutionLabel_frame.add(self.ResolutionLabel) self.ResolutionValue = gtk.Label( self.QualityIndicators['ResolutionHigh']) ResolutionBox_frame = gtk.Frame() self.ResolutionBox = gtk.EventBox() self.ResolutionBox.add(self.ResolutionValue) ResolutionBox_frame.add(self.ResolutionBox) MolprobityScoreLabel_frame = gtk.Frame() self.MolprobityScoreLabel = gtk.Label('MolprobityScore') MolprobityScoreLabel_frame.add(self.MolprobityScoreLabel) self.MolprobityScoreValue = gtk.Label( self.QualityIndicators['MolprobityScore']) MolprobityScoreBox_frame = gtk.Frame() self.MolprobityScoreBox = gtk.EventBox() self.MolprobityScoreBox.add(self.MolprobityScoreValue) MolprobityScoreBox_frame.add(self.MolprobityScoreBox) RamachandranOutliersLabel_frame = gtk.Frame() self.RamachandranOutliersLabel = gtk.Label('Rama Outliers') RamachandranOutliersLabel_frame.add(self.RamachandranOutliersLabel) self.RamachandranOutliersValue = gtk.Label( self.QualityIndicators['RamachandranOutliers']) RamachandranOutliersBox_frame = gtk.Frame() self.RamachandranOutliersBox = gtk.EventBox() self.RamachandranOutliersBox.add(self.RamachandranOutliersValue) RamachandranOutliersBox_frame.add(self.RamachandranOutliersBox) RamachandranFavoredLabel_frame = gtk.Frame() self.RamachandranFavoredLabel = gtk.Label('Rama Favored') RamachandranFavoredLabel_frame.add(self.RamachandranFavoredLabel) self.RamachandranFavoredValue = gtk.Label( self.QualityIndicators['RamachandranFavoredColor']) RamachandranFavoredBox_frame = gtk.Frame() self.RamachandranFavoredBox = gtk.EventBox() self.RamachandranFavoredBox.add(self.RamachandranFavoredValue) RamachandranFavoredBox_frame.add(self.RamachandranFavoredBox) rmsdBondsLabel_frame = gtk.Frame() self.rmsdBondsLabel = gtk.Label('rmsd(Bonds)') rmsdBondsLabel_frame.add(self.rmsdBondsLabel) self.rmsdBondsValue = gtk.Label(self.QualityIndicators['rmsdBonds']) rmsdBondsBox_frame = gtk.Frame() self.rmsdBondsBox = gtk.EventBox() self.rmsdBondsBox.add(self.rmsdBondsValue) rmsdBondsBox_frame.add(self.rmsdBondsBox) rmsdAnglesLabel_frame = gtk.Frame() self.rmsdAnglesLabel = gtk.Label('rmsd(Angles)') rmsdAnglesLabel_frame.add(self.rmsdAnglesLabel) self.rmsdAnglesValue = gtk.Label(self.QualityIndicators['rmsdAngles']) rmsdAnglesBox_frame = gtk.Frame() self.rmsdAnglesBox = gtk.EventBox() self.rmsdAnglesBox.add(self.rmsdAnglesValue) rmsdAnglesBox_frame.add(self.rmsdAnglesBox) MatrixWeightLabel_frame = gtk.Frame() self.MatrixWeightLabel = gtk.Label('Matrix Weight') MatrixWeightLabel_frame.add(self.MatrixWeightLabel) self.MatrixWeightValue = gtk.Label( self.QualityIndicators['MatrixWeight']) MatrixWeightBox_frame = gtk.Frame() self.MatrixWeightBox = gtk.EventBox() self.MatrixWeightBox.add(self.MatrixWeightValue) MatrixWeightBox_frame.add(self.MatrixWeightBox) outer_frame = gtk.Frame() hbox = gtk.HBox() frame = gtk.Frame() self.table_left = gtk.Table(8, 2, False) self.table_left.attach(RRfreeLabel_frame, 0, 1, 0, 1) self.table_left.attach(ResolutionLabel_frame, 0, 1, 1, 2) self.table_left.attach(MolprobityScoreLabel_frame, 0, 1, 2, 3) self.table_left.attach(RamachandranOutliersLabel_frame, 0, 1, 3, 4) self.table_left.attach(RamachandranFavoredLabel_frame, 0, 1, 4, 5) self.table_left.attach(rmsdBondsLabel_frame, 0, 1, 5, 6) self.table_left.attach(rmsdAnglesLabel_frame, 0, 1, 6, 7) self.table_left.attach(MatrixWeightLabel_frame, 0, 1, 7, 8) self.table_left.attach(RRfreeBox_frame, 1, 2, 0, 1) self.table_left.attach(ResolutionBox_frame, 1, 2, 1, 2) self.table_left.attach(MolprobityScoreBox_frame, 1, 2, 2, 3) self.table_left.attach(RamachandranOutliersBox_frame, 1, 2, 3, 4) self.table_left.attach(RamachandranFavoredBox_frame, 1, 2, 4, 5) self.table_left.attach(rmsdBondsBox_frame, 1, 2, 5, 6) self.table_left.attach(rmsdAnglesBox_frame, 1, 2, 6, 7) self.table_left.attach(MatrixWeightBox_frame, 1, 2, 7, 8) frame.add(self.table_left) hbox.add(frame) outer_frame.add(hbox) self.vbox.add(outer_frame) button = gtk.Button(label="Show MolProbity to-do list") button.connect("clicked", self.show_molprobity_to_do) self.vbox.add(button) self.vbox.pack_start(frame) # SPACER self.vbox.add(gtk.Label(' ')) # --- refinement & options --- self.hbox_for_refinement = gtk.HBox() self.REFINEbutton = gtk.Button(label="Refine") self.RefinementParamsButton = gtk.Button(label="refinement parameters") self.REFINEbutton.connect("clicked", self.REFINE) self.hbox_for_refinement.add(self.REFINEbutton) self.RefinementParamsButton.connect("clicked", self.RefinementParams) self.hbox_for_refinement.add(self.RefinementParamsButton) self.vbox.add(self.hbox_for_refinement) # --- CANCEL button --- self.CANCELbutton = gtk.Button(label="CANCEL") self.CANCELbutton.connect("clicked", self.CANCEL) self.vbox.add(self.CANCELbutton) self.window.add(self.vbox) self.window.show_all()
def generic_objects_gui(): pygtk_flag = False try: import pygtk pygtk.require("2.0") import gtk, pango pygtk_flag = True except: print "BL WARNING:: no pygtk2. Function wont work!!!" if (pygtk_flag and using_gui()): # Now we run the gui def delete_event(*args): # BL says: first we shall close the generic objects # or not #for generic_object_number in range(n_objects): # set_display_generic_object(generic_object_number, 0) gen_window.destroy() return False def check_button_callback(widget, generic_object_number): button_state = widget.get_active() object_state = generic_object_is_displayed_qm(generic_object_number) if ((button_state == True) and (object_state == 0)): set_display_generic_object(generic_object_number,1) if ((button_state == False) and (object_state == 1)): set_display_generic_object(generic_object_number,0) def all_check_button_callback(widget): show_all = widget.get_active() for check_button in open_generic_objects: if (show_all): check_button.set_active(True) else: check_button.set_active(False) n_objects = number_of_generic_objects() if (n_objects > 0): gen_window = gtk.Window(gtk.WINDOW_TOPLEVEL) gen_window.set_title("Generic objects") vbox = gtk.VBox(False, 0) open_generic_objects = [] no_active_generic_objects = 0 for generic_object_number in range(n_objects): print "INFO:: generic object attributes: ", \ generic_object_number, \ generic_object_name(generic_object_number), \ is_closed_generic_object_qm(generic_object_number) if (is_closed_generic_object_qm(generic_object_number) == 0): name = generic_object_name(generic_object_number) if (name): label = str(generic_object_number) + " " + name frame = gtk.Frame(label=None) check_button = gtk.CheckButton(label) # this callback gets called by the # gtk-toggle-button-set-active just below, # which is why we need the state and active # test. check_button.connect("toggled", check_button_callback, generic_object_number) current_state = generic_object_is_displayed_qm(generic_object_number) if (current_state == 1): check_button.set_active(True) no_active_generic_objects += 1 vbox.add(frame) frame.add(check_button) frame.show() check_button.show() open_generic_objects.append(check_button) if (len(open_generic_objects) > 1): hsep = gtk.HSeparator() label = "Show/hide all" frame = gtk.Frame(label=None) check_button = gtk.CheckButton(label) check_button.connect("toggled", all_check_button_callback) if (len(open_generic_objects) == no_active_generic_objects): check_button.set_active(True) vbox.add(hsep) hsep.show() vbox.add(frame) frame.add(check_button) frame.show() check_button.show() gen_window.connect("delete_event", delete_event) vbox.show() gen_window.add(vbox) gen_window.set_border_width(10) gen_window.show()
def handle_error(exception_type, exception_value, exception_traceback): """display errors to the end user using dialog boxes""" if exception_type == PyroomError: message = exception_value.message elif exception_type == KeyboardInterrupt: # ctrl+c return else: # uncaught exception in code message = _("""There has been an uncaught exception in pyroom.\n This is most likely a programming error. \ Please submit a bug report to launchpad""") error_dialog = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_NONE, message_format=message) error_dialog.set_title(_('Error')) error_dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) if not exception_type == PyroomError: error_dialog.add_button (_("Details..."), 2) error_dialog.set_position(gtk.WIN_POS_CENTER) error_dialog.set_gravity(gtk.gdk.GRAVITY_CENTER) error_dialog.show_all() details_textview = gtk.TextView() details_textview.show() details_textview.set_editable(False) details_textview.modify_font(pango.FontDescription('Monospace')) scrolled_window = gtk.ScrolledWindow() scrolled_window.show() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(details_textview) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_IN) frame.add(scrolled_window) frame.set_border_width(6) error_dialog.vbox.add(frame) details_buffer = details_textview.get_buffer() printable_traceback = "\n".join( traceback.format_exception( exception_type, exception_value, exception_traceback, ) ) details_buffer.set_text(printable_traceback) details_textview.set_size_request( gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3 ) error_dialog.details = frame while True: resp = error_dialog.run() if resp == 2: error_dialog.details.show() error_dialog.action_area.get_children()\ [0].set_sensitive(0) else: break error_dialog.destroy()
def __init__(self, client, event): gtk.Window.__init__(self) self._client = client self._event = event self.set_decorated(False) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_border_width(style.LINE_WIDTH) window = gtk.VBox() self.add(window) toolbar = gtk.Toolbar() window.pack_start(toolbar, False) icon = Icon() icon.set_from_icon_name('emblem-warning', gtk.ICON_SIZE_LARGE_TOOLBAR) icon.props.xo_color = profile.get_color() tool_item = gtk.ToolItem() tool_item.add(icon) toolbar.insert(tool_item, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(style.DEFAULT_SPACING, -1) toolbar.insert(separator, -1) title = gtk.Label(_('Submit failure report')) tool_item = gtk.ToolItem() tool_item.add(title) toolbar.insert(tool_item, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar.insert(separator, -1) submit = ToolButton('dialog-ok', tooltip=_('Submit')) submit.connect('clicked', lambda button: self._submit()) toolbar.insert(submit, -1) cancel = ToolButton('dialog-cancel', tooltip=_('Cancel')) cancel.connect('clicked', lambda button: self.destroy()) toolbar.insert(cancel, -1) bg = gtk.EventBox() bg.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) window.pack_start(bg) canvas = gtk.VBox() canvas.set_border_width(style.DEFAULT_SPACING) canvas.props.spacing = style.DEFAULT_SPACING bg.add(canvas) box = gtk.HBox() box.props.spacing = style.DEFAULT_SPACING canvas.pack_start(box, False) if 'icon' in event: icon = Icon(file=event['icon'], pixel_size=style.XLARGE_ICON_SIZE) else: icon = Icon() icon.set_from_icon_name('emblem-warning', gtk.ICON_SIZE_LARGE_TOOLBAR) box.pack_start(icon, False) label = gtk.Label() label.props.use_markup = True if 'solution' in event: activity_name = '%(name)s-%(version)s' % event['solution'][0] else: activity_name = event['context'] label.props.label = '<b>%s</b>\n%s' % (activity_name, event['error']) label.props.wrap = True box.pack_start(label, False) frame = gtk.Frame( _('Optionally, describe the problem in common sentences')) canvas.pack_start(frame) self._message = gtk.TextView() scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled.set_border_width(style.DEFAULT_PADDING) scrolled.add(self._message) frame.add(scrolled) frame = gtk.Frame(_('Log')) canvas.pack_start(frame) text = gtk.TextView() text.props.editable = False if 'trace' in event: text.props.buffer.props.text = '\n'.join(event['trace']) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_border_width(style.DEFAULT_PADDING) scrolled.add(text) frame.add(scrolled) self.show_all() self.set_focus(self._message) self.connect('realize', self.__realize_cb) gap = style.GRID_CELL_SIZE width = gtk.gdk.screen_width() - gap * 2 height = gtk.gdk.screen_height() - gap * 2 self.set_size_request(width, height) self.move(gap, gap)
def create_pm_window(self): # Creates GUI for channel last_index = len(self.lobby_pm_names) - 1 gtk.threads_enter() # Label label_box = gtk.EventBox() label = gtk.Label(self.lobby_pm_names[last_index]) label.show() label_box.show() label_box.add(label) # Vertical Pane vpane = gtk.HPaned() self.lobby_pm_vpanes.append(vpane) vpane.show() # Frame frame = gtk.Frame(None) frame.set_border_width(0) frame.set_size_request(100, 75) frame.show() vpane.pack1(frame, True, True) frame2 = gtk.Frame(None) frame2.set_border_width(0) frame2.show() vpane.pack2(frame2, True, True) # Player Window (scrolled) player_window = gtk.ScrolledWindow() player_window.set_border_width(0) player_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) player_window.show() # Player ListStore # 0 Username # 1 Country # 2 Cpu # 3 IP # 4 Status -> InGame / Away # 5 Rank # 6 Admin player_liststore = gtk.ListStore(str, gtk.gdk.Pixbuf, str, str, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) self.lobby_pm_users.append(player_liststore) player_treeview = gtk.TreeView(player_liststore) player_column_0 = gtk.TreeViewColumn('') # Away player_column_1 = gtk.TreeViewColumn('') # Country player_column_2 = gtk.TreeViewColumn('') # Name Rank Mod player_treeview.append_column(player_column_0) player_treeview.append_column(player_column_1) player_treeview.append_column(player_column_2) player_treeview.set_headers_visible(False) player_treeview.show() player_window.add(player_treeview) frame2.add(player_window) # Create a CellRenderers to render the data cell0 = gtk.CellRendererPixbuf() cell1 = gtk.CellRendererPixbuf() cell2 = gtk.CellRendererText() cell3 = gtk.CellRendererPixbuf() cell4 = gtk.CellRendererPixbuf() self.lobby_pm_users_columns.append( [player_column_0, player_column_1, player_column_2]) self.lobby_pm_users_cells.append([cell0, cell1, cell2, cell3, cell4]) # Add the cells to the columns player_column_0.pack_start(cell0, False) player_column_1.pack_start(cell1, False) player_column_2.pack_start(cell2, False) player_column_2.pack_start(cell3, False) player_column_2.pack_start(cell4, False) # Set the cell attributes to the appropriate liststore column player_column_2.set_attributes(cell2, text=0) # Allow sorting on the column player_column_2.set_sort_column_id(0) tag_table = self.lobby_pm_buffers[last_index].get_tag_table() join_tag = gtk.TextTag("join") join_tag.set_property("foreground", "blue") tag_table.add(join_tag) left_tag = gtk.TextTag("left") left_tag.set_property("foreground", "grey") tag_table.add(left_tag) # Table table = gtk.Table(rows=1, columns=4, homogeneous=False) frame.add(table) table.show() # Scrolled Window scrolled_window = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.lobby_pm_textview[last_index]) scrolled_window.show() table.attach(scrolled_window, 0, 2, 0, 1) # Entrys entry = gtk.Entry(max=0) entry.show() entry.connect("activate", self.parse_output_pm, self.lobby_pm_names[last_index]) table.attach(entry, 0, 2, 1, 2, gtk.FILL, gtk.FILL, 0, 0) # Notebook Page self.lobby_notebook.append_page(vpane, label_box) label_box.connect('event', self.on_pm_tab_click, self.lobby_pm_names[last_index]) gtk.threads_leave()
def __init__(self, parent): gtk.HBox.__init__(self) queryframe = gtk.Frame('Query Parameters') queryframe.set_border_width(2) filterframe = gtk.Frame('Filter') filterframe.set_border_width(2) self.gametypes = GametypesFilter() self.gametypes.set_border_width(2) self.pack_start(queryframe, False, False) self.pack_start(filterframe, True, True) self.pack_start(self.gametypes, False, False) #query parameters, empty and full querybox = gtk.VBox() querybox.set_border_width(5) self.checkbox_showfull = gtk.CheckButton('show full') self.checkbox_showfull.show() self.checkbox_showempty = gtk.CheckButton('show empty') self.checkbox_showempty.show() #filterframe content filtertable = gtk.Table(2, 3) filtertable.set_border_width(5) filterframe.add(filtertable) self.checkbox_hide_non_responsive = gtk.CheckButton( 'hide non responsive') self.checkbox_hide_passworded = gtk.CheckButton('hide passworded') minplayerlabel = gtk.Label('min. players:') maxplayerlabel = gtk.Label('max. players:') self.minplayerentry = gtk.SpinButton() self.maxplayerentry = gtk.SpinButton() self.minplayerentry.set_increments(1, 10) self.maxplayerentry.set_increments(1, 10) self.minplayerentry.set_range(0, 99) self.maxplayerentry.set_range(0, 99) filtertable.attach(self.checkbox_hide_non_responsive, 0, 1, 0, 1) filtertable.attach(self.checkbox_hide_passworded, 0, 1, 1, 2) filtertable.attach(minplayerlabel, 1, 2, 0, 1) filtertable.attach(maxplayerlabel, 1, 2, 1, 2) filtertable.attach(self.minplayerentry, 2, 3, 0, 1) filtertable.attach(self.maxplayerentry, 2, 3, 1, 2) querybox.pack_start(self.checkbox_showfull) querybox.pack_start(self.checkbox_showempty) queryframe.add(querybox) #buttonbox buttonbox = gtk.VBox() buttonbox.set_border_width(5) self.pack_start(buttonbox, False, False) resetbutton = gtk.Button('Reset') resetbutton.connect('clicked', self.on_reset_clicked) resetimage = gtk.Image() resetimage.set_from_stock(gtk.STOCK_REVERT_TO_SAVED,\ gtk.ICON_SIZE_BUTTON) resetbutton.set_image(resetimage) buttonbox.pack_start(resetbutton) self.searchbutton = gtk.Button('Search') self.searchbutton.connect("clicked", self.on_search_clicked) searchimage = gtk.Image() searchimage.set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON) self.searchbutton.set_image(searchimage) buttonbox.pack_start(self.searchbutton) self.set_default_values(False) self.show_all()
def init_Window(self): #ウィンドウを作成 self.window = gtk.Window() self.window.set_border_width(5) self.window.set_size_request(300, 200) self.window.set_title('目覚マシマシ') self.window.connect('destroy_event', self.end_application) self.window.connect('delete_event', self.end_application) self.window.fullscreen() # ラベルを作成 self.label_show = gtk.Label() self.label_str = '<big><b>Hi!</b></big>' self.button_quit = gtk.Button() self.button_quit.set_label('Quit') self.button_quit.connect('clicked', self.end_application) # テキストボックス作成 # self.entry = gtk.Entry() #set timerボタン self.button_timerSet = gtk.Button('Set Timer') self.button_timerSet.connect('clicked', self.timerSet_clicked) # スピンボタン # 時間(Hour) self.entry_hour = gtk.Entry() self.entry_hour.set_text('0') self.entry_hour.set_size_request(40, 40) self.hour_button_up = gtk.Button("△") self.hour_button_up.set_size_request(50, 40) self.hour_button_up.connect('clicked', self.hour_up) self.hour_button_down = gtk.Button('▽') self.hour_button_down.set_size_request(50, 40) self.hour_button_down.connect('clicked', self.hour_down) self.hour_buttons = gtk.VBox() self.hour_buttons.add(self.hour_button_up) self.hour_buttons.add(self.hour_button_down) self.hour = gtk.HBox() self.hour.add(self.entry_hour) self.hour.add(self.hour_buttons) # 分 self.entry_minute = gtk.Entry() self.entry_minute.set_text('0') self.entry_minute.set_size_request(40, 40) self.minute_button_up = gtk.Button('△') self.minute_button_up.set_size_request(50, 40) self.minute_button_up.connect('clicked', self.minute_up) self.minute_button_down = gtk.Button('▽') self.minute_button_down.set_size_request(50, 40) self.minute_button_down.connect('clicked', self.minute_down) self.minute_buttons = gtk.VBox() self.minute_buttons.add(self.minute_button_up) self.minute_buttons.add(self.minute_button_down) self.minute = gtk.HBox() self.minute.add(self.entry_minute) self.minute.add(self.minute_buttons) self.spins = gtk.HBox() self.spins.add(self.hour) self.spins.add(self.minute) # セットされたタイマーのチェックボックス self.timersVbox = gtk.VBox() self.check1 = gtk.CheckButton('empty') self.check2 = gtk.CheckButton('empty') self.check1.connect('toggled', self.on_toggle_check_1) self.check2.connect('toggled', self.on_toggle_check_2) self.timersVbox.pack_start(self.check1) self.timersVbox.pack_start(self.check2) # セットされたタイマーのチェックボックスを格納したフレーム self.checkFrm = gtk.Frame('Timers') self.checkFrm.add(self.timersVbox) # ラベルとボタンをVBoxにパック self.vbox = gtk.VBox() self.vbox.add(self.label_show) self.vbox.add(self.spins) # self.vbox.add(self.entry) self.vbox.add(self.button_timerSet) self.vbox.add(self.button_quit) # チェックフレームとVBoxをHBoxに格納 self.hbox = gtk.HBox() self.hbox.pack_start(self.vbox) self.hbox.pack_start(self.checkFrm) # HBoxをウィンドウに格納 self.window.add(self.hbox) # ウィンドウ、および配下の全ウィジェットを表示 self.window.show_all()
def __init__(self, cmds, lux): self.first_data = True self.need_to_set = False self.cmds = cmds self.mode = { 'cmd': 'set', 'profile': 'manual', 'mode': 2, 'higain': False, 'int_time': 500 } self.ev = 1.0 self.ev_max = 1.0 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect('destroy', self.destroy) self.window.set_title('BlueLightMeter') self.window.set_geometry_hints(min_width=400, min_height=500) vals = gtk.VBox() self.window.add(vals) cur = gtk.HBox() vals.pack_start(cur) self.cur_lux = self.new_val('Cur Lux:', cur) self.cur_ev = self.new_val('EV:', cur) max = gtk.HBox() vals.pack_start(max) self.max_lux = self.new_val('Max Lux:', max) self.max_ev = self.new_val('EV:', max) self.debug = gtk.Label('Debug Info') vals.pack_start(self.debug) ctrl = gtk.HBox() frame = gtk.Frame() frame.add(ctrl) vals.pack_start(frame) ctrl_left = gtk.VBox() ctrl.pack_start(ctrl_left) ctrl_right = gtk.VBox() ctrl.pack_start(ctrl_right) self.but_choices = {} self.new_choices(ctrl_left, 'profile', (('Manual', 'manual'), ('All Values', 'all'), ('Fast Modes', 'fast'), ('Low gain', 'logain')), 'Manual') self.higain = gtk.CheckButton('High Gain') ctrl_left.pack_start(self.higain) self.higain.connect( 'toggled', lambda w: self.setter(None, 'higain', w.get_active())) self.new_choices(ctrl_right, 'mode', (('13.7 ms', 0), ('101 ms', 1), ('402 ms', 2), ('Custom:', 3)), '402 ms') self.int_time = gtk.Entry() self.int_time.set_width_chars(6) ctrl_right.pack_start(self.int_time) self.int_time.set_text('500') self.int_time.connect('activate', lambda w: self.setter(None, None, None)) calc = gtk.VBox() frame = gtk.Frame() vals.pack_start(frame) frame.add(calc) calc_inputs = gtk.HBox() calc.pack_start(calc_inputs, expand=True) self.create_list(self.AVc, 'Av', calc_inputs) self.create_list(self.TVc, 'Tv', calc_inputs) self.create_list(self.ISOc, 'ISO', calc_inputs) calc_outputs = gtk.HBox() calc.pack_start(calc_outputs, expand=False) which = gtk.VBox() calc_outputs.pack_start(which) which.pack_start(gtk.Label('Calculate:')) self.which = 'Normal' self.which_base = None self.create_obj('which', 'Normal', which) self.create_obj('which', 'Flash', which) what = gtk.VBox() calc_outputs.pack_start(what) self.what = 'Tv' self.what_base = None self.create_obj('what', 'Tv', what) self.create_obj('what', 'Av', what) self.create_obj('what', 'ISO', what) goals = gtk.VBox() calc_outputs.pack_start(goals) self.goal = gtk.Label('<span size="38000">???</span>') self.goal.set_use_markup(gtk.TRUE) goals.pack_start(self.goal) self.goal_ev = gtk.Label('Ev=???') goals.pack_start(self.goal_ev) self.window.show_all() gobject.idle_add(lambda: self.process_lux(lux))
def __init__(self): # main window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("images2cot") self.window.connect("delete_event", self.delete_event) self.window.connect("destroy_event", self.destroy_event) self.window.set_size_request(800, 600) # vertical box self.vbox = gtk.VBox(False, 0) self.window.add(self.vbox) # menu bar mb = images2cot.MainMenuBar(self.window) self.menu_bar = mb.get() self.vbox.pack_start(self.menu_bar, False, False, 2) # horizontal pane, left side and right side self.hp1 = gtk.HPaned() self.hp1.set_position(400) self.vbox.pack_start(self.hp1, True, True, 2) # left child of horizontal pane, frame frame = gtk.Frame('Images') frame.set_shadow_type(gtk.SHADOW_OUT) frame.show() self.frm_images = frame self.hp1.add1(frame) # vbox in frm_images self.vbox_images = gtk.VBox() self.frm_images.add(self.vbox_images) self.vbox_images.show() # scroll window for list view self.scroll_images = gtk.ScrolledWindow() self.scroll_images.set_border_width(10) self.scroll_images.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.scroll_images.show() self.vbox_images.pack_start(self.scroll_images, True, True, 2) # list view for images self.lst_images = images2cot.ImagesList(self) self.lst_images = self.lst_images.get() self.lst_images.show_all() self.scroll_images.add_with_viewport(self.lst_images) # button list in the images frame self.bbox_images = gtk.HButtonBox() buttons = images2cot.I2cButtons() self.btn_add = buttons.get_btn_add(self.lst_images) self.btn_remove = buttons.get_btn_remove(self.lst_images, self) self.bbox_images.pack_start(self.btn_add, False, False, 2) self.bbox_images.pack_start(self.btn_remove, False, False, 2) self.bbox_images.show() self.vbox_images.pack_end(self.bbox_images, False, False, 2) self.frm_images.show_all() # right child of horizontal pane, frame frame = gtk.Frame('Exif Info') frame.set_shadow_type(gtk.SHADOW_OUT) frame.show() self.frm_exif = frame self.hp1.add2(frame) # scroll window for image info self.scroll_exif_info = gtk.ScrolledWindow() self.scroll_exif_info.set_border_width(5) self.scroll_exif_info.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.scroll_exif_info.show() self.frm_exif.add(self.scroll_exif_info) # text view for image info frame txt_info = gtk.TextView() txt_info.set_editable(False) self.scroll_exif_info.add(txt_info) txt_info.show() # horizontal pane, left side and right side self.hp2 = gtk.HPaned() self.hp2.set_position(400) self.vbox.pack_start(self.hp2, True, True, 2) # left child of horizontal pane frame = gtk.Frame('Image Preview') frame.set_shadow_type(gtk.SHADOW_OUT) frame.show() self.frm_img_prev = frame self.lst_images.frm_img_prev = frame self.hp2.add1(frame) img = gtk.Image() img.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_DIALOG) img.show() frame.add(img) # right child of horizontal pane, frame frame = gtk.Frame('Image Info') frame.set_shadow_type(gtk.SHADOW_OUT) frame.show() self.frm_img_info = frame self.hp2.add2(frame) self.scrl_info = gtk.ScrolledWindow() self.scrl_info.set_border_width(5) self.scrl_info.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) self.frm_img_info.add(self.scrl_info) self.txt_img_info = gtk.TextView() self.txt_img_info.set_editable(False) self.scrl_info.add(self.txt_img_info) self.scrl_info.show() self.txt_img_info.show() # horizontal box self.hbox = gtk.HBox(False, 0) self.vbox.pack_start(self.hbox, False, False, 20) # label: Destination label = gtk.Label('Destination:') label.show() self.hbox.pack_start(label, False, False, 10) # text entry box: Path self.entry = gtk.Entry() self.entry.set_text(os.getcwd() + '/xml_file.xml') self.hbox.pack_start(self.entry, True, True, 10) # Browse dialog button self.btn_browse = buttons.get_btn_browse() self.hbox.pack_start(self.btn_browse, False, False, 10) # Button box self.bbox = gtk.HButtonBox() self.bbox.set_layout(gtk.BUTTONBOX_END) self.bbox.set_spacing(5) # self.btn_preview = buttons.get_btn_preview(self.lst_images) self.bbox.add(self.btn_preview) # self.btn_save = buttons.get_btn_save(self.lst_images, self.entry) self.bbox.add(self.btn_save) # self.btn_quit = buttons.get_btn_quit() self.bbox.add(self.btn_quit) # self.vbox.pack_start(self.bbox, False, False, 10) # status bar self.status = gtk.Statusbar() self.vbox.pack_start(self.status, False, False, 2) # Show self.status.show() self.bbox.show() self.entry.show() self.hbox.show() self.hp2.show() self.hp1.show() self.menu_bar.show() self.vbox.show() self.window.show()
def __init__(self): self.frame = gtk.Frame() self.frame.show() return
def __init__(self, strx="No Content to display"): gtk.Window.__init__(self) #window = gtk.Window(gtk.WINDOW_POPUP) window = gtk.Window() window.set_flags(gtk.CAN_FOCUS | gtk.SENSITIVE) window.set_decorated(False) window.set_position(gtk.WIN_POS_CENTER_ALWAYS) mask = gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.KEY_PRESS_MASK | \ gtk.gdk.KEY_RELEASE_MASK window.set_events(window.get_events() | mask) window.connect("delete_event", self.close_application) #window.connect("button_press_event", self.close_application) window.connect("key-press-event", self.keypress) hbox = gtk.HBox() hbox.show() # ---------------------------------------------------------------- # Header frame2 = gtk.Frame() frame2.show() #frame2.set_border_width(10) label2 = gtk.Label() label2.set_text(" Header ") label2.show() frame2.add(label2) label1 = gtk.Label() label1.set_text(" ") label1.show() label3 = gtk.Label() label3.set_text(" ") label3.show() hbox.pack_start(label1, False) hbox.add(frame2) hbox.pack_start(label3, False) # ---------------------------------------------------------------- # Body ws = gtk.ScrolledWindow() ws.set_border_width(10) ws.show() vbox = gtk.VBox() vbox.show() #label = gtk.Label() #label.set_markup(strx) #label.show() buffer = gtk.TextBuffer() self.text_view = gtk.TextView(buffer) self.drawing = gtk.DrawingArea() #layout = self.drawing.create_pango_layout() strx = sys.argv[1] f = open(strx) buf = f.read() try: attrlist = pango.parse_markup(buf) except: print "Cannot load file" #print buf #buffer.insert_at_cursor(buf) frame = gtk.Frame() frame.show() ws.add_with_viewport(self.text_view) ws.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) frame.add(vbox) vbox.pack_start(hbox, False) vbox.add(ws) window.add(frame) window.set_default_size(2 * gtk.gdk.screen_width() / 3, 2 * gtk.gdk.screen_height() / 3) window.grab_focus() #window.move(gtk.gdk.screen_width() - (pixmap.get_size()[0] + 20), 40 ) window.show()
def dialog_codeboxhandle(self, title): """Opens the CodeBox Handle Dialog""" dialog = gtk.Dialog( title=title, parent=self.dad.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_default_size(300, -1) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) button_prog_lang = gtk.Button() button_label = self.dad.codebox_syn_highl if self.dad.codebox_syn_highl != cons.PLAIN_TEXT_ID else self.dad.auto_syn_highl button_stock_id = config.get_stock_id_for_code_type(button_label) button_prog_lang.set_label(button_label) button_prog_lang.set_image( gtk.image_new_from_stock(button_stock_id, gtk.ICON_SIZE_MENU)) radiobutton_plain_text = gtk.RadioButton(label=_("Plain Text")) radiobutton_auto_syntax_highl = gtk.RadioButton( label=_("Automatic Syntax Highlighting")) radiobutton_auto_syntax_highl.set_group(radiobutton_plain_text) if self.dad.codebox_syn_highl == cons.PLAIN_TEXT_ID: radiobutton_plain_text.set_active(True) button_prog_lang.set_sensitive(False) else: radiobutton_auto_syntax_highl.set_active(True) type_vbox = gtk.VBox() type_vbox.pack_start(radiobutton_plain_text) type_vbox.pack_start(radiobutton_auto_syntax_highl) type_vbox.pack_start(button_prog_lang) type_frame = gtk.Frame(label="<b>" + _("Type") + "</b>") type_frame.get_label_widget().set_use_markup(True) type_frame.set_shadow_type(gtk.SHADOW_NONE) type_frame.add(type_vbox) label_width = gtk.Label(_("Width")) adj_width = gtk.Adjustment(value=self.dad.codebox_width, lower=1, upper=10000, step_incr=1) spinbutton_width = gtk.SpinButton(adj_width) spinbutton_width.set_value(self.dad.codebox_width) label_height = gtk.Label(_("Height")) adj_height = gtk.Adjustment(value=self.dad.codebox_height, lower=1, upper=10000, step_incr=1) spinbutton_height = gtk.SpinButton(adj_height) spinbutton_height.set_value(self.dad.codebox_height) radiobutton_codebox_pixels = gtk.RadioButton(label=_("pixels")) radiobutton_codebox_percent = gtk.RadioButton(label="%") radiobutton_codebox_percent.set_group(radiobutton_codebox_pixels) radiobutton_codebox_pixels.set_active(self.dad.codebox_width_pixels) radiobutton_codebox_percent.set_active( not self.dad.codebox_width_pixels) vbox_pix_perc = gtk.VBox() vbox_pix_perc.pack_start(radiobutton_codebox_pixels) vbox_pix_perc.pack_start(radiobutton_codebox_percent) hbox_width = gtk.HBox() hbox_width.pack_start(label_width, expand=False) hbox_width.pack_start(spinbutton_width, expand=False) hbox_width.pack_start(vbox_pix_perc) hbox_width.set_spacing(5) hbox_height = gtk.HBox() hbox_height.pack_start(label_height, expand=False) hbox_height.pack_start(spinbutton_height, expand=False) hbox_height.set_spacing(5) vbox_size = gtk.VBox() vbox_size.pack_start(hbox_width) vbox_size.pack_start(hbox_height) size_align = gtk.Alignment() size_align.set_padding(0, 6, 6, 6) size_align.add(vbox_size) size_frame = gtk.Frame(label="<b>" + _("Size") + "</b>") size_frame.get_label_widget().set_use_markup(True) size_frame.set_shadow_type(gtk.SHADOW_NONE) size_frame.add(size_align) checkbutton_codebox_linenumbers = gtk.CheckButton( label=_("Show Line Numbers")) checkbutton_codebox_linenumbers.set_active(self.dad.codebox_line_num) checkbutton_codebox_matchbrackets = gtk.CheckButton( label=_("Highlight Matching Brackets")) checkbutton_codebox_matchbrackets.set_active( self.dad.codebox_match_bra) vbox_options = gtk.VBox() vbox_options.pack_start(checkbutton_codebox_linenumbers) vbox_options.pack_start(checkbutton_codebox_matchbrackets) opt_align = gtk.Alignment() opt_align.set_padding(6, 6, 6, 6) opt_align.add(vbox_options) options_frame = gtk.Frame(label="<b>" + _("Options") + "</b>") options_frame.get_label_widget().set_use_markup(True) options_frame.set_shadow_type(gtk.SHADOW_NONE) options_frame.add(opt_align) content_area = dialog.get_content_area() content_area.set_spacing(5) content_area.pack_start(type_frame) content_area.pack_start(size_frame) content_area.pack_start(options_frame) content_area.show_all() def on_button_prog_lang_clicked(button): icon_n_key_list = [] for key in self.dad.available_languages: stock_id = config.get_stock_id_for_code_type(key) icon_n_key_list.append([key, stock_id, key]) sel_key = support.dialog_choose_element_in_list( self.dad.window, _("Automatic Syntax Highlighting"), [], "", icon_n_key_list) if sel_key: button.set_label(sel_key) button.set_image( gtk.image_new_from_stock(sel_key, gtk.ICON_SIZE_MENU)) button_prog_lang.connect('clicked', on_button_prog_lang_clicked) def on_radiobutton_auto_syntax_highl_toggled(radiobutton): button_prog_lang.set_sensitive(radiobutton.get_active()) def on_key_press_codeboxhandle(widget, event): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == cons.STR_KEY_RETURN: spinbutton_width.update() spinbutton_height.update() try: dialog.get_widget_for_response( gtk.RESPONSE_ACCEPT).clicked() except: print cons.STR_PYGTK_222_REQUIRED return True return False def on_radiobutton_codebox_pixels_toggled(radiobutton): if radiobutton.get_active(): spinbutton_width.set_value(700) else: if spinbutton_width.get_value() > 100: spinbutton_width.set_value(90) radiobutton_auto_syntax_highl.connect( "toggled", on_radiobutton_auto_syntax_highl_toggled) dialog.connect('key_press_event', on_key_press_codeboxhandle) radiobutton_codebox_pixels.connect( 'toggled', on_radiobutton_codebox_pixels_toggled) response = dialog.run() dialog.hide() if response == gtk.RESPONSE_ACCEPT: self.dad.codebox_width = spinbutton_width.get_value() self.dad.codebox_width_pixels = radiobutton_codebox_pixels.get_active( ) self.dad.codebox_height = spinbutton_height.get_value() self.dad.codebox_line_num = checkbutton_codebox_linenumbers.get_active( ) self.dad.codebox_match_bra = checkbutton_codebox_matchbrackets.get_active( ) if radiobutton_plain_text.get_active(): self.dad.codebox_syn_highl = cons.PLAIN_TEXT_ID else: self.dad.codebox_syn_highl = button_prog_lang.get_label() return True return False
def __init__(self, view, attrs): super(One2Many, self).__init__(view, attrs) self.widget = gtk.Frame() self.widget.set_shadow_type(gtk.SHADOW_NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = gtk.VBox(homogeneous=False, spacing=2) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 self._length = 0 self.title_box = hbox = gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = gtk.Label(set_underline(attrs.get('string', ''))) self.title.set_use_underline(True) self.title.set_alignment(0.0, 0.5) hbox.pack_start(self.title, expand=True, fill=True) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) tooltips = common.Tooltips() but_switch = gtk.Button() tooltips.set_tip(but_switch, _('Switch')) but_switch.connect('clicked', self.switch_view) but_switch.add(common.IconFactory.get_image( 'tryton-switch', gtk.ICON_SIZE_SMALL_TOOLBAR)) but_switch.set_relief(gtk.RELIEF_NONE) hbox.pack_start(but_switch, expand=False, fill=False) self.but_pre = gtk.Button() tooltips.set_tip(self.but_pre, _('Previous')) self.but_pre.connect('clicked', self._sig_previous) self.but_pre.add(common.IconFactory.get_image( 'tryton-back', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_pre.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_pre, expand=False, fill=False) self.label = gtk.Label('(0,0)') hbox.pack_start(self.label, expand=False, fill=False) self.but_next = gtk.Button() tooltips.set_tip(self.but_next, _('Next')) self.but_next.connect('clicked', self._sig_next) self.but_next.add(common.IconFactory.get_image( 'tryton-forward', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_next.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_next, expand=False, fill=False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.focus_out = True self.wid_completion = None if attrs.get('add_remove'): self.wid_text = gtk.Entry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', self._focus_out) hbox.pack_start(self.wid_text, expand=True, fill=True) if int(self.attrs.get('completion', 1)): access = common.MODELACCESS[attrs['relation']] self.wid_completion = get_completion( search=access['read'] and access['write'], create=attrs.get('create', True) and access['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add existing record')) self.but_add.connect('clicked', self._sig_add) self.but_add.add(common.IconFactory.get_image( 'tryton-add', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_add.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_add, expand=False, fill=False) self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove selected record')) self.but_remove.connect('clicked', self._sig_remove, True) self.but_remove.add(common.IconFactory.get_image( 'tryton-remove', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_remove.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_remove, expand=False, fill=False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.but_new = gtk.Button() tooltips.set_tip(self.but_new, _('Create a new record <F3>')) self.but_new.connect('clicked', self._sig_new) self.but_new.add(common.IconFactory.get_image( 'tryton-create', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_new.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_new, expand=False, fill=False) self.but_open = gtk.Button() tooltips.set_tip(self.but_open, _('Edit selected record <F2>')) self.but_open.connect('clicked', self._sig_edit) self.but_open.add(common.IconFactory.get_image( 'tryton-open', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_open.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_open, expand=False, fill=False) self.but_del = gtk.Button() tooltips.set_tip(self.but_del, _('Delete selected record <Del>')) self.but_del.connect('clicked', self._sig_remove, False) self.but_del.add(common.IconFactory.get_image( 'tryton-delete', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_del.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_del, expand=False, fill=False) self.but_undel = gtk.Button() tooltips.set_tip(self.but_undel, _('Undelete selected record <Ins>')) self.but_undel.connect('clicked', self._sig_undelete) self.but_undel.add(common.IconFactory.get_image( 'tryton-undo', gtk.ICON_SIZE_SMALL_TOOLBAR)) self.but_undel.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_undel, expand=False, fill=False) if attrs.get('add_remove'): hbox.set_focus_chain([self.wid_text]) else: hbox.set_focus_chain([]) tooltips.enable() frame = gtk.Frame() frame.add(hbox) frame.set_shadow_type(gtk.SHADOW_OUT) vbox.pack_start(frame, expand=False, fill=True) self.screen = Screen(attrs['relation'], mode=attrs.get('mode', 'tree,form').split(','), view_ids=attrs.get('view_ids', '').split(','), views_preload=attrs.get('views', {}), row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None), limit=None) self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0))) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True) self.title.set_mnemonic_widget( self.screen.current_view.mnemonic_widget) self.screen.widget.connect('key_press_event', self.on_keypress) if self.attrs.get('add_remove'): self.wid_text.connect('key_press_event', self.on_keypress) but_switch.props.sensitive = self.screen.number_of_views > 1
def dialog_tablehandle(self, title, is_insert): """Opens the Table Handle Dialog""" dialog = gtk.Dialog( title=title, parent=self.dad.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_default_size(300, -1) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) label_rows = gtk.Label(_("Rows")) adj_rows = gtk.Adjustment(value=self.dad.table_rows, lower=1, upper=10000, step_incr=1) spinbutton_rows = gtk.SpinButton(adj_rows) spinbutton_rows.set_value(self.dad.table_rows) label_columns = gtk.Label(_("Columns")) adj_columns = gtk.Adjustment(value=self.dad.table_columns, lower=1, upper=10000, step_incr=1) spinbutton_columns = gtk.SpinButton(adj_columns) spinbutton_columns.set_value(self.dad.table_columns) hbox_rows_cols = gtk.HBox() hbox_rows_cols.pack_start(label_rows, expand=False) hbox_rows_cols.pack_start(spinbutton_rows, expand=False) hbox_rows_cols.pack_start(label_columns, expand=False) hbox_rows_cols.pack_start(spinbutton_columns, expand=False) hbox_rows_cols.set_spacing(5) size_align = gtk.Alignment() size_align.set_padding(6, 6, 6, 6) size_align.add(hbox_rows_cols) size_frame = gtk.Frame(label="<b>" + _("Table Size") + "</b>") size_frame.get_label_widget().set_use_markup(True) size_frame.set_shadow_type(gtk.SHADOW_NONE) size_frame.add(size_align) label_col_min = gtk.Label(_("Min Width")) adj_col_min = gtk.Adjustment(value=self.dad.table_col_min, lower=1, upper=10000, step_incr=1) spinbutton_col_min = gtk.SpinButton(adj_col_min) spinbutton_col_min.set_value(self.dad.table_col_min) label_col_max = gtk.Label(_("Max Width")) adj_col_max = gtk.Adjustment(value=self.dad.table_col_max, lower=1, upper=10000, step_incr=1) spinbutton_col_max = gtk.SpinButton(adj_col_max) spinbutton_col_max.set_value(self.dad.table_col_max) hbox_col_min_max = gtk.HBox() hbox_col_min_max.pack_start(label_col_min, expand=False) hbox_col_min_max.pack_start(spinbutton_col_min, expand=False) hbox_col_min_max.pack_start(label_col_max, expand=False) hbox_col_min_max.pack_start(spinbutton_col_max, expand=False) hbox_col_min_max.set_spacing(5) col_min_max_align = gtk.Alignment() col_min_max_align.set_padding(6, 6, 6, 6) col_min_max_align.add(hbox_col_min_max) col_min_max_frame = gtk.Frame(label="<b>" + _("Column Properties") + "</b>") col_min_max_frame.get_label_widget().set_use_markup(True) col_min_max_frame.set_shadow_type(gtk.SHADOW_NONE) col_min_max_frame.add(col_min_max_align) checkbutton_table_ins_from_file = gtk.CheckButton( label=_("Import from CSV File")) content_area = dialog.get_content_area() content_area.set_spacing(5) if is_insert: content_area.pack_start(size_frame) content_area.pack_start(col_min_max_frame) if is_insert: content_area.pack_start(checkbutton_table_ins_from_file) content_area.show_all() def on_key_press_tablehandle(widget, event): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == cons.STR_KEY_RETURN: spinbutton_rows.update() spinbutton_columns.update() spinbutton_col_min.update() spinbutton_col_max.update() try: dialog.get_widget_for_response( gtk.RESPONSE_ACCEPT).clicked() except: print cons.STR_PYGTK_222_REQUIRED return True return False def on_checkbutton_table_ins_from_file_toggled(checkbutton): size_frame.set_sensitive(not checkbutton.get_active()) col_min_max_frame.set_sensitive(not checkbutton.get_active()) dialog.connect('key_press_event', on_key_press_tablehandle) checkbutton_table_ins_from_file.connect( 'toggled', on_checkbutton_table_ins_from_file_toggled) response = dialog.run() dialog.hide() if response == gtk.RESPONSE_ACCEPT: self.dad.table_rows = int(spinbutton_rows.get_value()) self.dad.table_columns = int(spinbutton_columns.get_value()) self.dad.table_col_min = int(spinbutton_col_min.get_value()) self.dad.table_col_max = int(spinbutton_col_max.get_value()) ret_csv = checkbutton_table_ins_from_file.get_active() return [True, ret_csv] return [False, None]
def __init__(self, uid, panel_id): """Creating the applets core""" awn.AppletSimple.__init__(self, "media-control", uid, panel_id) self.set_tooltip_text(MediaControlApplet.APPLET_NAME) self.set_icon_info(['main-icon', 'play', 'pause', 'prev', 'next'], [ 'media-control', 'media-playback-start', 'media-playback-pause', 'media-skip-backward', 'media-skip-forward' ]) self.set_icon_state('main-icon') self.ui_path = os.path.join(os.path.dirname(__file__), "media-control.ui") # get the missing album art pixbuf try: file_name = __file__[0:__file__.rfind('/')] file_name += "/icons/missing-artwork.svg" self.no_album_art_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( file_name, 128, 128) except: self.no_album_art_pixbuf = None self.album_art_pixbuf = None self.timer_running = False self.playing_changed_id = 0 self.dbus_names = {} self.MediaPlayer = None self.is_playing = False # Player selection frame self.players_frame = gtk.Frame() self.controls = gtk.VBox() self.controls.set_spacing(5) self.label = gtk.Label() self.label.set_ellipsize(pango.ELLIPSIZE_END) self.label.set_max_width_chars(30) self.label.set_padding(4, 0) self.label.set_markup(MediaControlApplet.APPLET_NAME_MARKUP) # album overlay self.album_overlay = awn.OverlayPixbuf() self.album_overlay.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST self.album_overlay.props.alpha = 0.85 self.album_overlay.props.active = False self.add_overlay(self.album_overlay) # Dialog self.dialog = awn.Dialog(self) # Docklet related stuff self.docklet = None self.docklet_visible = False self.docklet_image = None self.docklet_label = None self.docklet_play_pause = None #Popup menu self.about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) self.about.connect("activate", self.show_about) self.prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) self.prefs.connect("activate", self.show_prefs) self.popup_menu = self.create_default_menu() self.popup_menu.append(self.prefs) self.popup_menu.append(gtk.SeparatorMenuItem()) self.popup_menu.append(self.about) self.popup_menu.show_all() self.ensure_player() # Defining Widgets vbox = gtk.VBox() self.players_frame.add(vbox) for player in self.get_supported_player_names(): button = gtk.Button(player) button.connect("clicked", self.start_player_pressed, player) vbox.add(button) # dialog widgets button_previous = gtk.ToolButton("gtk-media-previous") button_play = gtk.ToolButton("gtk-media-play") button_pause = gtk.ToolButton("gtk-media-pause") button_next = gtk.ToolButton("gtk-media-next") self.image = gtk.Image() # Packing Widgets hbox = gtk.HBox() hbox.pack_start(button_previous) hbox.add(button_play) hbox.add(button_next) self.controls.pack_start(self.image) self.controls.add(hbox) vbox = gtk.VBox() vbox.set_spacing(5) vbox.pack_start(self.label) vbox.add(self.players_frame) vbox.add(self.controls) self.dialog.add(vbox) hbox.show_all() vbox.show_all() # Button Connects button_previous.connect("clicked", self.button_previous_press) button_play.connect("clicked", self.button_pp_press) button_next.connect("clicked", self.button_next_press) # Standard AWN Connects self.connect("scroll-event", self.wheel_turn) self.connect("clicked", self.icon_clicked) self.connect("middle-clicked", self.button_pp_press) self.connect("context-menu-popup", self.menu_popup) self.connect("enter-notify-event", self.enter_notify) self.dialog.props.hide_on_unfocus = True # Drag&drop support self.get_icon().connect("drag-data-received", self.applet_drop_cb) self.get_icon().connect("drag-motion", self.applet_drag_motion_cb) self.get_icon().connect("drag-leave", self.applet_drag_leave_cb) self.get_icon().drag_dest_set( gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, [("text/uri-list", 0, 0), ("text/plain", 0, 1)], gtk.gdk.ACTION_COPY) self.client = awn.config_get_default_for_applet(self) self.client.bind(GROUP_DEFAULT, "use_docklet", self, "use-docklet", True, BIND_METHOD_FALLBACK) self.client.bind(GROUP_DEFAULT, "docklet_mouseout_close", self, "docklet-close", True, BIND_METHOD_FALLBACK) self.client.bind(GROUP_DEFAULT, "show_album_art", self, "album-art-enabled", True, BIND_METHOD_FALLBACK) self.client.bind(GROUP_DEFAULT, "album_art_size", self, "album-art-size", True, BIND_METHOD_FALLBACK) self.client.bind(GROUP_DEFAULT, "tooltip_format", self, "tooltip-order", True, BIND_METHOD_FALLBACK) try: if self.MediaPlayer: self.update_song_info() except: pass proxy = dbus.SessionBus().get_object('org.freedesktop.DBus', '/org/freedesktop/DBus') proxy.connect_to_signal('NameOwnerChanged', self.name_owner_changed_cb)