[cells-devel] Celtk: How to set title of Wish window and also name of app ?

Ken Tilton kentilton at gmail.com
Mon Apr 3 05:12:40 UTC 2006


Frank Goenninger wrote:

> Another question:
>
> Am 02.04.2006 um 06:12 schrieb Ken Tilton:
>
>> Goenninger, Frank wrote:
>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA512
>>>
>>> Hi Kenny and all others:
>>>
>>> I do have the following mini app now:
>>>
>>> - -x-x-x-x-x-
>>>
>>> (defmodel psu-rc-app (window)
>>>   ()
>>>   (:default-initargs
>>>       :id :psu-rc-app-w
>>>       :title$ "System Power Supply Remote Control (Version A.01.00)"
>>>       :kids (c? (the-kids
>>>           (app-menubar)))))
>>
>
> Why does the title not get set via this default-initargs statement ?

This is the same story: I just have not done anything yet to handle the 
window class itself.

Background: If you expand any of the (deftk <widget>...) forms 
(actually, I strongly recommend you do that and stare at /all/ the 
varieties of code) you will see they expand into quite a bit of code, 
including a (defobserver <config parameter> ...) for every slot/tk 
config parameter. The way Celtk (and Cells-Gtk) work is that CLOS 
classes are defined for every TK widget type. A CLOS slot is defined for 
every tk config parameter. So with widgets you just set the 
corresponding CLOS instance slot and a defobserver sends that to Tk via: 
"<widget> configure -<config param name> <value from CLOS slot>".

I just need to do for the window class what I did with all the widgets 
and canvas items (the other job deftk handles). What title$ needs is:

  (defobserver title$ ((self window))
     (tk-format '(:configure "title") "wm title . ~s" (or new-value 
"Untitled")))

As I look at the other "wm..." commands I can see I first need to add 
some slots to the window class and then for each a defobserver to shoot 
the value across to Tk on any change.

[Side note: if you track down the mechanism by which make-instance leads 
to a corresponding TK widget creation, you will find some code that 
sweeps throug all the slots populated at make-instance time and includes 
thos config options in the widget creation. Which is why the generated 
defobservers check for old-value-boundp; the first time the observer 
gets invoked (the only time old-value-boundp is nil) is during 
make-instance, and the observer need not do anything since make-instance 
(eventually) gets the configs across in the widget creation command.

>
> And another one:
>
> I see there is the title$ slot of a window. How do I setf this  
> correctly ?
> The following does not work:
>
> (setf (title$ (fm^ :psi-rc-app-w)) "my new title")
>
> It (of course) emits an error that title$ is not a valid function -  
> yes, no, ahem, what? why?

I am not sure I have the same code you have, since I have already 
changed that slot's initform thus:

  (title$ :initarg :title$ :accessor title$  :initform (c? 
(string-capitalize (class-name (class-of self)))))

So your error could be for two reasons. Either I originally coded it thus

  (title$ :reader title$....)

thinking the title$ would never change, which is nonsense because a doc 
window starts out "Untitled" and then that changes when they save. 
Anyway, if I do not tell CLOS to create a writer it will not do so. 
Simple. But I doubt I specified just "reader". More likely (because even 
i can see it on the current code base) title$ is not exported and you 
are playing around in celtk-user, as I did deliberately to find out 
which symbols need to be exported.

So just add title$ to the symbols exported from the defpackage :celtk form.

>
> Thanks for some help here., 


The greater help I can offer is what I do when I cannot believe my eyes 
on an error: (apropos "title$"), though we both use AllegrroCL so we get 
to use the groovy Apropos dialog. That not only shows you if a symbol is 
exported, it will show you if there is a setf as well as a reader. In a 
case like yours where you have already compiled code and it has failed, 
you will see the symbol title$ in both the celtk and celtk-user 
packages. That is a tip-off that the celtk symbol was not exported, 
because had it been the compiler would not have interned a new symbol in 
celtk-user when it got to the reference to title$.

kt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kentilton.vcf
Type: text/x-vcard
Size: 171 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cells-devel/attachments/20060403/01a32bf3/attachment.vcf>


More information about the cells-devel mailing list