reborn.gui.misc package

Submodules

reborn.gui.misc.observer module

class reborn.gui.misc.observer.Observable[source]

Bases: object

Broadcasts a notification to a registry of function objects.

Notes

  • Threading:
    • The notification will be broadcast on the thread calling notify

    • If notify occurs on a background, GUI elements will need make sure that updates are performed on the main/UI thread

  • How memory leaks and seg faults are prevented:
    • Consider the object map of Observable and the Observer.

    • Observable contains a reference to each Observer.

    • If an Observer object is ‘deleted’, what happens to the reference contained in Obserable’s registry list?

    • If Observable holds a weak reference, upon ‘deleting’ the Observer, the Observer is dealloc and the reference is now invalid (potential seg fault)

register_observer(func)[source]

Add a function to the notification registry. The function can have three different signatures:

  • func()

  • func(this_observer)

  • func(this_observer, user_data)

Parameters:

func (bound method) – This function is called by when observers are notified. A bound method is a method of a class with alloc’d instance.

unregister_observer(func)[source]

Removes a function from the notification registry

notify_observers(user_data=None)[source]

Notify all observers

Parameters:

user_data (Any) – An arbitrary object sent to the callback function

reborn.gui.misc.pen_editor module

reborn.gui.misc.pen_editor.dbgmsg(*args, **kwargs)[source]
class reborn.gui.misc.pen_editor.PenStylePreview(parent=None, pen=None, editable=True)[source]

Bases: QFrame

Simple QFrame that displays a QPen instance.

Parameters:
  • parent (QObject) – Look at Qt docs for this.

  • pen (QPen or None) – A QPen instance.

  • editable (bool) – If True, mouse clicks allow editing.

changed

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

paintEvent(self, a0: QPaintEvent | None)[source]
update_pen(pen)[source]
get_pen()[source]
mousePressEvent(self, a0: QMouseEvent | None)[source]
class reborn.gui.misc.pen_editor.PenStyleEditor(parent=None, pen=None)[source]

Bases: QWidget

Simple QWidget for specifying a QPen.

Parameters:
  • () (parent) – Look up Qt docs… I don’t know exactly what this does…

  • pen (QPen or None) – A QPen instance.

changed

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

set_color(color=None)[source]
set_style(style)[source]
set_width(value)[source]
set_width_from_edit()[source]
set_pen(pen)[source]
get_pen()[source]
on_change()[source]
class reborn.gui.misc.pen_editor.PenStyleDialog(parent=None, pen=None)[source]

Bases: QDialog

Simple QDialog for specifying a QPen. Emits QPen on accept.

Parameters:

pen (QPen or None) – A QPen instance to start with.

initUI(pen)[source]
set_pen(pen)[source]
get_pen()[source]
reborn.gui.misc.pen_editor.pen_dialog(parent=None, pen=None)[source]

Opens a simple QDialog to get a QPen. Returns the QPen.

Parameters:

pen (QPen or None) – A QPen instance to start with.

Returns:

QPen

reborn.gui.misc.spinbox module

class reborn.gui.misc.spinbox.BetterDoubleSpinBox(*args, format='e', decimals=5, **kwargs)[source]

Bases: QDoubleSpinBox

validate(self, input: str | None, pos: int)[source]
valueFromText(self, text: str | None) float[source]
textFromValue(self, v: float) str[source]
stepBy(self, steps: int)[source]
setValueSilently(value)[source]
reborn.gui.misc.spinbox.character_orders(text)[source]

Given a string in scientific notation (e.g. 56.23e-5), return a list where each element gives the order-of-magnitude corresponding to that character in the string. For example:

print(character_orders(“4.4966429e2”))

[ 2. 1. 1. 0. -1. -2. -3. -4. -5. -5. -5.]

reborn.gui.misc.value module

class reborn.gui.misc.value.Value(value=None)[source]

Bases: Observable

A simple observable for detecting changes to an “Equatable” value, i.e the value has the == operator implemented

property value
static build_property(value, doc=None)[source]

Builds the setters and getters to a Value for another class

Example

class MyClass:
    # contains the value instance
    is_visible_value = Value(False)

    # a property accessor for is_visible_value.value
    is_visible = Value.build_property(is_visible_value)

    def __init__(self):
        super().__init__()

        # example usage of property
        self.is_visible = True

Module contents