signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
@property<EOL><INDENT>def colors(self):<DEDENT>
return self.__colors<EOL>
Property for **self.__colors** attribute. :return: self.__colors. :rtype: tuple
f13149:c0:m4
@colors.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def colors(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is tuple, "<STR_LIT>".format("<STR_LIT>", value)<EOL>assert len(value) == <NUM_LIT:2>, "<STR_LIT>".format("<STR_LIT>", value)<EOL>for index in range(len(value)):<EOL><INDENT>assert type(<EOL>value[index]) is QColor, "<STR_LIT>".format(<EOL>"<STR_LIT>", index, value)<EOL><DEDENT><DEDENT>self.__colors = value<EOL>
Setter for **self.__colors** attribute. :param value: Attribute value. :type value: tuple
f13149:c0:m5
@colors.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def colors(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__colors** attribute.
f13149:c0:m6
@property<EOL><INDENT>def labels(self):<DEDENT>
return self.__labels<EOL>
Property for **self.__labels** attribute. :return: self.__labels. :rtype: tuple
f13149:c0:m7
@labels.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def labels(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is tuple, "<STR_LIT>".format("<STR_LIT>", value)<EOL>assert len(value) == <NUM_LIT:2>, "<STR_LIT>".format("<STR_LIT>", value)<EOL>for index in range(len(value)):<EOL><INDENT>assert type(value[index]) is unicode,"<STR_LIT>".format("<STR_LIT>", index, value)<EOL><DEDENT><DEDENT>self.__labels = value<EOL>
Setter for **self.__labels** attribute. :param value: Attribute value. :type value: tuple
f13149:c0:m8
@labels.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def labels(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__labels** attribute.
f13149:c0:m9
def __variable_QPushButton__clicked(self, checked):
if self.__state:<EOL><INDENT>self.__set_false_state()<EOL><DEDENT>else:<EOL><INDENT>self.__set_true_state()<EOL><DEDENT>
Defines the slot triggered by a **Variable_QPushButton** Widget when clicked. :param checked: Checked state. :type checked: bool
f13149:c0:m10
def __set_true_state(self):
LOGGER.debug("<STR_LIT>")<EOL>self.__state = True<EOL>palette = QPalette()<EOL>palette.setColor(QPalette.Button, foundations.common.get_first_item(self.__colors))<EOL>self.setPalette(palette)<EOL>self.setChecked(True)<EOL>self.setText(foundations.common.get_first_item(self.__labels))<EOL>
Sets the variable button true state.
f13149:c0:m11
def __set_false_state(self):
LOGGER.debug("<STR_LIT>")<EOL>self.__state = False<EOL>palette = QPalette()<EOL>palette.setColor(QPalette.Button, self.__colors[<NUM_LIT:1>])<EOL>self.setPalette(palette)<EOL>self.setChecked(False)<EOL>self.setText(self.__labels[<NUM_LIT:1>])<EOL>
Sets the variable QPushButton true state.
f13149:c0:m12
def __init__(self, parent=None):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QToolBar.__init__(self, parent)<EOL>self.__container = parent<EOL>self.__settings = self.__container.settings<EOL>self.__layouts_active_labels_collection = None<EOL>self.__custom_layouts_menu = None<EOL>self.__miscellaneous_menu = None<EOL>self.__user_layouts = (umbra.managers.layouts_manager.Layout(name="<STR_LIT:1>", identity="<STR_LIT>", shortcut=Qt.Key_1),<EOL>umbra.managers.layouts_manager.Layout(name="<STR_LIT:2>", identity="<STR_LIT>", shortcut=Qt.Key_2),<EOL>umbra.managers.layouts_manager.Layout(name="<STR_LIT:3>", identity="<STR_LIT>", shortcut=Qt.Key_3),<EOL>umbra.managers.layouts_manager.Layout(name="<STR_LIT:4>", identity="<STR_LIT>", shortcut=Qt.Key_4),<EOL>umbra.managers.layouts_manager.Layout(name="<STR_LIT:5>", identity="<STR_LIT>", shortcut=Qt.Key_5))<EOL>Application_QToolBar.__initialize_ui(self)<EOL>
Initializes the class. :param parent: Widget parent. :type parent: QObject
f13150:c0:m0
@property<EOL><INDENT>def container(self):<DEDENT>
return self.__container<EOL>
Property for **self.__container** attribute. :return: self.__container. :rtype: QObject
f13150:c0:m1
@container.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject
f13150:c0:m2
@container.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__container** attribute.
f13150:c0:m3
@property<EOL><INDENT>def settings(self):<DEDENT>
return self.__settings<EOL>
Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences
f13150:c0:m4
@settings.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def settings(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Preferences
f13150:c0:m5
@settings.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def settings(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__settings** attribute.
f13150:c0:m6
@property<EOL><INDENT>def layouts_active_labels_collection(self):<DEDENT>
return self.__layouts_active_labels_collection<EOL>
Property for **self.__layouts_active_labels_collection** attribute. :return: self.__layouts_active_labels_collection. :rtype: Active_QLabelsCollection
f13150:c0:m7
@layouts_active_labels_collection.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def layouts_active_labels_collection(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__layouts_active_labels_collection** attribute. :param value: Attribute value. :type value: Active_QLabelsCollection
f13150:c0:m8
@layouts_active_labels_collection.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def layouts_active_labels_collection(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__,<EOL>"<STR_LIT>"))<EOL>
Deleter for **self.__layouts_active_labels_collection** attribute.
f13150:c0:m9
@property<EOL><INDENT>def custom_layouts_menu(self):<DEDENT>
return self.__custom_layouts_menu<EOL>
Property for **self.__custom_layouts_menu** attribute. :return: self.__custom_layouts_menu. :rtype: QMenu
f13150:c0:m10
@custom_layouts_menu.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def custom_layouts_menu(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is QMenu, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__custom_layouts_menu = value<EOL>
Setter for **self.__custom_layouts_menu** attribute. :param value: Attribute value. :type value: QMenu
f13150:c0:m11
@custom_layouts_menu.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def custom_layouts_menu(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__custom_layouts_menu** attribute.
f13150:c0:m12
@property<EOL><INDENT>def miscellaneous_menu(self):<DEDENT>
return self.__miscellaneous_menu<EOL>
Property for **self.__miscellaneous_menu** attribute. :return: self.__miscellaneous_menu. :rtype: QMenu
f13150:c0:m13
@miscellaneous_menu.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def miscellaneous_menu(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is QMenu, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__miscellaneous_menu = value<EOL>
Setter for **self.__miscellaneous_menu** attribute. :param value: Attribute value. :type value: QMenu
f13150:c0:m14
@miscellaneous_menu.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def miscellaneous_menu(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__miscellaneous_menu** attribute.
f13150:c0:m15
def __initialize_ui(self):
LOGGER.debug("<STR_LIT>")<EOL>self.setIconSize(QSize(UiConstants.default_toolbar_icon_size, UiConstants.default_toolbar_icon_size))<EOL>self.setAllowedAreas(Qt.TopToolBarArea)<EOL>self.setFloatable(False)<EOL>self.setMovable(False)<EOL>self.set_layout_default_geometry()<EOL>self.setObjectName("<STR_LIT>")<EOL>self.setWindowTitle("<STR_LIT>".format(Constants.application_name))<EOL>self.set_toolbar_children_widgets()<EOL>self.__container.layouts_manager.layout_stored.connect(self.__layouts_manager__layout_stored)<EOL>self.__container.layouts_manager.layout_restored.connect(self.__layouts_manager__layout_restored)<EOL>
Initializes the Widget ui.
f13150:c0:m16
def __layout_active_label__clicked(self, layout):
self.__container.layouts_manager.restore_layout(layout)<EOL>
Defines the slot triggered by a **Active_QLabel** Widget when clicked. :param layout: Layout name. :type layout: unicode
f13150:c0:m17
def __layouts_manager__layout_stored(self, layout):
layout_active_label = self.__layouts_active_labels_collection.get_toggled_active_label()<EOL>layout_active_label and self.__settings.set_key("<STR_LIT>",<EOL>"<STR_LIT>".format(layout),<EOL>layout_active_label.objectName())<EOL>
Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is stored. :param layout: Layout name. :type layout: unicode
f13150:c0:m18
def __layouts_manager__layout_restored(self, layout):
layout_active_label = self.__settings.get_key("<STR_LIT>", "<STR_LIT>".format(layout)).toString()<EOL>for active_label in self.__layouts_active_labels_collection.active_labels:<EOL><INDENT>if not active_label.objectName() == layout_active_label:<EOL><INDENT>continue<EOL><DEDENT>active_label.set_checked(True)<EOL><DEDENT>
Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is restored. :param layout: Layout name. :type layout: unicode
f13150:c0:m19
def __help_display_misc_action__triggered(self, checked):
LOGGER.debug("<STR_LIT>".format(UiConstants.help_file))<EOL>QDesktopServices.openUrl(QUrl(QString(UiConstants.help_file)))<EOL>return True<EOL>
Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Help content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool
f13150:c0:m20
def __api_display_misc_action__triggered(self, checked):
LOGGER.debug("<STR_LIT>".format(UiConstants.api_file))<EOL>QDesktopServices.openUrl(QUrl(QString(UiConstants.api_file)))<EOL>return True<EOL>
Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Api content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool
f13150:c0:m21
def set_layout_default_geometry(self):
self.layout().setSpacing(<NUM_LIT:8>)<EOL>self.layout().setContentsMargins(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>)<EOL>return True<EOL>
Sets the toolBar layout default geometry. :return: Method success. :rtype: bool
f13150:c0:m22
def set_toolbar_children_widgets(self):
LOGGER.debug("<STR_LIT>")<EOL>self.addWidget(self.get_application_logo_label())<EOL>LOGGER.debug("<STR_LIT>")<EOL>self.addWidget(self.get_spacer_label())<EOL>LOGGER.debug("<STR_LIT>")<EOL>for layout_active_label in self.get_layouts_active_labels():<EOL><INDENT>self.addWidget(layout_active_label)<EOL><DEDENT>LOGGER.debug("<STR_LIT>")<EOL>self.addWidget(self.get_custom_layouts_active_label())<EOL>LOGGER.debug("<STR_LIT>")<EOL>self.addWidget(self.get_miscellaneous_active_label())<EOL>LOGGER.debug("<STR_LIT>")<EOL>self.addWidget(self.get_closure_spacer_label())<EOL>return True<EOL>
Sets the toolBar children widgets. :return: Method success. :rtype: bool
f13150:c0:m23
def get_application_logo_label(self):
logo_label = QLabel()<EOL>logo_label.setObjectName("<STR_LIT>")<EOL>logo_label.setPixmap(QPixmap(umbra.ui.common.get_resource_path(UiConstants.logo_image)))<EOL>return logo_label<EOL>
Provides the default **Application_Logo_label** widget. :return: Application logo label. :rtype: QLabel
f13150:c0:m24
def get_layout_active_label(self, resources, name, title, identity, shortcut):
default_icon, hover_icon, active_icon = resources<EOL>layout_active_label = Active_QLabel(self,<EOL>QPixmap(umbra.ui.common.get_resource_path(default_icon)),<EOL>QPixmap(umbra.ui.common.get_resource_path(hover_icon)),<EOL>QPixmap(umbra.ui.common.get_resource_path(active_icon)),<EOL>True)<EOL>self.__container.layouts_manager.register_layout(identity, umbra.managers.layouts_manager.Layout(name=title,<EOL>identity=identity,<EOL>shortcut=shortcut))<EOL>self.__container.addAction(<EOL>self.__container.actions_manager.register_action(<EOL>"<STR_LIT>".format(title),<EOL>shortcut=shortcut,<EOL>shortcut_context=Qt.ApplicationShortcut,<EOL>slot=functools.partial(<EOL>self.__container.layouts_manager.restore_layout, identity)))<EOL>layout_active_label.setObjectName(name)<EOL>layout_active_label.clicked.connect(functools.partial(self.__layout_active_label__clicked, identity))<EOL>return layout_active_label<EOL>
Returns a layout **Active_QLabel** widget. :param resources: Icons resources ( Default / Hover / Active ). :type resources: tuple :param name: Ui object name. :type name: unicode :param title: Layout registration title. :type title: unicode :param identity: Layout code name. :type identity: unicode :param shortcut: Layout associated shortcut. ( QtCore.Key ) :return: Layout active label. :rtype: Active_QLabel
f13150:c0:m25
def get_layouts_active_labels(self):
self.__layouts_active_labels_collection = Active_QLabelsCollection(self)<EOL>self.__layouts_active_labels_collection.add_active_label(<EOL>self.get_layout_active_label((UiConstants.development_icon,<EOL>UiConstants.development_hover_icon,<EOL>UiConstants.development_active_icon),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>Qt.Key_9))<EOL>self.__layouts_active_labels_collection.add_active_label(<EOL>self.get_layout_active_label((UiConstants.preferences_icon,<EOL>UiConstants.preferences_hover_icon,<EOL>UiConstants.preferences_active_icon),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>Qt.Key_0))<EOL>return self.__layouts_active_labels_collection.active_labels<EOL>
Returns the layouts **Active_QLabel** widgets. :return: Layouts active labels. :rtype: list
f13150:c0:m26
def get_custom_layouts_active_label(self):
layout_active_label = Active_QLabel(self,<EOL>QPixmap(umbra.ui.common.get_resource_path(UiConstants.custom_layouts_icon)),<EOL>QPixmap(<EOL>umbra.ui.common.get_resource_path(<EOL>UiConstants.custom_layouts_hover_icon)),<EOL>QPixmap(umbra.ui.common.get_resource_path(<EOL>UiConstants.custom_layouts_active_icon)))<EOL>layout_active_label.setObjectName("<STR_LIT>")<EOL>self.__custom_layouts_menu = QMenu("<STR_LIT>", layout_active_label)<EOL>for layout in self.__user_layouts:<EOL><INDENT>self.__container.layouts_manager.register_layout(layout.identity, layout)<EOL>self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(<EOL>"<STR_LIT>".format(layout.name),<EOL>shortcut=layout.shortcut,<EOL>slot=functools.partial(self.__container.layouts_manager.restore_layout, layout.identity)))<EOL><DEDENT>self.__custom_layouts_menu.addSeparator()<EOL>for layout in self.__user_layouts:<EOL><INDENT>self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(<EOL>"<STR_LIT>".format(layout.name),<EOL>shortcut=Qt.CTRL + layout.shortcut,<EOL>slot=functools.partial(self.__container.layouts_manager.store_layout, layout.identity)))<EOL><DEDENT>self.__custom_layouts_menu.addSeparator()<EOL>self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action(<EOL>"<STR_LIT>",<EOL>shortcut=Qt.ControlModifier + Qt.SHIFT + Qt.Key_F,<EOL>slot=self.__container.toggle_full_screen))<EOL>layout_active_label.set_menu(self.__custom_layouts_menu)<EOL>return layout_active_label<EOL>
Provides the default **Custom_Layouts_active_label** widget. :return: Layout active label. :rtype: Active_QLabel
f13150:c0:m27
def get_miscellaneous_active_label(self):
miscellaneous_active_label = Active_QLabel(self,<EOL>QPixmap(<EOL>umbra.ui.common.get_resource_path(<EOL>UiConstants.miscellaneous_icon)),<EOL>QPixmap(<EOL>umbra.ui.common.get_resource_path(<EOL>UiConstants.miscellaneous_hover_icon)),<EOL>QPixmap(umbra.ui.common.get_resource_path(<EOL>UiConstants.miscellaneous_active_icon)))<EOL>miscellaneous_active_label.setObjectName("<STR_LIT>")<EOL>self.__miscellaneous_menu = QMenu("<STR_LIT>", miscellaneous_active_label)<EOL>self.__miscellaneous_menu.addAction(self.__container.actions_manager.register_action(<EOL>"<STR_LIT>",<EOL>shortcut="<STR_LIT>",<EOL>slot=self.__help_display_misc_action__triggered))<EOL>self.__miscellaneous_menu.addAction(self.__container.actions_manager.register_action(<EOL>"<STR_LIT>",<EOL>slot=self.__api_display_misc_action__triggered))<EOL>self.__miscellaneous_menu.addSeparator()<EOL>miscellaneous_active_label.set_menu(self.__miscellaneous_menu)<EOL>return miscellaneous_active_label<EOL>
Provides the default **Miscellaneous_active_label** widget. :return: Miscellaneous active label. :rtype: Active_QLabel
f13150:c0:m28
def get_spacer_label(self):
spacer = QLabel()<EOL>spacer.setObjectName("<STR_LIT>")<EOL>spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)<EOL>return spacer<EOL>
Provides the default **Spacer_label** widget. :return: Logo spacer label. :rtype: QLabel
f13150:c0:m29
def get_closure_spacer_label(self):
spacer = QLabel()<EOL>spacer.setObjectName("<STR_LIT>")<EOL>spacer.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)<EOL>return spacer<EOL>
Provides the default **Closure_Spacer_label** widget. :return: Closure spacer label. :rtype: QLabel
f13150:c0:m30
def __init__(self, parent, *args, **kwargs):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QWidget.__init__(self, parent, *args, **kwargs)<EOL>self.__editor = parent<EOL>self.__margin = <NUM_LIT:16><EOL>self.__separator_width = <NUM_LIT:4><EOL>self.__background_color = QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>)<EOL>self.__color = QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>)<EOL>self.__separator_color = QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>)<EOL>self.set_editor_viewport_margins(<NUM_LIT:0>)<EOL>
Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\*
f13151:c0:m0
@property<EOL><INDENT>def editor(self):<DEDENT>
return self.__editor<EOL>
Property for **self.__editor** attribute. :return: self.__editor. :rtype: QWidget
f13151:c0:m1
@editor.setter<EOL><INDENT>def editor(self, value):<DEDENT>
self.__editor = value<EOL>
Setter for **self.__editor** attribute. :param value: Attribute value. :type value: QWidget
f13151:c0:m2
@editor.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def editor(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__editor** attribute.
f13151:c0:m3
@property<EOL><INDENT>def margin(self):<DEDENT>
return self.__margin<EOL>
Property for **self.__margin** attribute. :return: self.__margin. :rtype: int
f13151:c0:m4
@margin.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def margin(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>", value)<EOL>assert value > <NUM_LIT:0>, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__margin = value<EOL>
Setter for **self.__margin** attribute. :param value: Attribute value. :type value: int
f13151:c0:m5
@margin.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def margin(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__margin** attribute.
f13151:c0:m6
@property<EOL><INDENT>def separator_width(self):<DEDENT>
return self.__separator_width<EOL>
Property for **self.__separator_width** attribute. :return: self.__separator_width. :rtype: int
f13151:c0:m7
@separator_width.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def separator_width(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>", value)<EOL>assert value > <NUM_LIT:0>, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__separator_width = value<EOL>
Setter for **self.__separator_width** attribute. :param value: Attribute value. :type value: int
f13151:c0:m8
@separator_width.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def separator_width(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__separator_width** attribute.
f13151:c0:m9
@property<EOL><INDENT>def background_color(self):<DEDENT>
return self.__background_color<EOL>
Property for **self.__background_color** attribute. :return: self.__background_color. :rtype: QColor
f13151:c0:m10
@background_color.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def background_color(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is QColor, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__background_color = value<EOL>
Setter for **self.__background_color** attribute. :param value: Attribute value. :type value: QColor
f13151:c0:m11
@background_color.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def background_color(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__background_color** attribute.
f13151:c0:m12
@property<EOL><INDENT>def color(self):<DEDENT>
return self.__color<EOL>
Property for **self.__color** attribute. :return: self.__color. :rtype: QColor
f13151:c0:m13
@color.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def color(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is QColor, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__color = value<EOL>
Setter for **self.__color** attribute. :param value: Attribute value. :type value: QColor
f13151:c0:m14
@color.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def color(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__color** attribute.
f13151:c0:m15
@property<EOL><INDENT>def separator_color(self):<DEDENT>
return self.__separator_color<EOL>
Property for **self.__separator_color** attribute. :return: self.__separator_color. :rtype: QColor
f13151:c0:m16
@separator_color.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def separator_color(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is QColor, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__separator_color = value<EOL>
Setter for **self.__separator_color** attribute. :param value: Attribute value. :type value: QColor
f13151:c0:m17
@separator_color.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def separator_color(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__separator_color** attribute.
f13151:c0:m18
def sizeHint(self):
return QSize(self.get_width(), <NUM_LIT:0>)<EOL>
Reimplements the :meth:`QWidget.sizeHint` method. :return: Size hint. :rtype: QSize
f13151:c0:m19
def paintEvent(self, event):
def __set_bold(state):<EOL><INDENT>"""<STR_LIT>"""<EOL>font = painter.font()<EOL>font.setBold(state)<EOL>painter.setFont(font)<EOL>return True<EOL><DEDENT>painter = QPainter(self)<EOL>painter.fillRect(event.rect(), self.__background_color)<EOL>pen = QPen(QBrush(), self.__separator_width)<EOL>pen.setColor(self.__separator_color)<EOL>painter.setPen(pen)<EOL>top_right_corner = event.rect().topRight()<EOL>bottom_right_corner = event.rect().bottomRight()<EOL>painter.drawLine(top_right_corner.x(), top_right_corner.y(), bottom_right_corner.x(), bottom_right_corner.y())<EOL>painter.setPen(self.__color)<EOL>viewport_height = self.__editor.viewport().height()<EOL>metrics = QFontMetrics(self.__editor.document().defaultFont())<EOL>current_block = self.__editor.document().findBlock(<EOL>self.__editor.textCursor().position())<EOL>block = self.__editor.firstVisibleBlock()<EOL>block_number = block.blockNumber()<EOL>painter.setFont(self.__editor.document().defaultFont())<EOL>while block.isValid():<EOL><INDENT>block_number += <NUM_LIT:1><EOL>position = self.__editor.blockBoundingGeometry(block).topLeft() + self.__editor.contentOffset()<EOL>if position.y() > viewport_height:<EOL><INDENT>break<EOL><DEDENT>if not block.isVisible():<EOL><INDENT>continue<EOL><DEDENT>block == current_block and __set_bold(True) or __set_bold(False)<EOL>painter.drawText(<EOL>self.width() - metrics.width(foundations.strings.to_string(block_number)) - self.__margin / <NUM_LIT:3>,<EOL>round(position.y() + metrics.ascent() + metrics.descent() -<EOL>(self.__editor.blockBoundingRect(block).height() * <NUM_LIT> / <NUM_LIT:100>)),<EOL>foundations.strings.to_string(block_number))<EOL>block = block.next()<EOL><DEDENT>painter.end()<EOL>QWidget.paintEvent(self, event)<EOL>
Reimplements the :meth:`QWidget.paintEvent` method. :param event: Event. :type event: QEvent
f13151:c0:m20
def get_width(self):
return self.__margin +self.__editor.fontMetrics().width(foundations.strings.to_string(max(<NUM_LIT:1>, self.__editor.blockCount())))<EOL>
Returns the Widget target width. :return: Widget target width. :rtype: int
f13151:c0:m21
def set_editor_viewport_margins(self, newBlocksCount):
self.__editor.setViewportMargins(self.get_width(), <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>)<EOL>return True<EOL>
Sets the editor viewport margins. :param newBlocksCount: Updated editor blocks count. :type newBlocksCount: int :return: Method success. :rtype: bool
f13151:c0:m22
def update_rectangle(self, rectangle, scroll_y):
if scroll_y:<EOL><INDENT>self.scroll(<NUM_LIT:0>, scroll_y)<EOL><DEDENT>else:<EOL><INDENT>self.update(<NUM_LIT:0>, rectangle.y(), self.width(), rectangle.height())<EOL><DEDENT>if rectangle.contains(self.__editor.viewport().rect()):<EOL><INDENT>self.set_editor_viewport_margins(<NUM_LIT:0>)<EOL><DEDENT>return True<EOL>
Updates the given Widget rectangle. :param rectangle: Rectangle to update. :type rectangle: QRect :param scroll_y: Amount of pixels the viewport was scrolled. :type scroll_y: int :return: Method success. :rtype: bool
f13151:c0:m23
def update_geometry(self):
self.setGeometry(self.__editor.contentsRect().left(),<EOL>self.__editor.contentsRect().top(),<EOL>self.get_width(),<EOL>self.__editor.contentsRect().height())<EOL>return True<EOL>
Updates the Widget geometry. :return: Method success. :rtype: bool
f13151:c0:m24
def __init__(self,<EOL>parent=None,<EOL>language=umbra.ui.languages.PYTHON_LANGUAGE,<EOL>indent_marker="<STR_LIT:U+0020>" * <NUM_LIT:4>,<EOL>indent_width=<NUM_LIT:4>,<EOL>comment_marker="<STR_LIT:#>",<EOL>*args,<EOL>**kwargs):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>Basic_QPlainTextEdit.__init__(self, parent, *args, **kwargs)<EOL>self.__language = language<EOL>self.__indent_marker = None<EOL>self.indent_marker = indent_marker<EOL>self.__indent_width = None<EOL>self.indent_width = indent_width<EOL>self.__comment_marker = None<EOL>self.comment_marker = comment_marker<EOL>self.__margin_area_LinesNumbers_widget = None<EOL>self.__highlighter = None<EOL>self.__completer = None<EOL>self.__occurrences_highlight_color = QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>)<EOL>self.__pre_input_accelerators = []<EOL>self.__post_input_accelerators = []<EOL>self.__visual_accelerators = []<EOL>self.__text_cursor_anchor = None<EOL>CodeEditor_QPlainTextEdit.__initialize_ui(self)<EOL>
Initializes the class. :param parent: Widget parent. :type parent: QObject :param language: Editor language. :type language: Language :param indent_marker: Indentation marker. :type indent_marker: unicode :param indent_width: Indentation spaces count. :type indent_width: int :param comment_marker: Comment marker. :type comment_marker: unicode :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\*
f13151:c1:m0
@property<EOL><INDENT>def language(self):<DEDENT>
return self.__language<EOL>
Property for **self.__language** attribute. :return: self.__language. :rtype: Language
f13151:c1:m1
@language.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def language(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__language** attribute. :param value: Attribute value. :type value: Language
f13151:c1:m2
@language.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def language(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__language** attribute.
f13151:c1:m3
@property<EOL><INDENT>def indent_marker(self):<DEDENT>
return self.__indent_marker<EOL>
Property for **self.__indent_marker** attribute. :return: self.__indent_marker. :rtype: unicode
f13151:c1:m4
@indent_marker.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def indent_marker(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL>assert re.search(r"<STR_LIT>", value), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__indent_marker = value<EOL>
Setter for **self.__indent_marker** attribute. :param value: Attribute value. :type value: unicode
f13151:c1:m5
@indent_marker.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def indent_marker(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__indent_marker** attribute.
f13151:c1:m6
@property<EOL><INDENT>def indent_width(self):<DEDENT>
return self.__indent_width<EOL>
Property for **self.__indent_width** attribute. :return: self.__indent_width. :rtype: int
f13151:c1:m7
@indent_width.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def indent_width(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__indent_width = value<EOL>
Setter for **self.__indent_width** attribute. :param value: Attribute value. :type value: int
f13151:c1:m8
@indent_width.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def indent_width(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__indent_width** attribute.
f13151:c1:m9
@property<EOL><INDENT>def comment_marker(self):<DEDENT>
return self.__comment_marker<EOL>
Property for **self.__comment_marker** attribute. :return: self.__comment_marker. :rtype: unicode
f13151:c1:m10
@comment_marker.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def comment_marker(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__comment_marker = value<EOL>
Setter for **self.__comment_marker** attribute. :param value: Attribute value. :type value: unicode
f13151:c1:m11
@comment_marker.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def comment_marker(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__comment_marker** attribute.
f13151:c1:m12
@property<EOL><INDENT>def margin_area_LinesNumbers_widget(self):<DEDENT>
return self.__margin_area_LinesNumbers_widget<EOL>
Property for **self.__margin_area_LinesNumbers_widget** attribute. :return: self.__margin_area_LinesNumbers_widget. :rtype: LinesNumbers_QWidget
f13151:c1:m13
@margin_area_LinesNumbers_widget.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def margin_area_LinesNumbers_widget(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is LinesNumbers_QWidget,"<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__margin_area_LinesNumbers_widget = value<EOL>
Setter for **self.__margin_area_LinesNumbers_widget** attribute. :param value: Attribute value. :type value: LinesNumbers_QWidget
f13151:c1:m14
@margin_area_LinesNumbers_widget.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def margin_area_LinesNumbers_widget(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__,<EOL>"<STR_LIT>"))<EOL>
Deleter for **self.__margin_area_LinesNumbers_widget** attribute.
f13151:c1:m15
@property<EOL><INDENT>def highlighter(self):<DEDENT>
return self.__highlighter<EOL>
Property for **self.__highlighter** attribute. :return: self.__highlighter. :rtype: QSyntaxHighlighter
f13151:c1:m16
@highlighter.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def highlighter(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__highlighter** attribute. :param value: Attribute value. :type value: QSyntaxHighlighter
f13151:c1:m17
@highlighter.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def highlighter(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__highlighter** attribute.
f13151:c1:m18
@property<EOL><INDENT>def completer(self):<DEDENT>
return self.__completer<EOL>
Property for **self.__completer** attribute. :return: self.__completer. :rtype: QCompleter
f13151:c1:m19
@completer.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def completer(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__completer** attribute. :param value: Attribute value. :type value: QCompleter
f13151:c1:m20
@completer.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def completer(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__completer** attribute.
f13151:c1:m21
@property<EOL><INDENT>def pre_input_accelerators(self):<DEDENT>
return self.__pre_input_accelerators<EOL>
Property for **self.__pre_input_accelerators** attribute. :return: self.__pre_input_accelerators. :rtype: tuple or list
f13151:c1:m22
@pre_input_accelerators.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def pre_input_accelerators(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) in (tuple, list), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__pre_input_accelerators = value<EOL>
Setter for **self.__pre_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list
f13151:c1:m23
@pre_input_accelerators.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def pre_input_accelerators(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__pre_input_accelerators** attribute.
f13151:c1:m24
@property<EOL><INDENT>def post_input_accelerators(self):<DEDENT>
return self.__post_input_accelerators<EOL>
Property for **self.__post_input_accelerators** attribute. :return: self.__post_input_accelerators. :rtype: tuple or list
f13151:c1:m25
@post_input_accelerators.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def post_input_accelerators(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) in (tuple, list), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__post_input_accelerators = value<EOL>
Setter for **self.__post_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list
f13151:c1:m26
@post_input_accelerators.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def post_input_accelerators(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__post_input_accelerators** attribute.
f13151:c1:m27
@property<EOL><INDENT>def visual_accelerators(self):<DEDENT>
return self.__visual_accelerators<EOL>
Property for **self.__visual_accelerators** attribute. :return: self.__visual_accelerators. :rtype: tuple or list
f13151:c1:m28
@visual_accelerators.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def visual_accelerators(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) in (tuple, list), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__visual_accelerators = value<EOL>
Setter for **self.__visual_accelerators** attribute. :param value: Attribute value. :type value: tuple or list
f13151:c1:m29
@visual_accelerators.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def visual_accelerators(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__visual_accelerators** attribute.
f13151:c1:m30
def __initialize_ui(self):
self.__margin_area_LinesNumbers_widget = LinesNumbers_QWidget(self)<EOL>self.__set_extra_selections()<EOL>self.__set_language_description()<EOL>self.blockCountChanged.connect(self.__margin_area_LinesNumbers_widget.set_editor_viewport_margins)<EOL>self.updateRequest.connect(self.__margin_area_LinesNumbers_widget.update_rectangle)<EOL>self.cursorPositionChanged.connect(self.__set_extra_selections)<EOL>
Initializes the Widget ui.
f13151:c1:m31
def resizeEvent(self, event):
Basic_QPlainTextEdit.resizeEvent(self, event)<EOL>self.__margin_area_LinesNumbers_widget.update_geometry()<EOL>
Reimplements the :meth:`Basic_QPlainTextEdit.resizeEvent` method. :param event: Event. :type event: QEvent
f13151:c1:m32
@edit_block<EOL><INDENT>def keyPressEvent(self, event):<DEDENT>
processEvent = True<EOL>for accelerator in self.__pre_input_accelerators:<EOL><INDENT>processEvent *= accelerator(self, event)<EOL><DEDENT>if not processEvent:<EOL><INDENT>return<EOL><DEDENT>Basic_QPlainTextEdit.keyPressEvent(self, event)<EOL>for accelerator in self.__post_input_accelerators:<EOL><INDENT>accelerator(self, event)<EOL><DEDENT>
Reimplements the :meth:`Basic_QPlainTextEdit.keyPressEvent` method. :param event: Event. :type event: QEvent
f13151:c1:m33
def __set_extra_selections(self):
self.setExtraSelections(())<EOL>for accelerator in self.__visual_accelerators:<EOL><INDENT>accelerator(self)<EOL><DEDENT>
Sets current document extra selections.
f13151:c1:m34