本文整理汇总了Python中deepin_utils.config.Config.getfloat方法的典型用法代码示例。如果您正苦于以下问题:Python Config.getfloat方法的具体用法?Python Config.getfloat怎么用?Python Config.getfloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deepin_utils.config.Config
的用法示例。
在下文中一共展示了Config.getfloat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SkinConfig
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import getfloat [as 别名]
#.........这里部分代码省略.........
if os.path.exists(skin_config_file):
# Read skin name from config file.
skin_config = Config(skin_config_file)
skin_config.load()
# Load skin.
init_skin_name = skin_config.get("skin", "skin_name")
else:
# Create skin config if it not exists.
touch_file(self.skin_config_file)
init_skin_name = skin_name
if self.is_skin_exist(init_skin_name, system_skin_dir, user_skin_dir):
self.load_skin(init_skin_name, system_skin_dir, user_skin_dir)
else:
# Try load default skin if user's select skin not exists.
default_skin_name = self.get_default_skin(system_skin_dir, user_skin_dir)
assert(default_skin_name != None)
self.load_skin(default_skin_name, system_skin_dir, user_skin_dir)
self.app_given_id = app_given_id
self.app_given_version = app_given_version
def save_skin_name(self):
'''
Internal function to save skin name.
'''
skin_config = Config(self.skin_config_file)
skin_config.load()
if skin_config.get("skin", "skin_name") != self.skin_name:
skin_config.set("skin", "skin_name", self.skin_name)
skin_config.write(self.skin_config_file)
def reload_skin(self, skin_name=None):
'''
Internal function to reload skin.
'''
if skin_name:
return self.load_skin(skin_name)
else:
return self.load_skin(self.skin_name)
def load_skin(self, skin_name, system_skin_dir=None, user_skin_dir=None):
'''
Internal function to Load skin.
@return: Return True if load finish, otherwise return False.
'''
try:
# Save skin dir.
self.skin_name = skin_name
if system_skin_dir:
self.system_skin_dir = system_skin_dir
create_directory(self.system_skin_dir)
if user_skin_dir:
self.user_skin_dir = user_skin_dir
create_directory(self.user_skin_dir)
self.skin_dir = self.get_skin_dir()
# Load config file.
self.config = Config(self.get_skin_file_path("config.ini"))
self.config.load()
# Get theme config.
self.theme_name = self.config.get("theme", "theme_name")
# Get application config.
self.app_id = self.config.get("application", "app_id")
self.app_version = self.config.getfloat("application", "app_version")
# Get background config.
self.image = self.config.get("background", "image")
self.x = self.config.getfloat("background", "x")
self.y = self.config.getfloat("background", "y")
self.scale_x = self.config.getfloat("background", "scale_x")
self.scale_y = self.config.getfloat("background", "scale_y")
self.dominant_color = self.config.get("background", "dominant_color")
# Get action config.
self.deletable = self.config.getboolean("action", "deletable")
self.editable = self.config.getboolean("action", "editable")
self.vertical_mirror = self.config.getboolean("action", "vertical_mirror")
self.horizontal_mirror = self.config.getboolean("action", "horizontal_mirror")
# Generate background pixbuf.
self.background_pixbuf = gtk.gdk.pixbuf_new_from_file(self.get_skin_file_path(self.image))
# Save skin name.
self.save_skin_name()
return True
except Exception, e:
print "function load_skin got error: %s" % (e)
traceback.print_exc(file=sys.stdout)
return False