本文整理汇总了Python中PyQt4.QtCore.QTextStream.readAll方法的典型用法代码示例。如果您正苦于以下问题:Python QTextStream.readAll方法的具体用法?Python QTextStream.readAll怎么用?Python QTextStream.readAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTextStream
的用法示例。
在下文中一共展示了QTextStream.readAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def __init__(self, iface):
"""Constructor for the dialog.
Args:
iface: QgsInterface instance.
"""
QDialog.__init__(self, iface.mainWindow())
self.setupUi(self)
# Settings Tab
# Show the current value of client_id and client_secret
client_id = settings.read('gmeconnector/CLIENT_ID')
client_secret = settings.read('gmeconnector/CLIENT_SECRET')
if client_id is None:
client_id = ''
if client_secret is None:
client_secret = ''
self.lineEdit1.setText(client_id)
self.lineEdit2.setText(client_secret)
# Other settings
self.comboBoxProjects.setEnabled(False)
self.checkBoxDefault.stateChanged.connect(self.comboBoxProjects.setEnabled)
self.comboBoxFormat.addItem('JPEG', 'image/jpeg')
self.comboBoxFormat.addItem('PNG', 'image/png')
defaultFormat = settings.read('gmeconnector/WMS_IMAGE_FORMAT')
if defaultFormat:
defaultIndex = self.comboBoxFormat.findText(defaultFormat)
if defaultIndex != -1:
self.comboBoxFormat.setCurrentIndex(defaultIndex)
self.comboBoxFormat.currentIndexChanged.connect(self.handleFormatChanged)
# OAuth help
oAuthPage = QWebPage()
oAuthPage.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.webViewOAuth.setPage(oAuthPage)
# Load the oauth_help file
helpFile = QFile(':/plugins/googlemapsengineconnector/oauth_help.html')
helpFile.open(QIODevice.ReadOnly | QIODevice.Text)
helpStr = QTextStream(helpFile)
helpText = helpStr.readAll()
self.webViewOAuth.setHtml(helpText)
self.webViewOAuth.linkClicked.connect(self.handleWebLink)
# About Tab
aboutPage = QWebPage()
aboutPage.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.webViewAbout.setPage(aboutPage)
# Load the about.html file and add current version info.
aboutFile = QFile(':/plugins/googlemapsengineconnector/about.html')
aboutFile.open(QIODevice.ReadOnly | QIODevice.Text)
aboutStr = QTextStream(aboutFile)
aboutText = aboutStr.readAll()
newText = aboutText.format(version='1.0')
self.webViewAbout.setHtml(newText)
self.webViewAbout.linkClicked.connect(self.handleWebLink)
示例2: load_stylesheet
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [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():
print("Unable to set stylesheet, file not found\n")
return ""
else:
f.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(f)
return ts.readAll()
示例3: _replace_results
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def _replace_results(self):
result = QMessageBox.question(self, self.tr("Replace Files Contents"),
self.tr("Are you sure you want to replace the content in "
"this files?\n(The change is not reversible)"),
buttons=QMessageBox.Yes | QMessageBox.No)
if result == QMessageBox.Yes:
for index in xrange(self._result_widget.topLevelItemCount()):
parent = self._result_widget.topLevelItem(index)
root_dir_name = unicode(parent.dir_name_root)
file_name = unicode(parent.text(0))
file_path = file_manager.create_path(root_dir_name, file_name)
file_object = QFile(file_path)
if not file_object.open(QFile.ReadOnly):
return
stream = QTextStream(file_object)
content = stream.readAll()
file_object.close()
pattern = self._find_widget.pattern_line_edit.text()
case_sensitive = self._find_widget.case_checkbox.isChecked()
type_ = QRegExp.RegExp if \
self._find_widget.type_checkbox.isChecked() else \
QRegExp.FixedString
target = QRegExp(pattern, case_sensitive, type_)
content.replace(target, self._find_widget.replace_line.text())
file_manager.store_file_content(file_path, content, False)
示例4: main
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def main(argv):
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(QPixmap(":/logo_small")))
app.setOrganizationName('Hardcoded Software')
app.setApplicationName('moneyGuru')
settings = QSettings()
LOGGING_LEVEL = logging.DEBUG if adjust_after_deserialization(settings.value('DebugMode')) else logging.WARNING
setupQtLogging(level=LOGGING_LEVEL)
logging.debug('started in debug mode')
if ISLINUX:
stylesheetFile = QFile(':/stylesheet_lnx')
else:
stylesheetFile = QFile(':/stylesheet_win')
stylesheetFile.open(QFile.ReadOnly)
textStream = QTextStream(stylesheetFile)
style = textStream.readAll()
stylesheetFile.close()
app.setStyleSheet(style)
lang = settings.value('Language')
locale_folder = op.join(BASE_PATH, 'locale')
hscommon.trans.install_gettext_trans_under_qt(locale_folder, lang)
# Many strings are translated at import time, so this is why we only import after the translator
# has been installed
from qt.app import MoneyGuru
app.setApplicationVersion(MoneyGuru.VERSION)
mgapp = MoneyGuru()
install_excepthook()
exec_result = app.exec_()
del mgapp
# Since PyQt 4.7.2, I had crashes on exit, and from reading the mailing list, it seems to be
# caused by some weird crap about C++ instance being deleted with python instance still living.
# The worst part is that Phil seems to say this is expected behavior. So, whatever, this
# gc.collect() below is required to avoid a crash.
gc.collect()
return exec_result
示例5: __init__
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def __init__(self,parent=None):
QDialog.__init__(self, parent)
self.setupUi(self)
#Connect signals
self.btnContactUs.clicked.connect(self.onContactUs)
self.btnSTDMHome.clicked.connect(self.onSTDMHome)
#Load about HTML file
aboutLocation = PLUGIN_DIR + "/html/about.htm"
if QFile.exists(aboutLocation):
aboutFile = QFile(aboutLocation)
if not aboutFile.open(QIODevice.ReadOnly):
QMessageBox.critical(self,
QApplication.translate("AboutSTDMDialog","Open Operation Error"),
QApplication.translate("AboutSTDMDialog","Cannot read 'About STDM' source file."))
self.reject()
reader = QTextStream(aboutFile)
aboutSTDM = reader.readAll()
self.txtAbout.setHtml(aboutSTDM)
else:
QMessageBox.critical(self,
QApplication.translate("AboutSTDMDialog","File Does Not Exist"),
QApplication.translate("AboutSTDMDialog","'About STDM' source file does not exist."))
self.reject()
示例6: load_stylesheet_pyqt5
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [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: #353434;
text-align: center;
}
'''
stylesheet += mac_fix
return stylesheet
示例7: readyRead
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def readyRead(self): # 可以读数据了
local = self.sender() # 取得是哪个localsocket可以读数据了
if (local == None):
return
_in = QTextStream(local)
readMsg = _in.readAll()
print "recv Msg:",readMsg
self.emit(SIGNAL("newMessage(QString)"), QString(readMsg))
示例8: load
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def load(self):
exception = None
fh = None
try:
fh = QFile(self.filename)
if not fh.open(QIODevice.ReadOnly):
raise IOError, unicode(fh.errorString())
stream = QTextStream(fh)
stream.setCodec("UTF-8")
self.setPlainText(stream.readAll())
self.document().setModified(False)
except (IOError, OSError), e:
exception = e
示例9: __init__
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def __init__(self, species=None, parent=None):
super(CharacterSheetDocument, self).__init__( parent)
self.__species = species
## Lade Datei mit Stylesheet-Informationen
cssFile = QFile(":stylesheets/sheet.css")
if not cssFile.open(QIODevice.ReadOnly):
raise ErrFileNotOpened( "Wile opening file \"{}\", the error \"{}\" occured.".format(
item,
cssFile.errorString()
), filename=item )
cssStream = QTextStream(cssFile)
cssContent = cssStream.readAll()
cssFile.close()
self.setDefaultStyleSheet(cssContent)
示例10: get_style
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def get_style(style_sheet):
try:
mod = importlib.import_module("." + style_sheet, __name__)
hasattr(mod, "qt_resource_name")
f = QFile(":/%s/style.qss" % style_sheet)
f.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(f)
stylesheet = ts.readAll()
except ImportError as e:
print "Style sheet not available. Use available_styles() to check for valid styles"
return u""
except Exception as e:
print "Style sheet available, but an error occured..."
traceback.print_exc()
return u""
return stylesheet
示例11: load
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def load(self):
exception = None
fh = None
try:
fh = QFile(self.filename)
if not fh.open(QIODevice.ReadOnly):
raise IOError(str(fh.errorString()))
stream = QTextStream(fh)
stream.setCodec("UTF-8")
self.setPlainText(stream.readAll())
self.document().setModified(False)
except EnvironmentError as e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception
示例12: foreign_key_parent_tables
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def foreign_key_parent_tables(table_name):
"""
Functions that searches for foreign key references in the specified table.
:param table_name: Name of the database table.
:type table_name: str
:return: A list of tuples containing the local column name, foreign table
name and corresponding foreign column name.
:rtype: list
"""
#Check if the view for listing foreign key references exists
fk_ref_view = pg_table_exists("foreign_key_references")
#Create if it does not exist
if not fk_ref_view:
script_path = PLUGIN_DIR + "/scripts/foreign_key_references.sql"
script_file = QFile(script_path)
if script_file.exists():
if not script_file.open(QIODevice.ReadOnly):
return None
reader = QTextStream(script_file)
sql = reader.readAll()
if sql:
t = text(sql)
_execute(t)
else:
return None
#Fetch foreign key references
sql = "SELECT column_name,foreign_table_name,foreign_column_name FROM " \
"foreign_key_references where table_name=:tb_name"
t = text(sql)
result = _execute(t, tb_name=table_name)
fk_refs = []
for r in result:
fk_ref = r["column_name"], r["foreign_table_name"],\
r["foreign_column_name"]
fk_refs.append(fk_ref)
return fk_refs
示例13: __init__
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def __init__(self, parent=None ):
super(helpDisplay, self).__init__(parent)
# make page unmodifiable
self.page().setContentEditable(False)
# initialize settings
# Find out the nearest font to Palatino
qf = QFont()
qf.setStyleStrategy(QFont.PreferAntialias+QFont.PreferMatch)
qf.setStyleHint(QFont.Serif)
qf.setFamily(QString(u'Palatino'))
qfi = QFontInfo(qf)
# set the default font to that serif font
self.settings().setFontFamily(QWebSettings.StandardFont, qfi.family())
self.settings().setFontSize(QWebSettings.DefaultFontSize, 16)
self.settings().setFontSize(QWebSettings.MinimumFontSize, 6)
self.settings().setFontSize(QWebSettings.MinimumLogicalFontSize, 6)
self.textZoomFactor = 1.0
self.setTextSizeMultiplier(self.textZoomFactor)
self.settings().setAttribute(QWebSettings.JavascriptEnabled, False)
self.settings().setAttribute(QWebSettings.JavaEnabled, False)
self.settings().setAttribute(QWebSettings.PluginsEnabled, False)
self.settings().setAttribute(QWebSettings.ZoomTextOnly, True)
#self.settings().setAttribute(QWebSettings.SiteSpecificQuirksEnabled, False)
self.userFindText = QString()
# Look for pqHelp.html in the app folder and copy its text into
# a local buffer. If it isn't found, put a message there instead.
# We need to keep it in order to implement the "back" function.
helpPath = os.path.join(IMC.appBasePath,u'pqHelp.html')
helpFile = QFile(helpPath)
if not helpFile.exists():
self.HTMLstring = QString('''<p>Unable to locate pqHelp.html.</p>
<p>Looking in {0}'''.format(helpPath)
)
elif not helpFile.open(QIODevice.ReadOnly) :
self.HTMLstring = QString('''<p>Unable to open pqHelp.html.</p>
<p>Looking in {0}</p><p>Error code {1}</p>'''.format(helpPath,
helpFile.error())
)
else:
helpStream = QTextStream(helpFile)
helpStream.setCodec('ISO8859-1')
self.HTMLstring = helpStream.readAll()
self.setHtml(self.HTMLstring)
示例14: __init__
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [as 别名]
def __init__(self, parent=None):
""" Инициализируем интерфейс и задаём начальные значения внутренних переменных """
QMainWindow.__init__(self, parent)
self._alreadyShown = False
self.setupUi()
self._feedName = 'feed/http://habrahabr.ru/rss/'
self._filters = { 'Все' : '.*' }
self._categorizer = self.categorizeByDate
file = QFile(':/templates/content.html')
if file.open(QIODevice.ReadOnly | QIODevice.Text):
s = QTextStream(file)
self._entryTemplate = Template(s.readAll())
else:
self._entryTemplate = Template('')
self._curCategory = None
self._curEntryId = -1
self._loadingData = False
self._reader = libgreader.GoogleReader(None)
self._loggedIn = False
示例15: load_stylesheet
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import readAll [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
import petfactoryStyle.pyside_style_rc
else:
import petfactoryStyle.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")
f = QFile(":petfactoryStyle/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: #353434;
text-align: center;
height: 12px;
}
'''
stylesheet += mac_fix
return stylesheet