Добавить
Уведомления

Tkinter Scale to set and get value by moving slider with orient & other options and methods

We can use one Scale widget to slide the slider and display the value. We can also use set() and get() methods to fix the value or read the value of the scale. We can provide the from_ and to options to give a range over which the Scale widget can be used. Slider of the scale widget can be moved keeping this start and end values. By default the orientation of the scale is vertical but by setting the option orient to horizontal we can place it along with the x axis. We can read the value and copy the same to another scale by using set() and get() methods by click of a button. We can trigger a function on click of a button and set the value of second Scale after reading the value of first scale. my_scale2.set(my_scale1.get()) By using a command option we can trigger the function to read and set the value so no need of any button click event. We can connect spinbox widget to scale widget so once the spin box value is changed, same will be reflected in scale widget. Here one common string variable will be used. We can enable or disable a scale by using state option. We can use other options like bg ( background colour ) , fg ( font colour ) , bd ( border width ) , activebackground colour. We can change the cursor shape when mouse is over the scale by using cursor option. The list of cursor shapes we can use is available in the link at description. We can manage the length of the cursor by updating length option. By using relief option we can change the style of the border. It can take values raised , sunken ,flat, ridge, solid & groove. We can manage the length of the slider by using option sliderlength. The value shown above the slider ( based on slider position ) can be hidden by using showvalue=0 https://www.plus2net.com/python/tkinter-scale.php #scalewidget #tkitnerscale #sliderwidget #guiScale #plus2net #tkinter #python #scaleoptions #scalemethods

12+
16 просмотров
2 года назад
12+
16 просмотров
2 года назад

We can use one Scale widget to slide the slider and display the value. We can also use set() and get() methods to fix the value or read the value of the scale. We can provide the from_ and to options to give a range over which the Scale widget can be used. Slider of the scale widget can be moved keeping this start and end values. By default the orientation of the scale is vertical but by setting the option orient to horizontal we can place it along with the x axis. We can read the value and copy the same to another scale by using set() and get() methods by click of a button. We can trigger a function on click of a button and set the value of second Scale after reading the value of first scale. my_scale2.set(my_scale1.get()) By using a command option we can trigger the function to read and set the value so no need of any button click event. We can connect spinbox widget to scale widget so once the spin box value is changed, same will be reflected in scale widget. Here one common string variable will be used. We can enable or disable a scale by using state option. We can use other options like bg ( background colour ) , fg ( font colour ) , bd ( border width ) , activebackground colour. We can change the cursor shape when mouse is over the scale by using cursor option. The list of cursor shapes we can use is available in the link at description. We can manage the length of the cursor by updating length option. By using relief option we can change the style of the border. It can take values raised , sunken ,flat, ridge, solid & groove. We can manage the length of the slider by using option sliderlength. The value shown above the slider ( based on slider position ) can be hidden by using showvalue=0 https://www.plus2net.com/python/tkinter-scale.php #scalewidget #tkitnerscale #sliderwidget #guiScale #plus2net #tkinter #python #scaleoptions #scalemethods

, чтобы оставлять комментарии