12345678910111213141516171819202122232425262728293031 |
- import tkinter as tk
- from tkinter.ttk import Progressbar
- class LogScreen(tk.Frame):
- def __init__(self, root, log_handler):
- self.root = root
- tk.Frame.__init__(self, root)
- self.y_scroll = tk.Scrollbar(self.root)
- self.y_scroll.pack(side="right", fill="y")
- self.x_scroll = tk.Scrollbar(self.root, orient='horizontal')
- self.x_scroll.pack(side="bottom", fill="x")
- self.textfield = tk.Listbox(self.root, yscrollcommand=self.y_scroll.set, xscrollcommand=self.x_scroll.set)
- self.textfield.pack(side="left",expand=True, fill=tk.BOTH)
- for element in log_handler.get_log_list():
- self.textfield.insert(tk.END, element)
- self.y_scroll.config(command=self.textfield.yview)
- self.x_scroll.config(command=self.textfield.xview)
- root.bind('<Escape>', self.close)
-
- def update(self):
- if not self.root.winfo_exists():
- return
- def close(self):
- if self.root.winfo_exists():
- self.root.destroy()
|