Window pos from config-file

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Window pos from config-file

Post 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?
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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}
	}
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

thankyou , I will put this in the next version

Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post 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. :-)
Hans-Peter

Locked