Skip to content
Snippets Groups Projects
Commit 196e3c40 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Added labels for scale; removed print statements from tkprop.py

parent d5efd537
No related branches found
No related tags found
No related merge requests found
......@@ -170,8 +170,6 @@ class Number(PropertyBase):
def __set__(self, instance, value):
print('Attempt to set {} to {}'.format(self.label, value))
if self.minval is not None and value < self.minval:
raise ValueError('{} must be at least {}'.format(
self.label, self.minval))
......@@ -180,8 +178,6 @@ class Number(PropertyBase):
raise ValueError('{} must be at most {}'.format(
self.label, self.maxval))
print('Success')
super(Number, self).__set__(instance, value)
......
......@@ -68,10 +68,30 @@ def _Number(parent, propObj, tkProp, tkVar):
if makeScale:
# TODO labels
widget = ttk.Scale(parent, orient=tk.HORIZONTAL,
scaleFrame = ttk.Frame(parent)
scaleFrame.columnconfigure(0, weight=1)
scaleFrame.columnconfigure(1, weight=1)
scaleFrame.columnconfigure(2, weight=1)
widget = ttk.Scale(scaleFrame, orient=tk.HORIZONTAL,
from_=minval, to=maxval,
variable=tkVar)
minLabel = ttk.Label(scaleFrame, text='{}'.format(minval), anchor=tk.W)
curLabel = ttk.Label(scaleFrame, text='{}'.format(value), anchor=tk.CENTER)
maxLabel = ttk.Label(scaleFrame, text='{}'.format(maxval), anchor=tk.E)
widget .grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W, columnspan=3)
minLabel.grid(row=1, column=0, sticky=tk.W)
curLabel.grid(row=1, column=1)
maxLabel.grid(row=1, column=2, sticky=tk.E)
def updateLabel(*args):
curLabel.config(text='{:0.6}'.format(tkVar.get()))
tkVar.trace("w", updateLabel)
widget = scaleFrame
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment