GUI 와 echo server (thread)로 동작하는 예제
import tkinter as tk
import tkinter.ttk as ttk
import threading
import echo_server as myserver
import datetime
def run_echo_server(port=1234):
myserver.echo_server(port)
class workclass(threading.Thread):
def run(self):
run_echo_server()
class Window(ttk.Frame):
def __init__(self, master=None):
super().__init__(master)
hellolabel = ttk.Button(self, text="헬로" )
quitButton =ttk.Button(self, text="Quit", command=self.quit)
hellolabel.pack()
quitButton.pack()
self.pack()
if __name__ == '__main__':
th1 = workclass()
th1.setDaemon(True)
th1.start()
window = Window()
window.master.title("Hello")
window.master.mainloop()
import tkinter as tk
import tkinter.ttk as ttk
import threading
import echo_server as myserver
import datetime
def run_echo_server(port=1234):
myserver.echo_server(port)
class workclass(threading.Thread):
def run(self):
run_echo_server()
class Window(ttk.Frame):
def __init__(self, master=None):
super().__init__(master)
hellolabel = ttk.Button(self, text="헬로" )
quitButton =ttk.Button(self, text="Quit", command=self.quit)
hellolabel.pack()
quitButton.pack()
self.pack()
if __name__ == '__main__':
th1 = workclass()
th1.setDaemon(True)
th1.start()
window = Window()
window.master.title("Hello")
window.master.mainloop()
댓글