Home > Software design >  why isn't my frame stretch completely in tkinter
why isn't my frame stretch completely in tkinter

Time:09-24

I tried to stretch the frame using sticky='nsew' but it's not working properly. I have attached the enter image description here

For a more OOP geared option you can do something like this.

import tkinter as tk


class App(tk.Tk):
    def __init__(self):
        super().__init__()
        self.title("manage your cashflow")
        self.geometry("%dx%d" % (self.winfo_screenwidth(), self.winfo_screenheight()))
        self.configure(bg='grey')
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)

        tk.Button(self, text="the list of month", bg='#ebca87').grid(row=0, column=0, sticky='NEW')
        tk.Button(self, text="the new month", bg='#ebca87').grid(row=0, column=1, sticky='NEW', pady=0)
        frame2 = Frame2()
        frame2.grid(row=1, column=0, columnspan=2, sticky="NSEW")


class Frame2(tk.Frame):
    def __init__(self):
        super().__init__(bg='black')
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)

        tk.Label(self, text="salary").pack()
        salary_entry = tk.Entry(self)
        salary_entry.pack()


if __name__ == '__main__':
    App().mainloop()
  • Related