def createImport(self):
     ifNotInCode(
         self._import,
         "import sys\nimport os\nfrom PySide6.QtWidgets import *\n")
     ifNotInCode(
         self._import,
         F"from {self.softwareTitle}.GUI.mainUI import mainWindows\n\n\n")
Beispiel #2
0
 def isShortCutInTheDictionary(self, menuAction, code):
     for keyShortCut, valueShortCut in definition.shortCutDictionary.items(
     ):
         if keyShortCut == menuAction.replace(' ', '').lower():
             sentence = F"        {menuAction.lower().replace(' ', '_')}" \
                        F"_Action.setShortcut({valueShortCut})\n"
             ifNotInCode(code, sentence)
 def createInitUI(self):
     ifNotInCode(self._initUI, F"    def initUI(self):\n")
     ifNotInCode(
         self._initUI,
         F"        self.setWindowTitle(\"{self.softwareTitle}\")\n")
     ifNotInCode(
         self._initUI,
         F"        self.statusBar().showMessage(\"ready\", 3000)\n")
     ifNotInCode(self._initUI, F"        self.show()\n\n")
    def createMainInit(self):
        """
            def __init__(self):
                QMainWindow.__init__(self)
                self.initUI()
                self.setWindowTitle("Biggus Diskus v0.1")
                self.statusBar().showMessage("ready", 3000)

        :return: self._mainInit
        """
        ifNotInCode(self._mainInit,
                    "    def __init__(self, *args, **kwargs):\n")
        ifNotInCode(self._mainInit,
                    "        QMainWindow.__init__(self, *args, **kwargs)\n")
        ifNotInCode(self._mainInit, "        self.mainMenu = self.menuBar()\n")
        ifNotInCode(self._mainInit, "        self.Init_MainMenu()\n")
        ifNotInCode(self._mainInit, "        self.initUI()\n\n")
Beispiel #5
0
 def createFunctionFromMenuAction(self, menu, code):
     for menuAction, menuTitle in menu.items():
         if not menuAction.startswith('-'):
             sentence = "\n#    ACTION DEFINITION\n"
             ifNotInCode(self.function, sentence)
             sentence = F"    def do{menuAction.replace(' ', '_')}(self):\n        self.toBeImplemented()\n\n"
             ifNotInCode(code, sentence)
     sentence = "    def toBeImplemented(self):\n"
     ifNotInCode(self.function, sentence)
     sentence = F"        self.statusBar().showMessage(\"To Be Implemented\", 3000)\n\n"
     ifNotInCode(code, sentence)
Beispiel #6
0
    def menuGenerator(self, menu):
        for menuTitle in menu.values():
            if not menuTitle.startswith('*'):
                # in self._initMenuCode aggiunge:
                #   self.Init_MenuFile()    <- o il titolo del nuovo menù da creare
                ifNotInCode(self.initMenuCode,
                            F"    def Init_MainMenu(self):\n")
                ifNotInCode(self.initMenuCode,
                            F"        self.Init_Menu{menuTitle}()\n")
        _lastMenuTitle = ""
        for _menuAction, _menuTitle in menu.items():

            if not _menuAction.startswith('-'):
                # FINAL CODE MAY LOOK LIKE THIS:
                '''    def Init_MenuFile(self):
                            #        File
                            menuFile = self.mainMenu.addMenu("File")
                            #                NEW
                            new_Action = menuFile.addAction("New")
                            new_Action.setIcon(QIcon.fromTheme("document-new"))
                            new_Action.setShortcut(QKeySequence.New)
                            new_Action.triggered.connect(self.doNew)
                            menuFile.addAction(new_Action)
                '''
                if not _menuTitle.startswith('*'):
                    _lastMenuTitle = _menuTitle
                    sentence = F"\n    def Init_Menu{_menuTitle}(self):\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        #        {_menuTitle.upper()}\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        menu{_menuTitle} = self.mainMenu.addMenu(\"{_menuTitle}\")\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        #                {_menuAction.upper()}\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        {_menuAction.lower().replace(' ', '_')}_Action = menu{_menuTitle}.addAction(\"{_menuAction}\")\n"
                    ifNotInCode(self.menuCode, sentence)
                    # Search for the icon in the dictionary
                    self.isIconInDictionary(_menuAction, self.menuCode)
                    # Search for the ShortCutKey in the dictionaty
                    self.isShortCutInTheDictionary(_menuAction, self.menuCode)
                    # Search for the Hint in the dictionaty
                    self.isHintInTheDictionary(_menuAction, self.menuCode)
                    sentence = F"        {_menuAction.lower().replace(' ', '_')}_Action.triggered.connect(self.do{_menuAction.replace(' ', '_')})\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        menu{_menuTitle}.addAction({_menuAction.lower().replace(' ', '_')}_Action)\n"
                    ifNotInCode(self.menuCode, sentence)
                elif _menuTitle.startswith('*'):
                    _menuActionStar = _menuAction
                    _menuSubmenuStar = _menuTitle.replace('*', '')
                    '''
                    #####################################
                    menuSubmenu = menuMenuTitle.addMenu("subMenu")
                    #                MOVE
                    menuAction_Action = menu*Translate.addAction("Move")
                    menuAction_Action.triggered.connect(self.doMenuAction)
                    menuSubmenu.addAction(menuAction_Action)
                    '''
                    self.menuCode.append(
                        "        #####################################\n")
                    sentence = F"        menu{_menuSubmenuStar} = menu{_lastMenuTitle}.addMenu(\"{_menuSubmenuStar}\")\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        #                {_menuAction.upper()}\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        {_menuAction.lower().replace(' ', '_')}_Action = menu{_menuSubmenuStar}.addAction(\"{_menuAction}\")\n"
                    ifNotInCode(self.menuCode, sentence)
                    # Search for the icon in the dictionary
                    self.isIconInDictionary(_menuAction, self.menuCode)
                    # Search for the ShortCutKey in the dictionaty
                    self.isShortCutInTheDictionary(_menuAction, self.menuCode)
                    # Search for the Hint in the dictionaty
                    self.isHintInTheDictionary(_menuAction, self.menuCode)
                    sentence = F"        {_menuAction.lower().replace(' ', '_')}_Action.triggered.connect(self.do{_menuAction.replace(' ', '_')})\n"
                    ifNotInCode(self.menuCode, sentence)
                    sentence = F"        menu{_menuSubmenuStar}.addAction({_menuAction.lower().replace(' ', '_')}_Action)\n"
                    ifNotInCode(self.menuCode, sentence)

            elif _menuAction.startswith('-'):
                self.menuCode.append(
                    "        #####################################\n")
                self.menuCode.append(
                    F"        menu{_menuTitle}.addSeparator()\n")
Beispiel #7
0
 def isHintInTheDictionary(self, menuAction, code):
     for keyHint, valueHint in definition.definitionDictionary.items():
         if keyHint == menuAction.replace(' ', '').lower():
             sentence = F"        {menuAction.lower().replace(' ', '_')}" \
                        F"_Action..setToolTip({valueHint})\n"
             ifNotInCode(code, sentence)
Beispiel #8
0
 def isIconInDictionary(self, menuAction, code):
     for key, value in definition.iconDictionary.items():
         if key == menuAction.lower().replace(' ', ''):
             sentence = F"        {menuAction.lower().replace(' ', '')}_Action.setIcon(QIcon.fromTheme(\"{value}\"))\n"
             ifNotInCode(code, sentence)
 def createMainGuiClass(self):
     ifNotInCode(self._mainClass, "class mainWindows(QMainWindow):\n\n")
 def createImport(self):
     ifNotInCode(self._import, "import sys\n")
     ifNotInCode(self._import, "import os\n")
     ifNotInCode(self._import, "from PySide6.QtWidgets import *\n")
     ifNotInCode(self._import, "from PySide6.QtGui import *\n\n\n")
 def createMainRun(self):
     ifNotInCode(self._mainDefinition, "if __name__ == '__main__':\n")
     ifNotInCode(self._mainDefinition, "    main()\n")
 def createMainDefinition(self):
     ifNotInCode(self._mainDefinition, "def main():\n")
     ifNotInCode(self._mainDefinition, "    app = QApplication()\n")
     ifNotInCode(self._mainDefinition, "    exe = mainWindows()\n")
     ifNotInCode(self._mainDefinition, "    sys.exit(app.exec_())\n\n\n")