本文整理匯總了Python中configuration.Config.write_config_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.write_config_file方法的具體用法?Python Config.write_config_file怎麽用?Python Config.write_config_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類configuration.Config
的用法示例。
在下文中一共展示了Config.write_config_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ConfigDialog
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import write_config_file [as 別名]
class ConfigDialog(QtGui.QDialog):
def __init__(self, parent=None):
"""Initializes the Dialog"""
self.logger = logging.getLogger('pymetadatamanager.configuration_dialog')
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_ConfigDialog()
self.ui.setupUi(self)
self.config = Config()
self.ui.lineEdit_tv_dirs.setText(",".join(self.config.tv_dirs))
self.ui.lineEdit_movie_dirs.setText(",".join(self.config.movie_dirs))
self.ui.checkBox_prefer_local.setChecked(self.config.prefer_local)
self.ui.lineEdit_mediainfo_path.setText(self.config.mediainfo_path)
self.ui.pushButton_tv_browse.clicked.connect(self.tv_browser)
self.ui.pushButton_movie_browse.clicked.connect(self.movie_browser)
self.ui.pushButton_mediainfo_browse.clicked.connect(self.mediainfo_browser)
self.ui.buttonBox.accepted.connect(self.save_values)
def tv_browser(self):
old_filename = self.ui.lineEdit_tv_dirs.text()
filename = QtGui.QFileDialog.getExistingDirectory(self, "TV Directory", \
old_filename)
if not filename == '':
self.ui.lineEdit_tv_dirs.setText(filename)
else:
self.ui.lineEdit_tv_dirs.setText(old_filename)
def movie_browser(self):
old_filename = self.ui.lineEdit_movie_dirs.text()
filename = QtGui.QFileDialog.getExistingDirectory(self, "Movie Directory", \
old_filename)
if not filename == '':
self.ui.lineEdit_movie_dirs.setText(filename)
else:
self.ui.lineEdit_movie_dirs.setText(old_filename)
def mediainfo_browser(self):
old_path = self.ui.lineEdit_mediainfo_path.text()
path = QtGui.QFileDialog.getOpenFileName(self, \
"MediaInfo Path", \
os.path.expanduser("~"))
if not path == '':
self.ui.lineEdit_mediainfo_path.setText(path)
else:
self.ui.lineEdit_mediainfo_path.setText(old_path)
def save_values(self):
del self.config.tv_dirs[:]
for dir in str(self.ui.lineEdit_tv_dirs.text()).split(","):
self.config.tv_dirs.append(dir)
del self.config.movie_dirs[:]
for dir in str(self.ui.lineEdit_movie_dirs.text()).split(","):
self.config.movie_dirs.append(dir)
self.config.mediainfo_path = self.ui.lineEdit_mediainfo_path.text()
if self.ui.checkBox_prefer_local.isChecked():
self.config.prefer_local = 1
else:
self.config.prefer_local = 0
self.config.write_config_file()