Window pos from config-file

Started by HPW, October 25, 2003, 01:41:37 PM

Previous topic - Next topic

HPW

When you start newlisp several times it pop up on different locations.

Not so nice.



Modifying newlisp-tk.tcl helps:



Add to global vars:



set Ide(WinPosX)            "+100"
set Ide(WinPosY)            "+50"


Add to proc Setupconsole



wm title . $IDEversion      #Behind this line
wm geometry . $Ide(WinPosX)$Ide(WinPosY)


Then wrapp it. The next time you save the settings the new Property appear in the config-file. There you can set them without wrapping.

A plus-sign in front of the value indicates a distance from the left (top) and a minus-sign from the right (bottom).

Setting to an empty string bring back the old behaviour.





Still want to know how to read and set TK-variables from lisp?
Hans-Peter

Lutz

#1
Thanks for posting all these improvements in the Tcl.Tk code. About setting variables in Tcl/Tk: I just try to avoid it and work with the return values from the 'tk' statement stored in LISP variables.



To declare Tcl variables from newLISP, I think you would have to create a child interpreter. But I never went much into Tcl/Tk and newlisp-tk.tcl is the only program in Tcl/Tk I have ever written.



Today I am trying to concentrate on newLISP itself and advance the non-graphical aspects of it.



Lutz

HPW

#2
With this modified proc the pos is stored when you save the settings.


proc SaveSettings {} {

global Ide txt statusText

set posxprefix "+"
set posyprefix "+"

set Ide(WinPosX) [append posxprefix [winfo x .]]
set Ide(WinPosY) [append posyprefix [winfo y .]]

set initFile [open "newlisp-tk.config" w]

puts $initFile "# newlisp-tk.config - newLISP Tcl/Tk configuration file"
puts $initFile "#"
puts $initFile {# This file is generated by menu "Options/Save settings"}
puts $initFile "#n"

foreach idx [lsort [array names Ide]] {
puts $initFile "set Ide($idx) "$Ide($idx)""
}

close $initFile

set statusText {Saved settings in intcalc.config}
}
Hans-Peter

Lutz

#3
thankyou , I will put this in the next version



Lutz

Lutz

#4
we can just do:



set Ide(WinPosX) [winfo x .]
set Ide(WinPosY) [winfo y .]

// and when displaying:

wm geometry . +$Ide(WinPosX)+$Ide(WinPosY)


saves a little bit of code



Lutz

HPW

#5
Thanks for it!



By the way:



set Ide(Console....



In my own special main-tcl I have changed all first chars of the

Ide-var-names to capital letters, because they are sorted by

them when it save the config. This is case-sensitive and so

I get a  clean alpha-sort when all are capital letters.



But it's just cosmetic. :-)
Hans-Peter