当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QTextStream方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QTextStream方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QTextStream方法的具体用法?Python QtCore.QTextStream怎么用?Python QtCore.QTextStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore的用法示例。


在下文中一共展示了QtCore.QTextStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: whoisqutrub

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def whoisqutrub(self):
        RightToLeft=1;
        msgBox=QtGui.QMessageBox(self.centralwidget);
        msgBox.setWindowTitle(u"عن البرنامج");	
        data=QtCore.QFile("ar/projects.html");
        if (data.open(QtCore.QFile.ReadOnly)):
            textstream=QtCore.QTextStream(data);
            textstream.setCodec("UTF-8");
            text=textstream.readAll();
        else:
            text=u"لا يمكن فتح ملف المساعدة"


        msgBox.setText(text);
        msgBox.setLayoutDirection(RightToLeft);
        msgBox.setStandardButtons(QtGui.QMessageBox.Ok);
        msgBox.setDefaultButton(QtGui.QMessageBox.Ok);
        msgBox.exec_(); 
开发者ID:linuxscout,项目名称:mishkal,代码行数:20,代码来源:appgui.py

示例2: about

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def about(self):
        RightToLeft=1;
        msgBox=QtGui.QMessageBox(self.centralwidget);
        msgBox.setWindowTitle(u"عن البرنامج");
##          msgBox.setTextFormat(QrCore.QRichText);

        data=QtCore.QFile("ar/about.html");
        if (data.open(QtCore.QFile.ReadOnly)):
            textstream=QtCore.QTextStream(data);
            textstream.setCodec("UTF-8");
            text_about=textstream.readAll();
        else:
#            text=u"لا يمكن فتح ملف المساعدة"
            text_about=u"""<h1>فكرة</h1>

"""
        msgBox.setText(text_about);
        msgBox.setLayoutDirection(RightToLeft);
        msgBox.setStandardButtons(QtGui.QMessageBox.Ok);
        msgBox.setIconPixmap(QtGui.QPixmap(os.path.join(PWD, "ar/images/logo.png")));
        msgBox.setDefaultButton(QtGui.QMessageBox.Ok);
        msgBox.exec_(); 
开发者ID:linuxscout,项目名称:mishkal,代码行数:24,代码来源:appgui.py

示例3: _populate_config_from_old_config

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def _populate_config_from_old_config(self):
        """
        Read old configuration file and uses it content to populate new
        config file
        """
        configuration = self.doc_old.createElement("Configuration")
        configuration.setAttribute("version", '1.2')
        self.doc_old.appendChild(configuration)

        # Create profile valuelists and entity nodes
        config = self._create_profile_value_lists_entity_nodes(
                    self.entities_lookup_relations, configuration)

        # configuration.appendChild(config)

        self.doc_old.appendChild(config)

        stream = QTextStream(self.config_file)
        stream << self.doc_old.toString()
        self.config_file.close()
        self.doc_old.clear() 
开发者ID:gltn,项目名称:stdm,代码行数:23,代码来源:config_file_updater.py

示例4: print_result

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def print_result(self):
        if "HTML" in self.result:
            data=QtCore.QFile("ar/style.css");
            if (data.open(QtCore.QFile.ReadOnly)):
                mySTYLE_SHEET=QtCore.QTextStream(data).readAll();
    ##            text=unicode(text);
            else:
                mySTYLE_SHEET=u"""
body {
	direction: rtl;
	font-family: Traditional Arabic, "Times New Roman";
	font-size: 16pt;
}
"""
            document = QtGui.QTextDocument("")
            document.setDefaultStyleSheet(mySTYLE_SHEET)
            self.result["HTML"]=u"<html dir=rtl><body dir='rtl'>"+self.result["HTML"]+"</body></html>"
            document.setHtml(self.result["HTML"]);
            printer = QtGui.QPrinter()

            dlg = QtGui.QPrintDialog(printer, self.centralwidget)
            if dlg.exec_() != QtGui.QDialog.Accepted:
                return
            self.ResultVocalized.print_(printer)

        else:
            QtGui.QMessageBox.warning(self.centralwidget,U"خطأ",
                                u"لا شيء يمكن طبعه.") 
开发者ID:linuxscout,项目名称:mishkal,代码行数:30,代码来源:appgui.py

示例5: manual

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def manual(self):
        data=QtCore.QFile("ar/help_body.html");
        if (data.open(QtCore.QFile.ReadOnly)):
            textstream=QtCore.QTextStream(data);
            textstream.setCodec("UTF-8");
            text=textstream.readAll();
        else:
            text=u"لا يمكن فتح ملف المساعدة"

        Dialog=QtGui.QDialog(self.centralwidget)

        Dialog.setObjectName("Dialog")
        Dialog.resize(480, 480)
        Dialog.setWindowTitle(u'دليل الاستعمال')
        gridLayout = QtGui.QGridLayout(Dialog)
        gridLayout.setObjectName("gridLayout")
        textBrowser = QtGui.QTextBrowser(Dialog)
        textBrowser.setObjectName("textBrowser")
        gridLayout.addWidget(textBrowser, 0, 0, 1, 1)
        buttonBox = QtGui.QDialogButtonBox(Dialog)
        buttonBox.setOrientation(QtCore.Qt.Horizontal)
        buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
        buttonBox.setObjectName("buttonBox")
        gridLayout.addWidget(buttonBox, 1, 0, 1, 1)


        QtCore.QObject.connect(buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
        text2=unicode(text)
        textBrowser.setText(text2)
        RightToLeft=1;
        Dialog.setLayoutDirection(RightToLeft);
        Dialog.show(); 
开发者ID:linuxscout,项目名称:mishkal,代码行数:35,代码来源:appgui.py

示例6: display_result_in_tab

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def display_result_in_tab(self):
        if  "HTML" in self.result:
            #text="<html><body dir='rtl'>"+self.result["HTML"]+"</body></html>"
            text=self.result["HTML"]			
            #print text.encode('utf8');
            self.ResultVocalized.setPlainText(text)


        #display help
            filename="ar/help.html";
##            print filename;
            data=QtCore.QFile(filename);
            if (data.open(QtCore.QFile.ReadOnly)):
                textstream=QtCore.QTextStream(data);
                textstream.setCodec("UTF-8");
                text_help=textstream.readAll();

            else:
    #            text=u"لا يمكن فتح ملف المساعدة"
                text_help=u"""<h1>فكرة</h1>"""
            #self.HelpVocalized.setText(text_help)


            #show result /
            self.TabVoice.show();
            self.MainWindow.showMaximized();
            self.TabVoice.setCurrentIndex(0);
    # enable actions
            self.AExport.setEnabled(True)
            self.AFont.setEnabled(True)
            self.ACopy.setEnabled(True)
            self.APrint.setEnabled(True)
            #self.APrintPreview.setEnabled(True)
            #self.APagesetup.setEnabled(True)
            self.AZoomIn.setEnabled(True)
            self.AZoomOut.setEnabled(True)

            self.centralwidget.update();
        else:
            QtGui.QMessageBox.warning(self.centralwidget,U"خطأ",
                            u"لا نتائج  ") 
开发者ID:linuxscout,项目名称:mishkal,代码行数:43,代码来源:appgui.py

示例7: load_stylesheet_pyqt5

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def load_stylesheet_pyqt5():
    """
    Load 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
    """
    warnings.warn(
        "load_stylesheet_pyqt5() will be deprecated in version 3,"
        "set QtPy environment variable to specify the Qt binding and "
        "use load_stylesheet()",
        PendingDeprecationWarning
    )
    # 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 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:42,代码来源:__init__.py

示例8: load_stylesheet

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
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 
开发者ID:RedFalsh,项目名称:PyQt5_stylesheets,代码行数:42,代码来源:__init__.py

示例9: load_stylesheet_pyqt5

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
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 
开发者ID:quantOS-org,项目名称:TradeSim,代码行数:36,代码来源:__init__.py

示例10: savetext

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def savetext(self, fileName):
        textout = self.codebox.text()
        file = QtCore.QFile(fileName)
        if file.open(QtCore.QIODevice.WriteOnly):
            QtCore.QTextStream(file) << textout
        else:
            QtGui.QMessageBox.information(self.vindu, "Unable to open file",
                    file.errorString())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:11,代码来源:pyeditor.py

示例11: runto

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def runto(self):
        try:
            self.path = QtCore.QFileInfo(self.filename).path()
        except AttributeError:
            pass
        g = globals()
        os.chdir(str(self.path))
        os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
        script = str(self.codebox.text())
        try:
            exec (script, g)
            QtGui.QCloseEvent()


        except ImportError:
            os.chdir(str(self.path))
            os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
            sys.path.append(str(self.path))
            exec (script, g)
            QtGui.QCloseEvent()

            if TypeError (QTextStream):
                g = globals()
                os.chdir(str(self.path))
                os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
                sys.path.insert(0, str(self.path))
                exec int(script)
                QtGui.QCloseEvent() 
开发者ID:techbliss,项目名称:Python_editor,代码行数:30,代码来源:pyeditor.py

示例12: load_stylesheet

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def load_stylesheet(pyside=True):
    """
    Load 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
    """
    warnings.warn(
        "load_stylesheet() will not receive pyside parameter in version 3. "
        "Set QtPy environment variable to specify the Qt binding insteady.",
        FutureWarning
    )
    # 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 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:47,代码来源:__init__.py

示例13: load_stylesheet_pyqt5

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
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 
开发者ID:RedFalsh,项目名称:PyQt5_stylesheets,代码行数:55,代码来源:__init__.py

示例14: load_stylesheet

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
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:
        # PyQt 4/5 compatibility
        try:
            from PyQt4.QtCore import QFile, QTextStream
        except ImportError:
            from PyQt5.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 
开发者ID:quantOS-org,项目名称:TradeSim,代码行数:46,代码来源:__init__.py

示例15: append_profile_to_config_file

# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import QTextStream [as 别名]
def append_profile_to_config_file(
            self, source_config, destination_config
    ):
        """
        Appends a profile from a source configuration into
        the destination configuration file.
        :param source_config: The source config/ configuration_updated.stc
        :type source_config: String
        :param config_file_name: The destination config / configuration.stc
        :type config_file_name: String
        """
        stdm_path = self.file_handler.localPath()
        doc, root = self._get_doc_element(
            source_config
        )
        config_doc, config_root = self._get_doc_element(
            destination_config
        )
        config_file_path = os.path.join(
            stdm_path, destination_config
        )
        config_file = QFile(config_file_path)
        config_file.copy(os.path.join(
            stdm_path, 'configuration_pre_merged.stc')
        )
        open_file = config_file.open(
            QIODevice.ReadWrite |
            QIODevice.Truncate |
            QIODevice.Text
        )

        if open_file:
            # upgraded config from stdmConfig.xml
            child_nodes = root.childNodes()
            # existing config/ default config
            c_child_nodes = config_root.childNodes()
            # look through upgraded node
            for child_i in range(child_nodes.count()):
                child_node = child_nodes.item(child_i).toElement()
                if child_node.tagName() == "Profile":
                    # if duplicate profile exists, remove it first before
                    # adding a new one with the same name
                    for child_j in range(c_child_nodes.count()):
                        c_child_node = c_child_nodes.item(0).toElement()
                        if c_child_node.tagName() == "Profile":
                            # remove if the same profile name exists
                            if child_node.attribute('name') ==\
                                    c_child_node.attribute('name'):

                                config_root.removeChild(c_child_node)
                    # Insert at the top of the configuration
                    first_c_child_node = c_child_nodes.item(0).toElement()
                    config_root.insertBefore(
                        child_node, first_c_child_node
                    )

            stream = QTextStream(config_file)
            stream << config_doc.toString()
            config_file.close() 
开发者ID:gltn,项目名称:stdm,代码行数:61,代码来源:config_file_updater.py


注:本文中的PyQt4.QtCore.QTextStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。