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

Tile/ttk style/element/layout introspection?

46 views
Skip to first unread message

sch...@uni-oldenburg.de

unread,
Oct 19, 2007, 7:35:59 AM10/19/07
to
Hi all,

just played with tile/ttk a bit and wondered if there is any simple
way to introspect themes and styles.

Basically if i want to write my own button style or my own notebook
style or whatever, how can i find out:

- what elements are used by that Widget type?
- whats the default/theme layout for that widget type?

I was thinking about a small 'Widget/Style" Browser where you could
visually build your new widget styles in a simple way, but found no
good way to find the needed elements (other than RTFS or similar
techniques).

A second question:
Would it be possible to use e.g. an OpenGL surface or a Movie as an
element for ttk? Probably to build something like a button with a
preview movie or something strange like that.

Michael

Bryan Oakley

unread,
Oct 19, 2007, 9:37:46 AM10/19/07
to
sch...@uni-oldenburg.de wrote:
> A second question:
> Would it be possible to use e.g. an OpenGL surface or a Movie as an
> element for ttk? Probably to build something like a button with a
> preview movie or something strange like that.

This should be possible, for certain definitions of "possible". You can
create new elements based on images, and you can dynamically update
images, so it follows you could create a style that uses an image that
is animated.

People who are bored at work: Ready.... Set....

GO!


--
Bryan Oakley
http://www.tclscripting.com

Bryan Oakley

unread,
Oct 19, 2007, 9:56:16 AM10/19/07
to

Drat. It's not so simple. Apparently tile copies the image to a private
store rather than using the images directly, so changing the image
doesn't affect the element(s) based on that image.

What would really be nifty is if you could create an element from any Tk
widget. I would find that quite useful.

sch...@uni-oldenburg.de

unread,
Oct 19, 2007, 10:05:23 AM10/19/07
to

The docs mention the Ttk_RegisterElementFactory function, so it should
be surely possible in general
and i think tileqt uses it, but didn't look more closely. Reflecting a
Tk widget back in there would be
cool, as would be some kind of dynamic things.

Michael

Joe English

unread,
Oct 21, 2007, 10:21:53 AM10/21/07
to
schlenk wrote:
>
>just played with tile/ttk a bit and wondered if there is any simple
>way to introspect themes and styles.
>
>Basically if i want to write my own button style or my own notebook
>style or whatever, how can i find out:
>
>- what elements are used by that Widget type?
>- whats the default/theme layout for that widget type?

[ttk::style layout $stylename] returns the layout specification
used in the current theme (which might have been inherited from the
parent theme).

[ttk::style element names] lists all of the elements defined
in the current theme (*not* including those inherited from
the parent.)

Note that the layout doesn't always tell the whole story:
compound widgets like ttk::notebook and ttk::treeview use
multiple layouts internally, and for some widgets (in particular
those with "moving parts" like scrollbars) there are additional
rules for what elements must be available, so UTSL is still
recommended.

Other advice: if you're defining a new theme, follow the
naming conventions listed here:

<URL: http://tktable.sourceforge.net/tile/doc/elements.html >

The current element naming conventions evolved in a rather
ad-hoc fashion and aren't terribly consistent; that document
reflects future directions.

>A second question:
>Would it be possible to use e.g. an OpenGL surface or a Movie as an
>element for ttk? Probably to build something like a button with a
>preview movie or something strange like that.

I don't think so; elements are "flyweight" objects and
aren't bound to any particular window; there's no place
to keep track of persistent resources.


--Joe English

Phil Mercurio

unread,
Oct 21, 2007, 2:11:35 PM10/21/07
to
I've been trying to introspect ttk too--is there
any way to get a list of all of the styles currently
defined? Also, how do I find out what the default
style is for a widget, for example, that the style
for a button is called "TButton"? The default
value for style reported by invoking "configure" on a ttk::button
is {}.

Thanks,

Phil
--
Phil Mercurio
merc...@thyrd.org

http://www.thyrd.org/mercurio

Michael Schlenker

unread,
Oct 21, 2007, 2:49:15 PM10/21/07
to
Joe English schrieb:

> schlenk wrote:
>> just played with tile/ttk a bit and wondered if there is any simple
>> way to introspect themes and styles.
>>
> Note that the layout doesn't always tell the whole story:
> compound widgets like ttk::notebook and ttk::treeview use
> multiple layouts internally, and for some widgets (in particular
> those with "moving parts" like scrollbars) there are additional
> rules for what elements must be available, so UTSL is still
> recommended.
>
> Other advice: if you're defining a new theme, follow the
> naming conventions listed here:
>
> <URL: http://tktable.sourceforge.net/tile/doc/elements.html >
>
> The current element naming conventions evolved in a rather
> ad-hoc fashion and aren't terribly consistent; that document
> reflects future directions.
Thanks, missed that list while browsing the docs.


>
>> A second question:
>> Would it be possible to use e.g. an OpenGL surface or a Movie as an
>> element for ttk? Probably to build something like a button with a
>> preview movie or something strange like that.
>
> I don't think so; elements are "flyweight" objects and
> aren't bound to any particular window; there's no place
> to keep track of persistent resources.

Okay, would have been a nice too have thing, but not that important.

Michael

Joe English

unread,
Oct 23, 2007, 1:20:05 AM10/23/07
to
Phil Mercurio wrote:
>I've been trying to introspect ttk too--is there
>any way to get a list of all of the styles currently
>defined?

Not directly. (Note also that a "style" doesn't really
exist as an independent entity; it's just a name used to
query the style database for layouts and option settings.)

> Also, how do I find out what the default
>style is for a widget, for example, that the style
>for a button is called "TButton"? The default
>value for style reported by invoking "configure" on a ttk::button
>is {}.

If "-style" isn't specified, it defaults to the widget class
[winfo class $w].


--Joe English

Phil Mercurio

unread,
Oct 24, 2007, 3:05:30 PM10/24/07
to
Thanks for clarifying the default value, that makes
sense.

I understand now that "all of the styles currently defined"
isn't the right thing to ask for. Maybe a list
of all the styles that have been customized since
the interpreter started is what I'm looking for.

Phil

0 new messages