內部框架我試圖做一個框架滾動,我發現做到這一點的唯一方法是做一個滾動的帆布和添加一幀到它。如果它對我有效,這將工作正常。創建畫布
我能夠創建一個可滾動的帆布工作正常,但我似乎無法適當加在其內部框架:
self.title = Label(root, text="Brnr", font=("Helvetica", 50), anchor = W, pady = 40, padx = 50)
self.title.pack (anchor = NW)
#creates title widget for title
self.frame = Frame(screen, bd =1)
self.frame.pack(fill = BOTH)
#Creates frame widget under which all other widgets will be kept
self.canvas = Canvas(self.frame, bd=1,scrollregion=(0,0, 1000, 1000), height = 600)
#creates canvas so that screen can be scrollable
self.scrollbar = Scrollbar(self.frame, command=self.canvas.yview)
#creates scrollbar
self.canvas.config(yscrollcommand=self.scrollbar.set)
#connects the scrollbar to the canvas
self.scrollbar.pack(side=RIGHT, fill=Y)
self.canvas.pack(expand=YES, fill=BOTH)
#packs the scrollbar and canvas so that they fill the remainder of the screen
self.frameC = Frame(bg = "red")
self.canvas.create_window(0,0, anchor = NW, window = self.frameC, width = 200, height = 200)
#creates window on the scrollable area to add other widgets
self.frameC.pack()
self.groupRec = LabelFrame(self.frameC, text ="Recommendations:", font=("Helvetica", 20))
self.groupRec.pack()
self.signupButton = Button(self.groupRec, text="Sign Up", width=10)
self.signupButton.pack(side=RIGHT)
#creates button to submit login
這給了我一個滾動的,但空,帆布,用沒有一個labelframe /按鈕出現。
大,感謝您的幫助!現在我遵循了你告訴我要做的事情(錨定),並沒有改變任何事情。一旦我給框架添加顏色,也沒有任何改變。這導致我相信它沒有正確地插入到畫布中?任何建議?謝謝! – 2011-05-24 23:47:20
當我在你的問題中使用了確切的代碼,以及你省略的幾行代碼,加上我建議的更改,它工作正常。你確定你的問題中的代碼是_exactly_你正在使用的是什麼? – 2011-05-25 01:32:22
這很奇怪,所以我會在更新 – 2011-05-25 01:41:53