本文整理汇总了Python中kivy.config.Config.set方法的典型用法代码示例。如果您正苦于以下问题:Python Config.set方法的具体用法?Python Config.set怎么用?Python Config.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.Config
的用法示例。
在下文中一共展示了Config.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: album_save
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def album_save(self, album):
"""Saves an album data file.
Argument:
album: Dictionary containing album information:
file: String, filename of the album (with extension)
name: String, name of the album.
description: String, description of the album.
photos: List of Strings, each is a database-relative filepath to a photo in the album.
"""
configfile = ConfigParser(interpolation=None)
filename = os.path.join(self.album_directory, album['file'])
configfile.add_section('info')
configfile.set('info', 'name', album['name'])
configfile.set('info', 'description', album['description'])
configfile.add_section('photos')
for index, photo in enumerate(album['photos']):
configfile.set('photos', str(index), agnostic_path(photo))
with open(filename, 'w') as config:
configfile.write(config)
示例2: database_thumbnail_get
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def database_thumbnail_get(self, fullpath, temporary=False):
"""Gets a thumbnail image from the thumbnails database.
Arguments:
fullpath: String, the database-relative path of the photo to get the thumbnail of.
temporary: Boolean, set to True to get a thumbnail from the temporary thumbnail database.
Returns: List containing thumbnail information and data, or None if not found.
"""
fullpath = agnostic_path(fullpath)
if temporary:
thumbnail = self.tempthumbnails.select('SELECT * FROM thumbnails WHERE FullPath = ?', (fullpath,))
else:
thumbnail = self.thumbnails.select('SELECT * FROM thumbnails WHERE FullPath = ?', (fullpath,))
thumbnail = list(thumbnail)
if thumbnail:
thumbnail = local_thumbnail(list(thumbnail[0]))
return thumbnail
示例3: get_database_directories
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def get_database_directories(self, real=False):
"""Gets the current database directories.
Returns: List of Strings of the paths to each database.
"""
if not real and (self.standalone and not self.standalone_in_database):
#if real is not passed in, and a standalone database is set, use that
return [self.standalone_database]
else:
directories = self.config.get('Database Directories', 'paths')
directories = local_path(directories)
if directories:
databases = directories.split(';')
else:
databases = []
databases_cleaned = []
for database in databases:
if database:
databases_cleaned.append(database)
return databases_cleaned
示例4: apply_device
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def apply_device(device, scale, orientation):
name, width, height, dpi, density = devices[device]
if orientation == 'portrait':
width, height = height, width
Logger.info('Screen: Apply screen settings for {0}'.format(name))
Logger.info('Screen: size={0}x{1} dpi={2} density={3} '
'orientation={4}'.format(width, height, dpi, density,
orientation))
try:
scale = float(scale)
except:
scale = 1
environ['KIVY_METRICS_DENSITY'] = str(density * scale)
environ['KIVY_DPI'] = str(dpi * scale)
Config.set('graphics', 'width', str(int(width * scale)))
# simulate with the android bar
# FIXME should be configurable
Config.set('graphics', 'height', str(int(height * scale - 25 * density)))
Config.set('graphics', 'fullscreen', '0')
Config.set('graphics', 'show_mousecursor', '1')
示例5: write_config
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def write_config(self):
if not Config.has_section(default_section):
Config.add_section(default_section)
Config.set(default_section, 'user', self.user)
Config.set(default_section, 'password', crypto.encode_password(self.password))
Config.set(default_section, 'ip', self.ip)
Config.write()
示例6: build
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def build(self):
self.icon = 'data/icon/segreto_icon.png' # Don't know why icon isn't set :(
self.title = 'Segreto 3'
self.init()
return self.screenmanager
示例7: __init__
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def __init__(self, **kwargs):
super(AboutView, self).__init__(**kwargs)
# ==========================================
# Tie everything together and launch the app
# ==========================================
# everything works! set LED strip to initial state
示例8: message
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def message(self, text, timeout=20):
"""Sets the app.infotext variable to a specific message, and clears it after a set amount of time."""
self.infotext = text
if self.infotext_setter:
self.infotext_setter.cancel()
self.infotext_setter = Clock.schedule_once(self.clear_message, timeout)
示例9: toggle_quicktransfer
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def toggle_quicktransfer(self, button):
if self.config.get("Settings", "quicktransfer") == '0':
self.config.set("Settings", "quicktransfer", '1')
button.state = 'normal'
else:
self.config.set("Settings", "quicktransfer", '0')
button.state = 'down'
示例10: program_export
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def program_export(self):
"""Save current external program presets to the config file."""
configfile = ConfigParser(interpolation=None)
for index, preset in enumerate(self.programs):
name, command, argument = preset
section = str(index)
configfile.add_section(section)
configfile.set(section, 'name', name)
configfile.set(section, 'command', command)
configfile.set(section, 'argument', argument)
with open(self.data_directory+os.path.sep+'programs.ini', 'w') as config:
configfile.write(config)
示例11: update_photoinfo
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def update_photoinfo(self, folders=list()):
"""Updates the photoinfo files in given folders.
Arguments:
folders: List containing Strings for database-relative paths to each folder.
"""
if self.config.get("Settings", "photoinfo"):
databases = self.get_database_directories()
folders = list(set(folders))
for folder in folders:
for database in databases:
full_path = os.path.join(database, folder)
if os.path.isdir(full_path):
self.save_photoinfo(target=folder, save_location=full_path)
示例12: export_preset_write
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def export_preset_write(self):
"""Saves all export presets to the config file."""
configfile = ConfigParser(interpolation=None)
for index, preset in enumerate(self.exports):
section = str(index)
configfile.add_section(section)
configfile.set(section, 'name', preset['name'])
configfile.set(section, 'export', preset['export'])
configfile.set(section, 'ftp_address', preset['ftp_address'])
configfile.set(section, 'ftp_user', preset['ftp_user'])
configfile.set(section, 'ftp_password', preset['ftp_password'])
configfile.set(section, 'ftp_passive', str(preset['ftp_passive']))
configfile.set(section, 'ftp_port', str(preset['ftp_port']))
configfile.set(section, 'export_folder', agnostic_path(preset['export_folder']))
configfile.set(section, 'create_subfolder', str(preset['create_subfolder']))
configfile.set(section, 'export_info', str(preset['export_info']))
configfile.set(section, 'scale_image', str(preset['scale_image']))
configfile.set(section, 'scale_size', str(preset['scale_size']))
configfile.set(section, 'scale_size_to', preset['scale_size_to'])
configfile.set(section, 'jpeg_quality', str(preset['jpeg_quality']))
configfile.set(section, 'watermark', str(preset['watermark']))
configfile.set(section, 'watermark_image', agnostic_path(preset['watermark_image']))
configfile.set(section, 'watermark_opacity', str(preset['watermark_opacity']))
configfile.set(section, 'watermark_horizontal', str(preset['watermark_horizontal']))
configfile.set(section, 'watermark_vertical', str(preset['watermark_vertical']))
configfile.set(section, 'watermark_size', str(preset['watermark_size']))
configfile.set(section, 'ignore_tags', '|'.join(preset['ignore_tags']))
configfile.set(section, 'export_videos', str(preset['export_videos']))
with open(self.data_directory+os.path.sep+'exports.ini', 'w') as config:
configfile.write(config)
示例13: save_encoding_preset
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def save_encoding_preset(self):
self.config.set("Presets", "selected_preset", self.selected_encoder_preset)
示例14: edit_scale_image
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def edit_scale_image(self, imagedata, scale_size, scale_size_to):
"""Scales an image based on a side length while maintaining aspect ratio.
imagedata - the image to apply the scaling to, a PIL image object
scale_size - the target edge length in pixels
scale_size_to - scaling mode, set to one of ('width', 'height', 'short', 'long')
width - scales the image so the width matches scale_size
height - scales the image so the height matches scale_size
short - scales the image so the shorter side matches scale_size
long - scales the image so the longer side matches scale_size
Returns a PIL image object
"""
original_size = imagedata.size
ratio = original_size[0]/original_size[1]
if scale_size_to == 'width':
new_size = (scale_size, int(round(scale_size/ratio)))
elif scale_size_to == 'height':
new_size = (int(round(scale_size*ratio)), scale_size)
elif scale_size_to == 'short':
if original_size[0] > original_size[1]:
new_size = (int(round(scale_size*ratio)), scale_size)
else:
new_size = (scale_size, int(round(scale_size/ratio)))
else:
if original_size[0] > original_size[1]:
new_size = (scale_size, int(round(scale_size/ratio)))
else:
new_size = (int(round(scale_size*ratio)), scale_size)
return imagedata.resize(new_size, 3)
示例15: _update
# 需要导入模块: from kivy.config import Config [as 别名]
# 或者: from kivy.config.Config import set [as 别名]
def _update(self, dispatch_fn, value):
oscpath, args, types = value
command = args[0]
# verify commands
if command not in ['alive', 'set']:
return
# move or create a new touch
if command == 'set':
id = args[1]
if id not in self.touches[oscpath]:
# new touch
touch = TuioMotionEventProvider.__handlers__[oscpath](
self.device, id, args[2:])
self.touches[oscpath][id] = touch
dispatch_fn('begin', touch)
else:
# update a current touch
touch = self.touches[oscpath][id]
touch.move(args[2:])
dispatch_fn('update', touch)
# alive event, check for deleted touch
if command == 'alive':
alives = args[1:]
to_delete = []
for id in self.touches[oscpath]:
if not id in alives:
# touch up
touch = self.touches[oscpath][id]
if not touch in to_delete:
to_delete.append(touch)
for touch in to_delete:
dispatch_fn('end', touch)
del self.touches[oscpath][touch.id]