Ich bin neu in Python und brauche Hilfe, um die Schaltfläche zum Starten/Stoppen der Schleife zu erhaltenPython

Python-Programme
Anonymous
 Ich bin neu in Python und brauche Hilfe, um die Schaltfläche zum Starten/Stoppen der Schleife zu erhalten

Post by Anonymous »

Ich habe Sachen ausprobiert und nichts funktioniert, ich versuche, die Schaltfläche zum Starten/Stoppen der Bergbauschleife zu bekommen, aber es beginnt entweder nach dem Schließen des Programms oder tut überhaupt nichts

Code: Select all

import hashlib
import time
from tkinter import *
import tkinter as tk

i = 1
root = tk.Tk()
# root window title and dimension
root.title("Bitcoin miner")
# Set geometry (widthxheight)
root.geometry('200x100')
def toggle():

if toggle_btn.config('relief')[-1] == 'sunken':
toggle_btn.config(relief="raised", text="Off")
i == 2
else:
toggle_btn.config(relief="sunken", text="On")
i == 1
v = IntVar()

toggle_btn = tk.Button(text="Off", width=12, relief="raised", command=toggle)
toggle_btn.pack(pady=5)

toggle_btn.place(x=55, y=50)
root.mainloop()

def mine(block_string, difficulty):
nonce = 0
prefix_str = '0'*difficulty
while True:
text = block_string + str(nonce)
new_hash = hashlib.sha256(text.encode('ascii')).hexdigest()
if new_hash.startswith(prefix_str):
print("Yay! Bitcoin mined in nonce: %s with hash: %s" % (nonce, new_hash))
return new_hash
nonce += 1

if __name__ == '__main__':

while i == 1:
block_string = "Some transactions"
difficulty = 5
start = time.time()
print("Start mining")
new_hash = mine(block_string, difficulty)
total_time = str((time.time() - start))
print("end mining. Mining took: " + total_time + " seconds.")
Ich habe versucht, die Schleife unter und über Dingen zu setzen, und es hilft nicht

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post