All pastes #2036034 Raw Edit

Mine

public text v1 · immutable
#2036034 ·published 2011-01-01 20:37 UTC
rendered paste body
From 0753fbd5f5cf1584dbd2b7e62202f25f272feab2 Mon Sep 17 00:00:00 2001
From: Sebastian Kuzminsky <seb@highlab.com>
Date: Mon, 20 Dec 2010 17:19:27 -0700
Subject: [PATCH 1/4] remember the axis window geometry

At startup, try to read the [DEFAULT]window_geometry from
~/.axis_preferences; if it's found, set the window geometry to that
string.  If the string is "maximize", maximize the window.

Trap the <Configure> event (that's how Tcl/Tk spells "resize"), and
update the [DEFAULT]window_geometry with the new geometry.
---
 src/emc/usr_intf/axis/scripts/axis.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/emc/usr_intf/axis/scripts/axis.py b/src/emc/usr_intf/axis/scripts/axis.py
index 6ba0145..b3b9a4b 100755
--- a/src/emc/usr_intf/axis/scripts/axis.py
+++ b/src/emc/usr_intf/axis/scripts/axis.py
@@ -108,6 +108,14 @@ class AxisPreferences(cp):
 ap = AxisPreferences()
 
 root_window = Tkinter.Tk(className="Axis")
+
+window_geometry = ap.getpref('window_geometry', default='', type=str)
+print "got window geometry [%s]" % window_geometry
+if window_geometry == 'maximized':
+    window_geometry = "=%dx%d+0+0" % (root_window.winfo_screenwidth(), root_window.winfo_screenheight())
+if window_geometry != '':
+    root_window.wm_geometry(window_geometry)
+
 nf.start(root_window)
 nf.makecommand(root_window, "_", _)
 rs274.options.install(root_window)
@@ -2480,6 +2488,9 @@ def reload_file(refilter=True):
         o.set_highlight_line(line)
  
 class TclCommands(nf.TclCommands):
+    def resize_callback(event):
+        ap.putpref('window_geometry', root_window.wm_geometry(None), str)
+
     def toggle_preview(event=None):
         current = widgets.right.raise_page()
         if current == "preview": widgets.right.raise_page("numbers")
@@ -3501,6 +3512,7 @@ root_window.bind("<End>", commands.touch_off)
 root_window.bind("<Control-KP_Home>", kp_wrap(commands.home_all_axes, "KeyPress"))
 root_window.bind("<Shift-KP_Home>", kp_wrap(commands.set_axis_offset, "KeyPress"))
 root_window.bind("<KP_End>", kp_wrap(commands.touch_off, "KeyPress"))
+root_window.bind("<Configure>", commands.resize_callback)
 widgets.mdi_history.bind("<Configure>", "%W see end" )
 widgets.mdi_history.bind("<ButtonRelease-1>", commands.mdi_history_butt_1)
 widgets.mdi_history.bind("<Double-Button-1>", commands.mdi_history_double_butt_1)
-- 
1.7.0.4