Python gtk 模块,SpinButton() 实例源码

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

项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_number_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        adjustment = gtk.Adjustment(value, 0, sys.maxint, 1)
        spinbutton_value = gtk.SpinButton(adjustment)
        spinbutton_value.set_value(value)
        hbox_main.pack_start(label_text)
        hbox_main.pack_start(spinbutton_value)

        self.plugin_config_widgets.append(spinbutton_value)
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(spinbutton_value)

        return hbox_main
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def __init__(self, max_depth_value):
        self.on_max_depth_changed = None
        max_depth_entry = self.max_depth_entry = gtk.SpinButton(
            gtk.Adjustment(value=max_depth_value, lower=1, upper=100,
            step_incr=1, page_incr=10), digits=0)
        max_depth_entry.get_adjustment().connect('value_changed',
            self._max_depth_changed, max_depth_entry)
        max_depth_entry.set_alignment(0)
        max_depth_label = gtk.Label()
        max_depth_label.set_alignment(1, 0.5)
        max_depth_label.set_text_with_mnemonic('Maximum _Depth')
        max_depth_label.set_mnemonic_widget(max_depth_entry)
        legend = self._create_legend()
        table = self.view = gtk.Table(2, 3)
        table.set_border_width(8)
        table.set_row_spacings(8)
        table.set_col_spacings(8)
        table.attach(max_depth_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
        table.attach(max_depth_entry, 1, 2, 0, 1, gtk.SHRINK, gtk.FILL)
        table.attach(gtk.Label(), 2, 3, 0, 1)  # space filler
        table.attach(legend, 0, 3, 1, 2)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def get_mem_range(self):
        d = inputdialog.FieldDialog(title="Select Memory Range")

        limit = RADIOS[self.rtype].mem_upper_limit

        la = gtk.Adjustment(0, 0, limit, 1, 10, 10)
        d.add_field("Start", gtk.SpinButton(la, 0))

        ua = gtk.Adjustment(100, 0, limit, 1, 10, 10)
        d.add_field("End", gtk.SpinButton(ua, 0))

        r = d.run()
        low = int(la.get_value())
        high = int(ua.get_value())
        d.destroy()

        if r == gtk.RESPONSE_OK:
            return low, high
        else:
            return None, None
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_time_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        adjustment = gtk.Adjustment(value, 0, sys.maxint, 1)
        spinbutton_value = gtk.SpinButton(adjustment)
        combobox_units = gtk.combo_box_new_text()
        t_value, units = self.get_time_value_and_units(value)
        spinbutton_value.set_value(t_value)
        options = ["seconds", "minutes", "hours", "days", "weeks"]
        for option in options:
            combobox_units.append_text(option)
        selected_index = options.index(units)
        combobox_units.set_active(selected_index)
        hbox_main.pack_start(label_text)
        hbox_main.pack_start(spinbutton_value)
        hbox_main.pack_start(combobox_units)

        self.plugin_config_widgets.append([spinbutton_value, combobox_units])
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(spinbutton_value)

        return hbox_main

    #TODO: Refactor these
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def spin_button(name="variable",number_type="int",value=0,min=1,max=100,advance=1):
        adjustment = gtk.Adjustment(value,min,max,advance,advance)
        digits = 0
        if number_type != "int":
            digits = 3
        l = gtk.Label(name)
        b = gtk.SpinButton(adjustment,0,digits)

        h = gtk.HBox()
        h.pack_start(l)
        h.pack_start(b)
        return h,adjustment
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def addParam(self, name, field, ptype, *args):
        x = self.tblGeneral.rows
        self.tblGeneral.rows += 1
        value = eval(field)
        if ptype==bool:
            obj = gtk.CheckButton()
            obj.set_label(name)
            obj.set_active(value)
            obj.set_alignment(0, 0.5)            
            obj.show()
            obj.field=field
            self.tblGeneral.attach(obj, 0, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)            
        elif ptype==int:            
            obj = gtk.SpinButton(climb_rate=10)
            if len(args)==2:
                obj.set_range(args[0], args[1])
            obj.set_increments(1, 10)
            obj.set_numeric(True)
            obj.set_value(value)                        
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
        elif ptype==list:
            obj = gtk.combo_box_new_text()
            for s in args[0]:
                obj.append_text(s)
            obj.set_active(value)
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
        else:            
            obj = gtk.Entry()
            obj.set_text(value)            
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def on_okbutton1_clicked(self, widget, *args):
        for obj in self.tblGeneral:
            if hasattr(obj, "field"):
                if isinstance(obj, gtk.CheckButton):
                    value = obj.get_active()
                elif isinstance(obj, gtk.SpinButton):
                    value = obj.get_value_as_int()
                elif isinstance(obj, gtk.ComboBox):
                    value = obj.get_active()
                else:
                    value = '"%s"' % (obj.get_text())
                exec("%s=%s" % (obj.field, value))

        if self.get_widget("chkDefaultColors").get_active():
            conf.FONT_COLOR=""
            conf.BACK_COLOR=""
        else:
            conf.FONT_COLOR = self.btnFColor.selected_color
            conf.BACK_COLOR = self.btnBColor.selected_color

        if self.btnFont.selected_font.to_string() != 'monospace' and not self.chkDefaultFont.get_active():
            conf.FONT = self.btnFont.selected_font.to_string()
        else:
            conf.FONT = ''

        #Guardar shortcuts
        scuts={}
        for x in self.treeModel:
            if x[0]!='' and x[1]!='':
                scuts[x[1]] = [x[0]]
        for x in self.treeModel2:
            if x[0]!='' and x[1]!='':
                scuts[x[1]] = x[0]        
        global shortcuts        
        shortcuts = scuts

        #Boton donate
        global wMain
        if conf.HIDE_DONATE:
            wMain.get_widget("btnDonate").hide_all()
        else:
            wMain.get_widget("btnDonate").show_all()

        #Recrear menu de comandos personalizados
        wMain.populateCommandsMenu()        
        wMain.writeConfig()

        self.get_widget("wConfig").destroy()
    #-- Wconfig.on_okbutton1_clicked }

    #-- Wconfig.on_btnBColor_clicked {