import tkinter
from tkinter import *
root = Tk()
root.title("Demo")
class Application(Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.grid(sticky="ewns")
self.feet = StringVar()
self.meters = StringVar()
self.create_widgets()
def calculate(self):
try:
self.meters.set(int(0.3048 * 10000.0 + 0.5)/10000.0)
except ValueError:
pass
def create_widgets(self):
self.master.resizable(width=TRUE, height=TRUE)
top=self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
b1=Button(self, text="7", command=self.calculate,bg="lime")
b1.grid(column=1, row=4, columnspan=1, rowspan=1, padx=0, pady=0, ipadx=0, ipady=0, sticky='we')
''' configuring adjustability of column'''
self.columnconfigure(1, minsize=10, pad=0,weight=1)
''' configuring adjustability of rows'''
self.rowconfigure(4, minsize=10, pad=0,weight=1)
app = Application(master=root)
app.mainloop()on(master=root)
app.mainloop()
Here's the output
before resizing [the same what appears after compiling]
after resizing
As you can see, I am able to resize the width but not the height. Why so???
You have to use
sticky='news'
to make it sticky to all sides - top (north), right (east), left (west), botton (south).Almost the same code with few comments
PEP 8 -- Style Guide for Python Code