Re: Expanding a frame into an expanding window

Phil <[email protected]> Tue, 26 Mar 2024 08:57:09 +1000
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
On 25/3/24 21:05, Alan Gauld via Tutor wrote:
> On 25/03/2024 07:07, Phil wrote:
>
> I'm not seeing the problem. Both widgets move when the window is expanded.
> Here is my code, only slightly modified from yours:
>
>
> Thank you Alan for your reply and I appreaciate it geatly. The problem only occures when the class SimpleEntry is imported. The ButtonFrame widget moves but the EnrtyFrame widget (SimpleEntry) does not move.

import tkinter as tk
from tkinter_entry_class import SimpleEntry


class EntryFrame(tk.Frame):
     def __init__(self, parent):
         super().__init__(parent)
         self.entry_widget = SimpleEntry(self, bg_colour="yellow")
         self.entry_widget.pack(fill="both", expand=True)


class ButtonFrame(tk.Frame):
     def __init__(self, parent):
         super().__init__(parent, bg="light green")
         self.add_button = tk.Button(self, text="Press me", 
command=self.on_button_click)
         self.add_button.pack()

     def on_button_click(self):
         pass


class App(tk.Tk):
     def __init__(self):
         super().__init__()
         self.title("Simple Class Test")

         self.entry_frame = EntryFrame(self)
         self.button_frame = ButtonFrame(self)

         self.entry_frame.grid(row=0, column=0, padx=5, pady=5, 
sticky="nsew")
         self.button_frame.grid(row=1, column=0, padx=5, pady=5, 
sticky="nsew")

         self.grid_rowconfigure(0, weight=1)
         self.grid_rowconfigure(1, weight=1)
         self.grid_columnconfigure(0, weight=1)


def main():
     app = App()
     app.mainloop()


if __name__ == "__main__":
     main()


-- 
Regards,
Phil
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor