Mercurial > code > home > repos > light9
changeset 836:dc35587fbbb6
hack up the window-save-position code to try to ignore automatic size changes at start
Ignore-this: c563fa4e2f0a42444afd5ad223e84cb9
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 05 Jun 2013 00:11:22 +0000 |
parents | 9c8583cd14ea |
children | f3364e9f5c03 |
files | light9/uihelpers.py |
diffstat | 1 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/uihelpers.py Tue Jun 04 23:52:27 2013 +0000 +++ b/light9/uihelpers.py Wed Jun 05 00:11:22 2013 +0000 @@ -2,10 +2,14 @@ from __future__ import nested_scopes #from Tkinter import Button +import logging, time from rdflib import Literal from Tix import Button, Toplevel, Tk, IntVar, Entry, DoubleVar +import Tkinter from light9.namespaces import L9 +log = logging.getLogger("toplevel") + windowlocations = { 'sub' : '425x738+00+00', 'console' : '168x24+848+000', @@ -39,6 +43,7 @@ lastSaved = [None] setOnce = [False] + graphSetTime = [0] def setPosFromGraphOnce(): """ the graph is probably initially empty, but as soon as it gives @@ -47,22 +52,31 @@ if setOnce[0]: return geo = graph.value(session, L9.windowGeometry) + log.debug("setPosFromGraphOnce %s", geo) if geo is not None and geo != lastSaved[0]: setOnce[0] = True tl.geometry(geo) lastSaved[0] = geo - - def savePos(): - geo = tl.geometry() + graphSetTime[0] = time.time() - # todo: need a way to filter out the startup window sizes that - # weren't set by the user - if geo.startswith("1x1") or geo.startswith(("378x85", "378x86")): + def savePos(ev): + geo = tl.geometry() + if not isinstance(ev.widget, Tkinter.Tk): + # I think these are due to internal widget size changes, + # not the toplevel changing return + # this is trying to not save all the startup automatic window + # sizes. I don't have a better plan for this yet. + if graphSetTime[0] == 0 or time.time() < graphSetTime[0] + 3: + return + if geo == lastSaved[0]: return + if not setOnce[0]: + return lastSaved[0] = geo + log.debug("saving position %s", geo) graph.patchObject(session, session, L9.windowGeometry, Literal(geo)) if graph is not None and session is not None: @@ -72,7 +86,8 @@ tl.geometry(positionOnCurrentDesktop(windowlocations[name])) if graph is not None: - tl._toplevelat_funcid = tl.bind("<Configure>",lambda ev,tl=tl,name=name: savePos()) + tl._toplevelat_funcid = tl.bind("<Configure>", + lambda ev,tl=tl,name=name: savePos(ev)) return tl