Example #1
0
 def updateSerialPortList(self):
     # clear previous actions list
     self.serialPortMenu.clear()
     for act in self.serialPortGroup.actions():
         self.serialPortGroup.removeAction(act)
         del act
     
     # scan existing ports
     portList = scan_serialports() # serialport.py
     previousPortName = self.Configs.getSerialPortName()
     
     # create new actions & update serial port menu
     if len(portList):
         for i in range(len(portList)):
             act = QtGui.QAction(portList[i],  self, checkable=True,
                         statusTip="select " + portList[i] + " serial port",
                         triggered=self.selectSerialPort)
             self.serialPortGroup.addAction( act )
             self.serialPortMenu.addAction( act )
             if portList[i] == previousPortName:
                 act.setChecked(True)
                 act.trigger()
                 
     if not self.serialPortGroup.checkedAction():
         self.serialPortName = ''
Example #2
0
    def updateSerialPortList(self):
        # clear previous actions list
        self.serialPortMenu.clear()
        for act in self.serialPortGroup.actions():
            self.serialPortGroup.removeAction(act)
            del act

        # scan existing ports
        portList = scan_serialports()  # serialport.py
        previousPortName = self.Configs.getSerialPortName()

        # create new actions & update serial port menu
        if len(portList):
            for i in range(len(portList)):
                act = QtGui.QAction(portList[i],
                                    self,
                                    checkable=True,
                                    statusTip="select " + portList[i] +
                                    " serial port",
                                    triggered=self.selectSerialPort)
                self.serialPortGroup.addAction(act)
                self.serialPortMenu.addAction(act)
                if portList[i] == previousPortName:
                    act.setChecked(True)
                    act.trigger()

        if not self.serialPortGroup.checkedAction():
            self.serialPortName = ''
            self.insertLog(
                '<i><font color=gray>( please select a serial port. )</font></i>'
            )
Example #3
0
 def createActions(self):
     # file menu
     self.newAct = QtGui.QAction( QtGui.QIcon("./images/new.png"), "&New",
             self, shortcut=QtGui.QKeySequence("Ctrl+N"),
             statusTip="Create a new file", triggered=self.Editor.newFile)
     self.openAct = QtGui.QAction(QtGui.QIcon("./images/open.png"), "&Open...",
             self, shortcut=QtGui.QKeySequence("Ctrl+O"),
             statusTip="Open an existing file")
     self.openAct.triggered.connect( functools.partial(self.Editor.openFile, None) )
     self.closeAct = QtGui.QAction("&Close",
             self, shortcut=QtGui.QKeySequence("Ctrl+W"),
             statusTip="Close the current window", triggered=self.Editor.closeCurrentFile)
     self.saveAct = QtGui.QAction(QtGui.QIcon("./images/save.png"), "&Save",
             self, shortcut=QtGui.QKeySequence("Ctrl+S"),
             statusTip="Save the current file", triggered=self.Editor.saveFile)        
     self.saveAsAct = QtGui.QAction("Save &As...", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+S"),
             statusTip="Save to another file", triggered=self.Editor.saveFileAs)
     
     self.exitAct = QtGui.QAction("E&xit", self,
             shortcut=QtGui.QKeySequence("Alt+F4"),
             statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows)
     
     # edit menu
     self.editUndoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence("Ctrl+Z"),
                                      triggered=self.Editor.editUndo)
     self.editRedoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence("Ctrl+Y"),
                                      triggered=self.Editor.editRedo)
     self.editCutAct = QtGui.QAction("Cu&t", self, shortcut=QtGui.QKeySequence("Ctrl+X"),
                                      triggered=self.Editor.editCut)
     self.editCopyAct = QtGui.QAction("&Copy", self, shortcut=QtGui.QKeySequence("Ctrl+C"),
                                      triggered=self.Editor.editCopy)
     self.editPasteAct = QtGui.QAction("&Paste", self, shortcut=QtGui.QKeySequence("Ctrl+V"),
                                      triggered=self.Editor.editPaste)
     self.editSelectAllAct = QtGui.QAction("Select &All", self, shortcut=QtGui.QKeySequence("Ctrl+A"),
                                      triggered=self.Editor.editSelectAll)
     self.editClearAct = QtGui.QAction("Clear", self,  triggered=self.Editor.editClear)
     # find/replace
     self.findAct = QtGui.QAction("&Find/Replace...", self,
             shortcut=QtGui.QKeySequence("Ctrl+F"),
             statusTip="Find/Replace texts", triggered=self.Editor.showFindDialog)
     
     # project menu
     self.compileAct = QtGui.QAction(QtGui.QIcon("./images/build.png"), "&Compile",
             self, shortcut=QtGui.QKeySequence("Ctrl+B"),
             statusTip="Build the current project", triggered=self.startBuild)
     self.stopAct = QtGui.QAction(QtGui.QIcon("./images/stop.png"), "S&top",
             self, statusTip="Cancel the build process", triggered=self.stopBuild)
     self.programAct = QtGui.QAction(QtGui.QIcon("./images/load.png"), "&Load",
             self, shortcut=QtGui.QKeySequence("Ctrl+R"), 
             statusTip="Download program to the board using bootloader", triggered=self.programChip)
      
     self.firmwareLibList = scanFirmwareLibs()
     self.firmwareLibActs = []
     if len(self.firmwareLibList):
         for i in range(len(self.firmwareLibList)):
             self.firmwareLibActs.append(
                     QtGui.QAction(self.firmwareLibList[i],  self,
                         statusTip="include " + self.firmwareLibList[i] + " library" ) )
             
     self.exampleProjects = getExampleProjects(self.firmwareLibList)
     self.exampleFolderMenus = []
     self.openExampleActs = []
     for group in self.exampleProjects:
         folder, files = group[0], group[1]
         self.exampleFolderMenus.append(QtGui.QMenu(str(folder), self))
         for fname in files:
             baseName = os.path.basename(fname)
             self.openExampleActs.append(QtGui.QAction(os.path.splitext(baseName)[0], self,
                             statusTip = 'Open "' + str(fname).replace('\\', '/') + '"') )
     
     # serial monitor/terminal window
     self.serialMonitorAct = QtGui.QAction(QtGui.QIcon("./images/serial.png"), "Serial &Monitor",
             self, shortcut=QtGui.QKeySequence("Ctrl+Shift+M"),
             statusTip="Launch Serial Monitor Dialog", triggered=self.openSerialPortMonitorDialog)
     self.serialPortGroup = QtGui.QActionGroup(self)
     self.serialPortList = scan_serialports()
     self.serialPortActs = []
     if len(self.serialPortList):
         for i in range(len(self.serialPortList)):
             self.serialPortActs.append(
                     QtGui.QAction(self.serialPortList[i],  self, checkable=True,
                         statusTip="select " + self.serialPortList[i] + " serial port",
                         triggered=self.selectSerialPort) )
             self.serialPortGroup.addAction( self.serialPortActs[i] )
     
     # todo: board names??
     #self.boardAnitoAct = QtGui.QAction("PhilRobokit &Anito",  self,
     #        checkable=True, statusTip="Select PhilRobokit Anito board" )
     self.boardStellarisAct = QtGui.QAction("EK-&LM4F120XL",  self,
             checkable=True, statusTip="Select TI Stellaris LM4F120 LaunchPad" )
     self.boardGroup = QtGui.QActionGroup(self)
     #self.boardGroup.addAction(self.boardAnitoAct)
     self.boardGroup.addAction(self.boardStellarisAct)
     self.boardStellarisAct.setChecked(True)
     
     self.restoreDefaultsAct = QtGui.QAction("Restore Defaults",  self,
             statusTip="Clear configuration files", triggered=self.Configs.setDefaults)
     
     # help menu
     self.aboutAct = QtGui.QAction("&About", self, shortcut=QtGui.QKeySequence("F1"),
             statusTip="About the IDE", triggered=self.about)        
     self.aboutCompilerAct = QtGui.QAction("About &Compiler", self,
             statusTip="About GNU tools for ARM Embedded", triggered=self.aboutCompiler)
     self.aboutQtAct = QtGui.QAction("About &Qt", self,
             statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt)
     self.visitProjectprotoSiteAct = QtGui.QAction("Visit &ProjectProto", self,
             statusTip="Open ProjectProto blog site (yus' projects)", triggered=self.openProjectProtoSite)
     self.visitPhilroboticsSiteAct = QtGui.QAction("Visit Phil&Robotics", self,
             statusTip="Open PhilRobotics website", triggered=self.openPhilRoboticsSite)
Example #4
0
    def createActions(self):
        # file menu
        self.newAct = QtGui.QAction(QtGui.QIcon("./images/new.png"),
                                    "&New",
                                    self,
                                    shortcut=QtGui.QKeySequence("Ctrl+N"),
                                    statusTip="Create a new file",
                                    triggered=self.Editor.newFile)
        self.openAct = QtGui.QAction(QtGui.QIcon("./images/open.png"),
                                     "&Open...",
                                     self,
                                     shortcut=QtGui.QKeySequence("Ctrl+O"),
                                     statusTip="Open an existing file")
        self.openAct.triggered.connect(
            functools.partial(self.Editor.openFile, None))
        self.closeAct = QtGui.QAction("&Close",
                                      self,
                                      shortcut=QtGui.QKeySequence("Ctrl+W"),
                                      statusTip="Close the current window",
                                      triggered=self.Editor.closeCurrentFile)
        self.saveAct = QtGui.QAction(QtGui.QIcon("./images/save.png"),
                                     "&Save",
                                     self,
                                     shortcut=QtGui.QKeySequence("Ctrl+S"),
                                     statusTip="Save the current file",
                                     triggered=self.Editor.saveFile)
        self.saveAsAct = QtGui.QAction(
            "Save &As...",
            self,
            shortcut=QtGui.QKeySequence("Ctrl+Shift+S"),
            statusTip="Save to another file",
            triggered=self.Editor.saveFileAs)

        self.exitAct = QtGui.QAction("E&xit",
                                     self,
                                     shortcut=QtGui.QKeySequence("Alt+F4"),
                                     statusTip="Exit the application",
                                     triggered=QtGui.qApp.closeAllWindows)

        # edit menu
        self.editUndoAct = QtGui.QAction("&Undo",
                                         self,
                                         shortcut=QtGui.QKeySequence("Ctrl+Z"),
                                         triggered=self.Editor.editUndo)
        self.editRedoAct = QtGui.QAction("&Redo",
                                         self,
                                         shortcut=QtGui.QKeySequence("Ctrl+Y"),
                                         triggered=self.Editor.editRedo)
        self.editCutAct = QtGui.QAction("Cu&t",
                                        self,
                                        shortcut=QtGui.QKeySequence("Ctrl+X"),
                                        triggered=self.Editor.editCut)
        self.editCopyAct = QtGui.QAction("&Copy",
                                         self,
                                         shortcut=QtGui.QKeySequence("Ctrl+C"),
                                         triggered=self.Editor.editCopy)
        self.editPasteAct = QtGui.QAction(
            "&Paste",
            self,
            shortcut=QtGui.QKeySequence("Ctrl+V"),
            triggered=self.Editor.editPaste)
        self.editSelectAllAct = QtGui.QAction(
            "Select &All",
            self,
            shortcut=QtGui.QKeySequence("Ctrl+A"),
            triggered=self.Editor.editSelectAll)
        self.editClearAct = QtGui.QAction("Clear",
                                          self,
                                          triggered=self.Editor.editClear)
        # find/replace
        self.findAct = QtGui.QAction("&Find/Replace...",
                                     self,
                                     shortcut=QtGui.QKeySequence("Ctrl+F"),
                                     statusTip="Find/Replace texts",
                                     triggered=self.Editor.showFindDialog)

        # project menu
        self.compileAct = QtGui.QAction(QtGui.QIcon("./images/build.png"),
                                        "&Compile",
                                        self,
                                        shortcut=QtGui.QKeySequence("Ctrl+B"),
                                        statusTip="Build the current project",
                                        triggered=self.startBuild)
        self.stopAct = QtGui.QAction(QtGui.QIcon("./images/stop.png"),
                                     "S&top",
                                     self,
                                     statusTip="Cancel the build process",
                                     triggered=self.stopBuild)
        self.programAct = QtGui.QAction(
            QtGui.QIcon("./images/load.png"),
            "&Load",
            self,
            shortcut=QtGui.QKeySequence("Ctrl+R"),
            statusTip="Download program to the board using bootloader",
            triggered=self.programChip)

        self.firmwareLibList = scanFirmwareLibs()
        self.firmwareLibActs = []
        if len(self.firmwareLibList):
            for i in range(len(self.firmwareLibList)):
                self.firmwareLibActs.append(
                    QtGui.QAction(self.firmwareLibList[i],
                                  self,
                                  statusTip="include " +
                                  self.firmwareLibList[i] + " library"))

        self.exampleProjects = getExampleProjects(self.firmwareLibList)
        self.exampleFolderMenus = []
        self.openExampleActs = []
        for group in self.exampleProjects:
            folder, files = group[0], group[1]
            self.exampleFolderMenus.append(QtGui.QMenu(str(folder), self))
            for fname in files:
                baseName = os.path.basename(fname)
                self.openExampleActs.append(
                    QtGui.QAction(os.path.splitext(baseName)[0],
                                  self,
                                  statusTip='Open "' +
                                  str(fname).replace('\\', '/') + '"'))

        # serial monitor/terminal window
        self.serialMonitorAct = QtGui.QAction(
            QtGui.QIcon("./images/serial.png"),
            "Serial &Monitor",
            self,
            shortcut=QtGui.QKeySequence("Ctrl+Shift+M"),
            statusTip="Launch Serial Monitor Dialog",
            triggered=self.openSerialPortMonitorDialog)
        self.serialPortGroup = QtGui.QActionGroup(self)
        self.serialPortList = scan_serialports()
        self.serialPortActs = []
        if len(self.serialPortList):
            for i in range(len(self.serialPortList)):
                self.serialPortActs.append(
                    QtGui.QAction(self.serialPortList[i],
                                  self,
                                  checkable=True,
                                  statusTip="select " +
                                  self.serialPortList[i] + " serial port",
                                  triggered=self.selectSerialPort))
                self.serialPortGroup.addAction(self.serialPortActs[i])

        # todo: board names??
        #self.boardAnitoAct = QtGui.QAction("PhilRobokit &Anito",  self,
        #        checkable=True, statusTip="Select PhilRobokit Anito board" )
        self.boardEgizmoStm32Act = QtGui.QAction(
            "e&Gizmo STM32",
            self,
            checkable=True,
            statusTip="Select eGizmo STM32F100C8 MCU board")
        self.boardGroup = QtGui.QActionGroup(self)
        #self.boardGroup.addAction(self.boardAnitoAct)
        self.boardGroup.addAction(self.boardEgizmoStm32Act)
        self.boardEgizmoStm32Act.setChecked(True)

        self.restoreDefaultsAct = QtGui.QAction(
            "Restore Defaults",
            self,
            statusTip="Clear configuration files",
            triggered=self.Configs.setDefaults)

        # help menu
        self.aboutAct = QtGui.QAction("&About",
                                      self,
                                      shortcut=QtGui.QKeySequence("F1"),
                                      statusTip="About the IDE",
                                      triggered=self.about)
        self.aboutCompilerAct = QtGui.QAction(
            "About &Compiler",
            self,
            statusTip="About GNU tools for ARM Embedded",
            triggered=self.aboutCompiler)
        self.aboutQtAct = QtGui.QAction(
            "About &Qt",
            self,
            statusTip="Show the Qt library's About box",
            triggered=QtGui.qApp.aboutQt)
        self.visitProjectprotoSiteAct = QtGui.QAction(
            "Visit &ProjectProto",
            self,
            statusTip="Open ProjectProto blog site (yus' projects)",
            triggered=self.openProjectProtoSite)
        self.visitPhilroboticsSiteAct = QtGui.QAction(
            "Visit Phil&Robotics",
            self,
            statusTip="Open PhilRobotics website",
            triggered=self.openPhilRoboticsSite)