我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.POLICY_NEVER。
def scrollify(widget): #widget.set_word_wrap(gtk.TRUE) scrl=gtk.GtkScrolledWindow() scrl.add(widget) scrl.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) # scrl.set_update_policy(gtk.POLICY_AUTOMATIC) return scrl
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, 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 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")