Add Canvas

Add Canvas

Without OOP

import tkinter as tk

root = tk.Tk()
frame = tk.Frame(root)
canvas = tk.Canvas(frame, width=600, height=400, bg='#ffffff')
frame.pack()
canvas.pack()
root.mainloop()

With OOP

import tkinter as tk


class Canvas(tk.Frame):
    def __init__(self, master):
        super(Canvas, self).__init__(master)
        self.canvas = tk.Canvas(self, bg='#aaaaff',
                                width=600,
                                height=400)
        self.canvas.pack()
        self.pack()


if __name__ == '__main__':
    root = tk.Tk()
    Canvas = Canvas(root)
    root.mainloop()