2
我有一個帶有文本框的標籤頁,我想爲它添加一個滾動條,但它不適合我(它覆蓋標籤名稱)。Python tkinter:帶滾動條的標籤頁
這裏是我的代碼:
*Look below*
任何幫助,將不勝感激!
編輯:
我可能是愚蠢的,但現在當我切換標籤的文本不會更改(如果我輸入「a」和標籤之間切換它出現在所有的) ,直到我編輯代碼之前,這並沒有發生。這是我的代碼;讓我知道你是否需要更多它:
tabs = {}
tab_bar = {}
...
def doNew(self):
# Create a new tab with the file name and select it
self.nb.select(self.CreateTab())
# Create a new tab
def CreateTab(self, name='Untitled.asm'):
tab_num = len(tabs) # get current tab number
tab_bar_num = len(tab_bar) # get it's frame as well
tab_bar[tab_bar_num] = Frame(self.nb) # create a new frame
scrollbar = Scrollbar(self.root)
scrollbar.pack(side=RIGHT, fill=Y)
tabs[tab_num] = Text(self.root, yscrollcommand=scrollbar.set)
self.nb.add(tab_bar[tab_bar_num], text=name) # add tab
tabs[tab_num].pack(side=LEFT, fill=BOTH)
scrollbar.config(command=tabs[tab_num].yview)
return tab_num
再次感謝。
@ user2638731:你沒有按照我的建議去做:文本小部件和滾動條需要是框架的子項,而不是self.root的子項。 –