Python ttk 笔记本错误地显示了所选的标签

Python ttk notebook showing selected tab wrongly

from tkinter import *
from tkinter import ttk

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

    def tab_change(self, event):
        tab_id = self.page.index('current')
        print(tab_id, self.page.tab(tab_id, 'text'))

    def initUI(self):
        global canvas
        self.parent.title('PythonPage')
        self.pack(fill = BOTH, expand = 1)
        self.page = ttk.Notebook(self, width = 646 ,height = 629)
        self.page1 = Frame(self)
        self.page2 = Frame(self)
        self.page.add(self.page1, text = 'Tab1')
        self.page.add(self.page2, text = 'Tab2')
        self.page.bind('<ButtonPress-1>', self.tab_change)
        self.page.pack(expand = 0, anchor = 'w', side = 'top')

root = Tk()
root.geometry('925x650')
main = MainGame(root)
root.mainloop()

tab_change可以显示他们的id和名字,但是不正确。

点击Tab1时,我点击了Tab2,但还是打印0 Tab1,需要再点击一下才能打印1 Tab2

Tab2点击Tab1也是一样,需要多点击一次才能显示当前选中的tab

我想知道为什么标签需要双击?以及如何通过单击正确选择选项卡?

变化:

self.page.bind('<ButtonPress-1>', self.tab_change)

收件人:

self.page.bind('<ButtonRelease-1>', self.tab_change)

因为除非您松开按下的按钮,否则选项卡不会改变!