python - Tkinter Scale and floats when resolution > 1 -
how can float values scale when resolution above 1? if set resolution below 1, example 0.9, scale give floats. above 1, , can integers.
example code:
from tkinter import * root = tk() var = doublevar() scale = scale(root, variable=var, resolution=3.4) scale.pack() label = label(root, textvariable=var) label.pack() root.mainloop()
i'm using python 3.4.1 64-bit on windows 7.
troubles scale() widget mvc visual-part
doublevar()
not allow control ui presentation ( visual-part ) of scale()
( depth of decimal places ), while model-part remains correct ( though hidden, might inspected via ascaleinstance.get()
).
a workaround mock-up:
from tkinter import * # python 3+ root = tk() varastxt = stringvar() # mvc-trick indirect value-holder ascale = scale( root, variable = varastxt, # mvc-model-part value holder from_ = -10.0, # mvc-model-part value-min-limit = 10.0, # mvc-model-part value-max-limit length = 600, # mvc-visual-part layout geometry [px] digits = 4, # mvc-visual-part presentation trick resolution = 0.23 # mvc-controller-part stepping ) ascale.pack() root.lift()
Comments
Post a Comment