-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
40 lines (31 loc) · 822 Bytes
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from tkinter import *
import time
from blockchain import Blockchain, Block
window = Tk()
window.title("Blochchain")
window.minsize(width=500, height=400)
#Text
text = Text(height=30, width=70)
text.insert(END, "")
text.pack()
#Bouton stop
flag = True
def stop():
global flag
print("Stop request")
flag = False
Button(window,text=' Stop ',command=stop).pack()
blockchain = Blockchain()
num_block = 0
def update_blockchain():
global num_block, flag
num_block += 1
blockchain.mine(Block("Block " + str(num_block)))
text.insert(END,str(blockchain.block)+"\n")
if flag:
window.after(2000,update_blockchain)
else:
print("stop")
text.insert(END,"\n#### STOP ####")
window.after(500,update_blockchain)
window.mainloop()