当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QFile类代码示例

本文整理汇总了Python中PySide.QtCore.QFile的典型用法代码示例。如果您正苦于以下问题:Python QFile类的具体用法?Python QFile怎么用?Python QFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

	def __init__(self, parent=None):
		super(IPHelper, self).__init__(parent)
		f = QFile(os.path.join(os.path.split(__file__)[0], 'iphelper.ui'))
		loadUi(f, self)
		f.close()
		self.ipAddress = None
		
		# create validators
		validator = QRegExpValidator(QRegExp('\d{,3}'))
		self.uiFirstTetTXT.setValidator(validator)
		self.uiSecondTetTXT.setValidator(validator)
		self.uiThirdTetTXT.setValidator(validator)
		self.uiFourthTetTXT.setValidator(validator)
		
		# build a map of the buttons
		self.buttons = [None]*16
		self.signalMapper = QSignalMapper(self)
		self.signalMapper.mapped.connect(self.tetMap)
		for button in self.findChildren(QPushButton):
			match = re.findall(r'^uiTrellis(\d{,2})BTN$', button.objectName())
			if match:
				i = int(match[0])
				self.buttons[i] = button
				if i >= 12:
					self.signalMapper.setMapping(button, i)
					button.clicked.connect(self.signalMapper.map)
		self.tetMap(12)
开发者ID:MHendricks,项目名称:Motionbuilder-Remote,代码行数:27,代码来源:iphelper.py

示例2: findOrSaveConfig

 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)
开发者ID:XDATA-Year-2,项目名称:tangelo-wrapper,代码行数:27,代码来源:tangelo-wrapper.py

示例3: __init__

 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()
开发者ID:alex-r-bigelow,项目名称:updb-explorer,代码行数:33,代码来源:updb-explorer.py

示例4: loadDialog

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
开发者ID:F-Secure,项目名称:dvmps,代码行数:7,代码来源:progress_dialog.py

示例5: loadWindowFromFile

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
开发者ID:F-Secure,项目名称:dvmps,代码行数:8,代码来源:kvm_ui.py

示例6: getContent

def getContent(path):
    file = QFile(path)
    if not file.open(QIODevice.ReadOnly | QIODevice.Text):
        return
    ts = QTextStream(file)
    ts.setCodec("UTF-8")
    res = ts.readAll()
    return res
开发者ID:sousajmr,项目名称:ptpy,代码行数:8,代码来源:main.py

示例7: loadHyperlinkDialog

 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')
开发者ID:blipvert,项目名称:opengeode,代码行数:9,代码来源:genericSymbols.py

示例8: LogFilePositionSource

class LogFilePositionSource(QGeoPositionInfoSource):
    def __init__(self, parent):
        QGeoPositionInfoSource.__init__(self, parent)
        self.logFile = QFile(self)
        self.timer = QTimer(self)

        self.timer.timeout.connect(self.readNextPosition)

        self.logFile.setFileName(translate_filename('simplelog.txt'))
        assert self.logFile.open(QIODevice.ReadOnly)

        self.lastPosition = QGeoPositionInfo()

    def lastKnownPosition(self, fromSatellitePositioningMethodsOnly):
        return self.lastPosition

    def minimumUpdateInterval(self):
        return 100

    def startUpdates(self):
        interval = self.updateInterval()

        if interval < self.minimumUpdateInterval():
            interval = self.minimumUpdateInterval()

        self.timer.start(interval)

    def stopUpdates(self):
        self.timer.stop()

    def requestUpdate(self, timeout):
        # For simplicity, ignore timeout - assume that if data is not available
        # now, no data will be added to the file later
        if (self.logFile.canReadLine()):
            self.readNextPosition()
        else:
            self.updateTimeout.emit()

    def readNextPosition(self):
        line = self.logFile.readLine().trimmed()

        if not line.isEmpty():
            data = line.split(' ')
            hasLatitude = True
            hasLongitude = True
            timestamp = QDateTime.fromString(str(data[0]), Qt.ISODate)
            latitude = float(data[1])
            longitude = float(data[2])
            if timestamp.isValid():
                coordinate = QGeoCoordinate(latitude, longitude)
                info = QGeoPositionInfo(coordinate, timestamp)
                if info.isValid():
                    self.lastPosition = info
                    # Currently segfaulting. See Bug 657
                    # http://bugs.openbossa.org/show_bug.cgi?id=657
                    self.positionUpdated.emit(info)
开发者ID:alal,项目名称:Mobility,代码行数:56,代码来源:location_test.py

示例9: testBug909

    def testBug909(self):
        fileName = QFile(adjust_filename('bug_909.ui', __file__))
        loader = QUiLoader()
        main_win = loader.load(fileName)
        self.assertEqual(sys.getrefcount(main_win), 2)
        fileName.close()

        tw = QTabWidget(main_win)
        main_win.setCentralWidget(tw)
        main_win.show()
开发者ID:Hasimir,项目名称:PySide,代码行数:10,代码来源:bug_909.py

示例10: __load_ui

    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")])
开发者ID:qvoiriot,项目名称:ia_expert_system,代码行数:10,代码来源:Application.py

示例11: createWidget

 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)
开发者ID:XDATA-Year-2,项目名称:tangelo-wrapper,代码行数:10,代码来源:tangelo-wrapper.py

示例12: download_file

    def download_file(self, path, setting):
        version_file = self.settings['base_url'].format(self.selected_version())

        location = self.get_setting('download_dir').value

        versions = re.findall('v(\d+)\.(\d+)\.(\d+)', path)[0]

        minor = int(versions[1])
        if minor >= 12:
            path = path.replace('node-webkit', 'nwjs')

        self.progress_text = 'Downloading {}'.format(path.replace(version_file, ''))

        url = QUrl(path)
        file_name = setting.save_file_path(self.selected_version(), location)

        archive_exists = QFile.exists(file_name)

        #dest_files_exist = False

        # for dest_file in setting.dest_files:
        #    dest_file_path = os.path.join('files', setting.name, dest_file)
        #    dest_files_exist &= QFile.exists(dest_file_path)

        forced = self.get_setting('force_download').value

        if archive_exists and not forced:
            self.continue_downloading_or_extract()
            return

        self.out_file = QFile(file_name)
        if not self.out_file.open(QIODevice.WriteOnly):
            error = self.out_file.error().name
            self.show_error('Unable to save the file {}: {}.'.format(file_name,
                                                                     error))
            self.out_file = None
            self.enable_ui()
            return

        mode = QHttp.ConnectionModeHttp
        port = url.port()
        if port == -1:
            port = 0
        self.http.setHost(url.host(), mode, port)
        self.http_request_aborted = False

        path = QUrl.toPercentEncoding(url.path(), "!$&'()*+,;=:@/")
        if path:
            path = str(path)
        else:
            path = '/'

        # Download the file.
        self.http_get_id = self.http.get(path, self.out_file)
开发者ID:ebenshap,项目名称:Web2Executable,代码行数:54,代码来源:main.py

示例13: readModel

    def readModel(self,fileName):
	file = QFile(fileName)
	if (file.open(QIODevice.ReadOnly | QIODevice.Text)):
            xmlReader = QXmlSimpleReader()
            xmlReader.setContentHandler(self)
            xmlReader.setErrorHandler(self)
            xmlSource = QXmlInputSource(file)
            xmlReader.parse(xmlSource)
            return self.modelData
        else:
            return  None
开发者ID:webushka,项目名称:reduce,代码行数:11,代码来源:qrmodel.py

示例14: findTangelo

 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)
开发者ID:XDATA-Year-2,项目名称:tangelo-wrapper,代码行数:53,代码来源:tangelo-wrapper.py

示例15: TestQFileSignalBlocking

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)
开发者ID:Hasimir,项目名称:PySide,代码行数:35,代码来源:blocking_signals_test.py


注:本文中的PySide.QtCore.QFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。