Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Theme not retained in Text widget #98

Closed
Crystz99 opened this issue Dec 24, 2021 · 1 comment · Fixed by #101
Closed

Basic Theme not retained in Text widget #98

Crystz99 opened this issue Dec 24, 2021 · 1 comment · Fixed by #101
Labels
enhancement New feature or request

Comments

@Crystz99
Copy link

txt = Text(frme, background = '#000000', foreground = '#ffffff' ,font="Consolas 12 bold")
txt.pack(fill = BOTH)

Hi,
I tried running the above piece of code with ttkbootstrap themes but the bg/fg/font selected to the text is not applied on the final tkinter window, its still the same basic settings. This used to work fine in ttkbootstrap_v < 1.0.0.0, but in later versions Im facing this issue. Any fix for this...??

Thanks in advance.

@israel-dryer israel-dryer added the enhancement New feature or request label Dec 25, 2021
@israel-dryer
Copy link
Owner

@Crystz99, yes, you are correct. In ttkbootstrap 1.0, there is a default style applied to tk widgets. There is a publisher that tracks the legacy tk widgets and ensures that whenever the theme is changed or updated, a default style is applied to all those legacy widgets. This is the intended behavior, however, I can see how it could potentially be annoying if you wanted to update a legacy widget.

A temporary hack you can use now is to unsubscribe the widget from the Publisher and then configure the style settings.

import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.publisher import Publisher

app = ttk.Window()

txt = ttk.Text()
txt.pack(fill = BOTH)

# get the widget name
widget_name = str(txt)

# unsubscribe the name from Published update events
Publisher.unsubscribe(widget_name)

# configure the widget style
txt.configure(background = '#000000', foreground = '#ffffff', font="Consolas 12 bold")

app.mainloop()

A potential long-term solution may be to add a themed parameter that would prevent the widget from getting registered with the Publisher.

image

@israel-dryer israel-dryer linked a pull request Dec 26, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants