Esempio n. 1
0
    def __init__(self):
        '''
        Constructor
        '''
        self.win = WinMain(self)
        self.win.show()

        self.cfg = kmxINIConfigReadWrite.INIConfig("config.ini")
        self.iconPath = self.cfg.getOption('UserInterface', 'IconPath')
        self.icons = core.icons.iconSetup()
        self.infoStyle = kmxTools.infoStyle()
        self.infoStyle.errorLevel = 2
        self.infoStyle.infoLevel = 0

        self.tls = kmxTools.Tools(self.infoStyle)
        self.qtTools = kmxQtCommonTools.CommonTools(self.win, self.iconPath)
        self.qtTrees = kmxQtTreeWidget.TreeWidget()
        self.qtTools.applyStyle()
        dv = self.qtTools.getIconString('/04/16/39.png')
        self.qtConsole = DevConsolePlug.DevConsole(
            self.win,
            ShowPrint=True,
            ShowError=True,
            StatusBar=self.win.statusBar,
            AsDock=True,
            InitalizeScripts=True,
            logCount=30,
            btnIcon=dv,
            addObj=self)

        self.loadProject("currentProj")
Esempio n. 2
0
    def __init__(self):
        '''
        Constructor
        '''
        self.win = WinMain(self)
        self.win.show()

        self.cfg = kmxINIConfigReadWrite.INIConfig("config.ini")
        self.iconPath = self.cfg.getOption('UserInterface', 'IconPath')
        self.icons = core.icons.iconSetup()

        self.tls = kmxTools.Tools(kmxTools.infoStyle())
        self.qtConsole = DevConsolePlug.DevConsole(
            self.win,
            ShowPrint=True,
            ShowError=False,
            StatusBar=self.win.statusBar(),
            AsDock=True,
            InitalizeScripts=True)
        self.qtTrees = kmxQtTreeWidget.TreeWidget()
        self.qtTools = kmxQtCommonTools.CommonTools(self.win, self.iconPath)
        self.qtConn = kmxQtConnections.QtConnections(self.win)
        self.setupUI()
        if (os.path.exists('layout.lyt')):
            self.qtTools.uiLayoutRestore('layout.lyt', [self.win.splitter_2])
        self.tell("Ready!")
        self.currentNode = None
        self.selectedInputVariable = None
    def __init__(self, winHandle, currentObj, ppjCopy):
        '''
        Constructor
        '''

        self.mainWindow = winHandle
        self.ppjCopy = ppjCopy
        self.tools = kmxQtCommonTools.CommonTools(self.mainWindow)
        self.form = formCode.Ui_form()
        self.curObj = currentObj
        self.load()
Esempio n. 4
0
class MainApplication(QtWidgets.QMainWindow, Ui_MainWindow):

    pyFile = ""
    uiFile = ""
    cmp = ""
    ttl = kmxQtCommonTools.CommonTools(None)

    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.setupUi(self)
        self.cmp = CompileUItoPYCls()
        self.ttl = kmxQtCommonTools.CommonTools(self)
        self.pyFile = ""
        self.uiFile = ""

        if (len(sys.argv) > 1):
            self.uiFile = str(sys.argv[1]).strip()
            self.pyFile = self.cmp.getPyFileName(self.uiFile)

        self.lineEdit.setText(self.uiFile)
        self.lineEdit_2.setText(self.pyFile)

        self.textEdit.setEnabled(0)
        self.pushButton.clicked.connect(self.btnClickFn)
        self.toolButton.clicked.connect(self.btnBrowseUI)
        self.toolButton_2.clicked.connect(self.btnBrowsePY)

    def btnBrowseUI(self):
        self.uiFile = self.ttl.getFile("Select a UI File..", "main.ui",
                                       "UI Files (*.ui);;All Files (*);;")
        self.lineEdit.setText(self.uiFile)

    def btnBrowsePY(self):
        self.pyFile = self.ttl.getFile("Select a PY File..", "main.py",
                                       "Py Files (*.py);;All Files (*);;")
        self.lineEdit_2.setText(self.pyFile)

    def btnClickFn(self):
        self.uiFile = self.lineEdit.text()
        if (self.uiFile != ""):
            self.pyFile = self.lineEdit_2.text()
            if (self.pyFile == ""):
                self.pyFile = self.cmp.getPyFileName(self.uiFile)
                self.lineEdit_2.setText(self.pyFile)
            self.addInfo("Src: " + self.uiFile)
            self.addInfo("Dst: " + self.pyFile)
            self.cmp.convertCore(self.uiFile, self.pyFile)
            if (os.path.exists(self.pyFile)):
                self.addInfo("PY File Created! " + self.pyFile)
        self.addInfo("Done!")

    def addInfo(self, data):
        matter = self.textEdit.toPlainText() + "\n"
        self.textEdit.setText(matter + data)
Esempio n. 5
0
    def __init__(self):
        '''
        Constructor
        '''
        settingsLib.settings.__init__(self, None)
        widgetsLib.dynamicObjs.__init__(self, None)
        saftyLib.cryption.__init__(self, self)
        self.qtTools = kmxQtCommonTools.CommonTools(self)
        self.ttls = kmxTools.Tools()
        self.qtTree = kmxQtTreeWidget.TreeWidget()
        self.qtMenu = kmxQtMenuBuilder.MenuBuilder()
        self.qtConn = kmxQtConnections.QtConnections(self)
        self.qtIcon = kmxQtCommonTools.iconSetup(self)

        self.inter = InteractiveInterpreter()
        self.inter.locals['dev'] = self
        globals()['dev'] = self
Esempio n. 6
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.setupUi(self)
        self.cmp = CompileUItoPYCls()
        self.ttl = kmxQtCommonTools.CommonTools(self)
        self.pyFile = ""
        self.uiFile = ""

        if (len(sys.argv) > 1):
            self.uiFile = str(sys.argv[1]).strip()
            self.pyFile = self.cmp.getPyFileName(self.uiFile)

        self.lineEdit.setText(self.uiFile)
        self.lineEdit_2.setText(self.pyFile)

        self.textEdit.setEnabled(0)
        self.pushButton.clicked.connect(self.btnClickFn)
        self.toolButton.clicked.connect(self.btnBrowseUI)
        self.toolButton_2.clicked.connect(self.btnBrowsePY)
Esempio n. 7
0
    def __init__(self):
        '''
        Constructor
        '''
        self.win = WinMain(self)
        self.win.show()

        self.cfg = kmxINIConfigReadWrite.INIConfig("config.ini")
        self.iconPath = self.cfg.getOption('UserInterface', 'IconPath')
        self.icons = core.icons.iconSetup()

        self.tls = kmxTools.Tools(kmxTools.infoStyle())
        self.qtConsole = DevConsolePlug.DevConsole(
            self.win,
            ShowPrint=True,
            ShowError=True,
            StatusBar=self.win.statusBar(),
            AsDock=True,
            InitalizeScripts=True)
        self.qtTrees = kmxQtTreeWidget.TreeWidget()
        self.qtTools = kmxQtCommonTools.CommonTools(self.win, self.iconPath)
        self.setupUI()
Esempio n. 8
0
    def __init__(self,
                 parent=None,
                 ShowPrint=True,
                 ShowError=True,
                 StatusBar=None,
                 AsDock=False,
                 logCount=30,
                 ScriptsPath='Scripts/',
                 InitalizeScripts=True,
                 btnText="Console",
                 btnIcon="F:/04/06/29.PNG",
                 addObj=None):
        '''
        Parent - Pass QWIDGET based objects. Else I will create my own.
        ShowPrint - Redirect standard prints
        ShowError - Redirect standard errors
        StatusBar - Attach DevC Invoke button to this status bar else You should invoke DevC explicitly
        AsDock - If True creates DevC as a dock else as a dialog window
        '''
        last_update_date = 'July 02 2015'  # July 02 2015 , Jan 12 2013
        self.addObj = addObj
        self.parent = parent
        self.asDock = AsDock
        self.logCount = logCount

        super(DevConsole, self).__init__(self.parent)
        atexit.register(self.writeToLog)

        # Load File
        self.loadedFile = False
        self.loadedFileName = ''
        self.pyDesigner = 'C:\Python34\Lib\site-packages\PyQt5\designer.exe'

        #Flags
        self.qtTools = kmxQtCommonTools.CommonTools(self)
        self.ttls = kmxTools.Tools()
        self.qtTree = kmxQtTreeWidget.TreeWidget()
        self.qtMenu = kmxQtMenuBuilder.MenuBuilder()
        self.qtConn = kmxQtConnections.QtConnections(self)
        self.qtIcon = kmxQtCommonTools.iconSetup(self)

        self.standalone = 0 if self.parent else 1

        if self.standalone:
            print('No parent specified! Creating standalone console!')
            self.parent = self.win = QtWidgets.QMainWindow()
            self.win.resize(689, 504)

            self.mainWidget = QtWidgets.QWidget(self.win)
            self.setupUi(self.mainWidget)
            self.win.setCentralWidget(self.mainWidget)
            self.toolbar = QtWidgets.QToolBar('Main Tools', self)
            self.toolbar2 = QtWidgets.QToolBar('Additional Tools', self)
            self.toolbar.setFloatable(True)
            self.toolbar2.setFloatable(True)
            self.win.addToolBar(self.toolbar)
            self.win.addToolBar(self.toolbar2)
            self.setStandAloneModeFeatures()

            self.btnExecute.setVisible(0)
            self.btnLoadScript.setVisible(0)
            self.btnSaveScript.setVisible(0)
            self.btnNewScript.setVisible(0)
            self.btnQuickSaveScript.setVisible(0)

            self.label.setVisible(1)
            self.label.setText('Output:')
            self.line.setVisible(0)
            #self.sciOutput.resize(self.sciOutput.width(), self.sciOutput.height() + 90)

        elif self.asDock:
            if hasattr(self.parent, 'addDockWidget'):
                print('Creating dock based console!')
                self.win = QtWidgets.QDockWidget(self.parent)
                base = QtWidgets.QWidget()
                self.setupUi(base)
                self.win.setWidget(base)
                self.parent.addDockWidget(QtCore.Qt.DockWidgetArea(2),
                                          self.win)

                # print ('Creating dock based console!')
                # self.dck = QtWidgets.QDockWidget(self.parent)
                #
                # dlg = QtWidgets.QWidget()
                #
                # self.win = QtWidgets.QMainWindow()
                # lyt = QtWidgets.QVBoxLayout()
                # lyt.addWidget(self.win)
                # wdgt = QtWidgets.QWidget(self.dck)
                # self.setupUi(wdgt)
                # self.win.setCentralWidget(wdgt)
                #
                # dlg.setLayout(lyt)
                #
                # self.dck.setWidget(dlg)
                # self.parent.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dck)

            else:
                print('Unsupported Parent for creating dock based console! ' +
                      str(self.parent))
                print('Connecting console to given parent as a dialog...' +
                      str(self.parent))
                self.win = QtWidgets.QDialog(self.parent)
                self.setupUi(self.win)
        else:
            print('Connecting console to given parent as a dialog...' +
                  str(self.parent))
            self.win = QtWidgets.QDialog(self.parent)
            self.setupUi(self.win)

        self.outputFont = self.sciOutput.font()
        self.outputFont.setFamily("Courier")
        self.outputFont.setPointSize(10)
        self.outputFont.setFixedPitch(True)
        self.sciOutput.setFont(self.outputFont)
        self.sciOutput.setMarginsFont(self.outputFont)

        print(
            "Outputs Redirected to HaPy. Check HaPy console log for furthur system messages."
        )
        if ShowPrint: sys.stdout = self
        if ShowError: sys.stderr = self

        self.inter = InteractiveInterpreter()
        self.inter.locals['dev'] = self
        globals()['dev'] = self

        self.win.setWindowIcon(self.parent.windowIcon())
        self.win.setWindowTitle('HaPy')

        self.PLX = Qsci.QsciLexerPython(self)
        self.ABS = Qsci.QsciAPIs(self.PLX)
        # self.PLX.setAPIs(self.ABS)
        self.ABS.prepare()

        self.sciOutput.setReadOnly(1)
        self._setQSci(self.sciOutput)

        # Connections
        self.tabWidget.tabCloseRequested.connect(self.tabClose)

        if not self.standalone:
            self.btnExecute.clicked.connect(self.btnRedirector)
            #self.btnExecute_2.clicked.connect(self.btnRedirector)
            self.btnLoadScript.clicked.connect(self.btnRedirector)
            self.btnSaveScript.clicked.connect(self.btnRedirector)
            self.btnNewScript.clicked.connect(self.btnRedirector)
            self.btnQuickSaveScript.clicked.connect(self.btnRedirector)

        self.qtTools.connectToRightClick(self.treeWidget,
                                         self.pluginRightClick)
        self.tabWidget.__class__.keyReleaseEvent = self.tabKeyPress

        if StatusBar:
            self.stsBtnDebugger = QtWidgets.QToolButton(self.parent)
            self.stsBtnDebugger.setText(btnText)
            self.stsBtnDebugger.setToolTip(btnText)
            self.stsBtnDebugger.setAutoRaise(1)
            self.stsBtnDebugger.setMaximumHeight(18)
            StatusBar.addPermanentWidget(self.stsBtnDebugger, 0)
            self.stsBtnDebugger.clicked.connect(self.btnRedirector)
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(btnIcon), QtGui.QIcon.Normal,
                           QtGui.QIcon.On)
            self.stsBtnDebugger.setIcon(icon)
        else:
            self.stsBtnDebugger = None

        self.win.hide()

        # Plugin Lister
        #self.treeWidget.headerItem().setText(0, "DevS")
        self.treeWidget.itemDoubleClicked.connect(self.pluginSelected)

        self.treeWidget.setVisible(False)

        print('---------------------------------------')
        print('HaPy - Handy Python')
        print('Interactive Interpreter')
        print('---------------------------------------')
        print('Initiated!')

        print('\nLog Start Time: ' + str(strftime("%Y/%m/%d %H:%M:%S")))
        print('\n---------------------------------------\n')
        print('*** Python %s on %s.***' % (sys.version, sys.platform))
        print(sys.copyright)
        print('')
        print('Platform: ' + sys.platform)
        print('Version: ' + str(sys.getwindowsversion()))
        print('FileSys encodeing: ' + str(sys.getfilesystemencoding()))

        drline = "\n---------------------------------------\n"
        self.credit = drline + 'About HaPy:\nHandy Python - Interactive Interpreter/Scripting Environment \nAn expreimental project by \nKumaresan Lakshmanan\nFor Quick, Portable windows automation. \nDate: ' + last_update_date + drline
        print(self.credit)

        self.InitalizeScripts = InitalizeScripts
        self.scriptsDirName = ScriptsPath
        self.scriptsPath = os.path.abspath(self.scriptsDirName)
        print("Checking scripts path..." + os.path.abspath(self.scriptsPath))

        if self.scriptsPath:
            if self.InitalizeScripts and self.scriptsPath and not os.path.exists(
                    self.scriptsPath):
                os.makedirs(self.scriptsPath)
        else:
            print('Invalid script path!')

        #Start loading the scripts...
        try:
            self.execPlugin()
            self.treeWidget.setVisible(True)
        except:
            print(errorReport())

        try:
            if self.InitalizeScripts:
                self.execStartUp()
            else:
                self.addEmptyTab()
        except:
            print(errorReport())

        if self.standalone:
            self.qtConn.uiMain = self.win
            self.qtConn.installEventHandler()
            self.qtConn.addEventConnection(self.win, 'WindowDeactivate',
                                           self.onWinDeAct)
            self.qtConn.addEventConnection(self.win, 'Close', self.onClose)
            self.qtConn.addEventConnection(self.win, 'Hide', self.onHide)
            self.qtConn.addEventConnection(self.win, 'Show', self.onShow)

            if (os.path.exists('layout.lyt')):
                customList = self.qtTools.uiLayoutRestore(
                    'layout.lyt', [self.splitter, self.splitter_2])
                if (customList):
                    self.win.resize(customList[0])
                    self.win.move(customList[1])
            self.loadTabs()
        print("All set, You are ready to go...")