How to use the extensions.widgets.trAction function in extensions

To help you get started, we’ve selected a few extensions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cas4ey / behavior-studio / source / main_window.py View on Github external
class ConfigAction(trAction):
    def __init__(self, getter, setter, title, parent=None):
        trAction.__init__(self, title, parent)
        self.setCheckable(True)
        self.__getter = getter
        self.__setter = setter
        self.setChecked(self.__getter())
        self.toggled.connect(self.__onToggle)

    @QtCore.Slot(bool)
    def __onToggle(self, checked):
        self.__setter(checked)


class ExtendedCheckableAction(trAction):
    changed = QtCore.Signal(trAction)  # Signal emits on action trigger and sends \'self\' as signal parameter

    def __init__(self, text='', parent=None):
        trAction.__init__(self, text, parent)
        self.setCheckable(True)
        self.triggered.connect(self.__onTrigger)

    @QtCore.Slot()
    def __onTrigger(self):
        self.changed.emit(self)

########################################################################################################################
########################################################################################################################


def yearsStr():
github cas4ey / behavior-studio / source / main_window.py View on Github external
    @QtCore.Slot(trAction)
    def __onBackgroundTrigger(self, bgAction):
        if bgAction in self._actionsBackgroundImage:
            self._actionDisableBackground.setChecked(False)
            for bga in self._actionsBackgroundImage:
                bga.setChecked(False)
            i = self._actionsBackgroundImage.index(bgAction)
            self._actionsBackgroundImage[i].setChecked(True)
            print(trStr('info: Draw scene background {0} is \'ON\''.format(i+1),
                        u'info: Фоновое изображение {0} \'ВКЛ\''.format(i+1)).text())
            globals.background = i
            globals.optionsSignals.backgroundChanged.emit(int(globals.background))
        else:
            bgAction.setChecked(False)
github cas4ey / behavior-studio / source / main_window.py View on Github external
class ConfigAction(trAction):
    def __init__(self, getter, setter, title, parent=None):
        trAction.__init__(self, title, parent)
        self.setCheckable(True)
        self.__getter = getter
        self.__setter = setter
        self.setChecked(self.__getter())
        self.toggled.connect(self.__onToggle)

    @QtCore.Slot(bool)
    def __onToggle(self, checked):
        self.__setter(checked)


class ExtendedCheckableAction(trAction):
    changed = QtCore.Signal(trAction)  # Signal emits on action trigger and sends \'self\' as signal parameter

    def __init__(self, text='', parent=None):
        trAction.__init__(self, text, parent)
        self.setCheckable(True)
        self.triggered.connect(self.__onTrigger)

    @QtCore.Slot()
    def __onTrigger(self):
        self.changed.emit(self)

########################################################################################################################
########################################################################################################################


def yearsStr():
    year = datetime.now().year
github cas4ey / behavior-studio / source / main_window.py View on Github external
self._helpActionAbout = trAction(trStr('About', u'О программе'))
        self._helpActionAbout.triggered.connect(self.__showAbout)

        self._helpActionAboutQt = trAction(trStr('About Qt', u'Версия Qt'))
        self._helpActionAboutQt.triggered.connect(self.__showAboutQt)

        self._helpWindow = None
        self._helpActionHelp = trAction(trStr('Help', u'Справка'))
        self._helpActionHelp.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'help.png')))
        self._helpActionHelp.triggered.connect(self.__showHelp)

        self._viewActionLanguageEnglish = trAction(trStr('&English', u'&Английский'))
        self._viewActionLanguageEnglish.setToolTip(trStr(u'Английский', 'English'))
        self._viewActionLanguageEnglish.setCheckable(True)
        self._viewActionLanguageRussian = trAction(trStr('&Russian', u'&Русский'))
        self._viewActionLanguageRussian.setToolTip(trStr(u'Русский', 'Russian'))
        self._viewActionLanguageRussian.setCheckable(True)

        self._viewActionConnectorCurved = trAction(trStr('&Curved', u'&Гладкие кривые'))
        self._viewActionConnectorCurved.setCheckable(True)
        self._viewActionConnectorLine = trAction(trStr('&Line', u'&Прямые'))
        self._viewActionConnectorLine.setCheckable(True)
        self._viewActionConnectorPolyline = trAction(trStr('&Polyline', u'&Ломаные линии'))
        self._viewActionConnectorPolyline.setCheckable(True)
        if self._connectorType == ConnectorType.Curve:
            self._viewActionConnectorCurved.setChecked(True)
        elif self._connectorType == ConnectorType.Line:
            self._viewActionConnectorLine.setChecked(True)
        elif self._connectorType == ConnectorType.Polyline:
            self._viewActionConnectorPolyline.setChecked(True)
        self._viewActionConnectorCurved.triggered.connect(self.__onConnectorCurvedTrigger)
github cas4ey / behavior-studio / source / main_window.py View on Github external
self._optionsActionDebug.setToolTip(trStr('Turn on/off debug mode',
                                                  u'Вкл/выкл режим отладки'))
        self._optionsActionAutosave.setToolTip(trStr('Enable auto saving for project and libraries',
                                                     u'Разрешить автоматическое сохранение проекта и библиотек узлов'))

        self._helpActionColorsLegend = trAction(trStr('Output window legend', u'Памятка для окна вывода'))
        self._helpActionColorsLegend.triggered.connect(_printColors)

        self._helpActionAbout = trAction(trStr('About', u'О программе'))
        self._helpActionAbout.triggered.connect(self.__showAbout)

        self._helpActionAboutQt = trAction(trStr('About Qt', u'Версия Qt'))
        self._helpActionAboutQt.triggered.connect(self.__showAboutQt)

        self._helpWindow = None
        self._helpActionHelp = trAction(trStr('Help', u'Справка'))
        self._helpActionHelp.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'help.png')))
        self._helpActionHelp.triggered.connect(self.__showHelp)

        self._viewActionLanguageEnglish = trAction(trStr('&English', u'&Английский'))
        self._viewActionLanguageEnglish.setToolTip(trStr(u'Английский', 'English'))
        self._viewActionLanguageEnglish.setCheckable(True)
        self._viewActionLanguageRussian = trAction(trStr('&Russian', u'&Русский'))
        self._viewActionLanguageRussian.setToolTip(trStr(u'Русский', 'Russian'))
        self._viewActionLanguageRussian.setCheckable(True)

        self._viewActionConnectorCurved = trAction(trStr('&Curved', u'&Гладкие кривые'))
        self._viewActionConnectorCurved.setCheckable(True)
        self._viewActionConnectorLine = trAction(trStr('&Line', u'&Прямые'))
        self._viewActionConnectorLine.setCheckable(True)
        self._viewActionConnectorPolyline = trAction(trStr('&Polyline', u'&Ломаные линии'))
        self._viewActionConnectorPolyline.setCheckable(True)
github cas4ey / behavior-studio / source / main_window.py View on Github external
########################################################################################################################


class ProjectAction(trAction):
    def __init__(self, wnd, filepath, titleEng, titleRus, parent=None):
        trAction.__init__(self, trStr(titleEng, titleRus), parent)
        self.__wnd = wnd
        self.__file = filepath
        self.triggered.connect(self.__onTrigger)

    @QtCore.Slot()
    def __onTrigger(self):
        self.__wnd.openProject(self.__file)


class ConfigAction(trAction):
    def __init__(self, getter, setter, title, parent=None):
        trAction.__init__(self, title, parent)
        self.setCheckable(True)
        self.__getter = getter
        self.__setter = setter
        self.setChecked(self.__getter())
        self.toggled.connect(self.__onToggle)

    @QtCore.Slot(bool)
    def __onToggle(self, checked):
        self.__setter(checked)


class ExtendedCheckableAction(trAction):
    changed = QtCore.Signal(trAction)  # Signal emits on action trigger and sends \'self\' as signal parameter
github cas4ey / behavior-studio / source / main_window.py View on Github external
self._actionViewHorizontal = trAction()
        self._actionViewHorizontal.setToolTip(trStr('Horizontal view', u'Горизонтальный вид'))
        self._actionViewHorizontal.setCheckable(True)
        self._actionViewHorizontal.setChecked(False)
        self._actionViewHorizontal.triggered.connect(self.__horTriggered)
        self._actionViewHorizontal.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'chart_hor2.png')))

        self._actionViewVertical = trAction()
        self._actionViewVertical.setToolTip(trStr('Vertical view', u'Вертикальный вид'))
        self._actionViewVertical.setCheckable(True)
        self._actionViewVertical.setChecked(True)
        self._actionViewVertical.triggered.connect(self.__verTriggered)
        self._actionViewVertical.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'chart2.png')))

        self._actionModeCursor = trAction()
        self._actionModeCursor.setToolTip(trStr('Cursor mode', u'Режим курсора'))
        self._actionModeCursor.setCheckable(True)
        self._actionModeCursor.setChecked(True)
        self._actionModeCursor.triggered.connect(self.__cursorTriggered)
        self._actionModeCursor.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'cursor.png')))

        self._actionModeDrag = trAction()
        self._actionModeDrag.setToolTip(trStr('Drag mode', u'Режим перетаскивания'))
        self._actionModeDrag.setCheckable(True)
        self._actionModeDrag.setChecked(False)
        self._actionModeDrag.triggered.connect(self.__dragTriggered)
        self._actionModeDrag.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'hand-icon.png')))

        self._actionModeConnectorTool = trAction()
        self._actionModeConnectorTool.setToolTip(trStr('Connector tool', u'Соединительная линия'))
        self._actionModeConnectorTool.setCheckable(True)
github cas4ey / behavior-studio / source / main_window.py View on Github external
self._actionViewVertical = trAction()
        self._actionViewVertical.setToolTip(trStr('Vertical view', u'Вертикальный вид'))
        self._actionViewVertical.setCheckable(True)
        self._actionViewVertical.setChecked(True)
        self._actionViewVertical.triggered.connect(self.__verTriggered)
        self._actionViewVertical.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'chart2.png')))

        self._actionModeCursor = trAction()
        self._actionModeCursor.setToolTip(trStr('Cursor mode', u'Режим курсора'))
        self._actionModeCursor.setCheckable(True)
        self._actionModeCursor.setChecked(True)
        self._actionModeCursor.triggered.connect(self.__cursorTriggered)
        self._actionModeCursor.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'cursor.png')))

        self._actionModeDrag = trAction()
        self._actionModeDrag.setToolTip(trStr('Drag mode', u'Режим перетаскивания'))
        self._actionModeDrag.setCheckable(True)
        self._actionModeDrag.setChecked(False)
        self._actionModeDrag.triggered.connect(self.__dragTriggered)
        self._actionModeDrag.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'hand-icon.png')))

        self._actionModeConnectorTool = trAction()
        self._actionModeConnectorTool.setToolTip(trStr('Connector tool', u'Соединительная линия'))
        self._actionModeConnectorTool.setCheckable(True)
        self._actionModeConnectorTool.setChecked(False)
        self._actionModeConnectorTool.triggered.connect(self.__connectorTriggered)
        self._actionModeConnectorTool.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'connector1.png')))

        self._actionViewJustifyWidth = trAction()
        self._actionViewJustifyWidth.setToolTip(trStr('Justify widths', u'Выравнивать ширину\nграфических элементов'))
        self._actionViewJustifyWidth.setCheckable(True)
github cas4ey / behavior-studio / source / main_window.py View on Github external
self._helpWindow = None
        self._helpActionHelp = trAction(trStr('Help', u'Справка'))
        self._helpActionHelp.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'help.png')))
        self._helpActionHelp.triggered.connect(self.__showHelp)

        self._viewActionLanguageEnglish = trAction(trStr('&English', u'&Английский'))
        self._viewActionLanguageEnglish.setToolTip(trStr(u'Английский', 'English'))
        self._viewActionLanguageEnglish.setCheckable(True)
        self._viewActionLanguageRussian = trAction(trStr('&Russian', u'&Русский'))
        self._viewActionLanguageRussian.setToolTip(trStr(u'Русский', 'Russian'))
        self._viewActionLanguageRussian.setCheckable(True)

        self._viewActionConnectorCurved = trAction(trStr('&Curved', u'&Гладкие кривые'))
        self._viewActionConnectorCurved.setCheckable(True)
        self._viewActionConnectorLine = trAction(trStr('&Line', u'&Прямые'))
        self._viewActionConnectorLine.setCheckable(True)
        self._viewActionConnectorPolyline = trAction(trStr('&Polyline', u'&Ломаные линии'))
        self._viewActionConnectorPolyline.setCheckable(True)
        if self._connectorType == ConnectorType.Curve:
            self._viewActionConnectorCurved.setChecked(True)
        elif self._connectorType == ConnectorType.Line:
            self._viewActionConnectorLine.setChecked(True)
        elif self._connectorType == ConnectorType.Polyline:
            self._viewActionConnectorPolyline.setChecked(True)
        self._viewActionConnectorCurved.triggered.connect(self.__onConnectorCurvedTrigger)
        self._viewActionConnectorLine.triggered.connect(self.__onConnectorLineTrigger)
        self._viewActionConnectorPolyline.triggered.connect(self.__onConnectorPolylineTrigger)

        self._menuLanguage = trMenuWithTooltip(trStr('&Language', u'&Язык интерфейса'))
        self._menuLanguage.setToolTip(trStr(u'Язык интерфейса', 'Language'))
        self._menuLanguage.addAction(self._viewActionLanguageEnglish)
github cas4ey / behavior-studio / source / main_window.py View on Github external
# read recent projects file
        self.__readRecentProjects()

        self._menuRecentProjects = trMenuWithTooltip(trStr('Recent projects', u'Последние проекты'))
        self._menuRecentProjects.setEnabled(False)

        # ACTIONS: ---------------------------------------------
        self._actionOpenLibrary = trAction(trStr('&Load library...', u'Загрузить &библиотеку...'))
        self._actionOpenLibrary.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'book_add.png')))
        self._actionOpenLibrary.setToolTip(trStr('Add existing library into project',
                                                 u'Добавить файл с библиотекой узлов в проект'))
        self._actionCreateLibrary = trAction(trStr('&Create library...', u'&Создать библиотеку...'))
        self._actionCreateLibrary.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'book_add.png')))
        self._actionCreateLibrary.setToolTip(trStr('Create new library file\nand add it into project',
                                                   u'Создать пустой файл с библиотекой\nузлов и добавить его в проект'))
        self._actionOpenTree = trAction(trStr('Open existing &tree file...', u'Открыть файл с &деревом...'))
        self._actionOpenTree.setToolTip(trStr('Open existing tree file and\ninclude it into project',
                                        u'Открыть существующий файл с деревом\nи добавить его в проект'))
        self._actionOpenTree.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'chart_add2.png')))
        self._actionCreateTree = trAction(trStr('Create &new tree file...', u'Создать &файл с деревом...'))
        self._actionCreateTree.setToolTip(trStr('Create new tree file and\ninclude it into project',
                                                u'Создать новый файл с деревом\nи добавить его в проект'))
        self._actionCreateTree.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'chart_add.png')))
        self._actionOpenProject_menu = trAction(trStr('&Open project...', u'Открыть &проект...'))
        self._actionOpenProject_menu.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'folder_page.png')))
        self._actionSaveProject_menu = trAction(trStr('&Save all', u'&Сохранить все'))
        self._actionSaveProject_menu.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'save.png')))
        self._actionSaveProject_menu.setEnabled(False)
        self._actionReadAlphabet = trAction(trStr('Read &alphabet...', u'Открыть файл &алфавита...'))
        self._actionExit = trAction(trStr('&Exit', u'&Выход'))
        self._actionExit.setIcon(QIcon(joinPath(globals.applicationIconsPath, 'door.png')))