Python gi.repository.Gtk.Adjustment() Examples

The following are 13 code examples of gi.repository.Gtk.Adjustment(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: alttoolbar_widget.py    From alternative-toolbar with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, shell_player):
        super().__init__()
        self.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.adjustment = Gtk.Adjustment(0, 0, 10, 1, 10, 0)
        self.set_adjustment(self.adjustment)
        self.set_hexpand(True)
        self.set_draw_value(False)
        self.set_sensitive(False)

        self.shell_player = shell_player
        self.dragging = self.drag_moved = False

        self.connect('button-press-event', slider_press_callback)
        self.connect('motion-notify-event', slider_moved_callback)
        self.connect('button-release-event', slider_release_callback)
        self.connect('focus-out-event', slider_release_callback)
        self.changed_callback_id = self.connect('value-changed',
                                                slider_changed_callback)

        self.set_size_request(150, -1)
        self.show_all() 
Example #2
Source File: options.py    From rednotebook with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        text,
        option_name,
        default=0,
        min_value=0,
        max_value=1000,
        increment=1,
        **kwargs
    ):
        Option.__init__(self, text, option_name, **kwargs)

        value = Option.config.read(option_name, default=default)
        value = int(value)

        self.spin_button = Gtk.SpinButton()
        adjustment = Gtk.Adjustment(value, min_value, max_value, increment, 10, 0)
        self.spin_button.set_adjustment(adjustment)
        self.spin_button.set_value(value)
        self.spin_button.set_numeric(True)
        self.spin_button.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)

        self.pack_start(self.spin_button, True, True, 0) 
Example #3
Source File: plugins.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, name, *args, **kwargs):
		"""
		:param str name: The name of this option.
		:param str description: The description of this option.
		:param default: The default value of this option.
		:param str display_name: The name to display in the UI to the user for this option.
		:param adjustment: The adjustment details of the options value.
		:type adjustment: :py:class:`Gtk.Adjustment`
		"""
		self.adjustment = kwargs.pop('adjustment', Gtk.Adjustment(0, -0x7fffffff, 0x7fffffff, 1, 10, 0))
		super(ClientOptionInteger, self).__init__(name, *args, **kwargs) 
Example #4
Source File: plugins.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
		"""
		:param str name: The name of this option.
		:param str description: The description of this option.
		:param default: The default value of this option.
		:param str display_name: The name to display in the UI to the user for this option.
		"""
		kwargs['adjustment'] = Gtk.Adjustment(1, 1, 0xffff, 1, 10, 0)
		super(ClientOptionPort, self).__init__(*args, **kwargs)

# plugin base class 
Example #5
Source File: period.py    From gtg with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, req, backend, width):
        """
        Creates the Gtk.Adjustment and the related label. Loads the current
        period.

        @param req: a Requester
        @param backend: a backend object
        @param width: the width of the Gtk.Label object
        """
        super().__init__()
        self.backend = backend
        self.req = req
        self._populate_gtk(width)
        self._connect_signals() 
Example #6
Source File: period.py    From gtg with GNU General Public License v3.0 5 votes vote down vote up
def _populate_gtk(self, width):
        """Creates the gtk widgets

        @param width: the width of the Gtk.Label object
        """
        period_label = Gtk.Label(label=_("Check for new tasks every"))
        period_label.set_alignment(xalign=0, yalign=0.5)
        period_label.set_line_wrap(True)
        period_label.set_size_request(width=width, height=-1)
        self.pack_start(period_label, False, True, 0)
        align = Gtk.Alignment.new(0, 0.5, 1, 0)
        align.set_padding(0, 0, 10, 0)
        self.pack_start(align, False, True, 0)
        period = self.backend.get_parameters()['period']
        self.adjustment = Gtk.Adjustment(value=period,
                                         lower=1,
                                         upper=120,
                                         step_incr=1,
                                         page_incr=0,
                                         page_size=0)
        self.period_spin = Gtk.SpinButton(adjustment=self.adjustment,
                                          climb_rate=0.3,
                                          digits=0)
        self.minutes_label = Gtk.Label()
        self.update_minutes_label()
        self.minutes_label.set_alignment(xalign=0, yalign=0.5)
        self.pack_start(self.minutes_label, False, True, 0)
        align.add(self.period_spin)
        self.show_all() 
Example #7
Source File: enginesDialog.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
def do_set_property(self, pspec, value):
        if value["type"] == "check":
            self.toggle_renderer.set_active(value["value"])
            self.set_property("mode", Gtk.CellRendererMode.ACTIVATABLE)
        elif value["type"] == "spin":
            adjustment = Gtk.Adjustment(value=int(value["value"]),
                                        lower=value["min"],
                                        upper=value["max"],
                                        step_increment=1)
            self.spin_renderer.set_property("adjustment", adjustment)
            self.spin_renderer.set_property("text", str(value["value"]))
            self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
        elif value["type"] == "text":
            self.text_renderer.set_property("text", value["value"])
            self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
        elif value["type"] == "combo":
            liststore = Gtk.ListStore(str)
            for choice in value["choices"]:
                liststore.append([choice])
            self.combo_renderer.set_property("model", liststore)
            self.combo_renderer.set_property("text", value["value"])
            self.set_property("mode", Gtk.CellRendererMode.EDITABLE)
        elif value["type"] == "button":
            self.button_renderer.set_property("text", "")

        setattr(self, pspec.name, value) 
Example #8
Source File: custom.py    From Dindo-Bot with MIT License 5 votes vote down vote up
def __init__(self, min=0, max=100, value=0, step=1, page_step=5):
		adjustment = Gtk.Adjustment(value=value, lower=min, upper=max, step_increment=step, page_increment=page_step, page_size=0)
		Gtk.SpinButton.__init__(self, adjustment=adjustment) 
Example #9
Source File: colors_list.py    From oomox with GNU General Public License v3.0 5 votes vote down vote up
def __init__(  # pylint: disable=too-many-arguments
            self,
            display_name, key,
            callback,
            init_value,
            min_value, max_value,
            step_increment,
            page_increment,
            page_size
    ):

        adjustment = Gtk.Adjustment(
            value=init_value,
            lower=min_value,
            upper=max_value,
            step_increment=step_increment,
            page_increment=page_increment,
            page_size=page_size
        )
        spinbutton = Gtk.SpinButton(
            adjustment=adjustment,
        )
        spinbutton.set_numeric(True)
        spinbutton.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)

        super().__init__(
            display_name=display_name,
            key=key,
            callback=callback,
            value_widget=spinbutton
        ) 
Example #10
Source File: ui.py    From pympress with GNU General Public License v2.0 5 votes vote down vote up
def adjust_frame_position(self, *args):
        """ Select how to align the frame on screen.
        """
        win_aspect_ratio = float(self.c_win.get_allocated_width()) / self.c_win.get_allocated_height()

        if win_aspect_ratio <= float(self.c_frame.get_property("ratio")):
            prop = "yalign"
        else:
            prop = "xalign"

        val = self.c_frame.get_property(prop)

        button = Gtk.SpinButton()
        button.set_adjustment(Gtk.Adjustment(lower=0.0, upper=1.0, step_increment=0.01))
        button.set_digits(2)
        button.set_value(val)
        button.connect("value-changed", self.update_frame_position, prop)

        popup = Gtk.Dialog(title = _("Adjust alignment of slides in projector screen"), transient_for = self.p_win)
        popup.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)

        box = popup.get_content_area()
        box.add(button)
        popup.show_all()
        response = popup.run()
        popup.destroy()

        # revert if we cancelled
        if response == Gtk.ResponseType.CANCEL:
            self.c_frame.set_property(prop, val)
        else:
            self.config.set('content', prop, str(button.get_value())) 
Example #11
Source File: automaticaccounting.py    From amir with GNU General Public License v3.0 5 votes vote down vote up
def on_discount_clicked(self, button):
        dialog = Gtk.Dialog("Discount percentage",
                            self.builder.get_object('general'),
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK)
                            )
        adj = Gtk.Adjustment(0, 0, 100, 1, 1)
        spin = Gtk.SpinButton()
        spin.set_adjustment(adj)

        hbox = Gtk.HBox()
        hbox.pack_start(spin, True, True, 0)
        hbox.pack_start(Gtk.Label(' % ', True, True, 0), False, False, 0)
        hbox.show_all()

        dialog.vbox.pack_start(hbox, False, False, 0)

        result = dialog.run()
        if result == Gtk.ResponseType.OK:
            val = spin.get_value()
            total = self.total_credit_entry.get_float()
            discount = (val*total)/100
            self.discount_entry.set_text(str(discount))

        dialog.destroy() 
Example #12
Source File: color_picker.py    From wpgtk with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, parent, current_file, gcolor):
        Gtk.Dialog.__init__(self, "Pick a Color", parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_size(150, 100)
        box = self.get_content_area()
        box.set_border_width(10)
        box.set_spacing(10)

        sat_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)
        light_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)

        self.colorchooser = Gtk.ColorChooserWidget(show_editor=True)
        self.colorchooser.set_use_alpha(False)
        self.colorchooser.set_rgba(gcolor)

        r, g, b, _ = list(map(lambda x: round(x*100*2.55), gcolor))
        hue, light, sat = util.rgb_to_hls(r, g, b)

        self.sat_lbl = Gtk.Label('Saturation')
        self.light_lbl = Gtk.Label('Light    ')

        sat_range = Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0)
        self.sat_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
                                    adjustment=sat_range)
        self.sat_slider.set_value(-sat)
        self.sat_slider.set_digits(2)
        self.sat_slider.connect('value-changed', self.slider_changed, 'sat')

        light_range = Gtk.Adjustment(5, 0, 255, 1, 10, 0)
        self.light_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
                                      adjustment=light_range)
        self.light_slider.set_value(light)
        self.light_slider.connect('value-changed',
                                  self.slider_changed, 'light')

        box.add(self.colorchooser)

        sat_box.pack_start(self.sat_lbl, True, True, 0)
        sat_box.pack_start(self.sat_slider, True, True, 0)

        light_box.pack_start(self.light_lbl, True, True, 0)
        light_box.pack_start(self.light_slider, True, True, 0)

        box.add(light_box)
        box.add(sat_box)

        self.show_all() 
Example #13
Source File: sim.py    From bldc-sim with MIT License 4 votes vote down vote up
def __init__(self, controller):
        super( SimulatorWindow, self ).__init__()
        self.controller = controller
        self.elapsed = 0.0
        self.epoch = 0
        self.throttleval = 0.0
        self.loadval = 0.0
        self.committedThrottleVal = 0.0
        self.dt = 1.0 / simconstants.SIMFREQ
        self.va = 0.0
        self.vb = 0.0
        self.vc = 0.0

        self.connect('destroy', lambda w: Gtk.main_quit())
        self.set_default_size(1024, 800)

        vbox = Gtk.VBox()
        self.add(vbox)

        self.table = GraphTable()
        vbox.pack_start( self.table, True, True, 0 )

        self.table.add_row( "omega", 0.05 )
        self.table.add_row( "theta", 5 )
        self.table.add_row( "va", 3 )
        self.table.add_row( "ia", 3 )
        self.table.add_row( "bemf", 4 )
        self.table.add_row( "torque", 50 )
        self.table.add_row( "errors", 5 )

        hbox = Gtk.HBox()
        self.pwm = self.add_label( "throttle (%): ", hbox )
        adj1 = Gtk.Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0)
        self.throttlescale = Gtk.HScale()
        self.throttlescale.set_adjustment( adj1 )
        self.throttlescale.set_digits(1)
        self.throttlescale.set_draw_value(True)
        hbox.pack_start( self.throttlescale, True, True, 0 )
        self.throttlescale.connect( "change-value", self.change_throttle )

        self.load = self.add_label( "load (Nm): ", hbox )
        adj2 = Gtk.Adjustment(0.0, 0.0, 5.0, 0.01, 1.0, 1.0)
        self.loadscale = Gtk.HScale()
        self.loadscale.set_adjustment( adj2 )
        self.loadscale.set_digits(2)
        self.loadscale.set_draw_value(True)
        hbox.pack_start( self.loadscale, True, True, 0 )
        self.loadscale.connect( "change-value", self.change_load )

        vbox.pack_start(hbox, False, False, 0)
        self.sim = Simulator()

        GObject.timeout_add( 1, self.callback )

        self.show_all()