Comments (8)
It's a bug or a missing feature in customtkinter. So when you place a CTk element onto something I need to get the background color of the element on which the CTk element was placed. Then I can set the bg_colour of the CTk element to the bg color of the master, so that I can draw rounded corners. The rounded corners are just circles on a tkinter.Canvas which has the same bg color as the master on which the CTk element was placed so that you don't see the canvas and just the circles and rects on the canvas.
And at the moment I detect if the master widget as a tkinter widget, and if so, I read the bg color of the mastere by doing .cget("bg"). But that doesn't work on ttk widgets because they don't have a bg attribute, they have a style.
So I somehow need to get the style of the ttk element and from the style I can get the bg color, but I don't now if this will work. For now I will change the code so that it doesn't throw an error on ttk elements and just set the bg to black by default on ttk widgets . Then you have can set the bg_color attribute manually to the correct color if you want...
from customtkinter.
So the CTk widgets now work on ttk.Frame, ttk.LabelFrame and ttk.Notebook. But only with the default color:
Program: test/test_ttk_frames.py
If the color gets changed by a ttk style, then you have to manually set the bg_color
attribute of all CTk widgets on them to the new color, it's not possible to do this automatically for me at the moment.
But overall it would prefer to use a CTkFrame instead of a ttk.Labelframe because it's more convenient and you can also place a label at the top as I did in test/test_ttk_frames.py
and add a border if you want.
from customtkinter.
Its a bug? Tkinter sure as hell has a lot of bugs to be called stable and mature
from customtkinter.
bg_color = tkinter.ttk.Style().lookup(".", "background")
from customtkinter.
I now, actually, what I do to get the bg color of the master widget is this on ttk widgets:
ttk_style = ttk.Style()
return ttk_style.lookup(self.master.winfo_class(), 'background')
customtkinter/widgets/customtkinter_button.py line 144
The problem is, that I cannot now if the style gets changed afterwards in the runtime of the program. Then I would have to change the bg_color of the ctk button again. On tkinter widgets, I do this by overwriting the configure method of the master, so that all the ctk childs on that master get notified when the bg color of the master gets configured. But with ttk i can't do this, because the bg change of the master doesn't happen through the configure method, but a style change. And there is nothing like a style change event or something similar.
from customtkinter.
And there is nothing like a style change event
There is <<ThemeChanged>>
, although I am not sure you need it.
from customtkinter.
ThemeChanged only gets called if you load a new theme, but there is no event for individual theme modifications on widgets, so I will close this one.
from customtkinter.
@TomSchimansky There's also <Configure>
maybe that's what you are looking for?
from customtkinter.
Related Issues (20)
- _tkinter.TclError: can't invoke "winfo" command: application has been destroyed
- canvas.coords is not returning any values HOT 1
- how to use font from `.ttf` file HOT 3
- How to change the icon in CTkInputDialog HOT 4
- TypeError: CTkEntry.xview() takes 2 positional arguments but 3 were given HOT 3
- No CTkTreeView? HOT 10
- Can you change the font in a CTkTextBox with tags?
- 2656125603072update whats problem when i click on button HOT 2
- I can't add widgets to CTkTabview's Tab buttons
- Button Not Appearing HOT 1
- Unable to run examples: segmentation fault
- Bind "Enter Key" to button does not work HOT 4
- Switch does not go to the required position HOT 1
- ctk.CTk().state("zoomed") doesn't work HOT 1
- Invoking .geometry(), .winfo_height() or .winfo_width() on a window always returns 200 HOT 7
- Transparent Window HOT 2
- How to allow windows to overlap though it is topmost window like widgets? HOT 6
- focus_set() does not work HOT 1
- install CustomTkinter with conda HOT 1
- Image Button Transparent Borders HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from customtkinter.