Scale Class Module#

scaleClass module#

Module containing TtkScale based on the ttk Scale with the enhancements. The following options are added:-

  • display

    a range of values, corresponding to the from and to attributes.

  • tickinterval

    the interval between the values in the range

  • showvalue

    whether the Scale displays the actual value beside the slider

  • digits

    the number of decimal places shown in the actual value display

  • resolution

    the amount the slider will move if the trough is cliced

  • sliderlength

    the length used in calculating the range

  • length

    this value is overwritten if the range requires extra space

class scaleClass.TtkScale(parent, length=0, from_=0, to=255, orient='horizontal', variable=0, digits=0, tickinterval=None, sliderlength=32, command=None, style=None, showvalue=True, resolution=1)#

Bases: Scale

Enhanced ttk Scale

Parameters:
  • parent (str) -- The parent tk widget, normally a Frame.

  • length (int) -- The Scale length in pixels.

  • from (int) -- The minimum extent of the range.

  • to (int) -- the maximum extent of slider movement.

  • orient (str) -- Either 'horizontal' or 'vertical'

  • variable (var) -- Name of a tkinter variable.

  • digits (int) -- Number of decimal places displayed on actual value.

  • tickinterval (int or float) -- Spacing between range values.

  • sliderlength (int) -- Length used to set range position.

  • command (var) -- Method that is called whenever the slider moves.

  • style (str) -- Used to set the Scale's appearance.

  • showvalue (bool) -- True turns on the actual display value.

  • resolution (int) -- Amount slider moves when the trough is clicked, in pixels.

build(to, rel_min, rel_max, range_vals, len_rvs)#

Creates the Labels used to show the range and the first actual value.

Parameters:
  • to (int) -- The maximum extent of slider movement.

  • rel_min (float) -- The range's minimum position as a relative size of the Scale.

  • rel_max (float) -- The range's maximum position as a relative size of the Scale.

  • range_vals (tuple of int or floats) -- The values shown in the range.

  • len_rvs (int) -- Size of the range values.

convert_to_act(curr_val)#

Method to convert the actual value to an actual position.

Parameters:

curr_val (float) -- Actual value of the Scale.

Return type:

float

convert_to_rel(curr_val)#

Method to convert the actual value to a relative position.

Parameters:

curr_val (float) -- Actual value of the Scale.

Return type:

float

display_value(value)#

Position (in pixel) of the centre of the slider.

Parameters:

value (float) -- Actual value of the Scale.

Return type:

float

resolve(evt)#
Enables mouse click in trough to move slider selected pixel

amount

Parameters:

evt (str) -- Actual position of the cursor.