本文整理匯總了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_();
示例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_();
示例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()
示例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"لا شيء يمكن طبعه.")
示例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();
示例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"لا نتائج ")
示例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
示例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
示例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
示例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))
示例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()
示例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
示例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
示例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
示例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()