8637: Use keyword arguments to initialise Adjustment widgets

This should prevent the value being set to zero or the minumum
limit incorrectly.
This commit is contained in:
Nick Hall 2015-08-07 16:00:52 +01:00
parent c0bdfafbda
commit dcb8efd8e6
4 changed files with 14 additions and 8 deletions

View File

@ -443,7 +443,9 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_slider
lwidget = BasicLabel("%s: " % label)
adj = Gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
adj = Gtk.Adjustment(value=config.get(constant), lower=range[0],
upper=range[1], step_increment=1,
page_increment=0, page_size=0)
slider = Gtk.Scale(adjustment=adj)
slider.set_digits(0)
slider.set_value_pos(Gtk.PositionType.BOTTOM)
@ -463,7 +465,9 @@ class ConfigureDialog(ManagedWindow):
if not callback:
callback = self.update_spinner
lwidget = BasicLabel("%s: " % label)
adj = Gtk.Adjustment(config.get(constant), range[0], range[1], 1, 0, 0)
adj = Gtk.Adjustment(value=config.get(constant), lower=range[0],
upper=range[1], step_increment=1,
page_increment=0, page_size=0)
spinner = Gtk.SpinButton(adjustment=adj, climb_rate=0.0, digits=0)
spinner.connect('value-changed', callback, constant)
spinner.set_hexpand(True)

View File

@ -149,7 +149,8 @@ class MyInteger(Gtk.SpinButton):
def __init__(self, min, max):
GObject.GObject.__init__(self)
self.set_adjustment(Gtk.Adjustment(min, min, max, 1))
self.set_adjustment(Gtk.Adjustment(value=min, lower=min, upper=max,
step_increment=1))
self.show()
def get_text(self):

View File

@ -299,10 +299,10 @@ class GuiNumberOption(Gtk.SpinButton):
decimals = 0
step = self.__option.get_step()
adj = Gtk.Adjustment(1,
self.__option.get_min(),
self.__option.get_max(),
step)
adj = Gtk.Adjustment(value=1,
lower=self.__option.get_min(),
upper=self.__option.get_max(),
step_increment=step)
# Calculate the number of decimal places if necessary
if step < 1:

View File

@ -124,7 +124,8 @@ class PlaceSelection(ManagedWindow, OsmGps):
' oval depending on the latitude.'))
label.set_valign(Gtk.Align.END)
self.window.vbox.pack_start(label, False, True, 0)
adj = Gtk.Adjustment(1.0, 0.1, 3.0, 0.1, 0, 0)
adj = Gtk.Adjustment(value=1.0, lower=0.1, upper=3.0,
step_increment=0.1, page_increment=0, page_size=0)
# default value is 1.0, minimum is 0.1 and max is 3.0
slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=adj)