summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jepler@unpythonic.net>2014-06-11 16:28:51 -0500
committerChris Radek <chris@timeguy.com>2014-06-11 17:45:25 -0500
commitda8f3016aeae1bf1bcc7ef9cb00950c2c0e70a85 (patch)
tree68e22ca96e48fdf425b55f0de489ed0918d007f8
parente137bd011d559970073575cdef552c543ce2d4a7 (diff)
downloadlinuxcnc-da8f3016aeae1bf1bcc7ef9cb00950c2c0e70a85.tar.gz
linuxcnc-da8f3016aeae1bf1bcc7ef9cb00950c2c0e70a85.zip
linuxcnctop: fix the crawling scrollbar in many cases
.. by only changing the necessary part of the text, the 'crawl' is usually avoided. It might still occur in cases when a changing value is one that is split across more than two lines (at least this is the pattern I believed I saw when working on this problem). It looks and smells like a Tk bug but oh well
-rw-r--r--src/emc/usr_intf/axis/scripts/linuxcnctop.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/emc/usr_intf/axis/scripts/linuxcnctop.py b/src/emc/usr_intf/axis/scripts/linuxcnctop.py
index 6d85c7422..f9ee4a9c4 100644
--- a/src/emc/usr_intf/axis/scripts/linuxcnctop.py
+++ b/src/emc/usr_intf/axis/scripts/linuxcnctop.py
@@ -129,7 +129,6 @@ def gui():
s.poll()
except linuxcnc.error:
root.destroy()
- pos = t.yview()[0]
selection = t.tag_ranges("sel")
insert_point = t.index("insert")
insert_gravity = t.mark_gravity("insert")
@@ -138,7 +137,6 @@ def gui():
anchor_gravity = t.mark_gravity("anchor")
except TclError:
anchor_point = None
- t.delete("0.0", "end")
first = True
for k in dir(s):
if k.startswith("_"): continue
@@ -150,19 +148,25 @@ def gui():
v = m(v)
else:
v = m.get(v, v)
+ if isinstance(v, basestring):
+ v = v.strip()
+ v = v or "-"
if oldvalues.has_key(k):
changed = oldvalues[k] != v
if changed: changetime[k] = time.time() + 2
oldvalues[k] = v
+ vranges = t.tag_ranges(k)
if changetime.has_key(k) and changetime[k] >= time.time():
vtag = "changedvalue"
else:
vtag = "value"
- if first: first = False
- else: t.insert("end", "\n")
- t.insert("end", k, "key", "\t")
- t.insert("end", v, vtag)
- t.yview_moveto(pos)
+ if vranges:
+ t.tk.call(t, "replace", "%s.first" % k, "%s.last" % k, v, (k, vtag))
+ else:
+ if first: first = False
+ else: t.insert("end", "\n")
+ t.insert("end", k, "key", "\t")
+ t.insert("end", v, (k, vtag))
if selection:
t.tag_add("sel", *selection)
t.mark_set("insert", insert_point)