Skip to content

Commit

Permalink
Added a GUI and compiled it to an exe which can be located in the bin…
Browse files Browse the repository at this point in the history
…/ folder.
  • Loading branch information
Max00355 committed Nov 30, 2013
1 parent 0a49cba commit da67c28
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 2 deletions.
Binary file added bin/zCoin.exe
Binary file not shown.
1 change: 1 addition & 0 deletions shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def do_update(self, line):
"send_command.py":"https://raw.github.com/Max00355/zCoin/master/send_command.py",
"shell.py":"https://raw.github.com/Max00355/zCoin/master/shell.py",
"zcoin.py":"https://raw.github.com/Max00355/zCoin/master/zcoin.py",
"zcoingui.py":"https://raw.github.com/Max00355/zCoin/master/zcoingui.py",

}

Expand Down
7 changes: 5 additions & 2 deletions zcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def normal(self):
coin_count.send()
get_nodes.count_send()
time.sleep(60)
if __name__ == "__main__":

def run():
zc = zCoin()
check = config.nodes.find("nodes", "all")
if not check:
Expand All @@ -100,4 +101,6 @@ def normal(self):
else:
print "zCoin started as a normal node."
zc.normal()


if __name__ == "__main__":
run()
100 changes: 100 additions & 0 deletions zcoingui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from Tkinter import *
import config
import send_coin
import thread
import time
import tkMessageBox
import zcoin

class zCoinUI:

def __init__(self, root):
self.root = root
self.frame = Frame(self.root)
self.frame.pack()
self.c = StringVar()
self.t = StringVar()
self.addr_ = StringVar()
thread.start_new_thread(self._update, ())
self.addr()
self.coins()
self.totalcoins()
self.send()

def _update(self):
while True:

coins = config.db.find("coins", {"address":config.wallet.find("data", "all")[0]['address']})
if not coins:
coins = []
coins = len(coins)
totalcoins = config.db.find("coins", "all")
if not totalcoins:
totalcoins = []
totalcoins = len(totalcoins)
addr = config.wallet.find("data", "all")[0]['address']
self.addr_.set(addr)
self.c.set(coins)
self.t.set(totalcoins)
time.sleep(10)

def addr(self):

addr_f = LabelFrame(self.frame, text="Address", padx=5, pady=5)
addr_f.grid(sticky=E+W)
Entry(self.frame, state="readonly", textvariable=self.addr_, width=50).grid(in_=addr_f)

def coins(self):
coins_f = LabelFrame(self.frame, text="Your Coins", padx=5, pady=10)
coins_f.grid(sticky=E+W)
Label(self.frame, textvariable=self.c).grid(in_=coins_f)

def totalcoins(self):
total_f = LabelFrame(self.frame, text="Total Coins", padx=5, pady=10)
total_f.grid(sticky=E+W)
Label(self.frame, textvariable=self.t).grid(in_=total_f)

def send(self):
send_f = LabelFrame(self.frame, text="Send Coin", padx=5, pady=15)
send_f.grid(sticky=E+W)
to_l = Label(self.frame, text="To: ").grid(in_=send_f)
self.to = Entry(self.frame)
self.to.grid(in_=send_f, row=0, column=1, sticky=W)
amount_l = Label(self.frame, text="Amount: ").grid(in_=send_f, row=0, column=3, sticky=W)
self.amount = Entry(self.frame, width=4)
self.amount.grid(in_=send_f, row=0, column=4, sticky=W)
Label(self.frame, text=" ").grid(in_=send_f, row=0, column=5)
Label(self.frame, text=" ").grid(in_=send_f, row=0, column=2)
send_b = Button(self.frame, command=self._send, text="Send").grid(in_=send_f, row=0, column=8, sticky=W+E+N+S)

def _send(self):
amount = self.amount.get()
to = self.to.get()
addr = config.wallet.find("data", "all")[0]['address']
check = config.db.find("coins", {"address":addr})
if not check:
check = []
try:
int(amount)
except ValueError:
tkMessageBox.showinfo("Woops!", "Amount must be a number.")
return
if len(check) < int(amount):
tkMessageBox.showinfo("Woops!", "You don't have enough coins.")
return
check = config.nodes.find("nodes", {"address":to})
if not check:
tkMessageBox.showinfo("Woops!", "Address doesn't exist.")
return
thread.start_new_thread(send_coin.send, (to, amount))
tkMessageBox.showinfo("Sending...", "Your coins are being sent, this could take a while.")

if __name__ == "__main__":
if not config.wallet.find("data", "all"):
zcoin.zCoin().firstrun()
thread.start_new_thread(zcoin.run, ())
root = Tk()
root.geometry("450x250+350+100")
zCoinUI(root=root)
root.title("zCoin Client")
root.mainloop()

0 comments on commit da67c28

Please sign in to comment.