- modify the following code to add "Pin 0" text under checkboxes. import time import…
- User
- modify the following code to add "Pin 0" text under checkboxes.
import time import threading import tkinter as tk
state = False
def AND_Gate(a,b): return a and b def OR_Gate(a,b): return a or b def NOT_Gate(a): return not a def NAND_Gate(a,b): return not(a and b) def NOR_Gate(a,b): return not(a or b) def XOR_Gate(a,b): return (a or b) and not(a and b) def XNOR_Gate(a,b): return not((a or b) and not(a and b))
def clock(update_clock,speed = 1): cycle = 0 global state while True: state = False time.sleep(1 / speed / 2) update_clock(f"State : False , Cycle {cycle}") state = True time.sleep(1 / speed / 2) update_clock(f"State : True , Cycle {cycle}") cycle += 1
main_window = tk.Tk() main_window.title("Intel 4004") main_window.geometry("400x300") clock_label = tk.Label(main_window, text="") clock_label.pack(side="bottom") def update_clock(text): clock_label.config(text=text) checkbox_window_1 = tk.Frame(main_window) checkbox_window_1.pack(side="top") checkbox_window_2 = tk.Frame(main_window) checkbox_window_2.pack(side="top") pins = [] for i in range(8): var = tk.BooleanVar(name=f"Pin {i}") checkbox = tk.Checkbutton(checkbox_window_1, variable=var) checkbox.pack(side="left") pins.append(var) for i in range(8,16): var = tk.BooleanVar(name=f"Pin {i}") checkbox = tk.Checkbutton(checkbox_window_2, variable=var) checkbox.pack(side="left") pins.append(var) clock_thread = threading.Thread(target=clock,args=(update_clock,),daemon=True) clock_thread.start() main_window.mainloop()
- Assistant