I am trying to finish this personal project and am trying to develop a GUI for it. I only get a couple hours after work to work on it and I have been trying to fix this feature for 7 days now. I'm not one to ask for help, but it's time. It's so frustrating..
Problem: I want a tk.LabelFrame to appear in a Frame within a Canvas when I click a button. As you click the button, more Frames appear to fill the screen. I want the scrollbar to activate when there is no more room so that I can scroll.
import tkinter as tk
root = tk.Tk()
root.geometry("700x500")
mainframe = tk.Frame(root)
mainframe.pack(fill="both", expand=True)
mainframe.columnconfigure(0, weight=1)
mainframe.columnconfigure(1, weight=1)
mainframe.columnconfigure(2, weight=1)
mainframe.rowconfigure(1, weight=1)
EventsCanvas = tk.Canvas(mainframe)
EventsCanvas.grid(column=0, columnspan=2, row=1, sticky="NWES")
EventsMainframe = tk.Frame(EventsCanvas, bg="red")
EventsMainframe.pack(fill="both", expand=True)
vbar=tk.Scrollbar(EventsMainframe, orient="vertical")
vbar.pack(side="right", fill="y")
vbar.config(command=EventsCanvas.yview)
EventsCanvas.config(yscrollcommand=vbar.set)
def add():
Event = tk.LabelFrame(EventsMainframe, text="New Event", height=100)
Event.pack(anchor="nw", fill="x", expand=True)
EventsCanvas.configure(scrollregion=EventsCanvas.bbox("all"))
AddEvent = tk.Button(EventsMainframe, text="Add Event", command=add)
AddEvent.pack()
root.mainloop()
This is what happens when I run out of room:
I want the scrollbar to activate and let me scroll as I keep clicking "Add Event"