📜  打开 tkinter 和 cli - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:23.809000             🧑  作者: Mango

代码示例1
import threading
from tkinter import *

class GUI:
    def __init__(self):
        # Put whatever you want for the Tkinter window.
        self.window = Tk()

        Label(self.window, text="Tkinter GUI").pack()

        mainloop()

class CLI:
    def __init__(self):
        # Put whatever you wanted for the shell script.
        while True:
            inp = input("Select...")
            if inp == "1":
                print("1")
            elif inp == "2":
                print("2")
            else:
                print("error")

Thread1 = threading.Thread(target=GUI)
Thread1.start()

Thread2 = threading.Thread(target=CLI)
Thread2.start()