我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用gtk.ScrolledWindow()。
def _start_shell(self, dummy_button): if self.shell_window is not None: self.shell_window.present() return self.shell_window = gtk.Window() self.shell_window.set_size_request(750,550) self.shell_window.set_resizable(True) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) ipython = ipython_view.IPythonView() ipython.modify_font(pango.FontDescription(SHELL_FONT)) ipython.set_wrap_mode(gtk.WRAP_CHAR) ipython.show() scrolled_window.add(ipython) scrolled_window.show() self.shell_window.add(scrolled_window) self.shell_window.show() self.shell_window.connect('destroy', self._on_shell_window_destroy) self._update_ipython_selected_node() __IPYTHON__.user_ns['viz'] = self
def __init__(self): super(PyApp, self).__init__() self.set_title("Web Stalker Browser") self.set_size_request(1000,600) self.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox(False, 5) scw = gtk.ScrolledWindow(None, None) web = webkit.WebView() url = sys.argv[1] web.open(url) scw.add(web) vbox.add(scw) gobject.threads_init() self.add(vbox) self.connect("destroy", gtk.main_quit) self.show_all()
def __init__(self, mpi): import webkit self.webview = webkit.WebView() self.scroller = gtk.ScrolledWindow() self.scroller.add(self.webview) self.vbox = gtk.VBox(False, 1) self.vbox.pack_start(self.scroller, True, True) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_size_request(1100, 600) self.window.connect('delete-event', lambda w, e: w.hide() or True) self.window.add(self.vbox) self.browser_settings = self.webview.get_settings() self.browser_settings.set_property("enable-java-applet", False) self.browser_settings.set_property("enable-plugins", False) self.browser_settings.set_property("enable-scripts", True) self.browser_settings.set_property("enable-private-browsing", True) self.browser_settings.set_property("enable-spell-checking", True) self.browser_settings.set_property("enable-developer-extras", True) self.webview.set_settings(self.browser_settings)
def make_list(self, width): cols = [(gobject.TYPE_INT, ""), (gobject.TYPE_INT, ""), (gobject.TYPE_STRING, _("Callsign")), ] self.listw = miscwidgets.KeyedListWidget(cols) self.listw.show() self.listw.set_editable(1, True) self.listw.connect("item-set", self._cs_changed) rend = self.listw.get_renderer(1) rend.set_property("family", "Monospace") rend.set_property("width-chars", width) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(self.listw) sw.show() return sw
def __init__(self, fontfile): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("%s - pyftinspect" % fontfile) self.window.connect("delete_event", self._delete_event) self.window.set_size_request(400, 600) self.scrolled_window = gtk.ScrolledWindow() self.window.add(self.scrolled_window) self.font = ttLib.TTFont(fontfile, lazy=True) self.treemodel = FontTreeModel(self.font) self.treeview = gtk.TreeView(self.treemodel) #self.treeview.set_reorderable(True) for i in range(2): col_name = ('Key', 'Value')[i] col = gtk.TreeViewColumn(col_name) col.set_sort_column_id(-1) self.treeview.append_column(col) cell = gtk.CellRendererText() col.pack_start(cell, True) col.add_attribute(cell, 'text', i) self.treeview.set_search_column(1) self.scrolled_window.add(self.treeview) self.window.show_all()
def __init__(self): assert Visualizer.INSTANCE is None Visualizer.INSTANCE = self super(Visualizer, self).__init__() self.nodes = {} # node index -> Node self.channels = {} # id(ns3.Channel) -> Channel self.window = None # toplevel window self.canvas = None # goocanvas.Canvas self.time_label = None # gtk.Label self.play_button = None # gtk.ToggleButton self.zoom = None # gtk.Adjustment self._scrolled_window = None # gtk.ScrolledWindow self.links_group = goocanvas.Group() self.channels_group = goocanvas.Group() self.nodes_group = goocanvas.Group() self._update_timeout_id = None self.simulation = SimulationThread(self) self.selected_node = None # node currently selected self.speed = 1.0 self.information_windows = [] self._transmission_arrows = [] self._last_transmissions = [] self._drop_arrows = [] self._last_drops = [] self._show_transmissions_mode = None self.set_show_transmissions_mode(ShowTransmissionsMode.ALL) self._panning_state = None self.node_size_adjustment = None self.transmissions_smoothing_adjustment = None self.sample_period = SAMPLE_PERIOD self.node_drag_state = None self.follow_node = None self.shell_window = None self.create_gui() for plugin in plugins: plugin(self)
def __init__(self): super(ProgressBarDetails, self).__init__() #Configure the Window self.set_resizable(False) self.connect("destroy", self.destroy_progress) self.set_title("Progress Bar") self.set_position(gtk.WIN_POS_CENTER) self.set_size_request(460, 150) self.set_border_width(0) #Create the VBox in case we want to add additional items later self.vbox = gtk.VBox(False, 5) self.vbox.set_border_width(10) self.add(self.vbox) self.vbox.show() #create the scrolled window self.scrolled_window =gtk.ScrolledWindow() self.scrolled_window.set_usize(460, 100) self.vbox.add(self.scrolled_window) self.scrolled_window.show() self.text_view = gtk.TextView() self.msg_i = 0 self.text_buffer = self.text_view.get_buffer() self.scrolled_window.add_with_viewport(self.text_view) self.text_view.connect("size-allocate", self.autoscroll) self.text_view.show() # Create the ProgressBar self.pbar = gtk.ProgressBar() #self.pbar.set_usize(460, 40) self.pbar.set_fraction(0.0) self.vbox.add(self.pbar) self.pbar.show() #Display the Window self.show()
def __init__(self, index, index_ext, ui, uistate): # XXX gtk.ScrolledWindow.__init__(self) self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.set_shadow_type(gtk.SHADOW_IN) self.ui = ui self.treeview = IconsTreeView(ui) # XXX self.add(self.treeview) self.uistate = uistate self.uistate.setdefault('Open pages', 'default') # values 'default, collapse, disable' self.treeview.change_view(self.uistate['Open pages']) self.uistate.setdefault('show tags', False) # show tags with names self.uistate.setdefault('Icons for Tags', {}) # set icons for available tags # All available tags in the notebook. tags = [a.name for a in index.list_all_tags()] # Check that tags and icons are still available. self.uistate['Icons for Tags'] = dict( [(tag, icon) for (tag, icon) in self.uistate['Icons for Tags'].iteritems() if ( (tag in tags) and (icon in ICONS) )] ) self.index = index self.index_ext = index_ext self._show_tagged = False # if True - show only pages with tags self.connectto(self.treeview, 'populate-popup', self.on_populate_popup) self.connectto_all(ui, ( # XXX 'open-page', ('start-index-update', lambda o: self.disconnect_model()), ('end-index-update', lambda o: self.reload_model()), )) self.reload_model()
def __init__(self, window, index, uistate): Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title buttons=gtk.BUTTONS_OK_CANCEL, defaultwindowsize=(450, 400) ) # Don't confuse with local variable 'self.uistate', # which is already determined for this class. self._window = window self.plugin_uistate = uistate self.show_pages_button = gtk.ToggleButton('Show Pages') self.show_pages_button.connect('toggled', self.toggle_show_pages) self.add_extra_button(self.show_pages_button) self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags']) self.treeview_pages = TagsManagerPagesView(index, window.ui) self.scrolled_widget = ScrolledWindow(self.treeview_tags) self.vbox.pack_start(self.scrolled_widget, True) self.treeview_tags.connect('row-activated', self.get_tag) # Enable left/right arrows to navigate between views. self.treeview_tags.connect('key-release-event', self.toggle_view) self.treeview_pages.connect('key-release-event', self.toggle_view) # Update if tags change. self.connectto_all(index, ( ('tag-inserted', lambda *a: self.update()), ('tag-removed', lambda *a: self.update()) )) self.show_all()
def __init__(self, index, ui, uistate): # XXX gtk.ScrolledWindow.__init__(self) self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.set_shadow_type(gtk.SHADOW_IN) self.ui = ui self.index = index self.iconsindex = None self.treeview = IconsTreeView(ui) # XXX self.add(self.treeview) self.uistate = uistate self.uistate.setdefault('Open pages', 'default') # values 'default, collapse, disable' self.treeview.change_view(self.uistate['Open pages']) self.uistate.setdefault('show tags', False) # show tags with names self.uistate.setdefault('Icons for Tags', {}) # set icons for available tags # All available tags in the notebook. tags = [a.name for a in TagsView.new_from_index(index).list_all_tags()] # Check that tags and icons are still available. self.uistate['Icons for Tags'] = dict( [(tag, icon) for (tag, icon) in self.uistate['Icons for Tags'].iteritems() if ( (tag in tags) and (icon in ICONS) )] ) self._show_tagged = False # if True - show only pages with tags self.connectto(self.treeview, 'populate-popup', self.on_populate_popup) self.connectto_all(ui, ( # XXX 'open-page', ('start-index-update', lambda o: self.disconnect_model()), ('end-index-update', lambda o: self.reload_model()), )) self.reload_model()
def new_table(wids): """Creates a gtk.Table with two rows, use it for forms""" p = gtk.Table(rows=len(wids) or 1, columns=2, homogeneous=False) p.set_col_spacings(5) p.set_row_spacings(5) if len(wids) < 1: wid = gtk.Label("Empty") p.attach(wid, 0, 2, 0, 1) p.show_all() return p for i, row in enumerate(wids): if isinstance(row, basestring): wid = Label("<b>%s</b>" % row) p.attach(wid, 0, 2, i, i+1) wid.show() if i > 0: p.set_row_spacing(i-1, 10) elif isinstance(row, (tuple, list)): label, field = row wid = new_label_for(label, field) p.attach(wid, 0, 1, i, i+1, xoptions=gtk.FILL) p.attach(field, 1, 2, i, i+1) wid.show() field.show() sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_NONE) sw.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.add_with_viewport(p) p.show() sw.show() return sw # new_table()
def _setup_ui_chooser(self): self.chooser_layout = gtk.VBox(homogeneous=False, spacing=2) self.top_layout.pack_start(self.chooser_layout, fill=True, expand=True) msg = ("<big><b>Choose your media source</b></big>\n" "Click one of the buttons below to be able to " "select what to play") info = catota.ui.MultiLineLabel(msg) info.show() self.chooser_layout.pack_start(info, fill=True, expand=False) box = gtk.VBox(homogeneous=True, spacing=5) box.show() for o in self.sources: btn = gtk.Button() btn.add(o.gui_button_contents) btn.set_size_request(-1, 40) btn.show() btn.connect("clicked", self._source_activated, o) box.pack_start(btn, fill=True, expand=False) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_NONE) sw.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.add_with_viewport(box) sw.show() self.chooser_layout.pack_start(sw, fill=True, expand=True) # _setup_ui_chooser()
def setup_gui_url_chooser(self): d = catota.ui.Dialog("Choose Location", self.parent_win) label = catota.ui.Label("<small><b>Enter location</b> to be " "handled directly to underlying player engine" "</small>") d.vbox.pack_start(label, fill=True, expand=False) label.show() self.gui_url_chooser_entry = gtk.TextBuffer() textview = gtk.TextView(self.gui_url_chooser_entry) textview.set_editable(True) textview.set_cursor_visible(True) textview.set_left_margin(2) textview.set_right_margin(2) textview.set_wrap_mode(gtk.WRAP_CHAR) sw = gtk.ScrolledWindow() sw.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) sw.add(textview) d.vbox.pack_start(sw, fill=True, expand=True) sw.show_all() self.gui_url_chooser = d # setup_gui_url_chooser()
def createClockDisplayWidgets(self): """Create the Clock Display widgets.""" self.tableClockDisplays = gtk.Table(rows=3, columns=3, homogeneous=False) self.tableClockDisplays.set_row_spacings(5) self.tableClockDisplays.set_col_spacings(5) createLabel(self.tableClockDisplays, text="Show", gridX=0, gridY=0, xPadding=10) self.clockCheckButton = createCheckButton(self.tableClockDisplays, active=True, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) createLabel(self.tableClockDisplays, text="Time 1 Format", gridX=0, gridY=1, xPadding=10) self.clock1Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_1, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.clock1CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time1_format", self.clock1Format) createLabel(self.tableClockDisplays, text="Time 1 Font", gridX=0, gridY=2, xPadding=10) self.clock1FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=2, handler=self.changeOccurred) self.registerComponent("time1_font", self.clock1FontButton) createLabel(self.tableClockDisplays, text="Time 2 Format", gridX=0, gridY=3, xPadding=10) self.clock2Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_2, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.clock2CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time2_format", self.clock2Format) createLabel(self.tableClockDisplays, text="Time 2 Font", gridX=0, gridY=4, xPadding=10) self.clock2FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("time2_font", self.clock2FontButton) createLabel(self.tableClockDisplays, text="Tooltip Format", gridX=0, gridY=5, xPadding=10) self.clockTooltipFormat = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_TOOLTIP, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.clockTooltipCheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_tooltip", self.clockTooltipFormat) self.clockArea = gtk.ScrolledWindow() self.clockBuf = gtk.TextBuffer() self.clockTextView = gtk.TextView(self.clockBuf) self.clockBuf.insert_at_cursor("%H 00-23 (24-hour) %I 01-12 (12-hour) %l 1-12 (12-hour) %M 00-59 (minutes)\n%S 00-59 (seconds) %P am/pm %b Jan-Dec %B January-December\n%a Sun-Sat %A Sunday-Saturday %d 01-31 (day) %e 1-31 (day)\n%y 2 digit year, e.g. 09 %Y 4 digit year, e.g. 2009") self.clockTextView.set_editable(False) self.clockArea.add_with_viewport(self.clockTextView) self.tableClockDisplays.attach(self.clockArea, 0, 3, 6, 7, xpadding=10)
def __init__(self, window): self.dialog = gtk.Dialog('Debug Window', window, gtk.DIALOG_MODAL, ()) self.dialog.set_destroy_with_parent(True) self.dialog.set_transient_for(window) self.dialog.set_modal(False) self.textview = gtk.TextView() self.textview.set_editable(False) self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR) self.textview.set_scroll_adjustments(gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0), gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0)) self.scrolledwindow = gtk.ScrolledWindow(None, None) self.scrolledwindow.add(self.textview) self.dialog.vbox.pack_start(self.scrolledwindow) self.dialog.set_default_size(640, 480)
def __init__(self, parser, max_tree_depth): self.parser = parser self._max_tree_depth = max_tree_depth self.search_thread = None self.search_lock = threading.Lock() self.name_entry = name_entry = gtk.Entry() name_entry.connect('activate', self.on_name_entry_activate) search_button = self.search_button = gtk.Button(stock=gtk.STOCK_FIND) search_button.connect('clicked', self.on_search) search_button.set_no_show_all(True) search_button.show() stop_button = self.stop_button = gtk.Button(stock=gtk.STOCK_STOP) stop_button.connect('clicked', self.stop_search) stop_button.set_no_show_all(True) self.progress = progress = gtk.ProgressBar() progress.set_size_request(-1, 8) name_box = gtk.HBox(spacing=8) name_box.set_border_width(8) name_box.pack_start(name_entry, True, True) name_box.pack_start(search_button, False) name_box.pack_start(stop_button, False) self.store = gtk.TreeStore(str, str, str, str) # name, icon, fnstyle, info self.treeview = treeview = self._create_treeview(self.store) scroller = gtk.ScrolledWindow() scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroller.add(treeview) settings_view = SettingsView(max_depth_value=max_tree_depth) settings_view.on_max_depth_changed = self.on_max_depth_changed extension = gtk.expander_new_with_mnemonic('_Settings') extension.add(settings_view.view) vbox = gtk.VBox() vbox.pack_start(name_box, False) vbox.pack_start(progress, False) vbox.pack_start(scroller, True, True) vbox.pack_start(extension, False) self.window = window = gtk.Window() window.set_title(Application.title) window.set_default_size(800, 600) window.set_icon(Application.get_icon()) window.add(vbox)
def _build_ui(self): self._display = gtk.Table(20, 2) self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) self._tree = gtk.TreeView(self._store) rend = gtk.CellRendererText() tvc = gtk.TreeViewColumn('Element', rend, text=0) self._tree.append_column(tvc) self._tree.connect('button_press_event', self._tree_click) self._tree.set_size_request(200, -1) self.root = gtk.HBox(False, 3) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self._tree) sw.show() self.root.pack_start(sw, 0, 0, 0) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(self._display) sw.show() self.root.pack_start(sw, 1, 1, 1) self._tree.show() self._display.show() self.root.show()
def __init__(self, rthread): super(SettingsEditor, self).__init__(rthread) # The main box self.root = gtk.HBox(False, 0) # The pane paned = gtk.HPaned() paned.show() self.root.pack_start(paned, 1, 1, 0) # The selection tree self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT) self._view = gtk.TreeView(self._store) self._view.get_selection().connect("changed", self._view_changed_cb) self._view.append_column( gtk.TreeViewColumn("", gtk.CellRendererText(), text=0)) self._view.show() scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.add_with_viewport(self._view) scrolled_window.set_size_request(200, -1) scrolled_window.show() paned.pack1(scrolled_window) # The settings notebook self._notebook = gtk.Notebook() self._notebook.set_show_tabs(False) self._notebook.set_show_border(False) self._notebook.show() paned.pack2(self._notebook) self._changed = False self._settings = None job = common.RadioJob(self._get_settings_cb, "get_settings") job.set_desc("Getting radio settings") self.rthread.submit(job)
def _add_text(d, text): v = gtk.TextView() v.get_buffer().set_text(text) v.set_editable(False) v.set_cursor_visible(False) v.show() sw = gtk.ScrolledWindow() sw.add(v) sw.show() d.vbox.pack_start(sw, 1, 1, 1) return v
def __init__(self, visualizer, node_index): InformationWindow.__init__(self) self.win = gtk.Dialog(parent=visualizer.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.win.set_default_size(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/2) self.win.connect("response", self._response_cb) self.win.set_title("OLSR routing table for node %i" % node_index) self.visualizer = visualizer self.node_index = node_index self.table_model = gtk.ListStore(str, str, str, int) treeview = gtk.TreeView(self.table_model) treeview.show() sw = gtk.ScrolledWindow() sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.show() sw.add(treeview) self.win.vbox.add(sw) # Dest. column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(), text=self.COLUMN_DESTINATION) treeview.append_column(column) # Next hop column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP) treeview.append_column(column) # Interface column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(), text=self.COLUMN_INTERFACE) treeview.append_column(column) # Num. Hops column = gtk.TreeViewColumn('Num. Hops', gtk.CellRendererText(), text=self.COLUMN_NUM_HOPS) treeview.append_column(column) self.visualizer.add_information_window(self) self.win.show()
def __init__(self, visualizer, node_index): InformationWindow.__init__(self) self.win = gtk.Dialog(parent=visualizer.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) self.win.connect("response", self._response_cb) self.win.set_title("IPv4 routing table for node %i" % node_index) self.visualizer = visualizer self.node_index = node_index self.table_model = gtk.ListStore(str, str, str, str, int) treeview = gtk.TreeView(self.table_model) treeview.show() sw = gtk.ScrolledWindow() sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.show() sw.add(treeview) self.win.vbox.add(sw) self.win.set_default_size(600, 300) # Dest. column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(), text=self.COLUMN_DESTINATION) treeview.append_column(column) # Next hop column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(), text=self.COLUMN_NEXT_HOP) treeview.append_column(column) # Interface column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(), text=self.COLUMN_INTERFACE) treeview.append_column(column) # Type column = gtk.TreeViewColumn('Type', gtk.CellRendererText(), text=self.COLUMN_TYPE) treeview.append_column(column) # Prio column = gtk.TreeViewColumn('Prio', gtk.CellRendererText(), text=self.COLUMN_PRIO) treeview.append_column(column) self.visualizer.add_information_window(self) self.win.show()
def addNotebookPage(self, title, content, path): area = gtk.ScrolledWindow() area.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS) area.show() txtB = gtkSourceView.Buffer() txtB.begin_not_undoable_action() txtB.set_style_scheme(self.style_scheme) language = self.getLanguage(title) txtB.set_highlight_matching_brackets(True) if language is not None: txtB.set_highlight_syntax(True) txtB.set_language(language) txtB.set_text(content) txtB.place_cursor(txtB.get_start_iter()) txtB.set_modified(False) txtB.end_not_undoable_action() text = SourceView(txtB) text.set_tab_width(self.tabWidth) text.set_insert_spaces_instead_of_tabs(False) text.set_show_right_margin(True) text.set_show_line_marks(True) text.set_auto_indent(self.autoIndent) text.set_show_line_numbers(self.lineNumbers) text.show() text.modify_font(pango.FontDescription('Monospace 10')) area.add(text) top = gtk.HBox() title = gtk.Label(title) title.show() top.set_tooltip_text(path) top.pack_start(title, True, True, 0) butt = gtk.Button() img = gtk.Image() img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) img.show() butt.set_image(img) butt.connect_object("clicked", self.closePage, area) top.pack_end(butt, False, False, 0) butt.show() top.show() self.notebook.insert_page(area, top, 0) pages = self.notebook.get_n_pages() self.notebook.set_current_page(0)
def cb_ok(self, widget, data=None): buf = self._text.get_buffer() self.text = buf.get_text(buf.get_start_iter(), buf.get_end_iter()) if isinstance(self._preamble, gtk.FileChooser): self.preamble_file = self._preamble.get_filename() if not self.preamble_file: self.preamble_file = "" else: self.preamble_file = self._preamble.get_text() if self.scale_factor is not None: self.scale_factor = self._scale_adj.get_value() try: self.callback(self.text, self.preamble_file, self.scale_factor) except StandardError, e: err_msg = traceback.format_exc() dlg = gtk.Dialog("Textext Error", self._window, gtk.DIALOG_MODAL) dlg.set_default_size(600, 400) btn = dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE) btn.connect("clicked", lambda w, d=None: dlg.destroy()) msg = gtk.Label() msg.set_markup("<b>Error occurred while converting text from Latex to SVG:</b>") txtw = gtk.ScrolledWindow() txtw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) txtw.set_shadow_type(gtk.SHADOW_IN) txt = gtk.TextView() txt.set_editable(False) txt.get_buffer().set_text(err_msg) txtw.add(txt) dlg.vbox.pack_start(msg, expand=False, fill=True) dlg.vbox.pack_start(txtw, expand=True, fill=True) dlg.show_all() dlg.run() return False gtk.main_quit() return False
def _info(type, value, tb): """display exception""" #ungrab a potentially "grabbed" mouse pointer gtk.gdk.pointer_ungrab() #create dialog dialog = gtk.MessageDialog( parent = None, flags = 0, type = gtk.MESSAGE_WARNING, buttons = gtk.BUTTONS_NONE, message_format = _("<big><b>Error</b></big>")) dialog.set_title(_("Bug Detected")) dialog.vbox.get_children()[0].get_children()[1].get_children()[0].set_property("use-markup", True) dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) #details textview = gtk.TextView() textview.show() textview.set_editable(False) textview.modify_font(pango.FontDescription("Monospace")) sw = gtk.ScrolledWindow() sw.show() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(textview) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_IN) frame.add(sw) frame.set_border_width(6) dialog.vbox.add(frame) textbuffer = textview.get_buffer() trace = StringIO.StringIO() traceback.print_exception(type, value, tb, None, trace) textbuffer.set_text(trace.getvalue()) textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3) dialog.details = frame dialog.set_position(gtk.WIN_POS_CENTER) dialog.set_gravity(gtk.gdk.GRAVITY_CENTER) dialog.details.show() #display the dialog resp = dialog.run() if resp == gtk.RESPONSE_CLOSE: pass dialog.destroy() sys.exit(1) #sys.excepthook = _info
def setup_iconview(self, columns, column_types, container, changed_cb=None, activate_cb=None, text_style='text'): """ Create a ready-to-use (list based) iconview widget (GTK+2.6 and baove) Parameters: columns : List of column names (should only be two - one for icon & one for description) column_types : List of variable types for each column (eg. [gobject.TYPE_STRING, gobject.TYPE_LONG]) container : reference to widget that is to contain list, almost always a scrolled window - gtk.ScrolledWindow() changed_cb : the callback function for the "changed" TreeViewSelection signal activate_cb : the callback function for the "changed" TreeViewSelection signal text_style : 'text' for normail plain text, 'markup' for pango marked-up text Returns: Reference to IconView and ListStore widgets e.g. to create a four column (first two displayed, rest hidden) icon view... self.tvwProjects, self.lsProjects, self.tvwsProjects = self.setup_treeview( ['Picture', 'Desc'], [gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_LONG, gobject.TYPE_STRING], self.scwPictures, self.on_tvwsPictures_changed, None 'text') """ #create the ListStore and IconView objects ls = gtk.ListStore(*column_types) ivw = gtk.IconView(ls) #set columns for i in range(len(columns)): if column_types[i] != gtk.gdk.Pixbuf: #create text renderer tvwRendererText = gtk.CellRendererText() tvwRendererText.set_property('yalign', 0.0) if text_style == 'markup': #markup text rendering column = gtk.TreeViewColumn(columns[i], tvwRendererText, markup=i) ivw.set_markup_column(i) else: #default text rendering column = gtk.TreeViewColumn(columns[i], tvwRendererText, text=i) ivw.set_text_column(i) else: #create pixbuf renderer tvwRendererPixbuf = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(columns[i], tvwRendererPixbuf, pixbuf=i) ivw.set_pixbuf_column(i) #display it (add iconview to given widget) container.add(ivw) ivw.show() #connect callbacks if changed_cb: ivw.connect('selection_changed', changed_cb) if activate_cb: ivw.connect('item_activated', activate_cb) #done return ivw, ls
def _setup_widgets(self): """ create all the window staticaly placed widgets. """ #load the saved setting before start. self.set_settings(Utils.load_conffile("conf.json")) # basic window definitions self.connect("destroy",self.destroy) self.connect("focus_in_event",self.on_window_focus) self.connect("configure_event",self.on_window_resize) self.set_default_size(self.win_size[0],self.win_size[1]) self.set_keep_above(True) #self.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.move(self.win_pos[0],self.win_pos[1]) # parse gimp theme gtkrc gtkrc_path = self._get_theme_gtkrc(gimp.personal_rc_file('themerc')) if os.name != 'nt':# try apply the theme by parse a gtkrc file if is not a windows system. gtk.rc_parse(gtkrc_path) else: # if error occur them parse the file in another way. gtk.rc_add_default_file(gtkrc_path) gtk.rc_reparse_all() # start creating basic layout base = gtk.VBox() # commands bar widgets cbar = gtk.HBox() cbar.pack_start(self._setup_playbackbar(),False,False,10) cbar.pack_start(self._setup_editbar(),False,False,10) cbar.pack_start(self._setup_onionskin(),False,False,10) cbar.pack_start(self._setup_config(),False,False,10) cbar.pack_start(self._setup_generalbar(),False,False,10) # frames bar widgets self.frame_bar = gtk.HBox() scroll_window = gtk.ScrolledWindow() scroll_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) scroll_window.add_with_viewport(self.frame_bar) scroll_window.set_size_request(-1,140) # mount the widgets together base.pack_start(cbar,False,False,0) base.pack_start(scroll_window,True,True,0) self.add(base) # catch all layers self._scan_image_layers() self.active = 0 self.on_goto(None,GIMP_ACTIVE) # finalize showing all widgets self.show_all()
def do_columns(self): eset = self.get_current_editorset() driver = directory.get_driver(eset.rthread.radio.__class__) radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR, eset.rthread.radio.MODEL, eset.rthread.radio.VARIANT) d = gtk.Dialog(title=_("Select Columns"), parent=self, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) vbox = gtk.VBox() vbox.show() sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(vbox) sw.show() d.vbox.pack_start(sw, 1, 1, 1) d.set_size_request(-1, 300) d.set_resizable(False) labelstr = _("Visible columns for {radio}").format(radio=radio_name) label = gtk.Label(labelstr) label.show() vbox.pack_start(label) fields = [] memedit = eset.get_current_editor() # .editors["memedit"] unsupported = memedit.get_unsupported_columns() for colspec in memedit.cols: if colspec[0].startswith("_"): continue elif colspec[0] in unsupported: continue label = colspec[0] visible = memedit.get_column_visible(memedit.col(label)) widget = gtk.CheckButton(label) widget.set_active(visible) fields.append(widget) vbox.pack_start(widget, 1, 1, 1) widget.show() res = d.run() selected_columns = [] if res == gtk.RESPONSE_OK: for widget in fields: colnum = memedit.col(widget.get_label()) memedit.set_column_visible(colnum, widget.get_active()) if widget.get_active(): selected_columns.append(widget.get_label()) d.destroy() CONF.set(driver, ",".join(selected_columns), "memedit_columns")
def make_view(self): editable = [self.col_nloc, self.col_name, self.col_comm] self.__store = gtk.ListStore(gobject.TYPE_BOOLEAN, # Import gobject.TYPE_INT, # Source loc gobject.TYPE_INT, # Destination loc gobject.TYPE_STRING, # Name gobject.TYPE_STRING, # Frequency gobject.TYPE_STRING, # Comment gobject.TYPE_BOOLEAN, gobject.TYPE_STRING) self.__view = gtk.TreeView(self.__store) self.__view.show() tips = gtk.Tooltips() for k in self.caps.keys(): t = self.types[k] if t == gobject.TYPE_BOOLEAN: rend = gtk.CellRendererToggle() rend.connect("toggled", self._toggle, k) column = gtk.TreeViewColumn(self.caps[k], rend, active=k, sensitive=self.col_okay, activatable=self.col_okay) else: rend = gtk.CellRendererText() if k in editable: rend.set_property("editable", True) rend.connect("edited", self._edited, k) column = gtk.TreeViewColumn(self.caps[k], rend, text=k, sensitive=self.col_okay) if k == self.col_nloc: column.set_cell_data_func(rend, self._render, k) if k in self.tips.keys(): LOG.debug("Doing %s" % k) lab = gtk.Label(self.caps[k]) column.set_widget(lab) tips.set_tip(lab, self.tips[k]) lab.show() column.set_sort_column_id(k) self.__view.append_column(column) self.__view.set_tooltip_column(self.col_tmsg) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.__view) sw.show() return sw
def show_diff_blob(title, result): d = gtk.Dialog(title=title, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) b = gtk.TextBuffer() tags = b.get_tag_table() for color in ["red", "blue", "green", "grey"]: tag = gtk.TextTag(color) tag.set_property("foreground", color) tags.add(tag) tag = gtk.TextTag("bold") tag.set_property("weight", pango.WEIGHT_BOLD) tags.add(tag) try: fontsize = CONF.get_int("diff_fontsize", "developer") except Exception: fontsize = 11 if fontsize < 4 or fontsize > 144: LOG.info("Unsupported diff_fontsize %i. Using 11." % fontsize) fontsize = 11 lines = result.split(os.linesep) for line in lines: if line.startswith("-"): tags = ("red", "bold") elif line.startswith("+"): tags = ("blue", "bold") else: tags = () b.insert_with_tags_by_name(b.get_end_iter(), line + os.linesep, *tags) v = gtk.TextView(b) fontdesc = pango.FontDescription("Courier %i" % fontsize) v.modify_font(fontdesc) v.set_editable(False) v.show() s = gtk.ScrolledWindow() s.add(v) s.show() d.vbox.pack_start(s, 1, 1, 1) d.set_size_request(600, 400) d.run() d.destroy()