最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PYQT5實(shí)現(xiàn)控制臺(tái)顯示功能的方法

 更新時(shí)間:2019年06月25日 12:00:44   作者:晚安丶  
今天小編大家分享一篇PYQT5實(shí)現(xiàn)控制臺(tái)顯示功能的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

界面文件 Ui_ControlBoard.py

# -*- coding: utf-8 -*-
 
# Form implementation generated from reading ui file 'Ui_ControlBoard.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
 
from PyQt5 import QtCore, QtWidgets
 
class Ui_MainWindow(object):
  def setupUi(self, MainWindow):
    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(800, 600)
    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
    self.textBrowser.setGeometry(QtCore.QRect(50, 180, 591, 171))
    self.textBrowser.setObjectName("textBrowser")
    self.pushButton = QtWidgets.QPushButton(self.centralwidget)
    self.pushButton.setGeometry(QtCore.QRect(450, 390, 93, 28))
    self.pushButton.setObjectName("pushButton")
    MainWindow.setCentralWidget(self.centralwidget)
    self.menubar = QtWidgets.QMenuBar(MainWindow)
    self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
    self.menubar.setObjectName("menubar")
    MainWindow.setMenuBar(self.menubar)
    self.statusbar = QtWidgets.QStatusBar(MainWindow)
    self.statusbar.setObjectName("statusbar")
    MainWindow.setStatusBar(self.statusbar)
 
    self.retranslateUi(MainWindow)
    QtCore.QMetaObject.connectSlotsByName(MainWindow)
 
  def retranslateUi(self, MainWindow):
    _translate = QtCore.QCoreApplication.translate
    MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
    self.pushButton.setText(_translate("MainWindow", "PushButton"))
 

邏輯文件 Call_ControlBoard.py

版本一

#!/usr/bin/env python3
# -*- coding:utf-8 -*- 
from PyQt5 import QtCore, QtGui
import sys
from PyQt5.QtCore import QEventLoop, QTimer
from PyQt5.QtWidgets import QApplication, QMainWindow
 
from Ui_ControlBoard import Ui_MainWindow
 
class EmittingStr(QtCore.QObject):
    textWritten = QtCore.pyqtSignal(str) #定義一個(gè)發(fā)送str的信號(hào)
    def write(self, text):
      self.textWritten.emit(str(text))
 
 
class ControlBoard(QMainWindow, Ui_MainWindow):
  def __init__(self):
    super(ControlBoard, self).__init__()
    self.setupUi(self)
    # 下面將輸出重定向到textBrowser中
    sys.stdout = EmittingStr(textWritten=self.outputWritten)
    sys.stderr = EmittingStr(textWritten=self.outputWritten)
 
 
    self.pushButton.clicked.connect(self.bClicked)
 
  def outputWritten(self, text):
    cursor = self.textBrowser.textCursor()
    cursor.movePosition(QtGui.QTextCursor.End)
    cursor.insertText(text)
    self.textBrowser.setTextCursor(cursor)
    self.textBrowser.ensureCursorVisible()
 
  def bClicked(self):
    """Runs the main function."""
    print('Begin')
    loop = QEventLoop()
    QTimer.singleShot(1000, loop.quit)
    loop.exec_()
    self.printABCD()
    loop = QEventLoop()
    QTimer.singleShot(1000, loop.quit)
    loop.exec_()
    print("End")
 
  def printABCD(self):
    print("aaaaaaaaaaaaaaaa")
    print("bbbbbbbbbbbbbbbb")
    print("cccccccccccccccc")
    print("dddddddddddddddd")
 
 
 
 
if __name__ == "__main__":
  app = QApplication(sys.argv)
  win = ControlBoard()
  win.show()
  sys.exit(app.exec_())

版本二

#!/usr/bin/env python3
# -*- coding:utf-8 -*- 
from PyQt5 import QtCore, QtGui
import sys
from PyQt5.QtCore import QEventLoop, QTimer
from PyQt5.QtWidgets import QApplication, QMainWindow
 
from Ui_ControlBoard import Ui_MainWindow
 
class EmittingStr(QtCore.QObject):
    textWritten = QtCore.pyqtSignal(str) #定義一個(gè)發(fā)送str的信號(hào)
    def write(self, text):
      self.textWritten.emit(str(text))
      loop = QEventLoop()
      QTimer.singleShot(1000, loop.quit)
      loop.exec_()
 
 
class ControlBoard(QMainWindow, Ui_MainWindow):
  def __init__(self):
    super(ControlBoard, self).__init__()
    self.setupUi(self)
    # 下面將輸出重定向到textBrowser中
    sys.stdout = EmittingStr(textWritten=self.outputWritten)
    sys.stderr = EmittingStr(textWritten=self.outputWritten)
 
 
    self.pushButton.clicked.connect(self.bClicked)
 
  def outputWritten(self, text):
    cursor = self.textBrowser.textCursor()
    cursor.movePosition(QtGui.QTextCursor.End)
    cursor.insertText(text)
    self.textBrowser.setTextCursor(cursor)
    self.textBrowser.ensureCursorVisible()
 
  def bClicked(self):
    """Runs the main function."""
    print('Begin')
 
    self.printABCD()
 
    print("End")
 
  def printABCD(self):
    print("aaaaaaaaaaaaaaaa")
    print("bbbbbbbbbbbbbbbb")
    print("cccccccccccccccc")
    print("dddddddddddddddd")
 
 
 
 
if __name__ == "__main__":
  app = QApplication(sys.argv)
  win = ControlBoard()
  win.show()
  sys.exit(app.exec_())

版本三

#!/usr/bin/env python3
# -*- coding:utf-8 -*- 
from PyQt5 import QtCore, QtGui
import sys
from PyQt5.QtCore import QEventLoop, QTimer
from PyQt5.QtWidgets import QApplication, QMainWindow
 
from Ui_ControlBoard import Ui_MainWindow
 
class EmittingStr(QtCore.QObject):
    textWritten = QtCore.pyqtSignal(str) #定義一個(gè)發(fā)送str的信號(hào)
    def write(self, text):
      self.textWritten.emit(str(text))
 
 
class ControlBoard(QMainWindow, Ui_MainWindow):
  def __init__(self):
    super(ControlBoard, self).__init__()
    self.setupUi(self)
    # 下面將輸出重定向到textBrowser中
    sys.stdout = EmittingStr(textWritten=self.outputWritten)
    sys.stderr = EmittingStr(textWritten=self.outputWritten)
 
 
    self.pushButton.clicked.connect(self.bClicked)
 
  def outputWritten(self, text):
    cursor = self.textBrowser.textCursor()
    cursor.movePosition(QtGui.QTextCursor.End)
    cursor.insertText(text)
    self.textBrowser.setTextCursor(cursor)
    self.textBrowser.ensureCursorVisible()
 
  def bClicked(self):
    """Runs the main function."""
    print('Begin')
 
    self.printABCD()
 
    print("End")
 
  def printABCD(self):
    print("aaaaaaaaaaaaaaaa")
    print("bbbbbbbbbbbbbbbb")
    print("cccccccccccccccc")
    print("dddddddddddddddd")
 
 
 
 
if __name__ == "__main__":
  app = QApplication(sys.argv)
  win = ControlBoard()
  win.show()
  sys.exit(app.exec_())

以上這篇PYQT5實(shí)現(xiàn)控制臺(tái)顯示功能的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python NumPy創(chuàng)建數(shù)組方法

    Python NumPy創(chuàng)建數(shù)組方法

    這篇文章主要介紹了Python NumPy創(chuàng)建數(shù)組方法,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-09-09
  • 使用python查找windows系統(tǒng)中所有程序的安裝信息

    使用python查找windows系統(tǒng)中所有程序的安裝信息

    這篇文章主要為大家介紹了使用python查找windows系統(tǒng)中所有程序的安裝信息示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • Python數(shù)據(jù)可視化制作全球地震散點(diǎn)圖

    Python數(shù)據(jù)可視化制作全球地震散點(diǎn)圖

    這篇文章主要介紹了Python數(shù)據(jù)可視化制作全球地震散點(diǎn)圖,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-08-08
  • python 環(huán)境安裝及編輯器配置方法小結(jié)

    python 環(huán)境安裝及編輯器配置方法小結(jié)

    這篇文章主要介紹了python 環(huán)境安裝及編輯器配置方法小結(jié)的相關(guān)資料,需要的朋友可以參考下
    2021-06-06
  • Flask框架Flask-Login用法分析

    Flask框架Flask-Login用法分析

    這篇文章主要介紹了Flask框架Flask-Login用法,結(jié)合實(shí)例形式分析了Flask-Login插件進(jìn)行登錄驗(yàn)證的相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下
    2018-07-07
  • 理解python中生成器用法

    理解python中生成器用法

    本篇文章給大家詳細(xì)介紹了python中的生成器用法以及原理,有興趣的朋友參考學(xué)習(xí)下吧。
    2017-12-12
  • python3下實(shí)現(xiàn)搜狗AI API的代碼示例

    python3下實(shí)現(xiàn)搜狗AI API的代碼示例

    這篇文章主要介紹了python3下實(shí)現(xiàn)搜狗AI API的代碼示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-04-04
  • python使用Plotly繪圖工具繪制氣泡圖

    python使用Plotly繪圖工具繪制氣泡圖

    這篇文章主要為大家詳細(xì)介紹了python使用Plotly繪圖工具繪制氣泡圖,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • PyCharm中安裝PIL/Pillow的方法

    PyCharm中安裝PIL/Pillow的方法

    這篇文章主要介紹了PyCharm中PIL/Pillow的安裝,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • Appium+python+unittest搭建UI自動(dòng)化框架的實(shí)現(xiàn)

    Appium+python+unittest搭建UI自動(dòng)化框架的實(shí)現(xiàn)

    本文主要介紹了Appium+python+unittest搭建UI自動(dòng)化框架的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-03-03

最新評(píng)論

抚宁县| 甘肃省| 泸州市| 平南县| 安乡县| 建平县| 洞口县| 璧山县| 樟树市| 高碑店市| 长治县| 罗江县| 亚东县| 北京市| 确山县| 麦盖提县| 积石山| 图片| 平陆县| 石嘴山市| 廊坊市| 三都| 罗山县| 博湖县| 南部县| 化州市| 铜陵市| 德州市| 伊春市| 大关县| 湖州市| 融水| 南江县| 昌平区| 黔西| 井研县| 积石山| 泸水县| 左权县| 嘉善县| 金川县|