def _load_saved_settings(self): roi = json.loads((Config.getdefault(self.section, 'roi', "[0.0, 0.0, 1.0, 1.0]"))) self.scanner.set_region_of_interest_from_rel_points(*roi) self._encoder_threshold = int(Config.getdefault(self.section, 'encoder_threshold', 200)) self._encoder_null_zone = int(Config.getdefault(self.section, 'encoder_null_zone', 50)) encoder_point = json.loads(Config.getdefault(self.section, 'encoder_point', '[0.5, 0.5]')) self._encoder_point = tuple([float(p) for p in encoder_point]) if self._encoder_point[0] > 1.0 or self._encoder_point[1] > 1.0: self._encoder_point[0] == 0.5 self._encoder_point[1] == 0.5
def _load_saved_settings(self): roi = json.loads((Config.getdefault(self.section, 'roi', "[0.0, 0.0, 1.0, 1.0]"))) self.scanner.set_region_of_interest_from_rel_points(*roi) self._encoder_threshold = int( Config.getdefault(self.section, 'encoder_threshold', 200)) self._encoder_null_zone = int( Config.getdefault(self.section, 'encoder_null_zone', 50)) encoder_point = json.loads( Config.getdefault(self.section, 'encoder_point', '[0.5, 0.5]')) self._encoder_point = tuple([float(p) for p in encoder_point]) if self._encoder_point[0] > 1.0 or self._encoder_point[1] > 1.0: self._encoder_point[0] == 0.5 self._encoder_point[1] == 0.5
def _get_config(): frame_rate = float(Config.getdefault("SMILE", "FRAMERATE", 60.)) locked = Config.getdefaultint("SMILE", "LOCKEDSUBJID", 0) font_name = Config.getdefault("SMILE", "FONTNAME", "Roboto") font_size = float(Config.getdefault("SMILE", "FONTSIZE", 45.)) fullscreen = Config.getdefault("SMILE", "FULLSCREEN", "auto") density = Config.getdefault("SMILE", "DENSITY", "1.0") if platform == "android" or platform == "ios": data_dir = Config.getdefault("SMILE", "DEFAULTDATADIR", "/sdcard/SMILE/data") else: data_dir = Config.getdefault("SMILE", "DEFAULTDATADIR", os.path.join(".", "data")) return_dict = { "fullscreen": fullscreen, "locked": locked, "density": density, "font_size": font_size, "font_name": font_name, "frame_rate": frame_rate, "default_data_dir": data_dir } return return_dict
def show_disclaimer(self, *args): accepted_disclaimer = Config.getdefault('internal', 'disclaimer', False) if not accepted_disclaimer: self._disclaimer = I18NPopup( title_source=_("Disclaimer"), content=Disclaimer(self.accept_disclaimer, self.reject_disclaimer, ), size_hint=(0.9, 0.9), auto_dismiss=False) self._disclaimer.open()
def on_start(self): Config.read(self.get_application_config()) config_file_version = \ int(Config.getdefault('General', 'config_version', 0)) if config_file_version < self.config_version: self.config.write() self.osc_service = OSCClient(self)
def read_configs(): output = {} for key, default_value in SETTINGS_DEFAULTS.items(): output[key] = Config.getdefault( 'main', key, default_value, ) return output
def show_load(self): self.last_directory = Config.getdefault('internal', 'last_directory', self.last_directory) content = LoadDialog(load=self.load, cancel=self.dismiss_popup, last_directory=self.last_directory) self._popup = I18NPopup(title_source=_("Load file"), content=content, size_hint=(0.9, 0.9)) self._popup.open()
def show_disclaimer(self, *args): accepted_disclaimer = Config.getdefault('internal', 'disclaimer', False) if not accepted_disclaimer: self._disclaimer = I18NPopup(title_source=_("Disclaimer"), content=Disclaimer( self.accept_disclaimer, self.reject_disclaimer, ), size_hint=(0.9, 0.9), auto_dismiss=False) self._disclaimer.open()
def config_tweaks(): mouse_opt_str = Config.getdefault('input', 'mouse', None) if mouse_opt_str: mouse_options = mouse_opt_str.split(',') # disable mouse-based multitouch emulation if 'disable_multitouch' not in mouse_options: mouse_options.append('disable_multitouch') # on linux: disable mouse when another multitouch device is used # (see: http://kivy.org/docs/api-kivy.input.providers.mouse.html) if platform == 'linux' and 'disable_on_activity' not in mouse_options: mouse_options.append('disable_on_activity') Config.set('input', 'mouse', ', '.join(mouse_options))
def load_settings(self, **kwargs): """Load graphics configuration settings. Does not actually apply settings. filename - optional string argument. This will try to open the file with that filename instead. If no argument is used, the function will use the built-in Kivy configuration (or default values if it can't be found.) """ # Open the config file for reading. self.config_filename = kwargs.get('filename', None) if self.config_filename: Config.read(self.config_filename) # If a file wasn't used, use Kivy's Config object, or use a default if it isn't found. self.temporary_fullscreen = Config.getdefault('graphics', 'fullscreen', 'auto')
def get_location(self): mmdb_file = Config.get('geolite2', 'db') if os.path.isfile(mmdb_file): # get my IP ip = urllib.request.urlopen('http://icanhazip.com/').read().decode( "utf-8").strip() import geoip2.database reader = geoip2.database.Reader(mmdb_file) response = reader.city(ip) self.location = response.location.latitude, response.location.longitude self.name = response.city.name if response.subdivisions.most_specific.iso_code: self.name += ", " + response.subdivisions.most_specific.iso_code reader.close() else: self.location = Config.get('location', 'latitude'), Config.get( 'location', 'longitude') self.name = Config.getdefault('location', 'name', None)
def _get_config(): frame_rate = float(Config.getdefault("SMILE", "FRAMERATE", 60.)) locked = Config.getdefaultint("SMILE", "LOCKEDSUBJID", 0) font_name = Config.getdefault("SMILE", "FONTNAME", "Roboto") font_size = float(Config.getdefault("SMILE", "FONTSIZE", 45.)) fullscreen = Config.getdefault("SMILE", "FULLSCREEN", "auto") density = Config.getdefault("SMILE", "DENSITY", "1.0") if platform == "android" or platform == "ios": data_dir = Config.getdefault("SMILE", "DEFAULT_DATA_DIR", "/sdcard/SMILE/data") else: data_dir = Config.getdefault("SMILE", "DEFAULT_DATA_DIR", os.path.join(".", "data")) return_dict = {"fullscreen": fullscreen, "locked": locked, "density": density, "font_size": font_size, "font_name": font_name, "frame_rate": frame_rate, "default_data_dir": data_dir} return return_dict
def _get_config(): frame_rate = float(Config.getdefault("SMILE", "FRAMERATE", 60.)) locked = Config.getdefaultint("SMILE", "LOCKEDSUBJID", 0) font_name = Config.getdefault("SMILE", "FONTNAME", "Roboto") font_size = float(Config.getdefault("SMILE", "FONTSIZE", 45.)) fullscreen = Config.getdefault("SMILE", "FULLSCREEN", "auto") if platform == "android" or platform == "ios": data_dir = Config.getdefault("SMILE", "DEFAULT_DATA_DIR", "/sdcard/SMILE/") else: data_dir = Config.getdefault("SMILE", "DEFAULT_DATA_DIR", ".") return_dict = { "fullscreen": fullscreen, "locked": locked, "font_size": font_size, "font_name": font_name, "frame_rate": frame_rate, "default_data_dir": data_dir } return return_dict def _set_config(fullscreen=None, locked=None, framerate=None, fontname=None, fontsize=None, data_dir=None): if fullscreen is not None: Config.set("SMILE", "FULLSCREEN", fullscreen) if locked is not None: Config.set("SMILE", "LOCKEDSUBJID", locked) if framerate is not None: Config.set("SMILE", "FRAMERATE", float(framerate)) if fontname is not None: Config.set("SMILE", "FONTNAME", fontname) if fontsize is not None: Config.set("SMILE", "FONTSIZE", fontsize) if data_dir is not None: Config.set("SMILE", "DEFAULT_DATA_DIR", data_dir) Config.write()
def _load(self, *largs): self.camera_focal_length_mm = float(Config.getdefault(self.section, 'camera_focal_length_mm', '10.0')) self.sensor_size_x_mm = float(Config.getdefault(self.section, 'sensor_size_x_mm', '10.0')) self.sensor_size_y_mm = float(Config.getdefault(self.section, 'sensor_size_y_mm', '10.0')) self.focal_point_to_center = float(Config.getdefault(self.section, 'focal_point_to_center', '100.0')) self.laser_intersection_degree_1 = float(Config.getdefault(self.section, 'laser_intersection_degree_1', '35.0')) self.laser_intersection_degree_2 = float(Config.getdefault(self.section, 'laser_intersection_degree_2', '40.0')) self.laser_intersection_degree_3 = float(Config.getdefault(self.section, 'laser_intersection_degree_3', '45.0')) self.laser_intersection_degree_4 = float(Config.getdefault(self.section, 'laser_intersection_degree_4', '50.0')) self.laser_intersection_degree_5 = float(Config.getdefault(self.section, 'laser_intersection_degree_5', '55.0')) self.laser_intersection_distance_1 = float(Config.getdefault(self.section, 'laser_intersection_distance_1', '249.9')) self.laser_intersection_distance_2 = float(Config.getdefault(self.section, 'laser_intersection_distance_2', '208.9')) self.laser_intersection_distance_3 = float(Config.getdefault(self.section, 'laser_intersection_distance_3', '175.0')) self.laser_intersection_distance_4 = float(Config.getdefault(self.section, 'laser_intersection_distance_4', '146.8')) self.laser_intersection_distance_5 = float(Config.getdefault(self.section, 'laser_intersection_distance_5', '122.5'))
def get_hardware(): section = 'peachyscanner.hardware' Config.adddefaultsection(section) camera_focal_length_mm = float(Config.getdefault(section, 'camera_focal_length_mm', '10.0')) sensor_size_x_mm = float(Config.getdefault(section, 'sensor_size_x_mm', '10.0')) sensor_size_y_mm = float(Config.getdefault(section, 'sensor_size_y_mm', '10.0')) focal_point_to_center = float(Config.getdefault(section, 'focal_point_to_center', '100.0')) laser_intersection_degree_1 = float(Config.getdefault(section, 'laser_intersection_degree_1', '35.0')) laser_intersection_degree_2 = float(Config.getdefault(section, 'laser_intersection_degree_2', '40.0')) laser_intersection_degree_3 = float(Config.getdefault(section, 'laser_intersection_degree_3', '45.0')) laser_intersection_degree_4 = float(Config.getdefault(section, 'laser_intersection_degree_4', '50.0')) laser_intersection_degree_5 = float(Config.getdefault(section, 'laser_intersection_degree_5', '55.0')) laser_intersection_distance_1 = float(Config.getdefault(section, 'laser_intersection_distance_1', '249.9')) laser_intersection_distance_2 = float(Config.getdefault(section, 'laser_intersection_distance_2', '208.9')) laser_intersection_distance_3 = float(Config.getdefault(section, 'laser_intersection_distance_3', '175.0')) laser_intersection_distance_4 = float(Config.getdefault(section, 'laser_intersection_distance_4', '146.8')) laser_intersection_distance_5 = float(Config.getdefault(section, 'laser_intersection_distance_5', '122.5')) intersections_rad_mm = [ (np.deg2rad(laser_intersection_degree_1), laser_intersection_distance_1), (np.deg2rad(laser_intersection_degree_2), laser_intersection_distance_2), (np.deg2rad(laser_intersection_degree_3), laser_intersection_distance_3), (np.deg2rad(laser_intersection_degree_4), laser_intersection_distance_4), (np.deg2rad(laser_intersection_degree_5), laser_intersection_distance_5), ] camera_focal_length_mm = float(camera_focal_length_mm) sensor_size = (float(sensor_size_x_mm), float(sensor_size_y_mm)) focal_point_to_center = float(focal_point_to_center) return HardwareConfiguration( camera_focal_length_mm, sensor_size, focal_point_to_center, intersections_rad_mm)
def get_hardware(): section = 'peachyscanner.hardware' Config.adddefaultsection(section) camera_focal_length_mm = float( Config.getdefault(section, 'camera_focal_length_mm', '10.0')) sensor_size_x_mm = float( Config.getdefault(section, 'sensor_size_x_mm', '10.0')) sensor_size_y_mm = float( Config.getdefault(section, 'sensor_size_y_mm', '10.0')) focal_point_to_center = float( Config.getdefault(section, 'focal_point_to_center', '100.0')) laser_intersection_degree_1 = float( Config.getdefault(section, 'laser_intersection_degree_1', '35.0')) laser_intersection_degree_2 = float( Config.getdefault(section, 'laser_intersection_degree_2', '40.0')) laser_intersection_degree_3 = float( Config.getdefault(section, 'laser_intersection_degree_3', '45.0')) laser_intersection_degree_4 = float( Config.getdefault(section, 'laser_intersection_degree_4', '50.0')) laser_intersection_degree_5 = float( Config.getdefault(section, 'laser_intersection_degree_5', '55.0')) laser_intersection_distance_1 = float( Config.getdefault(section, 'laser_intersection_distance_1', '249.9')) laser_intersection_distance_2 = float( Config.getdefault(section, 'laser_intersection_distance_2', '208.9')) laser_intersection_distance_3 = float( Config.getdefault(section, 'laser_intersection_distance_3', '175.0')) laser_intersection_distance_4 = float( Config.getdefault(section, 'laser_intersection_distance_4', '146.8')) laser_intersection_distance_5 = float( Config.getdefault(section, 'laser_intersection_distance_5', '122.5')) intersections_rad_mm = [ (np.deg2rad(laser_intersection_degree_1), laser_intersection_distance_1), (np.deg2rad(laser_intersection_degree_2), laser_intersection_distance_2), (np.deg2rad(laser_intersection_degree_3), laser_intersection_distance_3), (np.deg2rad(laser_intersection_degree_4), laser_intersection_distance_4), (np.deg2rad(laser_intersection_degree_5), laser_intersection_distance_5), ] camera_focal_length_mm = float(camera_focal_length_mm) sensor_size = (float(sensor_size_x_mm), float(sensor_size_y_mm)) focal_point_to_center = float(focal_point_to_center) return HardwareConfiguration(camera_focal_length_mm, sensor_size, focal_point_to_center, intersections_rad_mm)
def _load(self, *largs): self.camera_focal_length_mm = float( Config.getdefault(self.section, 'camera_focal_length_mm', '10.0')) self.sensor_size_x_mm = float( Config.getdefault(self.section, 'sensor_size_x_mm', '10.0')) self.sensor_size_y_mm = float( Config.getdefault(self.section, 'sensor_size_y_mm', '10.0')) self.focal_point_to_center = float( Config.getdefault(self.section, 'focal_point_to_center', '100.0')) self.laser_intersection_degree_1 = float( Config.getdefault(self.section, 'laser_intersection_degree_1', '35.0')) self.laser_intersection_degree_2 = float( Config.getdefault(self.section, 'laser_intersection_degree_2', '40.0')) self.laser_intersection_degree_3 = float( Config.getdefault(self.section, 'laser_intersection_degree_3', '45.0')) self.laser_intersection_degree_4 = float( Config.getdefault(self.section, 'laser_intersection_degree_4', '50.0')) self.laser_intersection_degree_5 = float( Config.getdefault(self.section, 'laser_intersection_degree_5', '55.0')) self.laser_intersection_distance_1 = float( Config.getdefault(self.section, 'laser_intersection_distance_1', '249.9')) self.laser_intersection_distance_2 = float( Config.getdefault(self.section, 'laser_intersection_distance_2', '208.9')) self.laser_intersection_distance_3 = float( Config.getdefault(self.section, 'laser_intersection_distance_3', '175.0')) self.laser_intersection_distance_4 = float( Config.getdefault(self.section, 'laser_intersection_distance_4', '146.8')) self.laser_intersection_distance_5 = float( Config.getdefault(self.section, 'laser_intersection_distance_5', '122.5'))
def _load(self, *largs): self.color = Config.getdefault(self.section, "laser_color", "red") self.on_color(self, self.color) self.threshold = Config.getdefaultint(self.section, "threshold", 225)
def __init__(self, **kwargs): super(Mcnay, self).__init__(**kwargs) if Config.getdefault('input', 'keyboard', False): self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down)
def get(self, key, default=None): return kivy_config.getdefault(self.section, key, default)
def __init__(self, **kwargs): force = kwargs.pop('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not force: return self.initialized = False self._is_desktop = Config.getboolean('kivy', 'desktop') # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # Create a trigger for updating the keyboard height self.trigger_keyboard_height = Clock.create_trigger( self._upd_kbd_height, .5) # set the default window parameter according to the configuration if 'borderless' not in kwargs: kwargs['borderless'] = Config.getboolean('graphics', 'borderless') if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.getdefault('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window self._bind_create_window() self.bind(size=self.trigger_keyboard_height, rotation=self.trigger_keyboard_height) self.bind(softinput_mode=lambda *dt: self.update_viewport(), keyboard_height=lambda *dt: self.update_viewport()) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # NOQA # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # assign the default context of the widget creation if not hasattr(self, '_context'): self._context = get_current_context() # mark as initialized self.initialized = True
def __init__(self, **kwargs): kwargs.setdefault('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get('force'): return self.initialized = False # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # set the default window parameter according to the configuration if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.getdefault('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window for prop in ( 'fullscreen', 'position', 'top', 'left', '_size', 'system_size'): self.bind(**{prop: self.trigger_create_window}) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # mark as initialized self.initialized = True
# handle resolution if args.resolution: width, height = map(int, args.resolution.split("x")) Config.set("graphics", "width", width) Config.set("graphics", "height", height) # prevent right-click multitouch with mouse Config.set("input", "mouse", "mouse,disable_multitouch") # hide the cursor (currently doesn't work in 1.9.0, but fixed in 1.9.1) Config.set('graphics', 'show_cursor', 0) # we don't want to be able to resize Config.set('graphics', 'resizable', 0) density = Config.getdefault("SMILE", "DENSITY", "0.0") if density != "0.0": os.environ['KIVY_METRICS_DENSITY'] = density # handle supported kivy versions import kivy EXACT_KIVY_VERSIONS = ( "1.8.0", "1.9.0", "1.9.1-dev0", "1.9.1", "1.10.0", "1.10.1.dev0", "1.10.1") if kivy.__version__ not in EXACT_KIVY_VERSIONS:
def __init__(self, **kwargs): super(Mcnay, self).__init__(**kwargs) if Config.getdefault('input', 'keyboard', False): self._keyboard = Window.request_keyboard( self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): kwargs.setdefault("force", False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get("force"): return self.initialized = False # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger(self.create_window, -1) # Create a trigger for updating the keyboard height self.trigger_keyboard_height = Clock.create_trigger(self._upd_kbd_height, 0.5) # set the default window parameter according to the configuration if "fullscreen" not in kwargs: fullscreen = Config.get("graphics", "fullscreen") if fullscreen not in ("auto", "fake"): fullscreen = fullscreen.lower() in ("true", "1", "yes", "yup") kwargs["fullscreen"] = fullscreen if "width" not in kwargs: kwargs["width"] = Config.getint("graphics", "width") if "height" not in kwargs: kwargs["height"] = Config.getint("graphics", "height") if "rotation" not in kwargs: kwargs["rotation"] = Config.getint("graphics", "rotation") if "position" not in kwargs: kwargs["position"] = Config.getdefault("graphics", "position", "auto") if "top" in kwargs: kwargs["position"] = "custom" kwargs["top"] = kwargs["top"] else: kwargs["top"] = Config.getint("graphics", "top") if "left" in kwargs: kwargs["position"] = "custom" kwargs["left"] = kwargs["left"] else: kwargs["left"] = Config.getint("graphics", "left") kwargs["_size"] = (kwargs.pop("width"), kwargs.pop("height")) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window for prop in ("fullscreen", "position", "top", "left", "_size", "system_size"): self.bind(**{prop: self.trigger_create_window}) self.bind(size=self.trigger_keyboard_height, rotation=self.trigger_keyboard_height) self.bind(softinput_mode=lambda *dt: self.update_viewport(), keyboard_height=lambda *dt: self.update_viewport()) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {"system": self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # NOQA # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # assign the default context of the widget creation if not hasattr(self, "_context"): self._context = get_current_context() # mark as initialized self.initialized = True
def __init__(self, **kwargs): kwargs.setdefault('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get('force'): return self.initialized = False self._is_desktop = Config.getboolean('kivy', 'desktop') # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # Create a trigger for updating the keyboard height self.trigger_keyboard_height = Clock.create_trigger( self._upd_kbd_height, .5) # set the default window parameter according to the configuration if 'borderless' not in kwargs: kwargs['borderless'] = Config.getboolean('graphics', 'borderless') if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.getdefault('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window self._bind_create_window() self.bind(size=self.trigger_keyboard_height, rotation=self.trigger_keyboard_height) self.bind(softinput_mode=lambda *dt: self.update_viewport(), keyboard_height=lambda *dt: self.update_viewport()) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # NOQA # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # assign the default context of the widget creation if not hasattr(self, '_context'): self._context = get_current_context() # mark as initialized self.initialized = True
def _load(self, *largs): self.color = Config.getdefault(self.section, 'laser_color', 'red') self.on_color(self, self.color) self.threshold = Config.getdefaultint(self.section, 'threshold', 225)