Page 1 of 1

Window pos from config-file

Posted: Sat Oct 25, 2003 8:41 pm
by 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:

Code: Select all

set Ide(WinPosX)            "+100"
set Ide(WinPosY)            "+50"
Add to proc Setupconsole

Code: Select all

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?

Posted: Sun Oct 26, 2003 12:37 pm
by Lutz
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

Posted: Wed Nov 12, 2003 8:03 am
by HPW
With this modified proc the pos is stored when you save the settings.

Code: Select all

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}
	}

Posted: Wed Nov 12, 2003 1:03 pm
by Lutz
thankyou , I will put this in the next version

Lutz

Posted: Wed Nov 12, 2003 2:11 pm
by Lutz
we can just do:

Code: Select all

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

Posted: Wed Nov 12, 2003 3:18 pm
by HPW
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. :-)