Finding the currently selected tab of Ttk Notebook

前端 未结 5 1433
南旧
南旧 2021-02-07 19:58

I have a Ttk Notebook widget containing 8 Frames - so, 8 tabs. Each frame contains a Text widget. I have a button outside the Notebook widget, and I want to insert text into the

5条回答
  •  庸人自扰
    2021-02-07 20:11

    I am not a expert at all but hope i can help with some "fresh eyes". I imagine it could be something involving

    def buttonclick():
          somevariablename = focus_get()
          #Print your text into the somevariable notebook could be
          #something like(not sure about the syntax):
          focusednotebook = somevariablename
          focusednotebook.insert('1.0', 'your text here')
    
    yourbutton = Button(parent, text = "button name", command = buttonclick)
    yourbutton.pack()
    

    Hope it works or get you in the right direction.

    Please feel free to edit as I am fairly new here amd with python :-)

提交回复
热议问题