Package param :: Module tk :: Class TaggedSlider
[hide private]
[frames] | no frames]

Class TaggedSlider

source code


Widget for manipulating a numeric value using either a slider or a text-entry box, keeping the two values in sync.

Generates a number of Events:

<<TagFocusOut>> - tag loses focus <<TagReturn>> - Return pressed in tag <<SliderSet>> - slider is clicked/dragged

Nested Classes [hide private]

Inherited from Tkinter.Misc: getdouble, getint

Instance Methods [hide private]
 
__init__(self, master, variable, bounds=(0, 1), inclusive_bounds=(True, True), slider_length=100, tag_width=10, tag_extra_config={}, slider_extra_config={})
On clicking or dragging the slider, the tag value is set to the slider's value.
source code
 
tag_set(self)
After entering a value into the tag, this method should be called to set the slider correctly.
source code
 
set_slider_bounds(self, lower, upper, inclusive_bounds=None)
Set new lower and upper bounds for the slider.
source code
 
set_bounds(self, lower, upper, inclusive_bounds=None)
Set new lower and upper bounds for the slider.
source code
 
config(self, **options)
TaggedSlider is a compound widget.
source code
 
get(self)
Calls the tag's get() method.
source code
 
_slider_used(self, event=None) source code
 
_tag_press_return(self, event=None) source code
 
_tag_focus_out(self, event=None) source code
 
_set_slider_resolution(self, value) source code
 
_try_to_set_slider_resolution(self)
Use the actual number in the box to set the slider's resolution, so that user-entered resolutions are respected (e.g.
source code
 
_try_to_set_slider(self)
If the value in the box can't be converted to a float, the slider doesn't get set.
source code

Inherited from Tkinter.BaseWidget: destroy

Inherited from Tkinter.BaseWidget (private): _do, _setup

Inherited from Tkinter.Misc: __contains__, __getitem__, __setitem__, __str__, after, after_cancel, after_idle, bbox, bell, bind, bind_all, bind_class, bindtags, cget, clipboard_append, clipboard_clear, clipboard_get, colormodel, columnconfigure, configure, deletecommand, event_add, event_delete, event_generate, event_info, focus, focus_displayof, focus_force, focus_get, focus_lastfor, focus_set, getboolean, getvar, grab_current, grab_release, grab_set, grab_set_global, grab_status, grid_bbox, grid_columnconfigure, grid_location, grid_propagate, grid_rowconfigure, grid_size, grid_slaves, image_names, image_types, keys, lift, lower, mainloop, nametowidget, option_add, option_clear, option_get, option_readfile, pack_propagate, pack_slaves, place_slaves, propagate, quit, register, rowconfigure, selection_clear, selection_get, selection_handle, selection_own, selection_own_get, send, setvar, size, slaves, tk_bisque, tk_focusFollowsMouse, tk_focusNext, tk_focusPrev, tk_menuBar, tk_setPalette, tk_strictMotif, tkraise, unbind, unbind_all, unbind_class, update, update_idletasks, wait_variable, wait_visibility, wait_window, waitvar, winfo_atom, winfo_atomname, winfo_cells, winfo_children, winfo_class, winfo_colormapfull, winfo_containing, winfo_depth, winfo_exists, winfo_fpixels, winfo_geometry, winfo_height, winfo_id, winfo_interps, winfo_ismapped, winfo_manager, winfo_name, winfo_parent, winfo_pathname, winfo_pixels, winfo_pointerx, winfo_pointerxy, winfo_pointery, winfo_reqheight, winfo_reqwidth, winfo_rgb, winfo_rootx, winfo_rooty, winfo_screen, winfo_screencells, winfo_screendepth, winfo_screenheight, winfo_screenmmheight, winfo_screenmmwidth, winfo_screenvisual, winfo_screenwidth, winfo_server, winfo_toplevel, winfo_viewable, winfo_visual, winfo_visualid, winfo_visualsavailable, winfo_vrootheight, winfo_vrootwidth, winfo_vrootx, winfo_vrooty, winfo_width, winfo_x, winfo_y

Inherited from Tkinter.Misc (private): _bind, _configure, _displayof, _getboolean, _getdoubles, _getints, _grid_configure, _nametowidget, _options, _register, _report_exception, _root, _substitute

Inherited from Tkinter.Pack: forget, info, pack, pack_configure, pack_forget, pack_info

Inherited from Tkinter.Place: place, place_configure, place_forget, place_info

Inherited from Tkinter.Grid: grid, grid_configure, grid_forget, grid_info, grid_remove, location

Class Variables [hide private]

Inherited from Tkinter.Misc: _noarg_

Inherited from Tkinter.Misc (private): _subst_format, _subst_format_str, _tclCommands

Method Details [hide private]

__init__(self, master, variable, bounds=(0, 1), inclusive_bounds=(True, True), slider_length=100, tag_width=10, tag_extra_config={}, slider_extra_config={})
(Constructor)

source code 

On clicking or dragging the slider, the tag value is set to the slider's value.

On pressing Return in or moving focus from the tag, the slider value is set, but also:

  • the range of the slider is adjusted (e.g. to fit a larger max value)
  • the resolution of the slider is adjusted based on the the value in the tag (e.g. 0.01 in the tag gives a resolution of 0.01), also taking into account the precision of the value in the tag (e.g. 0.0100 gives a resolution of 0.0001).
Overrides: Tkinter.BaseWidget.__init__

tag_set(self)

source code 

After entering a value into the tag, this method should be called to set the slider correctly.

(Called automatically for tag's <Return> and <FocusOut> events.)

set_slider_bounds(self, lower, upper, inclusive_bounds=None)

source code 

Set new lower and upper bounds for the slider.

If specified, inclusive_bounds should be a sequence of length 2 specifying True or False for the lower and upper bounds.

set_bounds(self, lower, upper, inclusive_bounds=None)

source code 

Set new lower and upper bounds for the slider.

If specified, inclusive_bounds should be a sequence of length 2 specifying True or False for the lower and upper bounds.

config(self, **options)

source code 

TaggedSlider is a compound widget. In most cases, config options should be passed to one of the component widgets (i.e. the tag or the slider). For some options, however, we need to handle them being set on the widget as a whole; further, some of these should be applied to both component widgets, but some should just be applied to one.

Options handled: * state (applied to both) * background, foreground (applied to tag only)

Overrides: Tkinter.Grid.grid_configure

get(self)

source code 

Calls the tag's get() method.

Helps to match behavior of other Tkinter Widgets.

_try_to_set_slider_resolution(self)

source code 

Use the actual number in the box to set the slider's resolution, so that user-entered resolutions are respected (e.g. 0.1 vs 0.1000).

If that's not possible (e.g. there's text in the box), use the value contained in the variable (because whatever owns the variable could have performed a conversion of the text - TkParameterized does this, for instance).

Leaves the resolution as it was if no number is available.