user11918388
user11918388

Reputation:

how to assign an attribute of tkinter.scale with stringvar?

I want to make a Scale and assign it's "to" attribute with 0 and "from_" attribute with a stringvar like this.

import tkinter
str=tkinter.StringVar()
gui=tkinter.Tk()
s=tkinter.Scale(gui,from_="0",to=str)
str.set("50")

I also tried this:

import tkinter
str=tkinter.doubleVar()
gui=tkinter.Tk()
s=tkinter.Scale(gui,from_=0,to=str)
str.set(50)

I am stuck at this point

Upvotes: 1

Views: 305

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386220

You cannot do what you want. The from_ and to options require static values.

If you want to change the to value after creating the widget you will need to explicitly configure it (eg: s.configure(to=str.get())

Upvotes: 1

Related Questions