Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

python - How to make a frame browser in tkinter?

I am new to using tkinter in python and I was wondering how to make a window that has two buttons (one on the front and one on the back), with which a number of frames can be displayed one at a time and, once they have all crossed, they return to start indefinitely, pressing any of the two buttons (one would repeat this action from start to finish and the other from end to start)

this is my code sketch:

from tkinter import *
x = 0
mas = 1
menos = 0
c = []
def f(v):
    if v == 1:
        
        c.append(x)
        #print(len(c))
    elif v == 0:
        c.remove(c[len(c)-1])
        #print(len(c))
    
    j = len(c) -1
    

    print(j)

    lst[j-1].pack_forget()
    lst[j+1].pack_forget()
    lst[j].pack()

    if j > 7:
        j = 1
    elif j < 0:
        j = 7

root = Tk()
bad = Button(root,text = ">",command = lambda mas = mas: f(mas)).place(x = 20, y = 0)
bat = Button(root,text = "<",command = lambda menos = menos: f(menos)).place(x = 0, y = 0)
l1 = Label(root , text = 1)
l2 = Label(root , text = 2)
l3 = Label(root , text = 3)
l4 = Label(root , text = 4)
l5 = Label(root , text = 5)
l6 = Label(root , text = 6)
l7 = Label(root , text = 7)
lst = [l1,l2,l3,l5,l6,l7]

root.mainloop()
question from:https://stackoverflow.com/questions/65911051/how-to-make-a-frame-browser-in-tkinter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...