| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- from tkinter import *
- from linked_data import Chain, format_dict
- import pprint
- chain = Chain()
- chain.populate()
- root = Tk()
- root.title('dsp blockchain')
- view = Entry(root, width=35, borderwidth=5)
- view.grid(row=0, column=1, columnspan=3, padx=10, pady=10)
- def myClick():
- print(view.get())
- chain.current_contract_state(int(view.get()))
- pprint.pprint(chain.state)
- def add_contract():
- # add contract to the blockchain
- def add():
- chain.new_contract(client.get(), contractor.get(), deadline.get(), description.get(), name.get(), int(price.get()), people.get().split(','), initiator.get())
- # destroy add contract window, and print conformation
- newWindow.destroy()
- print('contract added')
- # make new window for adding the information for the contract
- newWindow = Toplevel(root)
- newWindow.title('Add contract')
- # create all text boxes
- Label(newWindow, text='The client: ').grid(row=0, column=0)
- client = Entry(newWindow, width=35, borderwidth=5)
- client.grid(row=0, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='The contractor: ').grid(row=1, column=0)
- contractor = Entry(newWindow, width=35, borderwidth=5)
- contractor.grid(row=1, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='Deadline: ').grid(row=2, column=0)
- deadline = Entry(newWindow, width=35, borderwidth=5)
- deadline.grid(row=2, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='Description: ').grid(row=3, column=0)
- description = Entry(newWindow, width=35, borderwidth=5)
- description.grid(row=3, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='Project name: ').grid(row=4, column=0)
- name = Entry(newWindow, width=35, borderwidth=5)
- name.grid(row=4, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='Price: ').grid(row=5, column=0)
- price = Entry(newWindow, width=35, borderwidth=5)
- price.grid(row=5, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='People involved: ').grid(row=6, column=0)
- people = Entry(newWindow, width=35, borderwidth=5)
- people.grid(row=6, column=1, columnspan=3, padx=10, pady=10)
- Label(newWindow, text='Initiator').grid(row=7, column=0)
- initiator = Entry(newWindow, width=35, borderwidth=5)
- initiator.grid(row=7, column=1, columnspan=3, padx=10, pady=10)
- # create the add contract button
- add_c = Button(newWindow, text = "Add contract", command=add)
- add_c.grid(row=8, column=0)
-
- myButton = Button(root, text="View contract", command=myClick)
- myButton.grid(row=0, column=0)
- myButton = Button(root, text="New contract", command=add_contract)
- myButton.grid(row=1, column=0)
- root.mainloop()
|