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

Example of Updating Style Across Themes?

53 views
Skip to first unread message

Jennifer Henderson

unread,
Apr 10, 2012, 12:23:19 PM4/10/12
to
Anyone have a quick example of how to define style changes for
different themes. We allow the user to change theme, so I would need
to update my style changes to TEntry for all the themes. We are
adding an selectable image in the entry field.

For xpnative I have:

ttk::style layout fileselector.TEntry {
Entry.field -sticky nswe -border 0 -children {
Entry.fileselector -side right -sticky ns
Entry.padding -expand 1 -sticky nswe -children {
Entry.textarea -sticky nswe
}
}
}

Thanks in advance,
Sue

Harald Oehlmann

unread,
Apr 11, 2012, 3:24:15 AM4/11/12
to
I suppose, you have to bind to the virtual event <<ThemeChanged>> and
reapply the private style.
I have no experience, but remembered Johanns talk on Tcl2010:
http://www.eurotcl.org/2010/Download/EuroTcl2010-Presentation-Bwidget-goes-Tile_JohannOberdorfer.pdf

-Harald

Emiliano

unread,
Apr 13, 2012, 6:45:38 PM4/13/12
to
You need to use [ttk::style theme settings $theme {# your setting
here}]
to install the desired layout on each theme.

To install a custom style/layout on each theme, I use

apply {{} {
foreach theme [themes] {
package require ttk::theme::$theme
style theme setting $theme {
style layout fileselector.TEntry {
# here comes the layout
}
}
}
} ::ttk}

[apply] is to avoid creating an (undesired) "theme" variable in
the current context.

Regards
Emiliano

Sue

unread,
May 4, 2012, 11:49:14 AM5/4/12
to
Emiliano,

Thank you for the suggestion. When I use the code above, I am now
seeing the style/layout being assigned to each theme when I query in
the console. But when I view my widget, it is not behaving as
expected. I am trying to put a folder image in the far right region
of the entry field. I see it on the xpnative theme, but no other
theme.

ttk::style element create fileselector image \
[list $launchimage {active pressed !disabled} \
$launchpressed {active !disabled} \
$launchactive ] \
-width 16 \
-sticky w

apply {{} {
foreach theme [ttk::themes] {
package require ttk::theme::$theme
ttk::style theme setting $theme {
ttk::style layout fileselector.TEntry {
Entry.field -sticky nswe -border 0 -children {
Entry.fileselector -side right -sticky ns
Entry.padding -expand 1 -sticky nswe -children {
Entry.textarea -sticky nswe
}
}
}
}
}

} ::ttk}



Thank you in advance
Message has been deleted
0 new messages