本文整理汇总了Python中PySide.QtCore.QFile.open方法的典型用法代码示例。如果您正苦于以下问题:Python QFile.open方法的具体用法?Python QFile.open怎么用?Python QFile.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QFile
的用法示例。
在下文中一共展示了QFile.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findOrSaveConfig
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def findOrSaveConfig(self):
infile = QFile('ui/config_path.ui')
infile.open(QFile.ReadOnly)
loader = QUiLoader()
dialog = loader.load(infile, self.window)
infile.close()
def browse():
path = QFileDialog.getSaveFileName(dialog, u"Choose or create a configuration file", dialog.pathBox.text())[0]
if path != '':
dialog.pathBox.setText(path)
def cancel():
dialog.hide()
def ok():
autodetectPort = dialog.autodetect.checkState() == Qt.Checked
configPath = os.path.expanduser(dialog.pathBox.text())
dialog.hide()
self.start(configPath, autodetectPort)
dialog.show()
dialog.pathBox.setText(os.path.expanduser('~/.config/tangelo/tangelo.conf'))
dialog.browseButton.clicked.connect(browse)
dialog.cancelButton.clicked.connect(cancel)
dialog.okButton.clicked.connect(ok)
示例2: testBasic
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def testBasic(self):
'''QFile.getChar'''
obj = QFile(self.filename)
obj.open(QIODevice.ReadOnly)
self.assertEqual(obj.getChar(), (True, 'a'))
self.assertFalse(obj.getChar()[0])
obj.close()
示例3: TestQFileSignalBlocking
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
class TestQFileSignalBlocking(unittest.TestCase):
'''Test case for blocking the signal QIODevice.aboutToClose()'''
def setUp(self):
#Set up the needed resources - A temp file and a QFile
self.called = False
handle, self.filename = mkstemp()
os.close(handle)
self.qfile = QFile(self.filename)
def tearDown(self):
#Release acquired resources
os.remove(self.filename)
del self.qfile
def callback(self):
#Default callback
self.called = True
def testAboutToCloseBlocking(self):
#QIODevice.aboutToClose() blocking
QObject.connect(self.qfile, SIGNAL('aboutToClose()'), self.callback)
self.assert_(self.qfile.open(QFile.ReadOnly))
self.qfile.close()
self.assert_(self.called)
self.called = False
self.qfile.blockSignals(True)
self.assert_(self.qfile.open(QFile.ReadOnly))
self.qfile.close()
self.assert_(not self.called)
示例4: __init__
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def __init__(self):
self.loader = QUiLoader()
infile = QFile("resources/loading.ui")
infile.open(QFile.ReadOnly)
self.window = self.loader.load(infile, None)
infile.close()
self.overrides = {'personID':self.window.personID,
'paID':self.window.paID,
'maID':self.window.maID,
'sex':self.window.sex,
'affected':self.window.affected,
'n_local_aff':self.window.n_local_aff,
'n_local_desc':self.window.n_local_desc,
'nicki_d':self.window.nicki_d,
'is_root':self.window.is_root,
'is_leaf':self.window.is_leaf,
'generation':self.window.generation}
self.requiredForCalculateD = set(['personID','paID','maID','sex','affected'])
self.header = []
self.lowerHeader = []
self.window.browseInputButton.clicked.connect(self.browseInput)
self.window.inputField.textChanged.connect(self.switchPrograms)
self.window.browseOutputButton.clicked.connect(self.browseOutput)
self.window.outputField.textChanged.connect(self.switchPrograms)
self.window.programBox.currentIndexChanged.connect(self.switchPrograms)
self.window.runButton.clicked.connect(self.go)
self.switchPrograms()
self.window.buttonBox.setEnabled(False)
self.window.show()
示例5: testBug721
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def testBug721(self):
obj = QFile(self.filename)
obj.open(QIODevice.ReadOnly)
memory = obj.map(0, 1)
self.assertEqual(len(memory), 1)
self.assertEqual(memory[0], py3k.b('a'))
obj.unmap(memory)
示例6: loadDialog
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def loadDialog(file_name):
loader = QUiLoader()
the_file = QFile(file_name)
the_file.open(QFile.ReadOnly)
ret_val = loader.load(the_file)
the_file.close()
return ret_val
示例7: main
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [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_()
示例8: loadWindowFromFile
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def loadWindowFromFile(file_name):
'''Load the window definition from the resource ui file'''
loader = QUiLoader()
ui_file = QFile(file_name)
ui_file.open(QFile.ReadOnly)
the_window = loader.load(ui_file)
ui_file.close()
return the_window
示例9: loadHyperlinkDialog
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def loadHyperlinkDialog(self):
''' Load dialog from ui file for defining hyperlink '''
loader = QUiLoader()
ui_file = QFile(':/hyperlink.ui') # UI_DIALOG_FILE)
ui_file.open(QFile.ReadOnly)
self.hyperlink_dialog = loader.load(ui_file)
ui_file.close()
self.hyperlink_dialog.accepted.connect(self.hyperlinkChanged)
self.hlink_field = self.hyperlink_dialog.findChild(QLineEdit, 'hlink')
示例10: __load_ui
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def __load_ui(self):
ui_path = os.path.dirname(__file__)
ui_path = os.path.join(ui_path, "MainWindow.ui")
ui_file = QFile(ui_path)
ui_file.open(QFile.ReadOnly)
ui_loader = QtUiTools.QUiLoader()
self.__ui = ui_loader.load(ui_file, None)
ui_file.close()
self.__ui.answerTableWidget.setHorizontalHeaderLabels([self.tr("Question"), self.tr("Answer")])
示例11: createWidget
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def createWidget(self):
# Override the existing widget
# TODO: Do I need to delete anything explicitly?
infile = QFile('ui/process_widget.ui')
infile.open(QFile.ReadOnly)
loader = QUiLoader()
self.widget = loader.load(infile, Globals.mainWindow.window)
infile.close()
self.updateWidget(True)
示例12: testPhrase
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [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)
示例13: findTangelo
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def findTangelo():
infile = QFile('ui/find_tangelo.ui')
infile.open(QFile.ReadOnly)
loader = QUiLoader()
dialog = loader.load(infile, None)
infile.close()
if sys.platform.startswith('win'):
Globals.pythonPath = subprocess.Popen(['where', 'python'], stdout=subprocess.PIPE).communicate()[0].strip()
Globals.tangeloPath = subprocess.Popen(['where', 'tangelo'], stdout=subprocess.PIPE).communicate()[0].strip()
else:
Globals.pythonPath = subprocess.Popen(['which', 'python'], stdout=subprocess.PIPE).communicate()[0].strip()
Globals.tangeloPath = subprocess.Popen(['which', 'tangelo'], stdout=subprocess.PIPE).communicate()[0].strip()
if os.path.exists(Globals.pythonPath):
dialog.pythonPathBox.setText(Globals.pythonPath)
if os.path.exists(Globals.tangeloPath):
dialog.tangeloPathBox.setText(Globals.tangeloPath)
def pythonBrowse():
path = QFileDialog.getOpenFileName(dialog, u"Find python", dialog.pythonPathBox.text())[0]
if path != '':
dialog.pythonPathBox.setText(path)
def tangeloBrowse():
path = QFileDialog.getOpenFileName(dialog, u"Find tangelo", dialog.tangeloPathBox.text())[0]
if path != '':
dialog.tangeloPathBox.setText(path)
def cancel():
dialog.hide()
sys.exit()
def ok():
Globals.pythonPath = os.path.expanduser(dialog.pythonPathBox.text())
Globals.tangeloPath = os.path.expanduser(dialog.tangeloPathBox.text())
if not os.path.exists(Globals.pythonPath):
Globals.criticalError("Sorry, that python interpreter doesn't exist.")
return
if not os.path.exists(Globals.tangeloPath):
Globals.criticalError("Sorry, that tangelo executable doesn't exist.")
return
Globals.mainWindow = Overview()
Globals.mainWindow.refresh()
dialog.hide()
dialog.show()
dialog.tangeloBrowse.clicked.connect(tangeloBrowse)
dialog.pythonBrowse.clicked.connect(pythonBrowse)
dialog.cancelButton.clicked.connect(cancel)
dialog.okButton.clicked.connect(ok)
示例14: testImage
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [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)
示例15: createManager
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import open [as 别名]
def createManager(self):
if self.manager != None:
self.updateManager()
self.manager.show()
else:
# Create the window
infile = QFile('ui/process_manager.ui')
infile.open(QFile.ReadOnly)
loader = QUiLoader()
#TODO: This isn't working:
loader.registerCustomWidget(ManagerHelper)
self.manager = loader.load(infile, Globals.mainWindow.window)
infile.close()
self.updateManager(True)
self.manager.show()