I am starting in python and this is my first language. I have been entrusted with something that is quickly becoming too big for me to understand that I need to finish. I almost did. At this point, I created a dialog box that serves as the main menu, a dialog box that is a selectable option from the main menu that launches the test, and a multi-threaded instance that runs the test opens “please wait”, and when the test finishes another dialog box that announces that the test is complete.
My problem: in the Run Test dialog box, I am trying to create a button that will trigger a multithreaded instance in action. From the code that I analyzed together with the help of others, I don’t see which class should be created in the Run Test dialog box.
I am starting to believe that my streaming implementation is wrong. However, there must be a way.
This is the module I'm trying to call.
from slice_setup import SLICE_SETUP import Tkinter as tk import threading import Queue class GuiPart: def __init__(self, master, queue): self.queue = queue self.master = master self.master.geometry("300x100+400+250") self.master.title("RSAM BCT") tk.Label(master, text="REDCOM SLICE", fg="red").pack() tk.Label(master, text="BCT - Basic Configuration Test", fg= "red").pack() tk.Label(master, text="Please wait...", fg= "black").pack() tk.Label(master, text="Estimated time: 3 min 6 sec", fg= "black").pack() def processIncoming(self): while self.queue.qsize(): try: text = self.queue.get(0) Complete(self.master, text) except Queue.Empty: pass class ThreadedClient: def __init__(self, master): self.master = master self.queue = Queue.Queue() self.gui = GuiPart(master, self.queue) self.running = True self.thread = threading.Thread(target=self.workerThread1) self.thread.start() self.periodicCall() def periodicCall(self): self.gui.processIncoming() if not self.running: return self.master.after(100, self.periodicCall) def workerThread1(self): obj_rcs = SLICE_SETUP() obj_rcs.SLICE() self.queue.put("Configuration Complete!") self.running = False class Complete(tk.Toplevel): def __init__(self, master=None, completetext=""): tk.Toplevel.__init__(self, master) self.geometry("400x300+400+250") self.title("RSAM BCT") tk.Label(self, text="REDCOME SLICE", fg="red").pack() tk.Label(self, text="BCT - Basic Configuration Test", fg="red").pack() tk.Label(self, text=completetext, fg="dark green").pack() tk.Label(self, text="Trunk 1: Port 1: Phone 1: 760-450-4500", fg="black").pack() tk.Label(self, text="Trunk 1: Port 2: Phone 2: 760-450-4501", fg="black").pack() tk.Button(self, text=" Exit ", command=self.destroy).pack() if __name__ == "__main__": root = tk.Tk() client = ThreadedClient(root) root.mainloop()
and here I am trying to call from:
import sys import Tkinter as Tk() from bct_pleasewait import ???? import threading import Queue import time sGui = Tk() class slice_menu: def runtest(self): obj_wait = ???? obj_wait.???? def slicemenu(self): sGui.geometry("400x300+400+250") sGui.title("RSAM BCT") Label(sGui, text= "REDCOM SLICE", fg="red").pack() Label(sGui, text= "BCT - Basic Configuration Test", fg= "red").pack() Label(sGui, text= "-Ensure you are logged off of HyperTerminal", fg= "black").pack() Label(sGui, text= "-Turn on your REDCOM SLICE unit", fg= "black").pack() Label(sGui, text= "-Please connect your laptop to SLICE CONSOLE", fg= "black").pack() Label(sGui, text= "-This configuration will take 3 minutes", fg= "black").pack() Button(sGui, text = " Run ", command = self.runtest).pack() Button(sGui, text = " Exit test ", command = sGui.destroy).pack() sGui.mainloop()
There are still small bugs in this class, but I just want this problem to be resolved first.