TomSchimansky / CustomTkinter

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

canot get value text when input CTkInputDialog #1722

Open bobwatcherx opened 1 year ago

bobwatcherx commented 1 year ago

my code

import tkinter
import customtkinter 

customtkinter.set_appearance_mode("System")
customtkinter.set_default_color_theme("green")

app = customtkinter.CTk()
app.geometry("400x300")

def button_click_event():
    dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test")
    print("Number:", dialog.get_input())

button = customtkinter.CTkButton(app, text="Open Dialog", command=button_click_event)
button.pack(padx=20, pady=20)

app.mainloop()

error root@miop-HP-Convertible-x360-11-ab1XX:/home/miop/belajar/custometkinter# python3 main.py Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python3.10/tkinter/init.py", line 1921, in call return self.func(*args) File "/usr/local/lib/python3.10/dist-packages/customtkinter/windows/widgets/ctk_button.py", line 553, in _clicked self._command() File "/home/miop/belajar/custometkinter/main.py", line 12, in button_click_event dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test") File "/usr/local/lib/python3.10/dist-packages/customtkinter/windows/ctk_input_dialog.py", line 50, in init self.grab_set() # make other windows not clickable File "/usr/lib/python3.10/tkinter/init.py", line 941, in grab_set self.tk.call('grab', 'set', self._w) _tkinter.TclError: grab failed: window not viewable

TomSchimansky commented 1 year ago

What platform are you using, Linux?

bobwatcherx commented 1 year ago

Yes , Linux mint

avalon60 commented 1 year ago

Hello @bobwatcherx. I'm on Linux Mint Cinnamon 21.1, and that runs fine for me.

image

Unless you have manually upgraded Python, I am guessing that you are also on Linux Mint 21.1 also. Anyhow, here is what I get:

image

image

When I enter a number, and click on the OK button, I get the entered number output to the console:

image

By the way, there is no need for the import tkinter.

bobwatcherx commented 1 year ago

why is it still not working on me and i using Awesome WM in Linux Min

root@miop-HP-Convertible-x360-11-ab1XX:/home/miop/belajar/fletsub2# pip list | grep customtkinter
customtkinter            5.1.3

root@miop-HP-Convertible-x360-11-ab1XX:/home/miop/belajar/fletsub2# python3 --version
Python 3.10.6

Selection_003

bobwatcherx commented 1 year ago

i remove code import tkinter

bobwatcherx commented 1 year ago

full code

import customtkinter 

customtkinter.set_appearance_mode("System")
customtkinter.set_default_color_theme("green")

app = customtkinter.CTk()
app.geometry("400x300")

def button_click_event():
    dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test")
    print("Number:", dialog.get_input())

button = customtkinter.CTkButton(app, text="Open Dialog", command=button_click_event)
button.pack(padx=20, pady=20)

app.mainloop()
bobwatcherx commented 1 year ago

you can try using Awesome WM . i get Errror

TomSchimansky commented 1 year ago

you can try it with normal tkinter to verify its a CustomTkinter issue

TheGreatSimo commented 1 year ago

The same here