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


Python Settings.value方法代码示例

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


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

示例1: onDbDownloaded

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import value [as 别名]
 def onDbDownloaded(self, tracks):
     settings = Settings()
     if settings.value("excludeLongTracks") == "True":
         excluding = True
         maxTrackSeconds = int(settings.value("maxTrackLength")) * 60
     else:
         excluding = False
     cursor = self.trackDB.cursor()
     cursor.execute("drop table if exists tracks")
     cursor.execute('''create table if not exists tracks
     (title text, artist text, file text, time integer, tag text)
     ''')
     for t in tracks:
         if excluding and int(t['time']) > maxTrackSeconds:
             continue
         cursor.execute('''insert into tracks(title, artist, file, 
         time, tag) values( ?, ?, ?, ?, ?) ''',\
         (t['title'], t['artist'], t['file'], t['time'], t['tag'])
         )
     self.trackDB.commit()
     cursor.close()
     self.dbUpdateDialog.ui.sqlupdatePixmap.setEnabled(True)
     self.dbUpdateDialog.accept()
     self.connected = True
     self.sigConnected.emit()
     self.sigDbUpdated.emit()
开发者ID:thomaslundgaard,项目名称:pimp,代码行数:28,代码来源:serverInterface.py

示例2: checkPwd

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import value [as 别名]
 def checkPwd(self):
     settings = Settings()
     if self.ui.pwdEdit.text() == settings.value("adminPassword"):
         return True
     else:
        self.ui.pwdEdit.clear()
        self.ui.infoLabel.setText("Invalid password - please try again:")
        self.ui.infoLabel.show()
        self.ui.pwdEdit.setFocus()
        return False
开发者ID:thomaslundgaard,项目名称:pimp,代码行数:12,代码来源:adminDialog.py

示例3: __init__

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import value [as 别名]
    def __init__ (self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.ui = Ui_SettingsDialog()
        self.ui.setupUi (self)
        conf = Settings()

        self.ui.adminPasswordEdit.setText (conf.value("adminPassword"))
        self.ui.adminPasswordRepeatEdit.setText (conf.value("adminPassword"))
        self.ui.maxPlaylistSpinBox.setValue (int(conf.value("maxPlaylist")))
        self.ui.maxTrackLengthSpinBox.setValue( \
                int(conf.value("maxTrackLength")))
        self.ui.mpdServerEdit.setText (conf.value("mpdServer"))
        self.ui.mpdPortEdit.setText (conf.value("mpdPort"))
        self.ui.mpdPasswordEdit.setText (conf.value("mpdPassword"))
        if( conf.value("fullscreenOnStart") == "True" ):
            self.ui.fullscreenOnStartCheckBox.setChecked(True)
        else:
            self.ui.fullscreenOnStartCheckBox.setChecked(False)
        if( conf.value("playOnConnect") == "True" ):
            self.ui.playOnConnectCheckBox.setChecked(True)
        else:
            self.ui.playOnConnectCheckBox.setChecked(False)
        if( conf.value("stopOnQuit") == "True" ):
            self.ui.stopOnQuitCheckBox.setChecked(True)
        else:
            self.ui.stopOnQuitCheckBox.setChecked(False)
        if (conf.value("excludeLongTracks") == "True"):
            self.ui.excludeLongTracksCheckbox.setChecked(True)
            self.ui.maxTrackLengthSpinBox.setEnabled(True)
            self.ui.maxTrackLengthLabel.setEnabled(True)
            self.ui.maxTrackLengthUp.setEnabled(True)
            self.ui.maxTrackLengthDown.setEnabled(True)
        else:
            self.ui.excludeLongTracksCheckbox.setChecked(False)
            self.ui.maxTrackLengthSpinBox.setEnabled(False)
            self.ui.maxTrackLengthLabel.setEnabled(False)
            self.ui.maxTrackLengthUp.setEnabled(False)
            self.ui.maxTrackLengthDown.setEnabled(False)
        self.ui.vkRow1Edit.setText (conf.value("vkRow1"))
        self.ui.vkRow2Edit.setText (conf.value("vkRow2"))
        self.ui.vkRow3Edit.setText (conf.value("vkRow3"))
        self.ui.vkRow4Edit.setText (conf.value("vkRow4"))

        self.vkb = VirtualKeyboard(self)
        self.vkb.setMinimumSize(600,300)
        self.layout().addWidget(self.vkb)
        QtGui.qApp.focusChanged.connect(self.focusChanged)
开发者ID:thomaslundgaard,项目名称:pimp,代码行数:49,代码来源:settingsDialog.py

示例4: ServerInterface

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import value [as 别名]
class ServerInterface(QtCore.QObject):
    sigConnected = QtCore.pyqtSignal()
    sigDisconnected = QtCore.pyqtSignal()
    sigDbUpdated = QtCore.pyqtSignal()
    sigStatusChanged = QtCore.pyqtSignal('PyQt_PyObject','PyQt_PyObject') 
                                          # changeList  , mpdStatusDict

    def __init__(self, parent=None):
        QtCore.QObject.__init__(self, parent)
        self.client = MPDClient()
        self.settings = Settings()
        self.mpdServer = str(self.settings.value("mpdServer"))
        self.mpdPort = str(self.settings.value("mpdPort"))
        self.mpdPassword = str(self.settings.value("mpdPassword"))

        self.lastState=-9999
        self.lastSongid=-9999
        self.lastTime=-9999
        self.lastPlaylist=-9999
        self.lastVolume=-1
        self.connected = False
        self.shuffleList = []
        self.timerId = False
        if self.settings.value("playOnConnect") == "True":
            self.autoAdd = True
        else:
            self.autoAdd = False

        self.trackDB = None 
        self.sigConnected.connect(self._onConnected)
        self.sigStatusChanged.connect(self._onStatusChanged)
        QtGui.qApp.aboutToQuit.connect(self._onAppQuit)

    def connect(self):
        try:
            self.client.connect(host=self.mpdServer, port=self.mpdPort)
        except socket.error:
            print datetime.now().isoformat(" ") + \
            ": Unable to connect to MPD: Socket error (will try again in 2 sec)"
            QtCore.QTimer.singleShot(2000, self.connect)
            return
        if self.mpdPassword != "":
            try:
                self.client.password(self.mpdPassword)
            except CommandError:
                print datetime.now().isoformat(" ") + \
                        ": Unable to connect to MPD: Invalid password"
                return
        if not self.trackDB:    # this is the first connection
            self.dbUpdate()
        else:
            self.connected = True
            self.sigConnected.emit()
            
    def dbUpdate(self):
        self.trackDB = sqlite3.connect(':memory:')
        self.dbUpdateDialog = DbUpdateDialog()
        self.dbUpdateDialog.ui.mpdupdatePixmap.show()
        self.dbUpdateDialog.setModal(True)
        self.dbUpdateDialog.show()
        self.dbUpdateWorker = DbUpdateWorker(self.client)
        self.dbUpdateWorker.sigRemoteUpdateFinished.connect( \
                self.onRemoteUpdateFinished)
        self.dbUpdateWorker.sigDbDownloaded.connect(self.onDbDownloaded)
        self.dbUpdateWorker.sigDbUpdateFailed.connect(self.onDbUpdateFailed)
        self.dbUpdateWorker.start()

    def onRemoteUpdateFinished(self):
        self.dbUpdateDialog.ui.mpdupdatePixmap.setEnabled(True)
        self.dbUpdateDialog.ui.sqlupdatePixmap.show()

    def onDbUpdateFailed(self):
        self.trackDB = None
        self.dbUpdateDialog.accept()
        self._lostConnection()

    @QtCore.pyqtSlot('PyQt_PyObject')
    def onDbDownloaded(self, tracks):
        settings = Settings()
        if settings.value("excludeLongTracks") == "True":
            excluding = True
            maxTrackSeconds = int(settings.value("maxTrackLength")) * 60
        else:
            excluding = False
        cursor = self.trackDB.cursor()
        cursor.execute("drop table if exists tracks")
        cursor.execute('''create table if not exists tracks
        (title text, artist text, file text, time integer, tag text)
        ''')
        for t in tracks:
            if excluding and int(t['time']) > maxTrackSeconds:
                continue
            cursor.execute('''insert into tracks(title, artist, file, 
            time, tag) values( ?, ?, ?, ?, ?) ''',\
            (t['title'], t['artist'], t['file'], t['time'], t['tag'])
            )
        self.trackDB.commit()
        cursor.close()
        self.dbUpdateDialog.ui.sqlupdatePixmap.setEnabled(True)
        self.dbUpdateDialog.accept()
#.........这里部分代码省略.........
开发者ID:thomaslundgaard,项目名称:pimp,代码行数:103,代码来源:serverInterface.py


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