I have comments in a number of places where I've tried to use the columnconfigure or rowconfigure methods to cause the windows to resize, but none of it seems to be working. I can also take out mainloop() and my program runs exactly the same. This leads me to believe I'm perhaps not calling/using mainloop correctly. The methods are mostly just for organization, and I know they're not reusable methods right now. I was planning on maybe fixing that at some point, but that's not the purpose of this post.
#!/usr/bin/python
from tkinter import *
from tkinter import ttk
import webbrowser
from dictionary import *
class AI():
def __init__(self):
self.urls = dictionary.get()
self.makeMainframe()
self.makeLabels()
self.makeDropDown()
self.makeButton()
self.makeEntry()
for child in self.mainframe.winfo_children():
child.grid_configure(padx=2, pady=2)
#child.columnconfigure(index='all',weight=1)
#child.rowconfigure(index='all',weight=1)
def openMenu(self):
webbrowser.open(self.urls[self.lunchVar.get()])
print(self.urls[self.lunchVar.get()])
def saveChoice(self, event):
print(self.foodVar.get())
def makeMainframe(self):
self.mainframe = ttk.Frame(padding="3 3 12 12")
self.mainframe.grid(column=0, row=0, sticky=(N,W,E,S))
#self.mainframe.columnconfigure('all', weight=1)
#self.mainframe.rowconfigure(index='all', weight=1)
def makeDropDown(self):
self.lunchVar = StringVar()
self.lunchChoice = ttk.Combobox(self.mainframe, textvariable=self.lunchVar, state='readonly')
self.lunchChoice['values'] = list(self.urls.keys())
self.lunchChoice.grid(column=2, row=1, sticky=(W, E))
def makeLabels(self):
ttk.Label(self.mainframe, text="Today's lunch is from...").grid(column=1, row=1, sticky=(E,W))
ttk.Label(self.mainframe, text="Click here for a menu -->").grid(column=1, row=2, sticky=(E,W))
ttk.Label(self.mainframe, text="What will you be having?").grid(column=1, row=3, sticky=(E,W))
def makeButton(self):
self.menu = ttk.Button(self.mainframe, textvariable=self.lunchVar, command=self.openMenu)
self.menu.grid(column=2, row=2, sticky=(W, E))
def makeEntry(self):
self.foodVar = StringVar()
self.foodChoice = ttk.Entry(self.mainframe, textvariable=self.foodVar)
self.foodChoice.grid(column=2, row=3, sticky=(E,W))
self.foodChoice.bind("<Return>", self.saveChoice)
#self.foodChoice.columnconfigure(index='all', weight=1)
AI=AI()
mainloop()