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


Python QFile.setFileName方法代码示例

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


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

示例1: LogFilePositionSource

# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import setFileName [as 别名]
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,代码行数:58,代码来源:location_test.py

示例2: webLoadFinished

# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import setFileName [as 别名]
    def webLoadFinished(self, loaded):
        print("We loaded a web page")

        infile = QFile(self)
        infile.setFileName("ui/resources/jquery-1.9.1.js")

        if not infile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
            print("Error opening file: " + infile.errorString())

        stream = QtCore.QTextStream(infile)
        self.jQuery = stream.readAll()
        infile.close()

        print("We loaded jQuery")

        self._web_view.page().mainFrame().evaluateJavaScript(self.jQuery)

        print("We evaluated jQuery")

        self._web_view.page().mainFrame().evaluateJavaScript("$( 'div.header' ).css( '-webkit-transition', '-webkit-transform 2s'); $( 'div.header' ).css('-webkit-transform', 'rotate(360deg)')")

        print("Ran some simple jQuery")
开发者ID:Dingobloo,项目名称:dreamer,代码行数:24,代码来源:main_window.py

示例3: MyMainWindow

# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import setFileName [as 别名]
class MyMainWindow(QtGui.QMainWindow):
    def __init__(self, frequency, parent=None):
        super(MyMainWindow, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        wd = os.path.dirname(os.path.abspath(__file__))

        self.tick_pixmaps = {True:  QtGui.QPixmap(os.path.join(wd, 'pics', 'blinkenlicht_on.png')),
                             False: QtGui.QPixmap(os.path.join(wd, 'pics', 'blinkenlicht_off.png'))}
        self.speaker_pixmaps = {True:  QtGui.QIcon(QtGui.QPixmap(os.path.join(wd, 'pics', 'speaker_on.png'))),
                                False: QtGui.QIcon(QtGui.QPixmap(os.path.join(wd, 'pics', 'speaker_off.png')))}
        
        self.tick_soundFile=QFile()
        self.tick_soundFile.setFileName(os.path.join(wd, 'sounds', 'tick.raw'))
        self.tick_soundFile.open(QIODevice.ReadOnly)

        self.play_sound = True

        self.format = QAudioFormat()  
        self.format.setChannels(1)  
        self.format.setFrequency(44050)  
        self.format.setSampleSize(16)  
        self.format.setCodec("audio/pcm")  
        self.format.setByteOrder(QAudioFormat.LittleEndian)  
        self.format.setSampleType(QAudioFormat.SignedInt) 

        self.audio_output = QAudioOutput(self.format)

  

       
        self.ui.ping_icon.setPixmap(self.tick_pixmaps[False])
        self.ui.speaker_button.setIcon(self.speaker_pixmaps[self.play_sound])

        self.blink_timer = QTimer()
        self.blink_timer.setSingleShot(True)
        self.blink_timer.timeout.connect(self.clear_blink)
        
        self.timer   = QTimer()                
        self.frequency = frequency
        self.last_played = 0
        self.count = 0
        
        self.ui.f_spin.setValue(self.frequency)
        self.set_speed()
        self.timer.timeout.connect(self.play_tick)

        self.play_ctrl = {True: 'Stop',
                          False: 'Start'}
        self.ui.play_button.setText(self.play_ctrl[False])
        self.ui.statusBar.showMessage('{count:04d} - Dev.: {delta:.3f} ms'.format(delta=0, count=self.count))

    def set_frequency(self, frequency):
        self.frequency = frequency
        self.set_speed()
        self.last_played = 0
        self.count = 0

    def set_speed(self):
        self.speed = 1000.0 / (self.frequency / 60.0)
        self.timer.setInterval(self.speed)

    def clear_blink(self):
        self.ui.ping_icon.setPixmap(self.tick_pixmaps[False])

    def toggle_play(self):
        if self.timer.isActive():
            self.timer.stop()
            self.last_played = 0
            self.count = 0
            self.ui.statusBar.clearMessage()
        else:
            self.timer.start(self.speed)
            self.play_tick()
        self.ui.play_button.setText(self.play_ctrl[self.timer.isActive()])

    def toggle_play_sound(self):
        if self.play_sound:
            self.play_sound = False
            self.audio_output.stop()
        else:
            self.play_sound = True
        self.ui.speaker_button.setIcon(self.speaker_pixmaps[self.play_sound])

    def play_tick(self):
        if self.last_played:
            delta = ((time.time() - self.last_played) * 1000.0) - self.speed
        else:
            delta = 0
        self.last_played = time.time()

        self.audio_output.stop()
        self.audio_output.reset()
        if self.play_sound:
            self.tick_soundFile.seek(0)
            self.audio_output.start(self.tick_soundFile)

        self.count += 1
        self.ui.statusBar.showMessage('{count:04d} - Dev.: {delta:.3f} ms'.format(delta=delta, count=self.count))
#.........这里部分代码省略.........
开发者ID:BugsBunnySan,项目名称:metrognome,代码行数:103,代码来源:metrognome.py


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