Python Forum
tkinter slider question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter slider question
#1
Hello guys.I have a question about a tutorial I saw and I don't understand something.
So, I have the following code that has 2 sliders.
from tkinter import *

root = Tk()
root.geometry("800x700")

def vertical_num(var):
    my_label = Label(root , text = vertical_slider.get() )
    my_label.place(x=650,y=100)
    
def horizontal_num(var):
    my_label = Label(root , text = horizontal_slider.get() )
    my_label.place(x=100,y=100)
    

vertical_slider = Scale(root , from_ = 0 , to = 400 , command = vertical_num)
vertical_slider.pack()

horizontal_slider = Scale(root , from_ = 0 , to = 400 , orient = HORIZONTAL , command = horizontal_num)
horizontal_slider.pack()


root.mainloop()
I want to get the values of sliders in real time (when I change the position of sliders of course) and I don't understand the point of passing an argument in these two functions I have.Without these arguments, I receive errors.

I don't use them inside functions.
So, what's the point of passing arguments in these 2 functions.
It's weird.

Thanks a lot!!
Reply


Messages In This Thread
tkinter slider question - by Nick_tkinter - Feb-21-2021, 10:05 PM
RE: tkinter slider question - by deanhystad - Feb-22-2021, 01:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  neeed to activate a custom tk slider janeik 1 1,910 Oct-09-2023, 09:29 AM
Last Post: deanhystad
  Beginner question re: Tkinter geometry return2sender 3 2,069 Jun-19-2023, 06:19 PM
Last Post: deanhystad
  Tkinter GUI question texan1836 3 3,931 Apr-13-2023, 03:12 AM
Last Post: deanhystad
  simple tkinter question function call not opening image gr3yali3n 5 6,301 Aug-02-2022, 09:13 PM
Last Post: woooee
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 3,130 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  Python tkinter question tablet Nick_tkinter 8 7,162 Mar-04-2021, 10:44 PM
Last Post: Larz60+
  [Tkinter] Noob question:Using pyttsx3 with tkinter causes program to stop and close, any ideas? Osman_P 4 7,297 Nov-14-2020, 10:51 AM
Last Post: Osman_P
  question on tkinter canvas PhotoImage gr3yali3n 1 2,896 Sep-05-2020, 12:18 PM
Last Post: Larz60+
  Tkinter parameter question DPaul 2 2,972 Mar-14-2020, 09:35 AM
Last Post: DPaul
  Newbie question with Tkinter Entry mariolopes 2 3,029 Oct-12-2019, 11:02 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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