Python PyQt5.QtCore 模块,QProcess() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用PyQt5.QtCore.QProcess()

项目:pyqt5    作者:yurisnm    | 项目源码 | 文件源码
def __init__(self):
        super(MainWindow, self).__init__()
        self.line_edit = None

        # Procesos
        self.build_process = QProcess(self)
        if not sys.platform.startswith('linux'):
            self._envgcc = QProcessEnvironment.systemEnvironment()
            self._envgcc.insert("QT5DIR", "/home/epson/Qt/5.8/gcc_64")
            self._envgcc.insert("QT_QPA_PLATFORM_PLUGIN_PATH", "/home/epson/Qt/5.8/gcc_64/plugins/platforms")
            self._envgcc.insert("QT_PLUGIN_PATH", "/home/epson/Qt/5.8/gcc_64/plugins")
            self._envgcc.insert("QML_IMPORT_PATH", "/home/epson/Qt/5.8/gcc_64/qml")
            self._envgcc.insert("QML2_IMPORT_PATH", "/home/epson/Qt/5.8/gcc_64/qml")
            self._envgcc.insert("QT_VIRTUALKEYBOARD_LAYOUT_PATH", "/home/epson/INTERACT/interact-ii/basic-b2qt.qml")
            self._envgcc.insert("QT_VIRTUALKEYBOARD_STYLE", "/home/epson/INTERACT/interact-ii/basic-b2qt.qml")
            self._envgcc.insert("QT_IM_MODULE", "qtvirtualkeyboard")
            self.build_process.setProcessEnvironment(self._envgcc)
        self.execution_process = QProcess(self)


        self.init_ui()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __run_command( app, cmd, all_args, working_dir ):
    all_args = [str(arg) for arg in all_args]
    app.log.info( '%s %s' % (cmd, ' '.join( all_args ) ) )
    proc = QtCore.QProcess()
    proc.setStandardInputFile( proc.nullDevice() )
    proc.setStandardOutputFile( proc.nullDevice() )
    proc.setStandardErrorFile( proc.nullDevice() )
    proc.startDetached( cmd, all_args, str( working_dir ) )
项目:kaptan    作者:KaOSx    | 项目源码 | 文件源码
def optionsAccepted(self, id):
        if id == self.otherId:

            #MouseWidget
            self.page(1).execute()
            #ThemeWidget
            self.page(2).execute()
            #MenuWidget
            self.page(3).execute()
            #WallpaperWidget
            self.page(4).execute()
            #AvatarWidget
            self.page(5).execute()


            p = QProcess()
            p.startDetached("kquitapp5 plasmashell")
            p.waitForStarted(2000)
            p.startDetached("plasmashell")

        if id == self.sumId:
            self.setButtonText(QWizard.NextButton, self.tr("Apply Settings"))
            self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("dialog-ok-apply"))
            self.summaryVisible.emit()
        else:
            self.setButtonText(QWizard.NextButton, self.tr("Next"))
            self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("arrow-right"))
            self.button(QWizard.HelpButton).setLayoutDirection(Qt.RightToLeft)

    #def closeEvent(self, event):
    #    desktop_file = os.path.join(os.environ["HOME"], ".config", "autostart", "kaptan.desktop")
    #    if os.path.exists(desktop_file):
    #        os.remove(desktop_file)
项目:kawaii-player    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWget(self, command, src, get_library=None):
        global wget
        wget = QtCore.QProcess()
        wget.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        self.curl_progress_init = ''
        self.curl_progress_end = ''
        wget.started.connect(self.startedW)
        wget.readyReadStandardOutput.connect(partial(self.dataReadyW, wget, get_library))
        wget.finished.connect(lambda x=src : self.finishedW(src))
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWgetM(self,command):
        wget = QtCore.QProcess()
        wget.started.connect(self.startedM)
        wget.finished.connect(self.finishedM)
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWget(self,command,src):
        global wget
        wget = QtCore.QProcess()
        wget.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        self.curl_progress_init = ''
        self.curl_progress_end = ''
        wget.started.connect(self.startedW)
        wget.readyReadStandardOutput.connect(partial(self.dataReadyW,wget))
        wget.finished.connect(lambda x=src : self.finishedW(src))
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoWget(self,command,src):
        global wget
        wget = QtCore.QProcess()
        wget.setProcessChannelMode(QtCore.QProcess.MergedChannels)
        self.curl_progress_init = ''
        self.curl_progress_end = ''
        wget.started.connect(self.startedW)
        wget.readyReadStandardOutput.connect(partial(self.dataReadyW,wget))
        wget.finished.connect(lambda x=src : self.finishedW(src))
        QtCore.QTimer.singleShot(1000, partial(wget.start, command))
项目:kaptan    作者:PisiLinuxNew    | 项目源码 | 文件源码
def optionsAccepted(self, id):
        if id == self.otherId:

            #MouseWidget
            self.page(1).execute()
            #ThemeWidget
            self.page(2).execute()
            #MenuWidget
            self.page(3).execute()
            #WallpaperWidget
            self.page(4).execute()
            #AvatarWidget
            self.page(5).execute()


            p = QProcess()
            p.startDetached("killall plasmashell")
            p.waitForStarted(2000)
            p.startDetached("kstart5 plasmashell")

        if id == self.sumId:
            self.setButtonText(QWizard.NextButton, self.tr("Apply Settings"))
            self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("dialog-ok-apply"))
            self.summaryVisible.emit()
        else:
            self.setButtonText(QWizard.NextButton, self.tr("Next"))
            self.button(QWizard.NextButton).setIcon(QIcon.fromTheme("arrow-right"))
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def console_ui(self, audio):
        self.clear_layout(self.rbox)
        self.clear_layout(self.hbox)
        self.hbox.addStretch()
        self.l1.setText("Installing requirements")

        self.process = QProcess()
        self.output = QTextEdit()
        self.percent = 0

        self.rbox.insertSpacing(1, 10)
        l2 = QLabel('Press Next when the last line says "Successfully Installed--"')
        self.rbox.addWidget(l2, 0, Qt.AlignTop)
        # this can be uncommented whenever I actually figure out Progress Bars
        # self.pbar = QtWidgets.QProgressBar()
        # self.pbar.setGeometry(30, 40, 200, 25)
        # self.rbox.addWidget(self.pbar)

        b5 = QPushButton("Dialog", self)
        b5.setMaximumWidth(75)

        self.rbox.addWidget(b5)
        self.rbox.addWidget(self.output)
        self.process.readyRead.connect(self.console_data)
        self.output.hide()

        # data flow
        remove_reqs_readonly()
        interpreter = sys.executable

        if interpreter is None:
            QMessageBox.warning(self, "404", "Python interpreter not found.")
            self.close()

        txt = REQS_TXT if audio else REQS_NO_AUDIO_TXT
        args = ["-m", "pip", "install", "--upgrade", "--target", REQS_DIR, "-r", txt]

        if IS_MAC:  # --target is a problem on Homebrew. See PR #552
            args.remove("--target")
            args.remove(REQS_DIR)

        # do call
        self.process.start(interpreter, args)

        # buttons
        self.buttons_panel()

        # binds
        self.b1.setEnabled(True)
        # self.b2.setEnabled(False)
        self.b1.clicked.connect(self.req_ui)
        self.b1.clicked.connect(self.process.close)
        self.b2.clicked.connect(self.token_ui)
        self.b3.clicked.connect(self.close_prompt)
        b5.clicked.connect(self.console_hide)
项目:vanessa-singleapp    作者:silverbulleters-research    | 项目源码 | 文件源码
def init_ui(self):
        # self.setGeometry(300, 300, 300, 220)
        self.center()
        self.setWindowTitle('Kiosk')
        # self.setWindowIcon(QIcon('web.png'))

        self.show()

        # programName("calc.exe");
        # QStringList arguments;

        # process_ptr = QProcess(self);

        # process_ptr.conn
        # QObject.connect(process_ptr, pyqtSignal(self, name="closeEmitApp()"), process_ptr, pyqtSlot(self, name="close()"))
        # process_ptr.start("calc.exe", [])
        # self.createWindowContainer()

        program = "calc.exe"
        arguments = []

        layout = QVBoxLayout()
        myProcess = QProcess(self)
        myProcess.setProgram(program)
        myProcess.setArguments(arguments)
        # myProcess.
        self.show()
        window = QWindow.fromWinId(self.winId())
        container = self.createWindowContainer(window)
        # container.
        container.show()
        myProcess.setParent(window)
        myProcess.start()
        pid = myProcess.pid()

        print("PID:",int(pid))

        LPWinProcInfo = ctypes.POINTER(WinProcInfo)

        lp = ctypes.cast(int(myProcess.pid()), LPWinProcInfo)

        print(lp.contents.dwProcessID)

        win32w = QWindow.fromWinId(pid)
        win32w.setFlags(Qt.FramelessWindowHint)
        widg = QWidget.createWindowContainer(win32w)

        # widget.
        #widget.setW

        layout.addWidget(widg)

        self.setLayout(layout)

        myProcess.waitForFinished()
项目:kawaii-player    作者:kanishka-linux    | 项目源码 | 文件源码
def get_yt_sub(url, name, dest_dir, tmp_dir, ytdl_path, log):
    global name_epn, dest_dir_sub, tmp_dir_sub, TMPFILE, logger
    logger = log
    if not ytdl_path:
        youtube_dl = 'youtube-dl'
    name_epn = name
    dest_dir_sub = dest_dir
    tmp_dir_sub = tmp_dir
    final_url = ''
    url = url.replace('"', '')
    m = []
    if '/watch?' in url:
        a = url.split('?')[-1]
        b = a.split('&')
        if b:
            for i in b:
                j = i.split('=')
                k = (j[0], j[1])
                m.append(k)
        else:
            j = a.split('=')
            k = (j[0], j[1])
            m.append(k)
        d = dict(m)
        print(d, '----dict--arguments---generated---')
        try:
            url = 'https://m.youtube.com/watch?v='+d['v']
        except:
            pass
    fh, TMPFILE = mkstemp(suffix=None, prefix='youtube-sub')
    dir_name, sub_name = os.path.split(TMPFILE)
    logger.info("TMPFILE={0};Output-dest={1};dir_name={2};sub_name={3}".format(TMPFILE, dest_dir_sub, dir_name, sub_name))
    if ytdl_path == 'default':
        youtube_dl = 'youtube-dl'
    else:
        youtube_dl = ytdl_path
    command = youtube_dl+" --all-sub --skip-download --output "+TMPFILE+" "+url
    logger.info(command)

    yt_sub_process = QtCore.QProcess()
    yt_sub_process.started.connect(yt_sub_started)
    yt_sub_process.readyReadStandardOutput.connect(partial(yt_sub_dataReady, yt_sub_process))
    yt_sub_process.finished.connect(yt_sub_finished)
    QtCore.QTimer.singleShot(1000, partial(yt_sub_process.start, command))
项目:kawaii-player    作者:kanishka-linux    | 项目源码 | 文件源码
def infoPlay(self, command):
        global Player, site, new_epn, mpv_indicator, cache_empty
        self.eof_reached = False
        self.eof_lock = False
        self.mpv_playback_duration = None
        logger.debug('Now Starting')
        if not command:
            t = "Loading Failed: No Url/File Found. Try Again"
            self.progressEpn.setFormat(t)
        else:
            if mpv_indicator:
                mpv_indicator.pop()
            cache_empty = 'no'
            if command.startswith('mplayer') and OSNAME == 'nt':
                command = command + ' -vo gl'
            if self.player_setLoop_var:
                if Player == 'mplayer':
                    command = command+' -loop 0'

            print('--line--15662--')
            if self.mpvplayer_val.processId()>0:
                self.mpvplayer_val.kill()
                self.mpvplayer_started = False
                try:
                    if not self.mplayer_status_thread.isRunning():
                        self.mplayer_status_thread = PlayerWaitThread(self, command)
                        self.mplayer_status_thread.start()
                    else:
                        self.mpvplayer_command.append(command)
                except Exception as e:
                    print(e)
            else:
                if self.mpvplayer_command:
                    command = self.mpvplayer_command[-1]
                    self.mpvplayer_command[:] = []
                self.tab_5.set_mpvplayer(player=self.player_val, mpvplayer=self.mpvplayer_val)
                self.mpvplayer_val.setProcessChannelMode(QtCore.QProcess.MergedChannels)
                self.mpvplayer_val.started.connect(self.started)
                self.mpvplayer_val.readyReadStandardOutput.connect(partial(self.dataReady, self.mpvplayer_val))
                self.mpvplayer_val.finished.connect(self.finished)
                QtCore.QTimer.singleShot(100, partial(self.mpvplayer_val.start, command))
                logger.info(command)
                logger.info('infoplay--18165--')
                self.mpvplayer_started = True
                if self.player_setLoop_var and Player == 'mpv':
                    QtCore.QTimer.singleShot(15000, partial(self.set_playerLoopFile))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def get_yt_sub(url,name,dest_dir,tmp_dir,ytdl_path,log):
    global name_epn, dest_dir_sub,tmp_dir_sub,TMPFILE,logger
    logger = log
    if not ytdl_path:
        youtube_dl = 'youtube-dl'
    name_epn = name
    dest_dir_sub = dest_dir
    tmp_dir_sub = tmp_dir
    final_url = ''
    url = url.replace('"','')
    m = []
    if '/watch?' in url:
        a = url.split('?')[-1]
        b = a.split('&')
        if b:
            for i in b:
                j = i.split('=')
                k = (j[0],j[1])
                m.append(k)
        else:
            j = a.split('=')
            k = (j[0],j[1])
            m.append(k)
        d = dict(m)
        print(d,'----dict--arguments---generated---')
        try:
            url = 'https://m.youtube.com/watch?v='+d['v']
        except:
            pass
    fh,TMPFILE = mkstemp(suffix=None,prefix='youtube-sub')
    dir_name,sub_name = os.path.split(TMPFILE)
    logger.info("TMPFILE={0};Output-dest={1};dir_name={2};sub_name={3}".format(TMPFILE,dest_dir_sub,dir_name,sub_name))
    if ytdl_path == 'default':
        youtube_dl = 'youtube-dl'
    else:
        youtube_dl = ytdl_path
    command = youtube_dl+" --all-sub --skip-download --output "+TMPFILE+" "+url
    logger.info(command)

    yt_sub_process = QtCore.QProcess()
    yt_sub_process.started.connect(yt_sub_started)
    yt_sub_process.readyReadStandardOutput.connect(partial(yt_sub_dataReady,yt_sub_process))
    yt_sub_process.finished.connect(yt_sub_finished)
    QtCore.QTimer.singleShot(1000, partial(yt_sub_process.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoPlay(self,command):
        global mpvplayer,Player,site,new_epn,mpv_indicator,cache_empty
        if mpv_indicator:
            mpv_indicator.pop()
        cache_empty = 'no'
        if command.startswith('mplayer'):
            #command = command.replace(
            #   '-msglevel all=4:statusline=5:global=6',
            #   '-msglevel statusline=5:global=6'
            #   )
            if OSNAME == 'nt':
                command = command + ' -vo gl'
        if self.player_setLoop_var == 1:
            if Player == 'mplayer':
                command = command+' -loop 0'

        print('--line--15662--')
        if mpvplayer.processId()>0:
            mpvplayer.kill()
            try:
                if not self.mplayer_status_thread.isRunning():
                    self.mplayer_status_thread = PlayerWaitThread(command)
                    self.mplayer_status_thread.start()
                else:
                    self.mpvplayer_command.append(command)
            except Exception as e:
                print(e)
        else:
            #mpvplayer = QtCore.QProcess()
            if self.mpvplayer_command:
                command = self.mpvplayer_command[-1]
                self.mpvplayer_command[:]=[]
            self.mpvplayer_val = mpvplayer
            mpvplayer.setProcessChannelMode(QtCore.QProcess.MergedChannels)
            mpvplayer.started.connect(self.started)
            mpvplayer.readyReadStandardOutput.connect(partial(self.dataReady,mpvplayer))
            mpvplayer.finished.connect(self.finished)
            QtCore.QTimer.singleShot(1000, partial(mpvplayer.start, command))
            logger.info(command)
            self.mpvplayer_started = True
            if self.player_setLoop_var == 1 and Player == 'mpv':
                QtCore.QTimer.singleShot(15000, partial(self.set_playerLoopFile))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def get_yt_sub(url,name,dest_dir,tmp_dir,ytdl_path,log):
    global name_epn, dest_dir_sub,tmp_dir_sub,TMPFILE,logger
    logger = log
    if not ytdl_path:
        youtube_dl = 'youtube-dl'
    name_epn = name
    dest_dir_sub = dest_dir
    tmp_dir_sub = tmp_dir
    final_url = ''
    url = url.replace('"','')
    m = []
    if '/watch?' in url:
        a = url.split('?')[-1]
        b = a.split('&')
        if b:
            for i in b:
                j = i.split('=')
                k = (j[0],j[1])
                m.append(k)
        else:
            j = a.split('=')
            k = (j[0],j[1])
            m.append(k)
        d = dict(m)
        print(d,'----dict--arguments---generated---')
        try:
            url = 'https://m.youtube.com/watch?v='+d['v']
        except:
            pass
    fh,TMPFILE = mkstemp(suffix=None,prefix='youtube-sub')
    dir_name,sub_name = os.path.split(TMPFILE)
    logger.info("TMPFILE={0};Output-dest={1};dir_name={2};sub_name={3}".format(TMPFILE,dest_dir_sub,dir_name,sub_name))
    if ytdl_path == 'default':
        youtube_dl = 'youtube-dl'
    else:
        youtube_dl = ytdl_path
    command = youtube_dl+" --all-sub --skip-download --output "+TMPFILE+" "+url
    logger.info(command)

    yt_sub_process = QtCore.QProcess()
    yt_sub_process.started.connect(yt_sub_started)
    yt_sub_process.readyReadStandardOutput.connect(partial(yt_sub_dataReady,yt_sub_process))
    yt_sub_process.finished.connect(yt_sub_finished)
    QtCore.QTimer.singleShot(1000, partial(yt_sub_process.start, command))
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def infoPlay(self,command):
        global mpvplayer,Player,site,new_epn,mpv_indicator,cache_empty
        if mpv_indicator:
            mpv_indicator.pop()
        cache_empty = 'no'
        if command.startswith('mplayer'):
            #command = command.replace(
            #   '-msglevel all=4:statusline=5:global=6',
            #   '-msglevel statusline=5:global=6'
            #   )
            if OSNAME == 'nt':
                command = command + ' -vo gl'
        if self.player_setLoop_var == 1:
            if Player == 'mplayer':
                command = command+' -loop 0'

        print('--line--15662--')
        if mpvplayer.processId()>0:
            mpvplayer.kill()
            try:
                if not self.mplayer_status_thread.isRunning():
                    self.mplayer_status_thread = PlayerWaitThread(command)
                    self.mplayer_status_thread.start()
                else:
                    self.mpvplayer_command.append(command)
            except Exception as e:
                print(e)
        else:
            #mpvplayer = QtCore.QProcess()
            if self.mpvplayer_command:
                command = self.mpvplayer_command[-1]
                self.mpvplayer_command[:]=[]
            self.mpvplayer_val = mpvplayer
            mpvplayer.setProcessChannelMode(QtCore.QProcess.MergedChannels)
            mpvplayer.started.connect(self.started)
            mpvplayer.readyReadStandardOutput.connect(partial(self.dataReady,mpvplayer))
            mpvplayer.finished.connect(self.finished)
            QtCore.QTimer.singleShot(1000, partial(mpvplayer.start, command))
            logger.info(command)
            self.mpvplayer_started = True
            if self.player_setLoop_var == 1 and Player == 'mpv':
                QtCore.QTimer.singleShot(15000, partial(self.set_playerLoopFile))