本文整理汇总了Python中PyQt5.QtCore.QFile.Text方法的典型用法代码示例。如果您正苦于以下问题:Python QFile.Text方法的具体用法?Python QFile.Text怎么用?Python QFile.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QFile
的用法示例。
在下文中一共展示了QFile.Text方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setPersepolisColorScheme
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def setPersepolisColorScheme(self, color_scheme):
self.persepolis_color_scheme = color_scheme
if color_scheme == 'Dark Fusion':
dark_fusion = DarkFusionPalette()
self.setPalette(dark_fusion)
file = QFile(":/dark_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())
elif color_scheme == 'Light Fusion':
dark_fusion = LightFusionPalette()
self.setPalette(dark_fusion)
file = QFile(":/light_style.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
self.setStyleSheet(stream.readAll())
# create terminal arguments
示例2: __init__
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def __init__(self, persepolis_setting):
super().__init__(persepolis_setting)
self.persepolis_setting = persepolis_setting
# setting window size and position
size = self.persepolis_setting.value(
'AboutWindow/size', QSize(545, 375))
position = self.persepolis_setting.value(
'AboutWindow/position', QPoint(300, 300))
# read translators.txt files.
# this file contains all translators.
f = QFile(':/translators.txt')
f.open(QIODevice.ReadOnly | QFile.Text)
f_text = QTextStream(f).readAll()
f.close()
self.translators_textEdit.insertPlainText(f_text)
self.resize(size)
self.move(position)
示例3: __init__
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def __init__(self):
super(VideoStyleLight, self).__init__()
palette = qApp.palette()
palette.setColor(QPalette.Window, QColor(239, 240, 241))
palette.setColor(QPalette.WindowText, QColor(49, 54, 59))
palette.setColor(QPalette.Base, QColor(252, 252, 252))
palette.setColor(QPalette.AlternateBase, QColor(239, 240, 241))
palette.setColor(QPalette.ToolTipBase, QColor(239, 240, 241))
palette.setColor(QPalette.ToolTipText, QColor(49, 54, 59))
palette.setColor(QPalette.Text, QColor(49, 54, 59))
palette.setColor(QPalette.Button, QColor(239, 240, 241))
palette.setColor(QPalette.ButtonText, QColor(49, 54, 59))
palette.setColor(QPalette.BrightText, QColor(255, 255, 255))
palette.setColor(QPalette.Link, QColor(41, 128, 185))
# palette.setColor(QPalette.Highlight, QColor(126, 71, 130))
# palette.setColor(QPalette.HighlightedText, Qt.white)
palette.setColor(QPalette.Disabled, QPalette.Light, Qt.white)
palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(234, 234, 234))
qApp.setPalette(palette)
示例4: load_stylesheet_pyqt5
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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
示例5: load_stylesheet
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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
示例6: load_stylesheet_pyqt5
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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
示例7: __init__
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def __init__(self, parent=None):
super(Changelog, self).__init__(parent, Qt.Dialog | Qt.WindowCloseButtonHint)
self.parent = parent
self.setWindowTitle('{} changelog'.format(qApp.applicationName()))
changelog = QFile(':/CHANGELOG')
changelog.open(QFile.ReadOnly | QFile.Text)
content = QTextStream(changelog).readAll()
label = QLabel(content, self)
label.setWordWrap(True)
label.setTextFormat(Qt.PlainText)
buttons = QDialogButtonBox(QDialogButtonBox.Close, self)
buttons.rejected.connect(self.close)
scrollarea = QScrollArea(self)
scrollarea.setStyleSheet('QScrollArea { background:transparent; }')
scrollarea.setWidgetResizable(True)
scrollarea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scrollarea.setFrameShape(QScrollArea.NoFrame)
scrollarea.setWidget(label)
if sys.platform in {'win32', 'darwin'}:
scrollarea.setStyle(QStyleFactory.create('Fusion'))
# noinspection PyUnresolvedReferences
if parent.parent.stylename == 'fusion' or sys.platform in {'win32', 'darwin'}:
self.setStyleSheet('''
QScrollArea {{
background-color: transparent;
margin-bottom: 10px;
border: none;
border-right: 1px solid {};
}}'''.format('#4D5355' if parent.theme == 'dark' else '#C0C2C3'))
else:
self.setStyleSheet('''
QScrollArea {{
background-color: transparent;
margin-bottom: 10px;
border: none;
}}''')
layout = QVBoxLayout()
layout.addWidget(scrollarea)
layout.addWidget(buttons)
self.setLayout(layout)
self.setMinimumSize(self.sizeHint())
示例8: loadQSS
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def loadQSS(theme) -> None:
filename = ':/styles/{}.qss'.format(theme)
if QFileInfo(filename).exists():
qssfile = QFile(filename)
qssfile.open(QFile.ReadOnly | QFile.Text)
content = QTextStream(qssfile).readAll()
qApp.setStyleSheet(content)
示例9: __init__
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def __init__(self, parent):
super(LicenseTab, self).__init__(parent)
self.setObjectName('license')
licensefile = QFile(':/license.html')
licensefile.open(QFile.ReadOnly | QFile.Text)
content = QTextStream(licensefile).readAll()
self.setText(content)
if sys.platform in {'win32', 'darwin'}:
self.setStyle(QStyleFactory.create('Fusion'))
示例10: main
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def main():
"""
Application entry point
"""
logging.basicConfig(level=logging.DEBUG)
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
#app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
window = QtWidgets.QMainWindow()
# setup ui
ui = example.Ui_MainWindow()
ui.setupUi(window)
ui.bt_delay_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_instant_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_menu_button_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
window.setWindowTitle("BreezeDark example")
# tabify dock widgets to show bug #6
window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)
# setup stylesheet
file = QFile(":/dark.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
app.setStyleSheet(stream.readAll())
# auto quit after 2s when testing on travis-ci
if "--travis" in sys.argv:
QtCore.QTimer.singleShot(2000, app.exit)
# run
window.show()
app.exec_()
示例11: main
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [as 别名]
def main():
"""
Application entry point
"""
logging.basicConfig(level=logging.DEBUG)
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
#app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
window = QtWidgets.QMainWindow()
# setup ui
ui = example.Ui_MainWindow()
ui.setupUi(window)
ui.bt_delay_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_instant_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
ui.bt_menu_button_popup.addActions([
ui.actionAction,
ui.actionAction_C
])
window.setWindowTitle("Breeze example")
# tabify dock widgets to show bug #6
window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)
# setup stylesheet
file = QFile(":/light.qss")
file.open(QFile.ReadOnly | QFile.Text)
stream = QTextStream(file)
app.setStyleSheet(stream.readAll())
# auto quit after 2s when testing on travis-ci
if "--travis" in sys.argv:
QtCore.QTimer.singleShot(2000, app.exit)
# run
window.show()
app.exec_()
示例12: load_stylesheet
# 需要导入模块: from PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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 PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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 PyQt5.QtCore import QFile [as 别名]
# 或者: from PyQt5.QtCore.QFile import Text [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