Skip to content

Commit

Permalink
Improvements to the update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Feb 26, 2015
1 parent c733e19 commit fd635ae
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions commands/update_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,19 @@ def __init__(self, parent, tdb, tdenv):
parent.wm_attributes("-topmost", sticky)


def selectWidget(self, widget, newValue=None):
if newValue is not None:
widget.val.set(newValue)
widget.focus_set()
widget.selection_range(0, tk.END)


def focusOn(self, displayNo, pos):
""" Set focus to a widget and select the text in it """

row = self.itemDisplays[displayNo]
widget = row[pos][0]
widget.focus_set()
widget.selection_range(0, tk.END)
self.selectWidget(widget)


def setValue(self, row, pos, value):
Expand Down Expand Up @@ -230,8 +236,7 @@ def checkValueAgainstStats(self, widget, stats):
cr, minCr,
))
if not ok:
widget.val.set("")
widget.focus_set()
self.selectWidget(widget, "")
return False
widget.configure(bg = '#ff8080')

Expand All @@ -248,8 +253,7 @@ def checkValueAgainstStats(self, widget, stats):
cr, maxCr,
))
if not ok:
widget.val.set("")
widget.focus_set()
self.selectWidget(widget, "")
return False
widget.configure(bg = '#8080ff')

Expand Down Expand Up @@ -343,8 +347,7 @@ def validate(self, widget):
parent=widget,
)
if not ok:
widget.val.set("")
widget.focus_set()
self.selectWidget(widget, "")
return False

return True
Expand Down Expand Up @@ -373,6 +376,7 @@ def validate(self, widget):
"EXAMPLE: If the UI says '2341 LOW', type '2341L'.\n"
)
widget.val.set("?")
self.selectWidget(widget)
return False

return True
Expand Down

0 comments on commit fd635ae

Please sign in to comment.