def key_down(self, event): k = event.key if k == 'left_arrow' or k == 'up_arrow': self._nudge_value(-1) elif k == 'right_arrow' or k == 'down_arrow': self._nudge_value(1) else: GSlider.key_down(self, event)
def __init__(self, orient, **kwds): win = ui.CreateSliderCtrl() win_flags = win_base_flags | win_no_ticks try: style = win_styles[orient] except KeyError: raise ValueError("Invalid Slider orientation %r" % orient) l = self._default_length b = self._default_breadth if orient == 'h': rect = (0, 0, l, b) else: rect = (0, 0, b, l) win.CreateWindow(style | win_flags, rect, win_none, 0) win.SetRange(0, win_continuous_range) GSlider.__init__(self, _win = win, **kwds)
def __init__(self, orient='h', ticks=0, **kwds): length = 100 if ticks: breadth = 30 else: breadth = 22 # Same as default height of a text-containing control if orient == 'h': ns_frame = ((0, 0), (length, breadth)) elif orient == 'v': ns_frame = ((0, 0), (breadth, length)) else: raise ValueError("Invalid orientation, should be 'h' or 'v'") ns_slider = PyGUI_NSSlider.alloc().initWithFrame_(ns_frame) ns_slider.pygui_component = self ns_set_action(ns_slider, 'doAction:') GSlider.__init__(self, _ns_view=ns_slider, **kwds) self.set_ticks(ticks) self._last_value = None
def __init__(self, orient = 'h', ticks = 0, **kwds): length = 100 if ticks: breadth = 30 else: breadth = 22 # Same as default height of a text-containing control if orient == 'h': ns_frame = ((0, 0), (length, breadth)) elif orient == 'v': ns_frame = ((0, 0), (breadth, length)) else: raise ValueError("Invalid orientation, should be 'h' or 'v'") ns_slider = PyGUI_NSSlider.alloc().initWithFrame_(ns_frame) ns_slider.pygui_component = self ns_set_action(ns_slider, 'doAction:') GSlider.__init__(self, _ns_view = ns_slider, **kwds) self.set_ticks(ticks) self._last_value = None
def __init__(self, orient='h', ticks=0, **kwds): self._orient = orient self._ticks = ticks self._discrete = False self._live = True self._gtk_ticks = None length = 100 gtk_adjustment = gtk.Adjustment(upper=1.0) xs = 0.0 ys = 0.0 if orient == 'h': gtk_scale = gtk.HScale(gtk_adjustment) gtk_scale.set_size_request(length, -1) gtk_box = gtk.VBox() xs = 1.0 elif orient == 'v': gtk_scale = gtk.VScale(gtk_adjustment) gtk_scale.set_size_request(-1, length) gtk_box = gtk.HBox() ys = 1.0 else: raise ValueError("Invalid orientation, should be 'h' or 'v'") gtk_scale.set_draw_value(False) self._gtk_scale = gtk_scale gtk_box.pack_start(gtk_scale) self._gtk_box = gtk_box if ticks: self._gtk_create_ticks() gtk_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=xs, yscale=ys) gtk_alignment.add(gtk_box) gtk_alignment.show_all() self._gtk_connect(gtk_adjustment, 'value-changed', self._gtk_value_changed) self._gtk_connect(gtk_scale, 'change-value', self._gtk_change_value) self._gtk_connect(gtk_scale, 'button-release-event', self._gtk_button_release) self._gtk_scale = gtk_scale self._gtk_adjustment = gtk_adjustment self._gtk_enable_action = True GSlider.__init__(self, _gtk_outer=gtk_alignment, **kwds)
def __init__(self, orient = 'h', ticks = 0, **kwds): self._orient = orient self._ticks = ticks self._discrete = False self._live = True self._gtk_ticks = None length = 100 gtk_adjustment = Gtk.Adjustment(upper = 1.0) xs = 0.0 ys = 0.0 if orient == 'h': gtk_scale = Gtk.HScale(gtk_adjustment) gtk_scale.set_size_request(length, -1) gtk_box = Gtk.VBox() xs = 1.0 elif orient == 'v': gtk_scale = Gtk.VScale(gtk_adjustment) gtk_scale.set_size_request(-1, length) gtk_box = Gtk.HBox() ys = 1.0 else: raise ValueError("Invalid orientation, should be 'h' or 'v'") gtk_scale.set_draw_value(False) self._gtk_scale = gtk_scale gtk_box.pack_start(gtk_scale, True, True, 0) self._gtk_box = gtk_box if ticks: self._gtk_create_ticks() gtk_alignment = Gtk.Alignment.new(xalign = 0.5, yalign = 0.5, xscale = xs, yscale = ys) gtk_alignment.add(gtk_box) gtk_alignment.show_all() self._gtk_connect(gtk_adjustment, 'value-changed', self._gtk_value_changed) self._gtk_connect(gtk_scale, 'change-value', self._gtk_change_value) self._gtk_connect(gtk_scale, 'button-release-event', self._gtk_button_release) self._gtk_scale = gtk_scale self._gtk_adjustment = gtk_adjustment self._gtk_enable_action = True GSlider.__init__(self, _gtk_outer = gtk_alignment, **kwds)
def do_action(self): value = self._ns_view.doubleValue() if value <> self._last_value: self._last_value = value GSlider.do_action(self)