magicclass.utils package¶
Submodules¶
magicclass.utils.functions module¶
- magicclass.utils.functions.get_signature(func)[source]¶
Similar to
inspect.signature
but safely returnsSignature
.
- magicclass.utils.functions.iter_members(cls: type, exclude_prefix: str = '__') Iterable[tuple[str, typing.Any]] [source]¶
Iterate over all the members in the order of source code line number. This function is identical to inspect.getmembers except for the order of the results. We have to sort the name in the order of line number.
magicclass.utils.qt module¶
- class magicclass.utils.qt.MessageBoxMode(value)[source]¶
Bases:
enum.Enum
An enumeration.
- ABOUT = 'about'¶
- ERROR = 'error'¶
- INFO = 'info'¶
- QUESTION = 'question'¶
- WARNING = 'warn'¶
- magicclass.utils.qt.move_to_screen_center(qwidget: PyQt5.QtWidgets.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.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
Create a worker in a superqt/napari style.
- property aborted: magicclass.utils.qthreading.Callbacks[None]¶
Event that will be emitted on aborted.
- property errored: magicclass.utils.qthreading.Callbacks[Exception]¶
Event that will be emitted on errored.
- property finished: magicclass.utils.qthreading.Callbacks[None]¶
Event that will be emitted on finished.
- property is_generator: bool¶
True if bound function is a generator function.
- property returned: magicclass.utils.qthreading.Callbacks[magicclass.utils.qthreading._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: magicclass.utils.qthreading.Callbacks[None]¶
Event that will be emitted on started.
- property yielded: magicclass.utils.qthreading.Callbacks[magicclass.utils.qthreading._R1]¶
Event that will be emitted on yielded.