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

ttkbootstrap

587 views
Skip to first unread message

welle ozean

unread,
Apr 27, 2021, 6:12:57 PM4/27/21
to
The following TK style for Tkinker looks imho just amazing.

https://github.com/israel-dryer/ttkbootstrap

Does anyone if Tkinker styles can be easily be used with Tcl/Tk?

Christian Gollwitzer

unread,
Apr 28, 2021, 1:12:36 AM4/28/21
to
Am 28.04.21 um 00:12 schrieb welle ozean:
> The following TK style for Tkinker looks imho just amazing.
>
> https://github.com/israel-dryer/ttkbootstrap
>
> Does anyone if Tkinker styles can be easily be used with Tcl/Tk?

I've checked the code, and the way it works it is not straightforward to
use it directly from Tcl. However with some work (and knowledge of
Python) it should be possible to translate the predefined themes into
Tcl. The color definitions for the predefinied themes are given here:

https://github.com/israel-dryer/ttkbootstrap/blob/master/src/ttkbootstrap/themes.json

The theme is then constructed at runtime in the python code from here:

https://github.com/israel-dryer/ttkbootstrap/blob/master/src/ttkbootstrap/__init__.py

Quite unusual, __init__.py is like pkgIndex.tcl, so it took me a bit to
figure out that the cose which does the work is embedded here.

Now there are these options:

a) Translate the __init__.py to Tcl and use the json file to do the work

b) Run the python code and then rip off the settings by inspecting the
ttk layouts or tracing the updates. E.g. you could replace all
"delf.settings.update()" with a "print()" and then see what it is doing.

In addition to just colours, the code also creates images for some parts
on the fly. You'd need to save those as PNG files, e.g. by hacking the
init.py to save the files after creation

Christian



Christian Gollwitzer

unread,
Apr 28, 2021, 1:28:01 AM4/28/21
to
Am 28.04.21 um 07:12 schrieb Christian Gollwitzer:

> b) Run the python code and then rip off the settings by inspecting the
> ttk layouts or tracing the updates. E.g. you could replace all
> "delf.settings.update()" with a "print()" and then see what it is doing.

This way might be even easier. The code collects all the changes first
inside the "settings" dictionary of the StylerTTK class, which is then
simply passed to "ttk theme create". So you could either dump this
dictionary, or trace the "theme create" with an injected Tcl command.

Christian

Harald Oehlmann

unread,
Apr 28, 2021, 7:26:35 AM4/28/21
to

Dear Team,

well, we have an Androwish with ttk::button style Toolbutton and
pressing it creates a PDF and a click sound.

Unfortunately, it is hard to press it only once.
You quickly get mutliple invocations.

Is there an easy way to avoid this ?

I can start a timer and invoke it only once per Second. But this is a
general issue, so there might be a general solution.

The Androwish initialization:

sdltk touchtranslate 3
bind . <<PinchToZoom>> +[namespace code {PinchToZoomDo %x %s}]
after 500 {sdltk textinput 0}
bind . <<DidEnterForeground>> "+after 500 {sdltk textinput 0}"

and the button stuff:
ttk::style configure Elmi.Toolbutton -font LabelFont
ttk::button .f.b -image PrintImage -style Elmi.Toolbutton -command
"PDFExport"

Thanks for any idea,
Harald

Israel Dryer

unread,
Apr 28, 2021, 10:48:23 AM4/28/21
to
I think what you are asking for is possible via the `Style._script_from_settings` method in ttk. I've posted the details here: https://github.com/israel-dryer/ttkbootstrap/issues/39#issuecomment-828515759

welle ozean

unread,
Apr 28, 2021, 5:37:29 PM4/28/21
to
Thank you all. I will look into it!

Ashok

unread,
May 3, 2021, 9:38:00 PM5/3/21
to
If you do tcl-ify this, please consider making it publicly available.
0 new messages