Python Forum
[Tkinter] Warnings Script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Warnings Script
#1
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()
Reply
#2
Your code works for me
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
The code does indeed work, but I prefer to get rid of the warnings :)
Reply
#4
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020