本文整理汇总了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()
示例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
示例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)
示例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()
#.........这里部分代码省略.........