Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slider GUI help
#1
I have a HW assignment where I need to control volume in a tank. I need a slider scale to set the desired height of the tank. If the desired tank height is higher than the actual then it will increase and vice versa. To accomplish this I need to be able to get the value of the slider as it is changed. For this part of the assignment I wrote this code however when run and the slider position is changed the GUI crashes. Any tips on how to correct this would be appreciated. Here is the code for the slider and a label to hold the slider value.
from tkinter import *
####################
root = Tk()
root.title('Tank Slider')
root.geometry('400x400')
######################
def StartC():
    while ( 2 > 1 ):
        SliderVal()

def SliderVal():
    Svalue["text"]=Slider.get()
############################
Slider = Scale(root, from_=100, to=0, length=200,bg='#80c1ff')
Slider.pack()

Svalue = Label(root,text=" ")
Svalue.pack()

StartB = Button(root,text="Start", command=StartC)
StartB.pack()
###########################
root.mainloop()
Reply


Messages In This Thread
Slider GUI help - by thass23 - Dec-02-2020, 04:04 PM
RE: Slider GUI help - by Axel_Erfurt - Dec-02-2020, 04:18 PM
RE: Slider GUI help - by thass23 - Dec-02-2020, 04:29 PM
RE: Slider GUI help - by Axel_Erfurt - Dec-02-2020, 04:53 PM
RE: Slider GUI help - by deanhystad - Dec-02-2020, 06:29 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020