Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good afternoon, everyone
I am a beginner at making guis with tkinter and Python 3.6
I wanted to make a 'Quizlet' like interface for adding questions.
How can I make the next frame appear right below the one in which I clicked +?
What I also want is to have easily accessible datat structure fot the frames.
Thank you very much!

What I have tried:

Here is my code:
Python
from tkinter import *
root = Tk()
height = root.winfo_screenheight()
canvas = Canvas(root, bd=0,width=800,height=height,bg = "blue")
screen_fit = height/105
frame_number = 2
EDIT_QUESTIONS= Label(root,text="Edit questions",font = "Courier").grid(row = 1,column = 1)
class edit:
    def __init__(self):
       canvas.grid(row=2,column=2)
       self.new_frame()
    def new_frame(self):
        def remove(window):
            pass
        def new_frame1(self):
            global frame_number
            
            frame = Frame(root)
            r = (10 + 105)* (frame_number -1)
            frame_number =  frame_number + 1
            window = canvas.create_window(25, r , anchor = "nw", window = frame,tags =(frame_number))
            text = Text(frame,height = 2)
            text.grid(row=1,column=2)
            plus = Button(frame,text="+",command = self.new_frame)
            plus.grid(row=2,column=1)            
            minus = Button(frame,text="-" )
            #minus.config(command = lambda: remove(window))
            minus.grid(row=3,column=1)

            if frame_number > int(screen_fit)or frame_number == int(screen_fit):
                def on_mousewheel(event):
                    canvas.yview_scroll(-1*(int(event.delta/120)), "units") 

                scrollbar= Scrollbar(root,orient="vertical",command=canvas.yview)
                scrollbar.grid(row=2,column=4,sticky = "ns")
                canvas.bind_all("<MouseWheel>", on_mousewheel)
                canvas.configure(scrollregion=canvas.bbox("all"),width=800,height=700) 
                canvas.configure(yscrollcommand=scrollbar.set)
        new_frame1(self)
Edit = edit()
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900