mentry::setTheme
Commandmentry::getCurrentTheme
Commandmentry::getThemes
Commandmentry::setThemeDefaults
CommandThe commands described in this reference page should only be invoked when using the package Mentry_tile. They enable you to set and query the current theme, to retrieve a list of the available themes, and to make sure that your widgets will have a theme-specific appearance.
mentry::setTheme
Commandmentry::setTheme
– Set the current themementry::setTheme theme
theme
,
loading it if necessary. It is simply an alias for
ttk::setTheme
or tile::setTheme
,
depending on the tile version loaded into the interpreter. (The
tile::setTheme
command was renamed to
ttk::setTheme
in tile version 0.8.)mentry::setTheme
command does exactly the same as the
original one: It loads the package implementing the given theme if needed,
sets the theme to the specified one, and saves the latter in the variable
ttk::currentTheme
or
tile::currentTheme
, depending on the current tile
version.mentry::getCurrentTheme
Commandmentry::getCurrentTheme
– Get the current themementry::getCurrentTheme
ttk::style theme use
command. If
an old tile version is being used which doesn't yet support this method
then the command returns the value of the variable
ttk::currentTheme
or
tile::currentTheme
, depending on the tile
version. (The namespace containing the variable
currentTheme
was changed in tile version 0.8 from
tile
to ttk
.)mentry::getThemes
Commandmentry::getThemes
– Get the themes registered in the
package databasementry::getThemes
ttk::themes
or tile::availableThemes
, depending on the tile version
loaded into the interpreter. (The
tile::availableThemes
command was renamed to
ttk::themes
in tile version 0.8.)mentry::setThemeDefaults
Commandmentry::setThemeDefaults
– Set theme-specific
default values of some mentry configuration optionsmentry::setThemeDefaults
mentry::themeDefaults
with theme-specific default
values of a series of Mentry configuration options. The array names
are the command-line names of the options, and the corresponding array
values are the default values of these configuration options for the
currently set tile theme.mentry::themeDefaults
are:
-background
, -foreground
, and
-font
. In addition, the command sets some other
array elements to theme-specific default values, needed for internal
purposes, like updating the background and foreground colors of the label
components of a mentry widget in disabled
or
readonly
state; the corresponding array names are:
-disabledbackground
,
-disabledforeground
, and
-readonlybackground
. Finally, the array values
associated with the names -selectbackground
,
-selectforeground
, and
-selectborderwidth
are not used by Mentry_tile, but
might prove useful for other purposes, as described below.mentry::setThemeDefaults
command is
invoked by Mentry_tile automatically at application start time and when the
<<ThemeChanged>>
virtual event is sent to
the main window. It is also invoked on Mac OS 10.14 (Mojave) and
later whenever the main window receives a
<<LightAqua>>
or
<<DarkAqua>>
virtual event, if the current
theme is aqua
. In these cases, after invoking the
mentry::setThemeDefaults
command, Mentry_tile sends the
virtual event
<<MentryThemeDefaultsChanged>>
to the main
window and reconfigures all mentry widgets of the application, using the
new default values of those options that were not set explicitly to values
different from the corresponding defaults.<<LightAqua>>
and
<<DarkAqua>>
are sent by Tk 8.6.10 and
later to all toplevel widgets whenever the system appearance toggles
between Light Mode and Dark Mode or the Accent Color in the General
Preferences changes. Tk versions 8.6.11 and later send these events
on Mac OS 10.15 (Catalina) and later also when changing the Highlight Color
in the General Preferences.mentry::themeDefaults
, you can make sure that classical
Tk widgets, e.g., text, will have a theme-specific appearance, just like
the tile widgets. For example, you can add some common configuration
options to the option database as follows:if {[tk windowingsystem] eq "x11"} { option add *Text.background $mentry::themeDefaults(-background) option add *Text.foreground $mentry::themeDefaults(-foreground) option add *selectBackground $mentry::themeDefaults(-selectbackground) option add *selectForeground $mentry::themeDefaults(-selectforeground) } option add *selectBorderWidth $mentry::themeDefaults(-selectborderwidth) option add *Font $mentry::themeDefaults(-font)
<<MentryThemeDefaultsChanged>>
to update
the appearance of your Tk widgets according to the new values contained in
the array mentry::themeDefaults
, by binding to the
dedicated binding tag MentryMain
associated with the
main window:bind MentryMain <<MentryThemeDefaultsChanged>> ...
MentryMain
is assigned by
Mentry_tile to the main window and used internally for handling the virtual
events <<ThemeChanged>>
,
<<LightAqua>>
, and
<<DarkAqua>>
. As shown above,
applications can make use of it, e.g., to handle the virtual event
<<MentryThemeDefaultsChanged>>
.