TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.33k stars 1.07k forks source link

Combining CTk with ordinary tkinter widgets #1980

Open mcfoi opened 1 year ago

mcfoi commented 1 year ago

The Github docs states that CustomTkinter "can also be used in combination with normal Tkinter elements". There is no clear documentation about hout to achieve this.

My use-case is that of a complex application with its own custom Tk App and a lot of plain tkinter UI. I tryed to make my custom Tk App extend customtkinter.CTk bat that was not enough. It seems that any tkinter.Frame MUST be a customtkinter.CTkFrame and if an ordinary tkinter.Button is placed inside a customtkinter.CTkFrame a second copy of Tk App is created causing fata error in main loop.

How can CustomTkinter be integrated in an existing App without reworking all UI, rebasing all custom widget on CTk base widgets (like CTkButton)

CustomTkinter seems wonderful.!

Thank you!

TomSchimansky commented 1 year ago

It should just work.

Tkinter widget in CustomTkinter window:

import customtkinter
import tkinter

app = customtkinter.CTk()

button = tkinter.Button(app, text="Button")
button.grid(padx=20, pady=20)

app.mainloop()

CustomTkinter widget in Tkinter window:

import customtkinter
import tkinter

app = tkinter.Tk()

button = customtkinter.CTkButton(app, text="Button")
button.grid(padx=20, pady=20)

app.mainloop()

Otherwise you have to provide a code example with an error log.

mcfoi commented 1 year ago

I could make a simpler test by directly adding a customtkinter.CTkButton into a plain tkinter.Tk() app: I confirm it works.

The documentation confused me as I uderstood any customtkinter widget would require the app to be a CTk class: I was wrong.: it just works even using plain tkinter.Tk() class.

I also tested that setting the global theme using methods on the "customtkinter" namespace works without using CTk() class as app.

What I still wonder now is which are the use-cases where you would need to use CTk() in place of Tk()

Best regards.

On Sun, 10 Sept 2023 at 21:33, Tom Schimansky @.***> wrote:

It just just work.

Tkinter widget in CustomTkinter window:

import customtkinterimport tkinter

app = customtkinter.CTk() button = tkinter.Button(app, text="Button")button.grid(padx=20, pady=20) app.mainloop()

CustomTkinter widget in Tkinter window:

import customtkinterimport tkinter

app = tkinter.Tk() button = customtkinter.CTkButton(app, text="Button")button.grid(padx=20, pady=20) app.mainloop()

Otherwise you have to provide a code example with an error log.

— Reply to this email directly, view it on GitHub https://github.com/TomSchimansky/CustomTkinter/issues/1980#issuecomment-1712918432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANEOSWWBXXVI2DOVZTB2STXZYI2LANCNFSM6AAAAAA4RRT5VU . You are receiving this because you authored the thread.Message ID: @.***>