magicclass.ext.qtconsole package

Submodules

magicclass.ext.qtconsole.widgets module

class magicclass.ext.qtconsole.widgets.QtConsole(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget

execute()[source]

Execute current code block.

executed

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

property value: str

Get current code block

Module contents

Jupyter QtConsole widget with callback signals.

You can embed a console widget in a magic class.

from magicclass import magicclass
from magicclass.widgets import QtConsole

class Main:
    console = QtConsole()

ui = Main()
ui.show()

There are some additional methods that would be very useful for developing a Python script executable GUI.

# programmatically add code to console.
ui.console.value = "a = 1"

# callback when code is executed.
@console.executed.connect
def _():
    print("executed!")

# programmatically execute code.
ui.console.execute()
class magicclass.ext.qtconsole.QtConsole(**kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget

central_widget: QWidget | None
execute()[source]

Execute current code block.

executed

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

name: str
property value: str

Get current code block