久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='CYx9s'><tr id='CYx9s'><dt id='CYx9s'><q id='CYx9s'><span id='CYx9s'><b id='CYx9s'><form id='CYx9s'><ins id='CYx9s'></ins><ul id='CYx9s'></ul><sub id='CYx9s'></sub></form><legend id='CYx9s'></legend><bdo id='CYx9s'><pre id='CYx9s'><center id='CYx9s'></center></pre></bdo></b><th id='CYx9s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CYx9s'><tfoot id='CYx9s'></tfoot><dl id='CYx9s'><fieldset id='CYx9s'></fieldset></dl></div>

    <small id='CYx9s'></small><noframes id='CYx9s'>

        <bdo id='CYx9s'></bdo><ul id='CYx9s'></ul>

    1. <tfoot id='CYx9s'></tfoot>
      1. <legend id='CYx9s'><style id='CYx9s'><dir id='CYx9s'><q id='CYx9s'></q></dir></style></legend>

        如何使用 Python 將控制臺輸出定向到 pyqt5 plainTe

        How do I direct console output to a pyqt5 plainTextEdit widget with Python?(如何使用 Python 將控制臺輸出定向到 pyqt5 plainTextEdit 小部件?)

          <bdo id='m2CRi'></bdo><ul id='m2CRi'></ul>

            <tbody id='m2CRi'></tbody>
          <i id='m2CRi'><tr id='m2CRi'><dt id='m2CRi'><q id='m2CRi'><span id='m2CRi'><b id='m2CRi'><form id='m2CRi'><ins id='m2CRi'></ins><ul id='m2CRi'></ul><sub id='m2CRi'></sub></form><legend id='m2CRi'></legend><bdo id='m2CRi'><pre id='m2CRi'><center id='m2CRi'></center></pre></bdo></b><th id='m2CRi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='m2CRi'><tfoot id='m2CRi'></tfoot><dl id='m2CRi'><fieldset id='m2CRi'></fieldset></dl></div>

          <small id='m2CRi'></small><noframes id='m2CRi'>

          1. <tfoot id='m2CRi'></tfoot>
              • <legend id='m2CRi'><style id='m2CRi'><dir id='m2CRi'><q id='m2CRi'></q></dir></style></legend>

                  本文介紹了如何使用 Python 將控制臺輸出定向到 pyqt5 plainTextEdit 小部件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試在 PyQt5 的 QplainTextEdit 小部件中顯示 python 腳本的控制臺輸出.

                  I am trying to display console output of a python script in a QplainTextEdit widget in PyQt5.

                  我收到此錯誤:

                  TypeError:調用元類庫時出錯元類沖突:派生類的元類必須是其所有基類的元類的(非嚴格)子類

                  TypeError: Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

                  我已經在 pyqt GUI 文件中定義了我的對象,并且我相信我擁有所有的導入.

                  I have defined my objects in the pyqt GUI file and I believe that I have all the imports.

                  我已經修改了這個問題的代碼:

                  I have amended the code in this question:

                  from PyQt5.QtCore import QRectF, Qt
                  from PyQt5.QtWidgets import QFileDialog, QPlainTextEdit
                  from PyQt5 import QtCore, QtGui, QtWidgets
                  from PIL import Image, ImageQt, ImageEnhance
                  # from PyQt5.QtGui import Qt
                  from pyqtgraph.examples.text import text
                  
                  from covid19gui_V3 import Ui_MainWindow
                  import os
                  import sys
                  
                  input_img = Image.open("/home/ironmantis7x/Documents/Maverick_AI/Python/keras-covid-19/maverickAI30k.png")
                  text_edit = QPlainTextEdit()
                  
                  class EmittingStream(QtCore.QObject):
                  
                      textWritten = QtCore.pyqtSignal(str)
                      def write(self, text):
                          self.textWritten.emit(str(text))
                  
                  class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
                      textWritten = QtCore.pyqtSignal(str)
                      def __init__(self, parent=None, **kwargs):
                          super(MainWindow, self).__init__(parent)
                          self.setupUi(self)
                          self.ShowIButton.clicked.connect(self.do_test)
                          self.chooseStudy.clicked.connect(self.do_choosestudy)
                          self.RunButton_3.clicked.connect(self.do_runstudy)
                          self.scene = QtWidgets.QGraphicsScene(self)
                          self.graphicsView.setScene(self.scene)
                          w, h = input_img.size
                          self.pixmap_item = self.scene.addPixmap(QtGui.QPixmap())
                          # self.graphicsView.fitInView(QRectF(0, 0, w, h), Qt.KeepAspectRatio)
                          self.graphicsView.update()
                          self.plainTextEdit.update()
                          self.level = 1
                          self.enhancer = None
                          self.timer = QtCore.QTimer(interval=500, timeout=self.on_timeout)
                          sys.stdout = EmittingStream(textWritten=self.normalOutputWritten)
                  
                      def write(self, text):
                          self.textWritten.emit(str(text))
                  
                      @QtCore.pyqtSlot()
                      def do_test(self):
                          # input_img = Image.open("/home/ironmantis7x/Documents/Maverick_AI/Python/keras-covid-19/maverickAI30k.png")
                          self.enhancer = ImageEnhance.Brightness(input_img)
                          self.timer.start()
                          self.ShowIButton.setDisabled(True)
                  
                      @QtCore.pyqtSlot()
                      def on_timeout(self):
                          if self.enhancer is not None:
                              result_img = self.enhancer.enhance(self.level)
                              qimage = ImageQt.ImageQt(result_img)
                              self.pixmap_item.setPixmap(QtGui.QPixmap.fromImage(qimage))
                          if self.level > 7:
                              self.timer.stop()
                              self.enhancer = None
                              self.level = 0
                              self.ShowIButton.setDisabled(False)
                          self.level = 1
                          self.ShowIButton.setDisabled(False)
                  
                      @QtCore.pyqtSlot()
                      def do_choosestudy(self):
                          dlg = QFileDialog()
                          dlg.setFileMode(QFileDialog.AnyFile)
                          if dlg.exec_():
                              filenames = dlg.selectedFiles()
                              f = open(filenames[0], 'r')
                  
                      @QtCore.pyqtSlot()
                      def do_runstudy(self):
                          os.system("df -h")
                          # filetext = open('screenout.txt').read()
                          # filetext.close()
                          # textViewValue = self.plainTextEdit.toPlainText()
                          # QPlainTextEdit.appendPlainText(self, str(textViewValue))
                          # sys.stdout = self(textWritten=self.textWritten)
                          self.normalOutputWritten(text_edit)
                  
                      def __del__(self):
                          # Restore sys.stdout
                          sys.stdout = sys.__stdout__
                  
                      def normalOutputWritten(self, text_edit):
                          #cursor = self.plainTextEdit.textCursor()
                          #cursor.movePosition(QtGui.QTextCursor.End)
                          #cursor.insertText(text_edit)
                          self.plainTextEdit.appendPlainText(text_edit)
                          #self.plainTextEdit.ensureCursorVisible()
                  
                  if __name__ == "__main__":
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      w = MainWindow()
                      w.show()
                      sys.exit(app.exec_())
                  

                  我怎樣才能使它正常工作?

                  How can I make this work correctly?

                  我確實對該主題進行了研究,這是我在發布問題之前用來嘗試解決問題的主要資源之一:如何捕獲 Python 解釋器的輸出并顯示在 Text 小部件中?

                  I indeed DID do research into the topic and this is one of the main resources I used to try to solve the issue before I posted my question: How to capture output of Python's interpreter and show in a Text widget?

                  我在帖子中修改了我的代碼,以反映我用來幫助我解決問題的鏈接中的代碼建議.

                  I have revised my code in the post to reflect code suggestions in the link I used to help me with my issue.

                  我仍然無法讓它正確運行.我現在收到此錯誤:

                  I am still unable to get this to run correctly. I now get this error:

                  self.plainTextEdit.appendPlainText(text_edit) 類型錯誤:appendPlainText(self, str):參數 1 具有意外類型'QPlainTextEdit'

                  self.plainTextEdit.appendPlainText(text_edit) TypeError: appendPlainText(self, str): argument 1 has unexpected type 'QPlainTextEdit'

                  推薦答案

                  我有一個用戶界面,TableManagerWindow,我一直在 Qt 設計器中維護和開發.通過 pyuic 轉換為 *.py 文件后,我能夠實現您在上面提供的鏈接中提出的 Ferdinand Beyer 的建議.將文本打印到終端的簡單按鈕,它確實通過 append() 附加到 QTextEdit 小部件.由于某種原因,不確定這是否適合您,但我可以保證它也對我有用.我不夠精明,無法了解導致您的問題的細微差別,但我想我會把它放在這里以防萬一.如果它無關緊要,管理員可以隨意刪除它,但它確實有效.

                  I have a user interface, TableManagerWindow, that I've been maintaining and developing in Qt designer. After converting via pyuic to a *.py file, I was able to implement what Ferdinand Beyer had suggested in the link you provided above. Simple button to print text to terminal and it indeed does get appended to the QTextEdit widget via append(). Not sure this fits the bill for you for some reason, but I can vouch that it worked for me as well. I'm not savvy enough to get the nuance that is causing your issue, but figured I'd put this here just in case. Admins feel free to delete this if it's extraneous, but it works.

                  import sys
                  from PyQt5 import QtCore, QtGui, QtWidgets
                  
                  # Define a stream, custom class, that reports data written to it, with a Qt signal
                  class EmittingStream(QtCore.QObject):
                  
                      textWritten = QtCore.pyqtSignal(str)
                  
                      def write(self, text):
                          self.textWritten.emit(str(text))
                  
                  class Ui_TableManagerWindow(object):
                      def setupUi(self, TableManagerWindow):
                          #define all of my widgets, layout, etc here
                          .
                          .
                          .
                          # Install a custom output stream by connecting sys.stdout to instance of EmmittingStream.
                          sys.stdout = EmittingStream(textWritten=self.output_terminal_written)
                  
                          # Create my signal/connections for custom method
                          self.source_dir_button.clicked.connect(self.sourceDirButtonClicked)
                  
                          self.retranslateUi(TableManagerWindow)
                          QtCore.QMetaObject.connectSlotsByName(TableManagerWindow)
                  
                  
                      def retranslateUi(self, TableManagerWindow):
                          .
                          .
                          .
                  
                      #custom method that prints to output terminal.  The point is to have this emmitted out to my QTextEdit widget.
                      def sourceDirButtonClicked(self):
                          for i in range(10):
                              print("The Source DIR button has been clicked " + str(i) + " times")
                  
                      #custom method to write anything printed out to console/terminal to my QTextEdit widget via append function.
                      def output_terminal_written(self, text):
                          self.output_terminal_textEdit.append(text)
                  
                  if __name__ == "__main__":
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      TableManagerWindow = QtWidgets.QMainWindow()
                      ui = Ui_TableManagerWindow()
                      ui.setupUi(TableManagerWindow)
                      TableManagerWindow.show()
                      sys.exit(app.exec_())
                  

                  這篇關于如何使用 Python 將控制臺輸出定向到 pyqt5 plainTextEdit 小部件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

                  • <small id='EToAC'></small><noframes id='EToAC'>

                    <tfoot id='EToAC'></tfoot>
                    <i id='EToAC'><tr id='EToAC'><dt id='EToAC'><q id='EToAC'><span id='EToAC'><b id='EToAC'><form id='EToAC'><ins id='EToAC'></ins><ul id='EToAC'></ul><sub id='EToAC'></sub></form><legend id='EToAC'></legend><bdo id='EToAC'><pre id='EToAC'><center id='EToAC'></center></pre></bdo></b><th id='EToAC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EToAC'><tfoot id='EToAC'></tfoot><dl id='EToAC'><fieldset id='EToAC'></fieldset></dl></div>

                      <tbody id='EToAC'></tbody>
                    <legend id='EToAC'><style id='EToAC'><dir id='EToAC'><q id='EToAC'></q></dir></style></legend>
                        <bdo id='EToAC'></bdo><ul id='EToAC'></ul>
                          • 主站蜘蛛池模板: 国产一区91精品张津瑜 | 人人澡人人爱 | 久久成人一区 | 国产一区二区三区 | 在线观看中文字幕 | 日日夜夜天天干 | 国产精品国产自产拍高清 | 日韩在线不卡 | 国产一区二区三区免费观看视频 | 亚洲人成人一区二区在线观看 | www.五月天婷婷.com | 亚洲精品乱码久久久久久按摩观 | 国产精品123区 | 特a毛片| 亚洲精品日韩精品 | 中文字幕亚洲精品在线观看 | 亚洲一区二区精品视频在线观看 | 久久久久久免费毛片精品 | 欧美国产精品久久久 | 亚洲精品成人在线 | 在线三级电影 | 999视频在线播放 | 手机av在线 | 瑟瑟激情 | 中文字幕一区二区三区四区五区 | 欧美激情久久久 | 91精品久久久久久久久中文字幕 | 精品成人在线视频 | 久久久久久高潮国产精品视 | 欧美成人猛片aaaaaaa | 国产高清一区二区 | 国产高清一二三区 | 毛片区| 中文字幕日韩一区二区 | 在线资源视频 | 一区二区欧美在线 | 久久综合狠狠综合久久综合88 | 一级欧美一级日韩片免费观看 | 午夜日韩| 亚洲高清视频一区二区 | 国产成人精品午夜视频免费 |