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
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
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.
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
[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
Thanks,
Phil
--
Phil Mercurio
merc...@thyrd.org
>
>> 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
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
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