本文整理汇总了Python中PySide.QtCore.QFile.readAll方法的典型用法代码示例。如果您正苦于以下问题:Python QFile.readAll方法的具体用法?Python QFile.readAll怎么用?Python QFile.readAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QFile
的用法示例。
在下文中一共展示了QFile.readAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readAll [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv
app = QApplication(argv)
engine = QScriptEngine()
if HAS_DEBUGGER:
debugger = QScriptEngineDebugger()
debugger.attachTo(engine)
debugWindow = debugger.standardWindow()
debugWindow.resize(1024, 640)
scriptFileName = './calculator.js'
scriptFile = QFile(scriptFileName)
scriptFile.open(QIODevice.ReadOnly)
engine.evaluate(unicode(scriptFile.readAll()), scriptFileName)
scriptFile.close()
loader = QUiLoader()
ui = loader.load(':/calculator.ui')
ctor = engine.evaluate('Calculator')
scriptUi = engine.newQObject(ui, QScriptEngine.ScriptOwnership)
calc = ctor.construct([scriptUi])
if HAS_DEBUGGER:
display = ui.findChild(QLineEdit, 'display')
display.connect(display, SIGNAL('returnPressed()'),
debugWindow, SLOT('show()'))
ui.show()
return app.exec_()
示例2: testImage
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readAll [as 别名]
def testImage(self):
#Test loading of sample.png resource
f = open(adjust_filename('sample.png', __file__), "rb")
orig = f.read()
f.close()
f = QFile(':/sample.png')
f.open(QIODevice.ReadOnly)
copy = f.readAll()
f.close()
self.assertEqual(len(orig), len(copy))
self.assertEqual(orig, copy)
示例3: testPhrase
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readAll [as 别名]
def testPhrase(self):
#Test loading of quote.txt resource
f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
orig = f.read()
f.close()
f = QFile(':/quote.txt')
f.open(QIODevice.ReadOnly) #|QIODevice.Text)
print("Error:", f.errorString())
copy = f.readAll()
f.close()
self.assertEqual(orig, copy)
示例4: loadStyleSheet
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readAll [as 别名]
def loadStyleSheet(sheetName):
file = QFile(sheetName)
file.open(QFile.ReadOnly)
styleSheet = file.readAll()
return str(styleSheet)
示例5: main
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readAll [as 别名]
def main():
pid_file = 'av-control.pid'
fp = open(pid_file, 'w')
try:
fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
# another instance is running
print "av-control is already running."
sys.exit(1)
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
level=logging.INFO)
app = QApplication(sys.argv)
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--fullscreen",
help="Run in fullscreen mode and hide the mouse cursor",
action="store_true")
parser.add_argument("-c",
help="Specify the controller ID to connect to",
metavar="CONTROLLERID",
default="")
parser.add_argument("-j", "--joystick",
help="Path to joystick device to use for camera control")
args = parser.parse_args()
try:
ssf = QFile(":/stylesheet")
ssf.open(QFile.ReadOnly)
styleSheet = str(ssf.readAll())
app.setStyleSheet(styleSheet)
except IOError:
# never mind
logging.warn("Cannot find stylesheet, using default system styles.")
try:
controller = Controller.fromPyro(args.c)
js = None
joystickDevice = args.joystick
print args
try:
if args.joystick:
if os.path.exists(joystickDevice):
logging.info("Configuring joystick {}".format(joystickDevice))
js = Joystick(joystickDevice)
js.start()
else:
logging.error("Specified joystick device {} does not exist!".format(joystickDevice))
except IOError:
logging.exception("Unable to configure joystick")
pass
jsa = SensitivityPrefsCameraJoystickAdapter(js)
jsa.start()
myapp = MainWindow(controller, jsa)
client = AvControlClient(myapp)
client.setDaemon(True)
client.start()
client.started.wait()
atexit.register(lambda: controller.unregisterClient(client.uri))
controller.registerClient(client.uri)
if args.fullscreen:
QApplication.setOverrideCursor(Qt.BlankCursor)
myapp.showFullScreen()
else:
myapp.show()
sys.exit(app.exec_())
except VersionMismatchError as e:
Dialogs.errorBox(str(e))