Home > OS >  CustomTkinter Text Box Not Eorking
CustomTkinter Text Box Not Eorking

Time:12-13

I cannot get this text box to work with CTkinter ERROR

Traceback (most recent call last):
  File "C:\Users\James Martin\PycharmProjects\Cal\Cal.py", line 43, in <module>
    textbox = customtkinter.CTkTextbox(app, width=18, height=2, CTkFont=("Roboto", 24))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\James Martin\PycharmProjects\Cal\Lib\site-packages\customtkinter\windows\widgets\ctk_textbox.py", line 91, in __init__
    check_kwargs_empty(kwargs, raise_error=True)
  File "C:\Users\James Martin\PycharmProjects\Cal\Lib\site-packages\customtkinter\windows\widgets\utility\utility_functions.py", line 18, in check_kwargs_empty
    raise ValueError(f"{list(kwargs_dict.keys())} are not supported arguments. Look at the documentation for supported arguments.")
ValueError: ['CTkFont'] are not supported arguments. Look at the documentation for supported arguments.

This is the whole code

import tkinter
import customtkinter

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


class App(customtkinter.CTk):
    cal_prb = ""

    def __int__(self):
        super().__init__()

        self.title("Cal")
        self.geometry("265x225")


def add_to_prb(symbol):
    global cal_prb
    cal_prb  = str(symbol)
    textbox.delete(1.0, "end")
    textbox.insert(1.0, cal_prb)


def slv_prb():
    global cal_prb
    try:
        cal_prb = str(eval(cal_prb))
        textbox.delete(1.0, "end")
        textbox.insert(1.0, cal_prb)
    except:
        clr_prb()
        textbox.insert(1.0, "Error")
        pass


App = customtkinter.CTkFrame


def clr_prb():
    global cal_prb
    cal_prb = ""
    textbox.delete(1.0, "end")

textbox = customtkinter.CTkTextbox(App, width=18, height=2, CTkFont=("Roboto", 24))
textbox.grid(collumspan=5)
textbox.configure(state="disabled")
btn_1 = customtkinter.CTkButton(App, text="1", command=lambda: add_to_prb(1), width=6, CTkFont=("Roboto", 14))
btn_1.grid(row=2, column=1)
btn_2 = customtkinter.CTkButton(App, text="2", command=lambda: add_to_prb(2), width=6, CTkFont="Roboto")
btn_2.grid(row=2, column=2)
btn_3 = customtkinter.CTkButton(App, text="3", command=lambda: add_to_prb(3), width=6, CTkFont="Roboto")
btn_3.grid(row=2, column=3)
btn_4 = customtkinter.CTkButton(App, text="4", command=lambda: add_to_prb(4), width=6, CTkFont="Roboto")
btn_4.grid(row=3, column=1)
btn_5 = customtkinter.CTkButton(App, text="5", command=lambda: add_to_prb(5), width=6, CTkFont="Roboto")
btn_5.grid(row=3, column=2)
btn_6 = customtkinter.CTkButton(App, text="6", command=lambda: add_to_prb(6), width=6, CTkFont="Roboto")
btn_6.grid(row=3, column=3)
btn_7 = customtkinter.CTkButton(App, text="7", command=lambda: add_to_prb(7), width=6, CTkFont="Roboto")
btn_7.grid(row=4, column=1)
btn_8 = customtkinter.CTkButton(App, text="8", command=lambda: add_to_prb(8), width=6, CTkFont="Roboto")
btn_8.grid(row=4, column=2)
btn_9 = customtkinter.CTkButton(App, text="9", command=lambda: add_to_prb(9), width=6, CTkFont="Roboto")
btn_9.grid(row=4, column=3)
btn_0 = customtkinter.CTkButton(App, text="0", command=lambda: add_to_prb(0), width=6, CTkFont="Roboto")
btn_0.grid(row=5, column=1)
btn_percent = customtkinter.CTkButton(App, text="%", command=lambda: add_to_prb("%"), width=5, CTkFont="Roboto")
btn_percent.grid(row=1, column=4)
btn_plus = customtkinter.CTkButton(App, text=" ", command=lambda: add_to_prb(" "), width=5, CTkFont="Roboto")
btn_plus.grid(row=2, column=4)
btn_minus = customtkinter.CTkButton(App, text="-", command=lambda: add_to_prb("-"), width=5, CTkFont="Roboto")
btn_minus.grid(row=3, column=4)
btn_times = customtkinter.CTkButton(App, text="X", command=lambda: add_to_prb("*"), width=5, CTkFont="Roboto")
btn_times.grid(row=4, column=4)
btn_div = customtkinter.CTkButton(App, text="/", command=lambda: add_to_prb("/"), width=5, CTkFont="Roboto")
btn_div.grid(row=5, column=4)
btn_open = customtkinter.CTkButton(App, text="(", command=lambda: add_to_prb("("), width=6, CTkFont="Roboto")
btn_open.grid(row=1, column=1)
btn_close = customtkinter.CTkButton(App, text=")", command=lambda: add_to_prb(")"), width=6, CTkFont="Roboto")
btn_close.grid(row=1, column=2)
btn_dot = customtkinter.CTkButton(App, text=".", command=lambda: add_to_prb("."), width=6, CTkFont="Roboto")
btn_dot.grid(row=1, column=3)
btn_slv = customtkinter.CTkButton(App, text="=", command=lambda: slv_prb(), width=6, CTkFont="Roboto")
btn_slv.grid(row=5, column=2)
btn_clr = customtkinter.CTkButton(App, text="CLR", command=lambda: clr_prb(), width=6, CTkFont="Roboto")
btn_clr.grid(row=5, column=3)

App.mainloop()

CodePudding user response:

Does this help?

Change this:

App = customtkinter.CTkFrame 

to:

app = App() #Don't use capital A in variable.

Put this:

app = App()
app.mainloop()

CodePudding user response:

I just had awful code! I used App in the wrong context.

  • Related