示例#1
0
    def deletePath(self):
        r"""
            外部ドロップパスデータを削除
        """
        _p = sg.toBasePath(self._TL.getDropPathData())
        if not _p:
            print('+ Not drop path data.')
            return
        jsonPath = _SPSL.getPath()
        if not os.path.isfile(jsonPath):
            print('+ Not json path. {}'.format(jsonPath))
            return
        _d = _SPSL.getJsonFile()
        _saveDict = _d.get(_DROPPATH)
        _saveBuf = _saveDict[:] if _saveDict else []
        if not _p in _saveDict:
            return

        _saveBuf.remove(_p)
        _d[_DROPPATH] = _saveBuf
        _SPSL.setDict(_d)
        _SPSL.setBackup(True)
        _SPSL.setJsonFile()
        print(u'+ Remove path. "{}"'.format(_p))

        if self._TL.getProcessNowFlag():
            return
        self._TL.setSubprocessText('Delete')
        self._TL.processAlphaTimeLine()
示例#2
0
 def keyMoveChangePath(self, keyType=None):
     r"""
         ↑↓キーを押した際に保存されているパスにスライドして切り替える
     """
     obj = self.getObject()
     jsonPath = _SPSL.getPath()
     if not os.path.isfile(jsonPath):
         print('+ Not found save json file.')
         print('  -> {}'.format(jsonPath))
         return
     if not obj._KEYMOVEPATHLIST:
         print('+ Nothing is saved.')
         return
     txt_path = sg.toBasePath(self.pathLine.text())
     try:
         if keyType == 'Up':
             limit = 0
             initi = (len(obj._KEYMOVEPATHLIST) - 1)
             step = -1
         else:
             limit = (len(obj._KEYMOVEPATHLIST) - 1)
             initi = 0
             step = 1
         INDEX = obj._KEYMOVEPATHLIST.index(txt_path)
         NEXT = (obj._KEYMOVEPATHLIST[initi]
                 if limit == INDEX else obj._KEYMOVEPATHLIST[INDEX + step])
     except:
         NEXT = obj._KEYMOVEPATHLIST[0]
     self.pathLine.setText(str(NEXT))
示例#3
0
 def openDir(self):
     r"""
         セットされているパスをエクスプローラーで開く
     """
     p = sg.toBasePath(self.pathLine.text())
     if os.path.isdir(p):
         sg.openExplorer(p)
示例#4
0
 def getEachPythonFile(self, uiname, filetype):
     r"""
         UI名とpythonファイルタイプを指定してファイルパス情報を取得
         ファイルパス先のデータが無い場合はNoneを返す
     """
     path = os.path.join(
         self.getNowFolderPath(), uiname,
         filetype if '.py' in filetype else '{}.py'.format(filetype))
     return sg.toBasePath(path) if os.path.isfile(path) else None
示例#5
0
    def keyMoveSetPath(self, keyType=None):
        r"""
            現在セットされているパスをjsonに保存/削除する
        """
        def _putPrint():
            r"""
                save,remove時にラベルとして可視表示する
            """
            self.resultText.setText('save' if keyType == 'F1' else 'remove')
            QtCore.QTimer.singleShot(1000,
                                     (lambda: self.resultText.setText('')))

        d = _SPSL.getJsonFile()
        saveDict = d.get(_path)
        _saveBuf = saveDict[:] if saveDict else []
        txt_path = sg.toBasePath(self.pathLine.text())
        # save
        if keyType in ('F1', ):
            if not txt_path in _saveBuf and not txt_path == '':
                _saveBuf.extend([txt_path])
                print('+ Save path.')
                print('  -> {}'.format(sg.toEncode(txt_path, 'cp932')))
                _putPrint()
        # remove
        elif keyType in ('F2', ):
            if txt_path in _saveBuf and txt_path:
                try:
                    _saveBuf.remove(txt_path)
                    print('+ Remove path.')
                    print('  -> {}'.format(txt_path))
                    _putPrint()
                except:
                    pass
        else:
            pass
        d[_path] = _saveBuf
        _SPSL.setDict(d)
        _SPSL.setJsonFile()
        obj = self.getObject()
        obj._KEYMOVEPATHLIST = _saveBuf[:]
        obj._KEYMOVEPATHLIST.sort()
        obj.keyReflect()
        self.setKeyPath()
示例#6
0
    def changePath(self, moveValue):
        r"""
            キー移動でのパス変化
        """
        _p = sg.toBasePath(self._TL.getDropPathData())
        jsonPath = _SPSL.getPath()
        if not os.path.isfile(jsonPath):
            print('+ Not json path. {}'.format(jsonPath))
            return
        _d = _SPSL.getJsonFile()
        _saveDict = _d.get(_DROPPATH)
        if not _saveDict:
            return
        _saveBuf = _saveDict[:] if _saveDict else []

        try:
            index = 0 if not _p else (_saveBuf.index(_p) + moveValue)
            index = 0 if index >= len(_saveBuf) else index
            self._TL.updateText(_saveBuf[index])
        except ValueError:
            self._TL.updateText(_saveBuf[0])
示例#7
0
    def keyPressEvent(self, event):
        r"""
            キープレス時のイベント情報(オーバーライド)
        """
        super(MainWindow, self).keyPressEvent(event)

        key = self.getKeyType(event)
        mask = self.getKeyMask()
        mask2 = self.getKeyMask2()

        # Debug/OFF
        if not self.debugFlag:
            maskCA = mask2(['ctrl', 'alt'])
            EXE = (lambda type, opentype=True: sg.openExplorer(
                sg.toBasePath(WSI.getEachPythonFile(self._guiName, type)),
                opentype))

            # XXX/ui.pyを開く
            if (key['press'] == 'F1') and key['mod1'] == maskCA:
                EXE('ui')
            # XXX/func.pyを開く
            elif (key['press'] == 'F2') and key['mod1'] == maskCA:
                EXE('func')
            # XXX/__init__.pyを開く
            elif (key['press'] == 'F3') and key['mod1'] == maskCA:
                EXE('__init__')
            # XXX folderを開く
            elif (key['press'] == 'F4') and key['mod1'] == maskCA:
                EXE('__init__', False)
            else:
                pass
        # Debug/ON
        else:
            # roamingフォルダを開く
            if (key['press'] == 'F1'):
                sg.openExplorer(self.PSL.msAppToolsPath)
            else:
                pass