Aug-03-2018, 04:28 AM
Hello, I recently started working on a personal app to help me learn GUI programming with python Tkinter. What I am having trouble with is coding the geometry, I learned how to make buttons and labels, but when I run my program I have no control over where they will be displayed within the screen. Here is an example program I wrote, It is to become an online shopping app:
NOTE: I thought I could show you a picture but I guess this forum doesn't support that.
Anyhow, the problem is, when I run the code, the buttons appear in the bottom center under a large white space. I want the buttons lined up from top to bottom on left side of screen. What can I do to fix my geometry problems?
from tkinter import * root = Tk() BeveragesButton = Button(master = root, bg = "white", fg = "green", text = "Beverages") Meat_SeafoodButton = Button(master = root, bg = "white", fg = "green", text = "Meat & Seafood") BakeryButton = Button(master = root, bg = "white", fg = "green", text = "Bakery") PantryButton = Button(master = root, bg = "white", fg = "green", text = "Pantry") Snacks_SweetsButton = Button(master = root, bg = "white", fg = "green", text = "Snacks & Sweets") Dairy_EggsButton = Button(master = root, bg = "white", fg = "green", text = " Dairy & Eggs") Frozen_Foods = Button(master = root, bg = "white", fg = "green", text = "Frozen Foods") ButtonsList1 = [BeveragesButton,Meat_SeafoodButton,BakeryButton,PantryButton,Snacks_SweetsButton,Dairy_EggsButton,Frozen_Foods] listbox = Listbox(root) listbox.pack(fill = BOTH,expand = 1) for button in ButtonsList1: listbox.insert(END) button.pack() mainloop()This is a image of the window python produces from the code:
NOTE: I thought I could show you a picture but I guess this forum doesn't support that.
Anyhow, the problem is, when I run the code, the buttons appear in the bottom center under a large white space. I want the buttons lined up from top to bottom on left side of screen. What can I do to fix my geometry problems?