Just started work on some GUI
. I am an absolutely new to tkinter
.
I can set the label
width and font size using .config
for individual labels.
I would like to make this the default for a specific column.
I tried:
Label.config(width=70, font=('Courier',15))
But keep getting errors:
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 3331, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 8, in Label.config(width=70, font=('Courier',15)) TypeError: configure() missing 1 required positional argument: 'self'
What is the correct way to do this?
Full Code:
from tkinter import *
from tkinter import ttk
reasons_window = Tk()
ttk.Style.configure('TLabel',width=70,font=('Courier',15))
reasons_window.geometry("500x200")
# Create rows for the reasons to be entered.
label1 = ttk.Label(reasons_window, text="Qty")
label1.grid(row=0,column=0)
# for field in fields
e1 = Entry(reasons_window)
e1.grid(row=0,column=1)
def eval_click():
if int(e1.get()) == 100:
print('GO AHEAD')
eval_button = Button(reasons_window, text="Evaluate", command=eval_click)
eval_button.grid(row=3, column=0)
reasons_window.mainloop()