我嘗試將樹視圖放入子框架中,但它不適合框架。
class Application(Frame):
def __init__(self,master=None):
self.pipeLine =[]
super().__init__(master)
self.master = master
self.PipeFrame = Frame(self.master,width=200,height=200).place(x=30,y=30)
self.PipeLineFrame = Frame(self.PipeFrame,width=200,height=220,bg='white',).place(x=10,y=100)
self.createPipeTree()
self.createWidget()
self.pack()
def createPipeTree(self):
self.PipeTree = ttk.Treeview(self.PipeLineFrame,column=("input","output"))
self.PipeTree.column("#0",minwidth=25,width= 60)
self.PipeTree.column("input",anchor=W,width=60)
self.PipeTree.column("output",anchor=W,width=60)
self.PipeTree.heading("#0",text="PipeLine")
self.PipeTree.heading("input",text="input")
self.PipeTree.heading("output",text="output")
self.PipeTree.pack(side=LEFT,expand=True)
def createWidget(self):
self.addNode = Button(self.PipeFrame,text="click to add procedure into pipeline",command=self.addNode).place(x=10,y=20)
self.inputBtn1 = Button(self.PipeFrame, text="F0").place(x=10,y=350)
self.inputBtn2 = Button(self.PipeFrame, text="Mel" ).place(x=50, y=350)
self.inputBtn3 = Button(self.PipeFrame, text="audio" ).place(x=100, y=350)
self.inputBtn4 = Button(self.PipeFrame, text="text").place(x=150,y=350)
self.inputBtn5 = Button(self.PipeFrame, text="f0").place(x=200, y=350)
if __name__ == '__main__':
root = Tk()
root.geometry("800x400 200 300")
root.title("HDI is the best")
Application(master=root)
root.mainloop()
PipeTree 應該適合 PipeLineFrame(白色區域),但目前,它像這樣脫離了框架。 當前結果
uj5u.com熱心網友回復:
當你布局一個小部件時,你可以像這樣在 1 行中完成:
Widget(root).pack()
或者你可以給它一個名字并使用像這樣的兩行:
name = Widget(root)
name.pack()
您不能組合這兩種方法并使用一行為其命名。如果您嘗試這樣做,這就是您得到的錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/357587.html
