123456789101112131415161718192021222324252627282930313233343536 |
- import queue as qu
- import tkinter
- class ConsoleLog(tkinter.Frame):
- def __init__(self, master=None):
- tkinter.Frame.__init__(self, master)
- self.queue = qu.Queue()
- self.text = tkinter.Text(self, highlightthickness=0, bd=0, bg='black', fg='white', relief='sunken',
- width=90, height=12)
- self.text.pack()
- self.sampler()
- def sampler(self):
- if self.queue.qsize():
-
- try:
- data = self.queue.get()
- self.text.insert('end', data)
- self.queue.task_done()
- except qu.Empty:
- pass
- self.after(50, self.sampler)
- def run(self):
- self.mainloop()
- def close(self):
- """Process before shutdown"""
- self.destroy()
|