Python gtk 模块,POLICY_AUTOMATIC 实例源码

我们从Python开源项目中,提取了以下20个代码示例,用于说明如何使用gtk.POLICY_AUTOMATIC

项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self):
            super(ShowLastPackets.PacketList, self).__init__()
            self.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                                vscrollbar_policy=gtk.POLICY_AUTOMATIC)
            self.table_model = gtk.ListStore(*([str]*4))
            treeview = gtk.TreeView(self.table_model)
            treeview.show()
            self.add(treeview)

            def add_column(descr, colid):
                column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
                treeview.append_column(column)

            add_column("Time", self.COLUMN_TIME)
            add_column("Interface", self.COLUMN_INTERFACE)
            add_column("Size", self.COLUMN_SIZE)
            add_column("Contents", self.COLUMN_CONTENTS)
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
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
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
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()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
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()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
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()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
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()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
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()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
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
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
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)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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)
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
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()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
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()
项目:inkscapeMadeEasy    作者:fsmMLK    | 项目源码 | 文件源码
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
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
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
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
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()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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")
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
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