updates to use tk after for backgrounded tasks, also added background task convenience class for running something in the background and running a callback using tk.after when done
This commit is contained in:
parent
dd43fae62a
commit
3e87737ee6
7 changed files with 127 additions and 110 deletions
|
@ -2,7 +2,6 @@
|
|||
marker dialog
|
||||
"""
|
||||
|
||||
import logging
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
|
@ -20,7 +19,6 @@ class MarkerDialog(Dialog):
|
|||
self.radius = MARKER_THICKNESS[0]
|
||||
self.marker_thickness = tk.IntVar(value=MARKER_THICKNESS[0])
|
||||
self.draw()
|
||||
self.top.bind("<Destroy>", self.close_marker)
|
||||
|
||||
def draw(self):
|
||||
button = ttk.Button(self.top, text="clear", command=self.clear_marker)
|
||||
|
@ -64,16 +62,8 @@ class MarkerDialog(Dialog):
|
|||
def change_thickness(self, event):
|
||||
self.radius = self.marker_thickness.get()
|
||||
|
||||
def close_marker(self, event):
|
||||
logging.debug("destroy marker dialog")
|
||||
self.app.toolbar.marker_tool = None
|
||||
|
||||
def position(self):
|
||||
print(self.winfo_width(), self.winfo_height())
|
||||
# print(self.app.master.winfo_x(), self.app.master.winfo_y())
|
||||
print(self.app.canvas.winfo_rootx())
|
||||
def show(self):
|
||||
super().show()
|
||||
self.geometry(
|
||||
"+{}+{}".format(
|
||||
self.app.canvas.winfo_rootx(), self.app.canvas.master.winfo_rooty()
|
||||
)
|
||||
f"+{self.app.canvas.winfo_rootx()}+{self.app.canvas.master.winfo_rooty()}"
|
||||
)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import logging
|
||||
import threading
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
|
@ -9,6 +8,7 @@ from core.api.grpc import core_pb2
|
|||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.errors import show_grpc_error
|
||||
from core.gui.images import ImageEnum, Images
|
||||
from core.gui.task import BackgroundTask
|
||||
from core.gui.themes import PADX, PADY
|
||||
|
||||
|
||||
|
@ -164,10 +164,8 @@ class SessionsDialog(Dialog):
|
|||
|
||||
def join_session(self, session_id):
|
||||
self.app.statusbar.progress_bar.start(5)
|
||||
thread = threading.Thread(
|
||||
target=self.app.core.join_session, args=([session_id])
|
||||
)
|
||||
thread.start()
|
||||
task = BackgroundTask(self.app, self.app.core.join_session, args=(session_id,))
|
||||
task.start()
|
||||
self.destroy()
|
||||
|
||||
def on_selected(self, event):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue