[Tutor] Tkinter canvas on frame

Alan Gauld alan.gauld at yahoo.co.uk
Sun Feb 27 03:35:31 EST 2022


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'


-- 
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