The Tkinter Pack Geometry Manager - options

痞子三分冷 提交于 2020-04-17 19:00:45

问题


I am teaching myself TKINTER at the moment. I have written...

self.frameBottom = tk.Frame(master)
self.frameBottom.pack(side=tk.BOTTOM, fill=tk.BOTH)

self.textBox = tk.Text(master, height=1)
self.textBox.pack(side = tk.LEFT, expand=1, fill=tk.X)

self.searchButton = tk.Button(master, text="Search",  command=self.searchButtonPress)
self.searchButton.pack(side = tk.RIGHT)

self.textBoxResults = tk.Text(self.frameBottom)
self.textBoxResults.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1)

however the lower textBoxResults does not expand in the Y direction to fill the window as can be seen in this GUI picture. How can I make the textBoxResults expand in the Y direction, and keep the textBox and searchButton attached to the top please?

TIA


回答1:


This is a community-wiky answer, feel free to add related content!

  • Python Tutorial - 25.1.6.2. The Packer

  • Python Tutorial - 25.1.6.3. Packer Options

    • expand
      Boolean, 0 or 1.
    • fill
      Legal values: 'x', 'y', 'both', 'none'.
  • The Tkinter Pack Geometry Manager

    The Pack geometry manager packs widgets in rows or columns. You can use options like fill, expand, and side to control this geometry manager.



来源:https://stackoverflow.com/questions/60931313/the-tkinter-pack-geometry-manager-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!