Python Forum
[Tkinter] Warnings Script - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Warnings Script (/thread-38966.html)



Warnings Script - CoPython - Dec-15-2022

Hello,

I'm working on python to discover the 1 and other after a simple course. I have found a script that I have partly incorporated into my own future script. Now this script only gives 2 warnings that I want out. Can someone help me?

Warnings

Line 29 : Too few arguments for "create_window" or "Canvas"
Line 29 : Argument 1 to "create_window" of "Canvas" has incompatible type "Tuple[int, int]"; expected "float"


from tkinter import *
from tkinter import ttk

root = Tk()
root.title('Learn To Code at Codemy.com')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x400")

# Create A Main Frame
main_frame = Frame(root)
main_frame.pack(fill=BOTH, expand=1)

# Create A Canvas
my_canvas = Canvas(main_frame)
my_canvas.pack(side=LEFT, fill=BOTH, expand=1)

# Add A Scrollbar To The Canvas
my_scrollbar = ttk.Scrollbar(main_frame, orient=VERTICAL, command=my_canvas.yview)
my_scrollbar.pack(side=RIGHT, fill=Y)

# Configure The Canvas
my_canvas.configure(yscrollcommand=my_scrollbar.set)
my_canvas.bind('<Configure>', lambda e: my_canvas.configure(scrollregion = my_canvas.bbox("all")))

# Create ANOTHER Frame INSIDE the Canvas
second_frame = Frame(my_canvas)

# Add that New frame To a Window In The Canvas
my_canvas.create_window((0,0), window=second_frame, anchor="nw")

for thing in range(100):
    Button(second_frame, text=f'Button {thing} Yo!').grid(row=thing, column=0, pady=10, padx=10)

Label(second_frame, text="It's Friday Yo!").grid(row=3, column=2)


root.mainloop()



RE: Warnings Script - menator01 - Dec-15-2022

Your code works for me


RE: Warnings Script - CoPython - Dec-15-2022

The code does indeed work, but I prefer to get rid of the warnings :)


RE: Warnings Script - deanhystad - Dec-15-2022

Post tkinter questions under the GUI topic.

https://python-forum.io/forum-10.html

I believe menator means it works fine and there are no warnings. Runs fine for me also, without any warnings. Only change is I deleted line 6 because I don't have your icon file.

Your warning message makes no sense. It makes me think you are not running the code you posted to the forum.

What is your os and python version? I am running python 3.9 on windows.