magicclass.utils package

Submodules

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.screen_center()[source]

Get the center coordinate of the screen.

magicclass.utils.qt.screen_scale() float[source]

Get the scale of main screen.

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.qt.to_clipboard(obj) None[source]

Copy an object of any type to the clipboard. You can copy text, ndarray as an image or data frame as a table data.

Parameters

obj (Any) -- Object to be copied.

magicclass.utils.qthreading module

class magicclass.utils.qthreading.Callback(f: Callable[[], Any])[source]

Bases: object

Callback object that can be recognized by thread_worker.

static catch(out, macro: GuiMacro)[source]
class magicclass.utils.qthreading.Timer[source]

Bases: object

A timer class with intuitive API.

format_time(fmt: str = '{hour:0>2}:{min:0>2}:{sec:0>2}') str[source]

Format current time.

lap() float[source]

Return lap time.

reset()[source]

Reset timer.

property sec: float

Return current second.

start()[source]

Start timer.

stop() float[source]

Stop timer.

magicclass.utils.qtsignal module

class magicclass.utils.qtsignal.QtSignal[source]

Bases: PyQt5.QtCore.QObject

Dummy qt object for pyqt signal operations.

connect(slot: Callable)[source]
emit(val: Optional[Any] = None)[source]
signal

Module contents