Logscreen.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import tkinter as tk
  2. from tkinter.ttk import Progressbar
  3. class LogScreen(tk.Frame):
  4. def __init__(self, root, log_handler):
  5. self.root = root
  6. tk.Frame.__init__(self, root)
  7. self.y_scroll = tk.Scrollbar(self.root)
  8. self.y_scroll.pack(side="right", fill="y")
  9. self.x_scroll = tk.Scrollbar(self.root, orient='horizontal')
  10. self.x_scroll.pack(side="bottom", fill="x")
  11. self.textfield = tk.Listbox(self.root, yscrollcommand=self.y_scroll.set, xscrollcommand=self.x_scroll.set)
  12. self.textfield.pack(side="left",expand=True, fill=tk.BOTH)
  13. for element in log_handler.get_log_list():
  14. self.textfield.insert(tk.END, element)
  15. self.y_scroll.config(command=self.textfield.yview)
  16. self.x_scroll.config(command=self.textfield.xview)
  17. root.bind('<Escape>', self.close)
  18. def update(self):
  19. if not self.root.winfo_exists():
  20. return
  21. def close(self):
  22. if self.root.winfo_exists():
  23. self.root.destroy()