[Tutor] Tkinter canvas on frame
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Feb 27 12:01:33 EST 2022
On 27/02/2022 08:35, Alan Gauld via Tutor wrote:
> On 27/02/2022 04:55, Phil wrote:
>
>> class Root(tk.Tk):
>> def __init__(self):
>> super().__init__()
>> self.title("Canvas Template")
>> self.geometry("400x300")
>>
>> self.frame = tk.Frame(background='cornflowerblue')
>>
>> self.frame.pack(fill=tk.BOTH, expand=1)
>>
>> canvas = tk.Canvas(self, relief='flat', background='lightgrey',
>> width=200, height=200)
>> canvas.pack(side=tk.TOP, anchor='nw', padx=10, pady=10)
>
> Try changing the anchor from Northwest('nw') to 'center'
>
>
I meant to add, if you want a colour border why not just
set the border of the frame? Then you can make the canvas fill it.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list