def initUI(self):
self.columnconfigure(5, weight=1)
self.rowconfigure(3, weight=1)
self.search_label = Label(self, text='Keyword:')
self.search_label.grid(row=0, column=0, padx=5)
self.keywords = StringVar()
self.search_bar = Entry(self, width=30,textvariable=self.keywords)
self.search_bar.grid(row=0, column=1)
self.search_button = Button(self, text="Search",
command=self.handler_search)
self.search_button.grid(row=0, column=3, padx=5)
self.pack(fill=BOTH)#, expand='yes')
#self.pack(fill=BOTH)
self.box = Text(self, state='disabled')
self.box.grid(row=1, column=0)
UI由三個子框架組成,文本編輯器爲一個,側面按鈕形成在另一個框架內,搜索位於另一個框架內。上面的代碼片段是用於搜索的UI。如何使TextBox正確放置在Tkinter的搜索條目下?
見截圖:http://i.imgur.com/Vip1t.png
我希望把一個文本框是搜索框,這是搜索條目下的一部分。我希望它儘可能地擴展底部區域。我試過展開,填充等,但它不能解決入口被拉伸的問題,並且我的文本框被切斷(我以前添加了滾動條,但它也被切斷了)。
問題在哪裏?謝謝。
謝謝布萊恩。同時,爲什麼把第1列放錯了?該行雖然不同。 – CppLearner
@cpplearner:也許我誤解了你想要的東西,但看起來你想要一個文本小部件頂部的條目。要做到這一點,他們需要佔用同一列。如果文本只在列0中,並且條目在列1中,則它們不能排隊。 –
謝謝布萊恩。這是有幫助的! – CppLearner