Tkinter白色窗口

时间:2016-06-26 18:51:32

标签: multithreading tkinter python-3.5

我使用Tkinter在Python 3.5中创建了一个多线程程序。

当我启动程序时,它不会给出任何错误,但它会形成一个完全白色的窗口。 我也尝试停止GUI线程,但程序没有退出...

感谢您的回答。

import datetime
import imaplib
import os
import queue
import requests
import smtplib
import sqlite3
import threading
import time

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from tkinter import *

class StartGUI(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)
        self._stop = threading.Event()

    def run(self):
        self.GUI = GUI(None)
        self.GUI.title('Eve 3.0')
        self.GUI.mainloop()

    def stop(self):
        self._stop.set()

    def stopped(self):
        return self._stop.isSet()

class GUI(Tk):

    def __init__(self, parent):
        Tk.__init__(self, parent)
        self.parent = parent
        self.initialize()

    def initialize(self):
        self.grid()

        self.outTxt = Text(self, height=5)
        self.outTxt.grid(column=0, columnspan=3)

        self.eraseButton = Button(
            self, bg='#424242', fg='white', text='Erase', command=self.eraseInput)
        self.inTxt = Entry(self, bg='#424242', fg='white')  # , height=2)
        self.submitButton = Button(
            self, bg='#424242', fg='white', text='Submit', command=self.submitInput)

        self.eraseButton.grid(column=0, row=1, sticky='EW')
        self.inTxt.grid(column=1, row=1, sticky='EW')
        self.submitButton.grid(column=2, row=1, sticky='EW')

    def eraseInput(self):
        self.inTxt.delete(0, END)

    def submitInput(self):
        input = self.inTxt.get()
        self.inTxt.delete(0, END)
        print(input)

if __name__ == '__main__':
    GUIThread = StartGUI()
    GUIThread.start()
    GUIThread.stop()
    stopped = GUIThread.stopped()

编辑: 窗口是完全白色的,即使操作系统特定的覆盖层也不会呈现......

0 个答案:

没有答案