问题
Suppose I have two separate files,
e.g. customerorder.py and employeeside.py
customerorder.py gathers the customer order and employeeside.py displays the queue of orders.
Conceptually, these would run on two separate screens inside a coffee shop.
However, when i import employeeside.py from customerorder.py, it displays the employeeside.py GUI instead. I need to import the file as I am calling a function in employeeside.py when from the customerorder.py file. Is there a way to run the specific module in one file without running the whole file? I understand I could do 'from emplyeeside import ...', but this still runs the whole file.
Also, would using a MYSQL client-served database where both programs connect to the database on the network allow for the two separate GUIs to be connected even if physically on two separate computers
#Customerside.py
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
def restartApplicationFromEmployee():
start = EmployeeFrontend.baristaPage()
start.startQueue()
self.payButton1 = tk.Button(self,image=self.payImage1,command=restartApplicationFromEmployee)
self.payButton1.place(x=730,y=690)
#Baristaside.py
class baristaPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
def startQueue():
baristaPage.queue1 = Queue() #instantiating queue class
baristaPage.queue1.enqueue() #running method
#GUI for queue
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
To note, the class named Queue() reads the records in from the database of the customer orders which were recorded in the database when they payed
The class MyFirstGGUI displays the contents of the Queue() class visually
来源:https://stackoverflow.com/questions/59533932/python-link-two-separate-guis-on-physically-different-computers