Hello there! I had to make a lift which can you control with buttons of floor... I got it already but I wanted to add some more things... I want to make a display which will change numbers of floors... I thought that it can be done with pictures like when it goes from 0 to 1 the display which is at 0 will dissapear and when then lift will come to 1 the display will show on floor 1 over the lift... I dont know if is there any other opinion than with pictures but I also thought about some animation which will change that numbers... But I dont know how to make that... Im still learning to Python so I need to get some help with it... I already done thing that when it will go to 1 the display on 0 will dissapear but throught delete.canvas which is not quite good I think so... Still thinking that the best way will be maybe if but I already tried it and it didnt work... All help is highly appreciated... Thanks
It looks like this right now: https://imgur.com/a/VMhgx
It looks like this right now: https://imgur.com/a/VMhgx
import tkinter import random from random import * canvas = tkinter.Canvas(width = 1600, height = 1600, bg = "#58ACFA") canvas.pack() #PosunyVytahu #1 def posun_1(): global y_vytah if y_vytah > 330: y_vytah = y_vytah - 20 canvas.move("Vytah", 0, - 20) canvas.after(100, posun_1) def zmazanie(): canvas.delete(img1) #2 def posun_2(): global y_vytah if y_vytah < 50: y_vytah = y_vytah - 20 canvas.move("Vytah", 0, - 20) if y_vytah < 50: canvas.after(100, posun_2) if y_vytah > 50: y_vytah = y_vytah - 20 canvas.move("Vytah", 0, - 20) if y_vytah > 50: canvas.after(100, posun_2) #0 def posun_3(): global y_vytah if y_vytah < 580: y_vytah = y_vytah + 20 canvas.move("Vytah", 0, + 20) if y_vytah < 580: canvas.after(100, posun_3) if y_vytah > 580: y_vytah = y_vytah + 20 canvas.move("Vytah", 0, + 20) if y_vytah > 580: canvas.after(100, posun_3) #-1 def posun_4(): global y_vytah if y_vytah > 330: y_vytah = y_vytah + 20 canvas.move("Vytah", 0, + 20) if y_vytah > 330: canvas.after(100, posun_4) if y_vytah < 330: y_vytah = y_vytah + 20 canvas.move("Vytah", 0, + 20) if y_vytah < 330: canvas.after(100, posun_4) #(command=lambda:[posun_1(),zmazanie()]) #Bytovka x_bytovka = 450 y_bytovka = 10 sirka_bytovka = 1000 vyska_bytovka = 1000 canvas.create_rectangle(x_bytovka, y_bytovka, sirka_bytovka, vyska_bytovka, fill = "#D8D8D8", outline = "") #Vytah x_vytah = 630 y_vytah = 580 sirka_vytah = 810 vyska_vytah = 790 canvas.create_rectangle(x_vytah, y_vytah, sirka_vytah, vyska_vytah, fill = "white", outline = "black", tags = "Vytah") #Vypinac+Tlacidla x_vypinac1 = 550 y_vypinac1 = 620 sirka_vypinac1 = 600 vyska_vypinac1 = 720 canvas.create_rectangle(x_vypinac1, y_vypinac1, sirka_vypinac1, vyska_vypinac1, fill = "white", outline = "black") x_vypinac2 = 550 y_vypinac2 = 380 sirka_vypinac2 = 600 vyska_vypinac2 = 480 canvas.create_rectangle(x_vypinac2, y_vypinac2, sirka_vypinac2, vyska_vypinac2, fill = "white", outline = "black") x_vypinac3 = 550 y_vypinac3 = 80 sirka_vypinac3 = 600 vyska_vypinac3 = 180 canvas.create_rectangle(x_vypinac3, y_vypinac3, sirka_vypinac3, vyska_vypinac3, fill = "white", outline = "black") #TlacidloHore1 button_up1 = tkinter.Button(command=lambda:[posun_1(), zmazanie()]) button_up1.pack() button_up1.place(x = 559, y = 680) obrazok_up1 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/1poschodie.png") button_up1.config(image = obrazok_up1) #TlacidloHore2 button_up2 = tkinter.Button(command = posun_2) button_up2.pack() button_up2.place(x = 559, y = 630) obrazok_up2 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/2poschodie.png") button_up2.config(image = obrazok_up2) #TlacidloDole1 button_down1 = tkinter.Button(command = posun_3) button_down1.pack() button_down1.place(x = 559, y = 440) obrazok_down1 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/prizemie.png") button_down1.config(image = obrazok_down1) #TlacidloHore3 button_up3 = tkinter.Button(command = posun_2) button_up3.pack() button_up3.place(x = 559, y = 390) obrazok_up3 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/2poschodie.png") button_up3.config(image = obrazok_up2) #TlacidloDole2 button_down2 = tkinter.Button(command = posun_4) button_down2.pack() button_down2.place(x = 559, y = 90) obrazok_down2 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/1poschodie.png") button_down2.config(image = obrazok_down2) #TlacidloDole3 button_down3 = tkinter.Button(command = posun_3) button_down3.pack() button_down3.place(x = 559, y = 140) obrazok_down3 = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/prizemie.png") button_down3.config(image = obrazok_down3) #TabulkaPrizemie picture = tkinter.PhotoImage(file = "C:/Users/Dominik/Desktop/INF - Výťah/tabulkaprizemie.png") img1 = canvas.create_image(720, 560, image = picture)
Output: