Python kivy.config.Config.set() Examples
The following are 19
code examples of kivy.config.Config.set().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.config.Config
, or try the search function
.
Example #1
Source File: screen.py From Tickeys-linux with MIT License | 6 votes |
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')
Example #2
Source File: screen.py From Tickeys-linux with MIT License | 6 votes |
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')
Example #3
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #4
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #5
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #6
Source File: execute.py From telenium with MIT License | 5 votes |
def run_executable(executable_name): # insert the telenium module path # we do the import here to be able to load kivy args from kivy.modules import Modules from kivy.config import Config from os.path import dirname, join import runpy Modules.add_path(join(dirname(__file__), "mods")) Config.set("modules", "telenium_client", "") runpy.run_path(executable_name, run_name="__main__")
Example #7
Source File: main.py From huawei-lte-examples with GNU General Public License v3.0 | 5 votes |
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()
Example #8
Source File: tuio.py From Tickeys-linux with MIT License | 5 votes |
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]
Example #9
Source File: tuio.py From Tickeys-linux with MIT License | 5 votes |
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]
Example #10
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #11
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def save_encoding_preset(self): self.config.set("Presets", "selected_preset", self.selected_encoder_preset)
Example #12
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #13
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #14
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #15
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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'
Example #16
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #17
Source File: SmartBinApp.py From SmartBin with MIT License | 5 votes |
def __init__(self, **kwargs): super(AboutView, self).__init__(**kwargs) # ========================================== # Tie everything together and launch the app # ========================================== # everything works! set LED strip to initial state
Example #18
Source File: app.py From segreto-3 with MIT License | 5 votes |
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
Example #19
Source File: main.py From GroundControl with GNU General Public License v3.0 | 4 votes |
def computeSettings(self, section, key, value): # Update Computed settings if key == 'kinematicsType': if value == 'Quadrilateral': self.config.set('Computed Settings', 'kinematicsTypeComputed', "1") else: self.config.set('Computed Settings', 'kinematicsTypeComputed', "2") elif (key == 'gearTeeth' or key == 'chainPitch') and self.config.has_option('Advanced Settings', 'gearTeeth') and self.config.has_option('Advanced Settings', 'chainPitch'): distPerRot = float(self.config.get('Advanced Settings', 'gearTeeth')) * float(self.config.get('Advanced Settings', 'chainPitch')) self.config.set('Computed Settings', "distPerRot", str(distPerRot)) elif key == 'enablePosPIDValues': for key in ('KpPos', 'KiPos', 'KdPos', 'propWeight'): if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1: value = float(self.config.get('Advanced Settings', key)) else: value = maslowSettings.getDefaultValue('Advanced Settings', key) self.config.set('Computed Settings', key + "Main", value) #updated computed values for z-axis for key in ('KpPosZ', 'KiPosZ', 'KdPosZ', 'propWeightZ'): if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1: value = float(self.config.get('Advanced Settings', key)) else: value = maslowSettings.getDefaultValue('Advanced Settings', key) self.config.set('Computed Settings', key, value) elif key == 'enableVPIDValues': for key in ('KpV', 'KiV', 'KdV'): if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1: value = float(self.config.get('Advanced Settings', key)) else: value = maslowSettings.getDefaultValue('Advanced Settings', key) self.config.set('Computed Settings', key + "Main", value) #updated computed values for z-axis for key in ('KpVZ', 'KiVZ', 'KdVZ'): if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1: value = float(self.config.get('Advanced Settings', key)) else: value = maslowSettings.getDefaultValue('Advanced Settings', key) self.config.set('Computed Settings', key, value) elif key == 'chainOverSprocket': if value == 'Top': self.config.set('Computed Settings', 'chainOverSprocketComputed', 1) else: self.config.set('Computed Settings', 'chainOverSprocketComputed', 2) elif key == 'fPWM': if value == '31,000Hz': self.config.set('Computed Settings', 'fPWMComputed', 1) elif value == '4,100Hz': self.config.set('Computed Settings', 'fPWMComputed', 2) else: self.config.set('Computed Settings', 'fPWMComputed', 3)