magicclass.utils package¶
Submodules¶
magicclass.utils.qt module¶
- class magicclass.utils.qt.MessageBoxMode(value)[source]¶
Bases:
Enum
An enumeration.
- ABOUT = 'about'¶
- ERROR = 'error'¶
- INFO = 'info'¶
- QUESTION = 'question'¶
- WARNING = 'warn'¶
- magicclass.utils.qt.move_to_screen_center(qwidget: QWidget) None [source]¶
Move a QWidget to the center of screen.
- magicclass.utils.qt.open_url(link: str) None [source]¶
Open the link with the default browser.
- Parameters
link (str) -- Link to the home page.
- magicclass.utils.qt.show_messagebox(mode: str | MessageBoxMode = MessageBoxMode.INFO, title: str = None, text: str = None, parent=None) bool [source]¶
Freeze the GUI and open a messagebox dialog.
- Parameters
mode (str or MessageBoxMode, default is MessageBoxMode.INFO) -- Mode of message box. Must be "error", "warn", "info", "question" or "about".
title (str, optional) -- Title of messagebox.
text (str, optional) -- Text in messagebox.
parent (QWidget, optional) -- Parent widget.
- Returns
If "OK" or "Yes" is clicked, return True. Otherwise return False.
- Return type
bool
magicclass.utils.qthreading module¶
- class magicclass.utils.qthreading.Callback(f: Callable[[], Any])[source]¶
Bases:
object
Callback object that can be recognized by thread_worker.
- class magicclass.utils.qthreading.Timer[source]¶
Bases:
object
A timer class with intuitive API.
- property sec: float¶
Return current second.
- class magicclass.utils.qthreading.thread_worker(f: Callable[_P, _R1] | None = None, *, ignore_errors: bool = False, progress: ProgressDict | None = None)[source]¶
Bases:
object
- property aborted: CallbackList[None]¶
Event that will be emitted on aborted.
- property errored: CallbackList[Exception]¶
Event that will be emitted on errored.
- property finished: CallbackList[None]¶
Event that will be emitted on finished.
- property func: Callable[[_P], _R1]¶
- property is_generator: bool¶
True if bound function is a generator function.
- property returned: CallbackList[_R1]¶
Event that will be emitted on returned.
- classmethod set_default(pbar_cls: Callable | str)[source]¶
Set the default progressbar class.
This class method is useful when there is an user-defined class that follows
_SupportProgress
protocol.- Parameters
pbar_cls (callable or str) -- The default class. In principle this parameter does not have to be a class. As long as
pbar_cls(max=...)
returns a_SupportProgress
object it works. Either "default" or "napari" is also accepted.
- property started: CallbackList[None]¶
Event that will be emitted on started.
- static to_callback(callback: Callable, *args, **kwargs) Callback [source]¶
Convert a callback to a callback object.
- property yielded: CallbackList[_R1]¶
Event that will be emitted on yielded.