Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using option db to store data other than tk config options

40 views
Skip to first unread message

Bezoar

unread,
Mar 11, 2018, 11:11:57 PM3/11/18
to
Suppose I have a text widget that I want to display some text on start up. I also want to save it in the options db. Supposedly, from what I read I can do this.

option add .frame1.text.Startcontents "Please load a file" widgetDefault

where .frame1.text is the widget path Startcontents is the class and "Please load a file" is the value. To retrieve I used the 'option get <path> <name> <class>' command. in this case my name and class are the same. I have tried many permutations but none work.

option get .frame1.text Startcontents Startcontents

I have also set the font in the options database and retrieved it successfully at the same point in the code as the one above. What am I doing wrong and/or is it not possible to store data outside what a tk widget may expect?

Schelte Bron

unread,
Mar 12, 2018, 5:01:41 PM3/12/18
to
Bezoar wrote:
> Suppose I have a text widget that I want to display some text on
> start up. I also want to save it in the options db. Supposedly,
> from what I read I can do this.
>
> option add .frame1.text.Startcontents "Please load a file"
> widgetDefault
>
The Startcontents you showed is a fully specified path, so it must
match exactly. The thing it must match is the appname + widgetname.
You get the appname with [tk appname]. When just experimenting in
wish, the appname is "wish". Then this works for me:
option add wish.frame1.text.Startcontents "Please load a file"
option get .frame1.text Startcontents Startcontents

You can also use wildcards in your specification:
option add *frame1.text.Startcontents "Please load a file"

You didn't show what you did for your font specification that
worked, but I suspect it contained a *.


Schelte.

0 new messages