君子Python 3 - ttk.treeview不與網格一起工作,爲什麼會發生這種情況?
下面的代碼已經與.pack()
工作,但不.grid()
的treeview
已滾動條工作時.pack()
已啓用,但如果我改變代碼爲.grid()
滾動條停止工作,沒有工作一些可能性的代碼.grid()
from tkinter import *
from tkinter import ttk
class App(object):
def run(self):
root=Tk()
root.geometry('768x612')
title='dp'
root.title(title)
head_columns = (
"ID CLIENTE",
"NOME",
"CPF",
"DATA Expedição CPF",
"RG",
"DATA Expedição RG",
"ENDEREÇO",
"NÚMERO",
"BAIRRO", "CIDADE", "ESTADO", "CEP", "TEL", "CEL", "E-MAIL", "OBS")
f = Frame(root)
f.pack()
#f.grid()
xscrollbar = Scrollbar(f, orient=HORIZONTAL)
xscrollbar.pack(side='bottom', fill='both')
text = ttk.Treeview(f,
xscrollcommand=xscrollbar.set,
show="headings",
columns=head_columns,)
text.pack(side='right', fill='y') #if I change this for .grid() he's not working
for item in text["columns"]:
text.column(item)
text.heading(item, text=item)
text.insert("", 0, text=item, values=("a" * 200))
xscrollbar.config(command=text.xview)
mainloop()
if __name__=='__main__':
win=App()
win.run()
做得好解決這個自己。爲了將來的參考,這是一個很好的做法,總是至少配置一行和一列,使用網格來創建GUI時有一個權重:) –
Yeap,謝謝你!我用另一個我創建的函數來做這件事 –