Python can't add canvas to ttk notebook page
<pre><code>from tkinter import *
from tkinter import ttk

class MainGame(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent        
        self.initUI()

    def initUI(self):
        global canvas
        # ===Part A ===
        self.parent.title('PythonPage')
        self.pack(fill = BOTH, expand = 1)
        self.page = ttk.Notebook(self, width = 650 ,height = 630)
        self.page1 = ttk.Frame(self)
        self.page.add(self.page1, text = 'Tab1')
        self.page.pack(expand = 1, anchor = 'nw', side = 'top')
        # ===Part B ===            
        canvas = Canvas(self)
        canvas.create_rectangle([10,10, 650,630], fill = 'blue')
        canvas.pack(fill = BOTH, expand = 1)
        canvas.update()
        self.a = Label(self, text = 'Haha')
        self.a.place(x=50,y=50)

root = Tk()
root.geometry('925x650')
main = MainGame(root)
root.mainloop()
</code></pre>

<p>How can I add my rectangle into ttk's notebook? I found that my rectangle is always created below the notebook, but this situation is not the same with <code>Label</code>.</p>

<p>I want to put the rectangle inside the notebook, should I add something to <code>self.page1</code>?.</p>

<p>If you want the canvas to be in the notebook, you must add it to one of the notebook pages. For example, if you want it in <code>self.page</code>, you would change this line:</p>

<pre><code>canvas = Canvas(self)
</code></pre>

<p>... to this:</p>

<pre><code>canvas = Canvas(self.page1)
</code></pre>

python tkinter polygon ttk tkinter-canvas