Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ProgressBar(tk.Canvas):
- def __init__(self, master):
- super().__init__(master)
- self._c=Canvas(master, width=400, height=50)
- self._c.pack()
- def update_bar(self, moves):
- bar=self._c.create_rectangle(0, 0, 50, 20, fill="purple", width=0)
- x0, y0, x1, y1 = self._c.coords(bar)
- for i in str(moves):
- if x1<=300:
- self._c.coords(bar, x0, y0, x1*(20-moves), y1)
- print(x1)
- elif x1>300:
- self._c.coords(bar, x0, y0, 50, y1)
Add Comment
Please, Sign In to add comment