Apr-05-2019, 08:19 PM
(Apr-05-2019, 04:26 PM)wuf Wrote: Hi jpezzGreat! Wonderful explanation of the choices and I can easily change the numbers so that canvas and move to different positions Since I have used the label widget before (but don't yet fully understand it), I'd prefer not to have to have a canvas. I played around with your program and I see how I can move things around.
You can't place a Canvas directly on the screen. It must be embedded on the main window. Here some different placements of an image in a tk-Application:
[/python]wuf :-)
My objective would be to put out a single letter in the Label but it would be big enough for multiple letters. Then I would, in a function, update the label to add an additional letter. I tried just simply creating the label then updating it in the mainloop so this:
# Create a label widget containig the image and place it directly on # the main window image_label = tk.Label(root, text="Image Label placed\non main window", compound='bottom', image=root.test_image) image_label.place(x=500, y=50)looks like this now:
# Create a label widget containig the image and place it directly on # the main window image_label = tk.Label(root, text="Image Label placed\non main window", compound='bottom', image=root.test_image) image_label.place(x=500, y=50) image2 = Image.open("pngs/b.png") root.test_image = ImageTk.PhotoImage(image2) image_label.place(x=600, y=50) image_label.config (root,image=root.test_image)and I get this error.
Quote:Traceback (most recent call last):
File "his_original.py", line 58, in <module>
root.place(x=600, y=50)
File "/usr/lib/python3.6/tkinter/__init__.py", line 2101, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'place'
Fumbling my way through python one error at a time.