我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用PySide.QtCore.QTextStream()。
def save_file(self, fileName): '''(file open for writing)-> boolean ''' fname = QtCore.QFile(fileName) if not fname.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "Application", "Cannot write file %s:\n%s." % (fileName, fname.errorString())) return False outf = QtCore.QTextStream(fname) QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) outf << self.ui.textEdit.toPlainText() QtGui.QApplication.restoreOverrideCursor() # self.setCurrentFile(fileName); # QtGui.QMessageBox.about(self,'Information',"File saved")
def displaylog_totextedit(self): ''' This method displaying Design messages(log messages)to textedit widget. ''' afile = QtCore.QFile('./Connections/Shear/Finplate/fin.log') if not afile.open(QtCore.QIODevice.ReadOnly): # ReadOnly QtGui.QMessageBox.information(None, 'info', afile.errorString()) stream = QtCore.QTextStream(afile) self.ui.textEdit.clear() self.ui.textEdit.setHtml(stream.readAll()) vscrollBar = self.ui.textEdit.verticalScrollBar(); vscrollBar.setValue(vscrollBar.maximum()); afile.close()
def load_stylesheet(pyside=True): """ Loads the stylesheet. Takes care of importing the rc module. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string """ # Smart import of the rc file if pyside: import qdarkstyle.pyside_style_rc else: import qdarkstyle.pyqt_style_rc # Load the stylesheet content from resources if not pyside: from PyQt4.QtCore import QFile, QTextStream else: from PySide.QtCore import QFile, QTextStream f = QFile(":qdarkstyle/style.qss") if not f.exists(): _logger().error("Unable to load stylesheet, file not found in " "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() if platform.system().lower() == 'darwin': # see issue #12 on github mac_fix = ''' QDockWidget::title { background-color: #31363b; text-align: center; height: 12px; } ''' stylesheet += mac_fix return stylesheet
def load_stylesheet_pyqt5(): """ Loads the stylesheet for use in a pyqt5 application. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string """ # Smart import of the rc file import qdarkstyle.pyqt5_style_rc # Load the stylesheet content from resources from PyQt5.QtCore import QFile, QTextStream f = QFile(":qdarkstyle/style.qss") if not f.exists(): _logger().error("Unable to load stylesheet, file not found in " "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() if platform.system().lower() == 'darwin': # see issue #12 on github mac_fix = ''' QDockWidget::title { background-color: #31363b; text-align: center; height: 12px; } ''' stylesheet += mac_fix return stylesheet
def load_stylesheet(pyside=True): """ Loads the stylesheet. Takes care of importing the images module. :param pyside: True to load the pyside images file, False to load the PyQt images file :return the stylesheet string """ # Smart import of the images file if pyside: import qdarkstyle.pyside_style_rc else: import qdarkstyle.pyqt_style_rc # Load the stylesheet content from resources if not pyside: from PyQt4.QtCore import QFile, QTextStream else: from PySide.QtCore import QFile, QTextStream f = QFile(":darkBlue/style.qss") if not f.exists(): _logger().error("Unable to load stylesheet, file not found in " "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() if platform.system().lower() == 'darwin': # see issue #12 on github mac_fix = ''' QDockWidget::title { background-color: #31363b; text-align: center; height: 12px; } ''' stylesheet += mac_fix return stylesheet
def load_stylesheet_pyqt5(): """ Loads the stylesheet for use in a pyqt5 application. :param pyside: True to load the pyside images file, False to load the PyQt images file :return the stylesheet string """ # Smart import of the images file import qdarkstyle.pyqt5_style_rc # Load the stylesheet content from resources from PyQt5.QtCore import QFile, QTextStream f = QFile(":darkBlue/style.qss") if not f.exists(): _logger().error("Unable to load stylesheet, file not found in " "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() if platform.system().lower() == 'darwin': # see issue #12 on github mac_fix = ''' QDockWidget::title { background-color: #31363b; text-align: center; height: 12px; } ''' stylesheet += mac_fix return stylesheet
def load_stylesheet_pyqt5(**kwargs): """ Loads the stylesheet for use in a pyqt5 application. :param pyside: True to load the pyside rc file, False to load the PyQt rc file :return the stylesheet string """ # Smart import of the rc file if kwargs["style"] == "style_Dark": import PyQt5_stylesheets.pyqt5_style_Dark_rc if kwargs["style"] == "style_DarkOrange": import PyQt5_stylesheets.pyqt5_style_DarkOrange_rc if kwargs["style"] == "style_Classic": import PyQt5_stylesheets.pyqt5_style_Classic_rc if kwargs["style"] == "style_navy": import PyQt5_stylesheets.pyqt5_style_navy_rc if kwargs["style"] == "style_gray": import PyQt5_stylesheets.pyqt5_style_gray_rc if kwargs["style"] == "style_blue": import PyQt5_stylesheets.pyqt5_style_blue_rc if kwargs["style"] == "style_black": import PyQt5_stylesheets.pyqt5_style_black_rc # Load the stylesheet content from resources from PyQt5.QtCore import QFile, QTextStream f = QFile(":PyQt5_stylesheets/%s.qss"%kwargs["style"]) if not f.exists(): f = QFile(":PyQt5_stylesheets/%s.css"%kwargs["style"]) if not f.exists(): _logger().error("Unable to load stylesheet, file not found in " "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text) ts = QTextStream(f) stylesheet = ts.readAll() if platform.system().lower() == 'darwin': # see issue #12 on github mac_fix = ''' QDockWidget::title { background-color: #31363b; text-align: center; height: 12px; } ''' stylesheet += mac_fix return stylesheet