Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- from tkinter import *
- root = Tk()
- root.wm_title("Mining Calc")
- diff = StringVar()
- hashpower = StringVar()
- hashpower.set("100")
- hashtype = StringVar()
- hashtype.set("GH/s")
- btcprice = StringVar()
- answer = StringVar()
- def calculate(w, x, y, z):
- x = float(x)
- w = float(w)
- z = float(z)
- if y == 'H/s':
- pass
- elif y == 'KH/s':
- x = x * 1000
- elif y == 'MH/s':
- x = (x * 1000) * 1000
- elif y == 'GH/s':
- x = ((x * 1000) * 1000) * 1000
- else:
- x = (((x * 1000) * 1000) * 1000) * 1000
- mine = ((86400 * x * 25) / ((2**32) * w))
- mine = float(mine)
- mine = ("%.6f" % mine)
- mine = float(mine)
- mine_usd = mine * z
- mine_usd = ("%.2f" % mine_usd)
- labeltext = [mine, ' or ',mine_usd,' USD']
- labeltext = ''.join(str(v) for v in labeltext)
- answer.set(labeltext)
- return
- label1 = Label(root, text="Difficulty:")
- label1.pack()
- difficulty_entry = Entry(root, textvariable=diff)
- difficulty_entry.pack()
- label2 = Label(root, text="GH/s:")
- label2.pack()
- hash_entry = Entry(root, textvariable=hashpower)
- hash_entry.pack()
- label3 = Label(root, text="BTC Price:")
- label3.pack()
- price_entry = Entry(root, textvariable=btcprice)
- price_entry.pack()
- label4 = Label(root, text="BTC/day:")
- label4.pack()
- ans = Entry(root, textvariable=answer)
- ans.pack()
- hashtype_select = OptionMenu(root, hashtype, "H/s", "KH/s", "MH/s", "GH/s", \
- "TH/s")
- hashtype_select.pack()
- button1 = Button(root, text="Calculate", command= lambda: calculate(diff.get(), hashpower.get(), hashtype.get(), btcprice.get()))
- button1.pack()
- url = requests.get("https://blockchain.info/stats?format=json").json()
- diff.set("%.1f" % (url['difficulty']))
- btcprice.set("%.2f" % (url['market_price_usd']))
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement