TomSchimansky / CustomTkinter

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

MacOS OptionMenu and ComboBox #149

Closed PeymanSeirafi closed 2 years ago

PeymanSeirafi commented 2 years ago

Today I was trying to create a simple app in my mac with python and customtkinter but I had a simple problem. When I use OptionMenu or ComboBox there is a frame like an app window and makes OptionMenu not like the thing that it should be. you can see what i mean:

image

please solve this problem as fast as possible because I need OptionMenu for my code ...

felipetesc commented 2 years ago

Hello PeymanSeirafi. Can you post the code please ? Thank you.

TomSchimansky commented 2 years ago

I know of this problem, this occurs only on macOS with python >= 3.10.0. I think I will convert the dropdown menu to a standard tkinter.Menu, very soon, because there occur so much platform specific bugs. It's just not possible to create a custom dropdown menu with tkinter.Toplevel, which works reliable on every platform.

PeymanSeirafi commented 2 years ago

Hello PeymanSeirafi. Can you post the code please ? Thank you.

import tkinter import customtkinter

customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light" customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"

app = customtkinter.CTk() app.geometry("400x580") app.title("CustomTkinter simple_example.py")

def button_callback(): print("Button click", combobox_1.get())

def slider_callback(value): progressbar_1.set(value)

frame_1 = customtkinter.CTkFrame(master=app) frame_1.pack(pady=20, padx=60, fill="both", expand=True)

label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT) label_1.pack(pady=12, padx=10)

progressbar_1 = customtkinter.CTkProgressBar(master=frame_1) progressbar_1.pack(pady=12, padx=10)

button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback) button_1.pack(pady=12, padx=10)

slider_1 = customtkinter.CTkSlider(master=frame_1, command=slidercallback, from=0, to=1) slider_1.pack(pady=12, padx=10) slider_1.set(0.5)

entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry") entry_1.pack(pady=12, padx=10)

optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42"]) optionmenu_1.pack(pady=12, padx=10) optionmenu_1.set("CTkOptionMenu")

combobox_1 = customtkinter.CTkComboBox(frame_1, values=["Option 1", "Option 2", "Option 42"]) combobox_1.pack(pady=12, padx=10) optionmenu_1.set("CTkComboBox")

checkbox_1 = customtkinter.CTkCheckBox(master=frame_1) checkbox_1.pack(pady=12, padx=10)

radiobutton_var = tkinter.IntVar(value=1)

radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1) radiobutton_1.pack(pady=12, padx=10)

radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2) radiobutton_2.pack(pady=12, padx=10)

switch_1 = customtkinter.CTkSwitch(master=frame_1) switch_1.pack(pady=12, padx=10)

app.mainloop()

TomSchimansky commented 2 years ago

This is fixed now with version 4.4.0.