python类VBox()的实例源码

fanim_timeline.py 文件源码 项目:gimp-fanim 作者: douglasvini 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _setup_widgets(self):

        h_space = 4 # horizontal space

        # create the frames to contein the diferent settings.
        f_time = gtk.Frame(label="Time")
        f_oskin = gtk.Frame(label="Onion Skin")
        self.set_size_request(300,-1)
        self.vbox.pack_start(f_time,True,True,h_space)
        self.vbox.pack_start(f_oskin,True,True,h_space)

        # create the time settings.
        th = gtk.HBox()
        fps,fps_spin = Utils.spin_button("Framerate",'int',self.last_config[FRAMERATE],1,100) #conf fps

        th.pack_start(fps,True,True,h_space)

        f_time.add(th)
        # create onion skin settings
        ov = gtk.VBox()
        f_oskin.add(ov)

        # fist line
        oh1 = gtk.HBox()
        depth,depth_spin = Utils.spin_button("Depth",'int',self.last_config[OSKIN_DEPTH],1,4,1) #conf depth

        on_play = gtk.CheckButton("On Play")
        on_play.set_active(self.last_config[OSKIN_ONPLAY])

        oh1.pack_start(depth,True,True,h_space)
        oh1.pack_start(on_play,True,True,h_space)
        ov.pack_start(oh1)
        # second line
        oh2 = gtk.HBox()
        forward = gtk.CheckButton("Forward")
        forward.set_active(self.last_config[OSKIN_FORWARD])

        backward = gtk.CheckButton("Backward")
        backward.set_active(self.last_config[OSKIN_BACKWARD])

        oh2.pack_start(forward,True,True,h_space)
        oh2.pack_start(backward,True,True,h_space)

        ov.pack_start(oh2)
        # last line

        # connect a callback to all

        fps_spin.connect("value_changed",self.update_config,FRAMERATE)
        depth_spin.connect("value_changed",self.update_config,OSKIN_DEPTH)
        on_play.connect("toggled",self.update_config,OSKIN_ONPLAY)
        forward.connect("toggled",self.update_config,OSKIN_FORWARD)
        backward.connect("toggled",self.update_config,OSKIN_BACKWARD)

        # show all
        self.show_all()
fanim_timeline.py 文件源码 项目:gimp-fanim 作者: douglasvini 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
mainapp.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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")
memedit.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, rthread):
        super(MemoryEditor, self).__init__(rthread)

        self.defaults = dict(self.defaults)

        self._config = config.get("memedit")

        self.bandplans = bandplans.BandPlans(config.get())

        self.allowed_bands = [144, 440]
        self.count = 100
        self.show_special = self._config.get_bool("show_special")
        self.show_empty = not self._config.get_bool("hide_empty")
        self.hide_unused = self._config.get_bool("hide_unused", default=True)
        self.read_only = False

        self.need_refresh = False
        self._in_editing = False

        self.lo_limit_adj = self.hi_limit_adj = None
        self.store = self.view = None

        self.__cache_columns()

        self._features = self.rthread.radio.get_features()

        (min, max) = self._features.memory_bounds

        self.choices[_("Mode")] = self._features["valid_modes"]
        self.choices[_("Tone Mode")] = self._features["valid_tmodes"]
        self.choices[_("Cross Mode")] = self._features["valid_cross_modes"]
        self.choices[_("Skip")] = self._features["valid_skips"]
        self.choices[_("Power")] = [str(x) for x in
                                    self._features["valid_power_levels"]]
        self.choices[_("DTCS Pol")] = self._features["valid_dtcs_pols"]
        self.choices[_("DTCS Code")] = self._features["valid_dtcs_codes"]
        self.choices[_("DTCS Rx Code")] = self._features["valid_dtcs_codes"]

        if self._features["valid_power_levels"]:
            self.defaults[_("Power")] = self._features["valid_power_levels"][0]

        self.choices[_("Duplex")] = list(self._features.valid_duplexes)

        if self.defaults[_("Mode")] not in self._features.valid_modes:
            self.defaults[_("Mode")] = self._features.valid_modes[0]

        vbox = gtk.VBox(False, 2)
        vbox.pack_start(self.make_controls(min, max), 0, 0, 0)
        vbox.pack_start(self.make_editor(), 1, 1, 1)
        vbox.show()

        self.prefill()

        self.root = vbox

        # Run low priority jobs to get the rest of the memories
        hi = int(self.hi_limit_adj.get_value())
        for i in range(hi, max+1):
            job = common.RadioJob(None, "get_memory", i)
            job.set_desc(_("Getting memory {number}").format(number=i))
            self.rthread.submit(job, 10)
csvdump.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def make_file_ctl(self):
        self.w_fileframe = gtk.Frame("File")

        vbox = gtk.VBox(False, 2)
        vbox.set_border_width(2)

        hbox = gtk.HBox(False, 2)
        hbox.set_border_width(2)

        l = gtk.Label("File")
        l.show()
        hbox.pack_start(l, 0, , )

        self.w_filename = gtk.Entry()
        self.w_filename.connect("changed", self.file_changed)
        self.tips.set_tip(self.w_filename, "Path to CSV file")
        self.w_filename.show()
        hbox.pack_start(self.w_filename, 1, , )

        bb = StdButton("Browse")
        bb.connect("clicked", self.pick_file)
        bb.show()
        hbox.pack_start(bb, 0, , )

        hbox.show()
        vbox.pack_start(hbox, 0, , )

        hbox = gtk.HBox(True, 2)
        hbox.set_border_width(2)

        def export_handler(x):
            return self.fn_eport(self.w_filename.get_text())
        self.w_export = StdButton("Export")
        self.w_export.set_sensitive(False)
        self.w_export.connect("clicked", export_handler)
        self.tips.set_tip(self.w_export,
                          "Export radio memories to CSV file")
        self.w_export.show()
        hbox.pack_start(self.w_export, 0, , )

        def import_handler(x):
            return self.fn_iport(self.w_filename.get_text())
        self.w_import = StdButton("Import")
        self.w_import.set_sensitive(False)
        self.w_import.connect("clicked", import_handler)
        self.tips.set_tip(self.w_import,
                          "Import radio memories from CSV file")
        self.w_import.show()
        hbox.pack_start(self.w_import, 0, , )

        hbox.show()
        vbox.pack_start(hbox, 0, , )

        vbox.show()
        self.w_fileframe.add(vbox)
        self.w_fileframe.show()

        return self.w_fileframe


问题


面经


文章

微信
公众号

扫码关注公众号