def __init__(self, **kwargs): Builder.load_file(WIRELESS_CONFIG_VIEW_KV) super(WirelessConfigView, self).__init__(**kwargs) self.register_event_type("on_config_updated") self.base_dir = kwargs.get("base_dir") btEnable = kvFind(self, "rcid", "btEnable") btEnable.bind(on_setting=self.on_bt_enable) btEnable.setControl(SettingsSwitch()) # btConfig = kvFind(self, 'rcid', 'btconfig') # btConfig.bind(on_setting=self.on_bt_configure) # btConfig.setControl(SettingsButton(text='Configure', disabled=True)) cellEnable = kvFind(self, "rcid", "cellEnable") cellEnable.bind(on_setting=self.on_cell_enable) cellEnable.setControl(SettingsSwitch()) cellProvider = kvFind(self, "rcid", "cellprovider") cellProvider.bind(on_setting=self.on_cell_provider) apnSpinner = SettingsMappedSpinner() self.loadApnSettingsSpinner(apnSpinner) self.apnSpinner = apnSpinner cellProvider.setControl(apnSpinner) self.apnHostField = kvFind(self, "rcid", "apnHost") self.apnUserField = kvFind(self, "rcid", "apnUser") self.apnPassField = kvFind(self, "rcid", "apnPass")
def __init__(self, **kwargs): Builder.load_file(DASHBOARD_VIEW_KV) super(DashboardView, self).__init__(**kwargs) self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self.init_view()
def __init__(self, **kwargs): Builder.load_file(WIRELESS_CONFIG_VIEW_KV) super(WirelessConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.base_dir = kwargs.get('base_dir') btEnable = kvFind(self, 'rcid', 'btEnable') btEnable.bind(on_setting=self.on_bt_enable) btEnable.setControl(SettingsSwitch()) #btConfig = kvFind(self, 'rcid', 'btconfig') #btConfig.bind(on_setting=self.on_bt_configure) #btConfig.setControl(SettingsButton(text='Configure', disabled=True)) cellEnable = kvFind(self, 'rcid', 'cellEnable') cellEnable.bind(on_setting=self.on_cell_enable) cellEnable.setControl(SettingsSwitch()) cellProvider = kvFind(self, 'rcid', 'cellprovider') cellProvider.bind(on_setting=self.on_cell_provider) apnSpinner = SettingsMappedSpinner() self.loadApnSettingsSpinner(apnSpinner) self.apnSpinner = apnSpinner cellProvider.setControl(apnSpinner) self.apnHostField = kvFind(self, 'rcid', 'apnHost') self.apnUserField = kvFind(self, 'rcid', 'apnUser') self.apnPassField = kvFind(self, 'rcid', 'apnPass')
def __init__(self, settings, **kwargs): Builder.load_file(PREFERENCES_KV_FILE) super(PreferencesView, self).__init__(**kwargs) self.settings = settings self.base_dir = kwargs.get('base_dir') self.register_event_type('on_pref_change') self.settings_view = SettingsWithNoMenu() self.settings_view.bind(on_config_change=self._on_preferences_change) # So, Kivy's Settings object doesn't allow you to add multiple json panels at a time, only 1. If you add # multiple, the last one added 'wins'. So what we do is load the settings JSON ourselves and then merge it # with any platform-specific settings (if applicable). It's silly, but works. settings_json = json.loads( open( os.path.join(self.base_dir, 'resource', 'settings', 'settings.json')).read()) if platform == 'android': android_settings_json = json.loads( open( os.path.join(self.base_dir, 'resource', 'settings', 'android_settings.json')).read()) settings_json = settings_json + android_settings_json self.settings_view.add_json_panel('Preferences', self.settings.userPrefs.config, data=json.dumps(settings_json)) self.content = kvFind(self, 'rcid', 'preferences') self.content.add_widget(self.settings_view)
def __init__(self, **kwargs): Builder.load_file(DASHBOARD_VIEW_KV) super(DashboardView, self).__init__(**kwargs) self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self.init_view()
def build(self) -> App: self.title = "PathFinder" Builder.load_file('ui/ui_path_finder.kv') app = UiPathFinder() return app
def build(self): Builder.load_file(os.path.join(KV_DIRECTORY, "main.kv")) layout = Main() game = Game() layout.ventures = game.ventures game.calculate() return layout
def __init__(self, **kwargs): Builder.load_file(CAN_CONFIG_VIEW_KV) super(CANConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') btEnable = self.ids.can_enabled btEnable.bind(on_setting=self.on_can_enabled) btEnable.setControl(SettingsSwitch())
def __init__(self, **kwargs): Builder.load_file(ANALYSIS_VIEW_KV) super(AnalysisView, self).__init__(**kwargs) self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self._trackmanager = kwargs.get('trackmanager') self.init_view()
def __init__(self, **kwargs): Builder.load_file(LAPSTATS_VIEW_KV) super(LapStatsView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.ids.lapstats.setControl(SettingsSwitch()) self.ids.lapstats.bind(on_setting=self.on_lapstats_enabled) self.ids.predtime.setControl(SettingsSwitch()) self.ids.predtime.bind(on_setting=self.on_predtime_enabled)
def __init__(self, **kwargs): Builder.load_file(LAPSTATS_VIEW_KV) super(LapStatsView, self).__init__(**kwargs) self.register_event_type("on_config_updated") self.ids.lapstats.setControl(SettingsSwitch()) self.ids.lapstats.bind(on_setting=self.on_lapstats_enabled) self.ids.predtime.setControl(SettingsSwitch()) self.ids.predtime.bind(on_setting=self.on_predtime_enabled)
def __init__(self, **kwargs): Builder.load_file(ANALYSIS_VIEW_KV) super(AnalysisView, self).__init__(**kwargs) self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self._trackmanager = kwargs.get('trackmanager') self.init_view()
def __init__(self, track_manager, status_pump, **kwargs): Builder.load_file(STATUS_KV_FILE) super(StatusView, self).__init__(**kwargs) self.track_manager = track_manager self.register_event_type("on_tracks_updated") self._menu_node = self.ids.menu self._menu_node.bind(selected_node=self._on_menu_select) status_pump.add_listener(self.status_updated)
def __init__(self, **kwargs): Builder.load_file(CAN_CONFIG_VIEW_KV) super(CANConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') btEnable = self.ids.can_enabled btEnable.bind(on_setting=self.on_can_enabled) btEnable.setControl(SettingsSwitch())
def __init__(self, track_manager, status_pump, **kwargs): Builder.load_file(STATUS_KV_FILE) super(StatusView, self).__init__(**kwargs) self.track_manager = track_manager self.register_event_type('on_tracks_updated') self._menu_node = self.ids.menu self._menu_node.bind(selected_node=self._on_menu_select) status_pump.add_listener(self.status_updated)
def __init__(self, **kwargs): Builder.load_file(IMU_CHANNELS_VIEW_KV) super(ImuChannelsView, self).__init__(**kwargs) self.register_event_type('on_config_updated') imu_container = self.ids.imu_channels self.appendImuChannels(imu_container, self.editors, IMU_ACCEL_CHANNEL_IDS) self.appendImuChannels(imu_container, self.editors, IMU_GYRO_CHANNEL_IDS) self.ids.sr.bind(on_sample_rate = self.on_sample_rate)
def __init__(self, app): Builder.load_file("Dossier/Dossier.kv") super(Dossier, self).__init__() self.App = app self.grid = self.ids.grid self.grid.bind(minimum_height=self.grid.setter("height")) for i in self.load_chars(): btn = DossierButton(text=i.Name, char=i) btn.bind(on_press=self.btn_press) self.ids.grid.add_widget(btn)
def __init__(self, **kwargs): Builder.load_file(IMU_CHANNELS_VIEW_KV) super(ImuChannelsView, self).__init__(**kwargs) self.register_event_type('on_config_updated') imu_container = self.ids.imu_channels self.appendImuChannels(imu_container, self.editors, IMU_ACCEL_CHANNEL_IDS) self.appendImuChannels(imu_container, self.editors, IMU_GYRO_CHANNEL_IDS) self.ids.sr.bind(on_sample_rate=self.on_sample_rate)
def __init__(self, **kwargs): Builder.load_file(SCRIPT_VIEW_KV) super(LuaScriptingView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.register_event_type('on_run_script') self.register_event_type('on_poll_logfile') self.register_event_type('on_logfile') self.register_event_type('on_set_logfile_level') self.logfileView = kvFind(self, 'rcid', 'logfile') self.script_view = kvFind(self, 'rcid', 'script') self.logfileScrollView = kvFind(self, 'rcid', 'logfileSv')
def __init__(self, **kwargs): Builder.load_file(SCRIPT_VIEW_KV) super(LuaScriptingView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.register_event_type('on_run_script') self.register_event_type('on_poll_logfile') self.register_event_type('on_logfile') self.register_event_type('on_set_logfile_level') self.logfileView = kvFind(self, 'rcid', 'logfile') self.script_view = kvFind(self, 'rcid', 'script') self.logfileScrollView = kvFind(self, 'rcid', 'logfileSv')
def __init__(self, settings, **kwargs): Builder.load_file(PREFERENCES_KV_FILE) super(PreferencesView, self).__init__(**kwargs) self.settings = settings self.base_dir = kwargs.get('base_dir') self.settings_view = SettingsWithNoMenu() self.settings_view.add_json_panel('Preferences', self.settings.userPrefs.config, os.path.join(self.base_dir, 'resource', 'settings', 'settings.json')) self.content = kvFind(self, 'rcid', 'preferences') self.content.add_widget(self.settings_view)
def __init__(self, **kwargs): Builder.load_file(TELEMETRY_CONFIG_VIEW_KV) super(TelemetryConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') deviceId = kvFind(self, 'rcid', 'deviceId') deviceId.bind(on_setting=self.on_device_id) deviceId.setControl(SettingsTextField()) bgStream = kvFind(self, 'rcid', 'bgStream') bgStream.bind(on_setting=self.on_bg_stream) bgStream.setControl(SettingsSwitch())
def __init__(self, **kwargs): Builder.load_file(TELEMETRY_CONFIG_VIEW_KV) super(TelemetryConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') deviceId = kvFind(self, 'rcid', 'deviceId') deviceId.bind(on_setting=self.on_device_id) deviceId.setControl(SettingsTextField()) bgStream = kvFind(self, 'rcid', 'bgStream') bgStream.bind(on_setting=self.on_bg_stream) bgStream.setControl(SettingsSwitch())
def __init__(self, **kwargs): Builder.load_file(OBD2_CHANNELS_VIEW_KV) super(OBD2ChannelsView, self).__init__(**kwargs) self.register_event_type("on_config_updated") self.obd2_grid = self.ids.obd2grid obd2_enable = self.ids.obd2enable obd2_enable.bind(on_setting=self.on_obd2_enabled) obd2_enable.setControl(SettingsSwitch()) self.base_dir = kwargs.get("base_dir") self.obd2_settings = OBD2Settings(base_dir=self.base_dir) self.update_view_enabled()
def __init__(self, **kwargs): Builder.load_file(ANALYSIS_VIEW_KV) super(AnalysisView, self).__init__(**kwargs) self._datastore = CachingAnalysisDatastore() self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self._track_manager = kwargs.get('track_manager') self.ids.sessions_view.bind(on_lap_selected=self.lap_selected) self.ids.channelvalues.color_sequence = self._color_sequence self.ids.mainchart.color_sequence = self._color_sequence self.stream_connecting = False self.init_view()
def __init__(self, **kwargs): Builder.load_file(OBD2_CHANNELS_VIEW_KV) super(OBD2ChannelsView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.obd2_grid = self.ids.obd2grid obd2_enable = self.ids.obd2enable obd2_enable.bind(on_setting=self.on_obd2_enabled) obd2_enable.setControl(SettingsSwitch()) self.base_dir = kwargs.get('base_dir') self.obd2_settings = OBD2Settings(base_dir=self.base_dir) self.update_view_enabled()
def __init__(self, settings, **kwargs): Builder.load_file(PREFERENCES_KV_FILE) super(PreferencesView, self).__init__(**kwargs) self.settings = settings self.base_dir = kwargs.get('base_dir') self.settings_view = SettingsWithNoMenu() self.settings_view.add_json_panel( 'Preferences', self.settings.userPrefs.config, os.path.join(self.base_dir, 'resource', 'settings', 'settings.json')) self.content = kvFind(self, 'rcid', 'preferences') self.content.add_widget(self.settings_view)
def __init__(self, **kwargs): Builder.load_file(ANALYSIS_VIEW_KV) super(AnalysisView, self).__init__(**kwargs) self._datastore = CachingAnalysisDatastore() self.register_event_type('on_tracks_updated') self._databus = kwargs.get('dataBus') self._settings = kwargs.get('settings') self._track_manager = kwargs.get('track_manager') self.ids.sessions_view.bind(on_lap_selection=self.lap_selection) self.ids.channelvalues.color_sequence = self._color_sequence self.ids.mainchart.color_sequence = self._color_sequence self.stream_connecting = False Window.bind(mouse_pos=self.on_mouse_pos) Window.bind(on_motion=self.on_motion) self.init_view()
class LapStatsView(BaseConfigView): lap_config = None gps_config = None Builder.load_file(LAPSTATS_VIEW_KV) def __init__(self, **kwargs): super(LapStatsView, self).__init__(**kwargs) self.view_loaded = False self.register_event_type('on_config_updated') self.ids.lapstats.setControl(SettingsSwitch()) self.ids.lapstats.bind(on_setting=self.on_lapstats_enabled) self.ids.predtime.setControl(SettingsSwitch()) self.ids.predtime.bind(on_setting=self.on_predtime_enabled) def on_lapstats_enabled(self, instance, value): if not self.view_loaded: return if self.lap_config: lap_cfg = self.lap_config self._normalize_lap_config(lap_cfg, self.gps_config, value) lap_cfg.stale = True self.dispatch('on_modified') if not value: self.ids.predtime.setValue(False) def on_predtime_enabled(self, instance, value): if not self.view_loaded: return if self.lap_config: if value: # force lapstats enabled if we enable prdictive timing self.ids.lapstats.setValue(True) rate = LapConfig.DEFAULT_PREDICTED_TIME_SAMPLE_RATE if value else 0 config = self.lap_config config.predTime.sampleRate = rate config.stale = True self.dispatch('on_modified') def _normalize_lap_config(self, lap_cfg, gps_cfg, lapstats_enabled): gps_sample_rate = gps_cfg.sampleRate rate = gps_sample_rate if lapstats_enabled else 0 lap_cfg.set_primary_stats(rate) def on_config_updated(self, rcp_cfg): self.view_loaded = False lap_config = rcp_cfg.lapConfig gps_config = rcp_cfg.gpsConfig primary_stats_enabled = lap_config.primary_stats_enabled() self._normalize_lap_config(lap_config, gps_config, primary_stats_enabled) self.ids.lapstats.setValue(primary_stats_enabled) if lap_config.predTime.sampleRate > 0: self.ids.predtime.setValue(True) self.gps_config = rcp_cfg.gpsConfig self.lap_config = lap_config self.view_loaded = True
def __init__(self, **kwargs): Builder.load_file(CONFIG_VIEW_KV) super(ConfigView, self).__init__(**kwargs) self._databus = kwargs.get('databus') self.rc_config = kwargs.get('rcpConfig', None) self.rc_api = kwargs.get('rc_api', None) self._settings = kwargs.get('settings') self.base_dir = kwargs.get('base_dir') self.register_event_type('on_config_updated') self.register_event_type('on_channels_updated') self.register_event_type('on_config_written') self.register_event_type('on_tracks_updated') self.register_event_type('on_config_modified') self.register_event_type('on_read_config') self.register_event_type('on_write_config')
class TrackConfigView(BaseConfigView): Builder.load_file(TRACK_CONFIG_VIEW_KV) trackCfg = None trackDb = None screenManager = None manualTrackConfigView = None autoConfigView = None _databus = None def __init__(self, **kwargs): super(TrackConfigView, self).__init__(**kwargs) self._databus = kwargs.get('databus') self.register_event_type('on_config_updated') self.manualTrackConfigView = ManualTrackConfigScreen( name='manual', databus=self._databus) self.manualTrackConfigView.bind(on_modified=self.on_modified) self.autoConfigView = AutomaticTrackConfigScreen(name='auto') self.autoConfigView.bind(on_modified=self.on_modified) screenMgr = kvFind(self, 'rcid', 'screenmgr') screenMgr.add_widget(self.manualTrackConfigView) self.screenManager = screenMgr autoDetect = kvFind(self, 'rcid', 'autoDetect') autoDetect.bind(on_setting=self.on_auto_detect) autoDetect.setControl(SettingsSwitch()) self.autoConfigView.track_manager = kwargs.get('track_manager') def on_tracks_updated(self, track_manager): self.autoConfigView.track_manager = track_manager def on_config_updated(self, rcpCfg): trackCfg = rcpCfg.trackConfig trackDb = rcpCfg.trackDb autoDetectSwitch = kvFind(self, 'rcid', 'autoDetect') autoDetectSwitch.setValue(trackCfg.autoDetect) self.manualTrackConfigView.on_config_updated(rcpCfg) self.autoConfigView.on_config_updated(rcpCfg) self.trackCfg = trackCfg self.trackDb = trackDb def on_auto_detect(self, instance, value): if value: self.screenManager.switch_to(self.autoConfigView) else: self.screenManager.switch_to(self.manualTrackConfigView) if self.trackCfg: self.trackCfg.autoDetect = value self.trackCfg.stale = True self.dispatch('on_modified')
class WirelessConfigView(BaseConfigView): Builder.load_file(WIRELESS_CONFIG_VIEW_KV) def __init__(self, base_dir, config, capabilities, **kwargs): super(WirelessConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') self.register_event_type('on_config_modified') self.base_dir = base_dir self.rcp_capabilities = capabilities self.rcp_config = config self._views = [] self._render() self._attach_event_handlers() def _render(self): if not self.rcp_capabilities or (self.rcp_capabilities and self.rcp_capabilities.has_bluetooth): bluetooth_view = BluetoothConfigView(self.rcp_config) self.ids.wireless_settings.add_widget(bluetooth_view, index=0) self._views.append(bluetooth_view) if not self.rcp_capabilities or (self.rcp_capabilities and self.rcp_capabilities.has_wifi): wifi_view = WifiConfigView(self.base_dir, self.rcp_config) self.ids.wireless_settings.add_widget(wifi_view, index=0) self._views.append(wifi_view) if not self.rcp_capabilities or (self.rcp_capabilities and self.rcp_capabilities.has_cellular): cellular_view = CellularConfigView(self.base_dir, self.rcp_config) self.ids.wireless_settings.add_widget(cellular_view, index=0) self._views.append(cellular_view) def _attach_event_handlers(self): for view in self._views: view.bind(on_modified=self._on_views_modified) def on_config_updated(self, config): # Just destroy everything, re-render self.rcp_config = config self._update_view_configs() def _update_view_configs(self): for view in self._views: view.config_updated(self.rcp_config) def _on_views_modified(self, *args): Logger.debug( "WirelessConfigView: _on_views_modified args: {}".format(args)) Logger.debug("Got view modified") self.dispatch('on_config_modified') def on_config_modified(self, *args): pass
def build(self): self.init_view_builders() Builder.load_file('racecapture.kv') root = self.root status_bar = root.ids.status_bar status_bar.bind(on_main_menu=self.on_main_menu) self.status_bar = status_bar root.ids.main_menu.bind(on_main_menu_item=self.on_main_menu_item) self.mainNav = root.ids.main_nav # reveal_below_anim # reveal_below_simple # slide_above_anim # slide_above_simple # fade_in self.mainNav.anim_type = 'slide_above_anim' rc_api = self._rc_api rc_api.on_progress = lambda value: status_bar.dispatch( 'on_progress', value) rc_api.on_rx = lambda value: status_bar.dispatch('on_data_rx', value) screenMgr = root.ids.main # NoTransition # SlideTransition # SwapTransition # FadeTransition # WipeTransition # FallOutTransition # RiseInTransition screenMgr.transition = NoTransition( ) # FallOutTransition() # NoTransition() self.screenMgr = screenMgr self.icon = ('resource/images/app_icon_128x128.ico' if sys.platform == 'win32' else 'resource/images/app_icon_128x128.png') Clock.schedule_once(lambda dt: self.post_launch(), 1.0)
def __init__(self, settings, **kwargs): Builder.load_file(PREFERENCES_KV_FILE) super(PreferencesView, self).__init__(**kwargs) self.settings = settings self.base_dir = kwargs.get('base_dir') self.settings_view = SettingsWithNoMenu() # So, Kivy's Settings object doesn't allow you to add multiple json panels at a time, only 1. If you add # multiple, the last one added 'wins'. So what we do is load the settings JSON ourselves and then merge it # with any platform-specific settings (if applicable). It's silly, but works. settings_json = json.loads(open(os.path.join(self.base_dir, 'resource', 'settings', 'settings.json')).read()) if platform == 'android': android_settings_json = json.loads(open(os.path.join(self.base_dir, 'resource', 'settings', 'android_settings.json')).read()) settings_json = settings_json + android_settings_json self.settings_view.add_json_panel('Preferences', self.settings.userPrefs.config, data=json.dumps(settings_json)) self.content = kvFind(self, 'rcid', 'preferences') self.content.add_widget(self.settings_view)
def __init__(self, **kwargs): Builder.load_file(TRACK_CONFIG_VIEW_KV) super(TrackConfigView, self).__init__(**kwargs) self._databus = kwargs.get('databus') self.register_event_type('on_config_updated') self.manualTrackConfigView = ManualTrackConfigScreen(name='manual', databus=self._databus) self.manualTrackConfigView.bind(on_modified=self.on_modified) self.autoConfigView = AutomaticTrackConfigScreen(name='auto') self.autoConfigView.bind(on_modified=self.on_modified) screenMgr = kvFind(self, 'rcid', 'screenmgr') screenMgr.add_widget(self.manualTrackConfigView) self.screenManager = screenMgr autoDetect = kvFind(self, 'rcid', 'autoDetect') autoDetect.bind(on_setting=self.on_auto_detect) autoDetect.setControl(SettingsSwitch()) self.autoConfigView.track_manager = kwargs.get('track_manager')
class CANConfigView(BaseConfigView): can_config = None can_settings = [] Builder.load_file(CAN_CONFIG_VIEW_KV) def __init__(self, **kwargs): super(CANConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') btEnable = self.ids.can_enabled btEnable.bind(on_setting=self.on_can_enabled) btEnable.setControl(SettingsSwitch()) def on_can_enabled(self, instance, value): if self.can_config: self.can_config.enabled = value self.can_config.stale = True self.dispatch('on_modified') def on_can_baud(self, instance, value): if self.can_config: channel_id = instance.channel_id self.can_config.baudRate[channel_id] = value self.can_config.stale = True self.dispatch('on_modified') def on_config_updated(self, rcpCfg): can_config = rcpCfg.canConfig self.ids.can_enabled.setValue(can_config.enabled) self.update_can_baud_rates(rcpCfg) self.can_config = can_config def update_can_baud_rates(self, rcpCfg): can_config = rcpCfg.canConfig capabilities = rcpCfg.capabilities can_baud_container = self.ids.can_bauds current_children = can_baud_container.children can_channel_count = capabilities.channels.can if len(current_children) != can_channel_count: self.can_settings = [] can_baud_container.clear_widgets for i in range(0, can_channel_count): can_baud_rate_setting = CANBaudRateSettings() self.can_settings.append(can_baud_rate_setting) can_baud_rate_setting.channel_id = i can_baud_rate_setting.label_text = 'CAN {} Baud Rate'.format( i + 1) can_baud_rate_setting.setControl(CANBaudRateSpinner()) can_baud_rate_setting.bind(on_setting=self.on_can_baud) can_baud_container.add_widget(can_baud_rate_setting) for settings, baud in zip(self.can_settings, can_config.baudRate): settings.setValue(baud)
class TelemetryConfigView(BaseConfigView): connectivityConfig = None Builder.load_file(TELEMETRY_CONFIG_VIEW_KV) def __init__(self, capabilities, **kwargs): super(TelemetryConfigView, self).__init__(**kwargs) self.register_event_type('on_config_updated') deviceId = kvFind(self, 'rcid', 'deviceId') deviceId.bind(on_setting=self.on_device_id) deviceId.setControl(SettingsTextField()) self._bg_stream_view = None self.capabilities = capabilities self._render() def _render(self): if self.capabilities.has_cellular: separator = HLineSeparator() self.ids.content.add_widget(separator) bg_stream_view = BackgroundStreamingView() self.ids.content.add_widget(bg_stream_view) bg_stream_view.bind(on_modified=self._on_bg_stream_modified) self._bg_stream_view = bg_stream_view def _on_bg_stream_modified(self, *args): self.dispatch('on_config_modified') def on_device_id(self, instance, value): if self.connectivityConfig and value != self.connectivityConfig.telemetryConfig.deviceId: value = strip_whitespace(value) if len(value) > 0 and not self.validate_device_id(value): instance.set_error('Only numbers / letters allowed') else: #instance.setValue(value) self.connectivityConfig.telemetryConfig.deviceId = value self.connectivityConfig.stale = True self.dispatch('on_modified') instance.clear_error() def on_config_updated(self, rcpCfg): connectivityConfig = rcpCfg.connectivityConfig kvFind(self, 'rcid', 'deviceId').setValue( connectivityConfig.telemetryConfig.deviceId) self.connectivityConfig = connectivityConfig if self._bg_stream_view: self._bg_stream_view.on_config_updated(rcpCfg) def validate_device_id(self, device_id): return device_id.isalnum()
def build(self): self.init_view_builders() Builder.load_file('racecapture.kv') root = self.root status_bar = root.ids.status_bar status_bar.bind(on_main_menu=self.on_main_menu) self.status_bar = status_bar root.ids.main_menu.bind(on_main_menu_item=self.on_main_menu_item) self.mainNav = root.ids.main_nav #reveal_below_anim #reveal_below_simple #slide_above_anim #slide_above_simple #fade_in self.mainNav.anim_type = 'slide_above_anim' rc_api = self._rc_api rc_api.on_progress = lambda value: status_bar.dispatch('on_progress', value) rc_api.on_rx = lambda value: status_bar.dispatch('on_rc_rx', value) rc_api.on_tx = lambda value: status_bar.dispatch('on_rc_tx', value) screenMgr = root.ids.main #NoTransition #SlideTransition #SwapTransition #FadeTransition #WipeTransition #FallOutTransition #RiseInTransition screenMgr.transition=NoTransition() self.screenMgr = screenMgr self.icon = ('resource/images/app_icon_128x128.ico' if sys.platform == 'win32' else 'resource/images/app_icon_128x128.png') Clock.schedule_once(lambda dt: self.post_launch(), 1.0)
def __init__(self, **kwargs): Builder.load_file(TRACK_CONFIG_VIEW_KV) super(TrackConfigView, self).__init__(**kwargs) self._databus = kwargs.get('databus') self.register_event_type('on_config_updated') self.manualTrackConfigView = ManualTrackConfigScreen( name='manual', databus=self._databus) self.manualTrackConfigView.bind(on_modified=self.on_modified) self.autoConfigView = AutomaticTrackConfigScreen(name='auto') self.autoConfigView.bind(on_modified=self.on_modified) screenMgr = kvFind(self, 'rcid', 'screenmgr') screenMgr.add_widget(self.manualTrackConfigView) self.screenManager = screenMgr autoDetect = kvFind(self, 'rcid', 'autoDetect') autoDetect.bind(on_setting=self.on_auto_detect) autoDetect.setControl(SettingsSwitch()) self.autoConfigView.track_manager = kwargs.get('track_manager')
def build(self): Config.set("graphics", "width", X) Config.set("graphics", "height", Y) self.x = X self.y = Y self.home_country = "" self.destination_country = "" self.home_code = "" self.destination_code = "" self.title = "App" self.root = Builder.load_file('gui.kv') self.currency_rates = [] self.app_can_run = True return self.root
class PulseChannelsView(BaseMultiChannelConfigView): Builder.load_file(TIMER_CHANNELS_VIEW_KV) def __init__(self, **kwargs): super(PulseChannelsView, self).__init__(**kwargs) self.channel_title = 'Timer ' self.accordion_item_height = sp(150) def channel_builder(self, index, max_sample_rate): editor = PulseChannel(id='timer' + str(index), channels=self.channels) editor.bind(on_modified=self.on_modified) if self.config: editor.on_config_updated(self.config.channels[index], max_sample_rate) return editor def get_specific_config(self, rcp_cfg): return rcp_cfg.timerConfig
class GPIOChannelsView(BaseMultiChannelConfigView): Builder.load_file(GPIO_CHANNELS_VIEW_KV) def __init__(self, **kwargs): super(GPIOChannelsView, self).__init__(**kwargs) self.channel_title = 'Digital Input/Output ' self.accordion_item_height = sp(120) def channel_builder(self, index, max_sample_rate): editor = GPIOChannel(id='gpio' + str(index), channels=self.channels) editor.bind(on_modified=self.on_modified) if self.config: editor.on_config_updated(self.config.channels[index], max_sample_rate) return editor def get_specific_config(self, rcp_cfg): return rcp_cfg.gpioConfig
class AnalogPulseOutputChannelsView(BaseMultiChannelConfigView): Builder.load_file(ANALOG_PULSE_CHANNELS_VIEW_KV) def __init__(self, **kwargs): super(AnalogPulseOutputChannelsView, self).__init__(**kwargs) self.channel_title = 'Pulse / Analog Output ' self.accordion_item_height = sp(200) def channel_builder(self, index, max_sample_rate): editor = AnalogPulseOutputChannel(id='pwm' + str(index), channels=self.channels) editor.bind(on_modified=self.on_modified) if self.config: editor.on_config_updated(self.config.channels[index], max_sample_rate) return editor def get_specific_config(self, rcp_cfg): return rcp_cfg.pwmConfig
from autosportlabs.racecapture.views.util.alertview import alertPopup from autosportlabs.racecapture.views.analysis.analysiswidget import ChannelAnalysisWidget from autosportlabs.racecapture.views.analysis.markerevent import MarkerEvent from autosportlabs.racecapture.datastore import Filter from autosportlabs.racecapture.views.analysis.analysisdata import ChannelData from autosportlabs.uix.progressspinner import ProgressSpinner from autosportlabs.uix.options.optionsview import OptionsView, BaseOptionsScreen from autosportlabs.racecapture.views.analysis.customizechannelsview import CustomizeChannelsView from autosportlabs.uix.button.widgetbuttons import LabelButton from autosportlabs.racecapture.theme.color import ColorScheme from autosportlabs.uix.toast.kivytoast import toast from fieldlabel import FieldLabel from iconbutton import IconButton, LabelIconButton from autosportlabs.racecapture.views.util.viewutils import format_laptime Builder.load_file('autosportlabs/racecapture/views/analysis/linechart.kv') class ChannelPlot(object): def __init__(self, plot, channel, min_value, max_value, sourceref): self.lap = None self.chart_x_index = None self.plot = plot self.channel = channel self.min_value = min_value self.max_value = max_value self.sourceref = sourceref def __str__(self): return "{}_{}".format(str(self.sourceref), self.channel)
# See the GNU General Public License for more details. You should #have received a copy of the GNU General Public License along with #this code. If not, see <http://www.gnu.org/licenses/>. import kivy kivy.require('1.9.0') from kivy.logger import Logger from kivy.app import Builder from kivy.clock import Clock from kivy.uix.anchorlayout import AnchorLayout from iconbutton import IconButton from autosportlabs.racecapture.views.channels.channelselectview import ChannelSelectView from autosportlabs.racecapture.views.analysis.customizechannelsview import CustomizeChannelsView from autosportlabs.racecapture.views.analysis.markerevent import SourceRef from kivy.uix.popup import Popup from kivy.properties import BooleanProperty, ObjectProperty Builder.load_file('autosportlabs/racecapture/views/analysis/analysiswidget.kv') class OptionsButton(AnchorLayout): pass class AnalysisWidget(AnchorLayout): """ The base for all analysis UI widgets This base class can handle the addition / removal of laps selected for viewing. Selected laps are the basis for determining what data is displayed in a particular widget. Extend this class directly when you want to create a widget that specifically controls the data to be displayed, such as the analysis map. """ options_enabled = BooleanProperty(None)
from kivy.metrics import dp from kivy.uix.boxlayout import BoxLayout from kivy.uix.listview import ListView, ListItemButton from kivy.uix.screenmanager import Screen, SwapTransition from utils import kvFind from kivy.adapters.listadapter import ListAdapter from iconbutton import IconButton from autosportlabs.uix.button.featurebutton import FeatureButton from autosportlabs.racecapture.views.util.alertview import alertPopup from autosportlabs.racecapture.views.file.loaddialogview import LoadDialog from autosportlabs.racecapture.views.file.savedialogview import SaveDialog from autosportlabs.racecapture.views.channels.channelselectview import ChannelSelectorView from iconbutton import IconButton from fieldlabel import FieldLabel Builder.load_file('autosportlabs/racecapture/views/analysis/customizechannelsview.kv') class CustomizeChannelsView(BoxLayout): def __init__(self, **kwargs): super(CustomizeChannelsView, self).__init__(**kwargs) self.register_event_type('on_channels_customized') self.datastore = kwargs.get('datastore') channels = kwargs.get('current_channels') screen_manager = self.ids.screens screen_manager.transition = SwapTransition() add_channels_view = AddChannelsView(name='add') current_channels_view = CurrentChannelsView(name='current') current_channels_view.bind(on_confirm_customize=self.confirm_customize) current_channels_view.bind(on_add_channels=self.add_channels)
import kivy kivy.require('1.9.0') from iconbutton import IconButton from kivy.app import Builder from kivy.metrics import dp from kivy.uix.floatlayout import FloatLayout from kivy.uix.boxlayout import BoxLayout from kivy.uix.listview import ListView, ListItemButton from utils import kvFind from kivy.adapters.listadapter import ListAdapter from kivy.properties import ListProperty from kivy.logger import Logger Builder.load_file('autosportlabs/racecapture/views/channels/channelselectview.kv') class ChannelItemButton(ListItemButton): def __init__(self, **kwargs): super(ChannelItemButton, self).__init__(**kwargs) class ChannelSelectorView(BoxLayout): channels = ListProperty() def __init__(self, **kwargs): super(ChannelSelectorView, self).__init__(**kwargs) self.multi_select = False self.register_event_type('on_channel_selected') self.multi_select = kwargs.get('multi_select', self.multi_select) def select_channel(self, channels): ''' Select one or more channels to show as selected in the view. the view.trigger_action is some voodoo that simulates a UI selection.
#this code. If not, see <http://www.gnu.org/licenses/>. import kivy kivy.require('1.9.1') from kivy.logger import Logger from kivy.graphics import Color from kivy.app import Builder from kivy.clock import Clock from kivy.uix.boxlayout import BoxLayout from kivy.properties import ObjectProperty from autosportlabs.widgets.scrollcontainer import ScrollContainer from autosportlabs.racecapture.datastore import DataStore, Filter from autosportlabs.racecapture.views.analysis.markerevent import SourceRef from autosportlabs.racecapture.views.analysis.analysiswidget import ChannelAnalysisWidget from autosportlabs.uix.gauge.bargraphgauge import BarGraphGauge Builder.load_file('autosportlabs/racecapture/views/analysis/channelvaluesview.kv') class ChannelValueView(BoxLayout): def __init__(self, **kwargs): super(ChannelValueView, self).__init__(**kwargs) self.session_view = self.ids.session self.lap_view = self.ids.lap self.channel_view = self.ids.channel self.value_view = self.ids.value @property def session(self): return self.session_view.text @session.setter
def __init__(self, **kwargs): Builder.load_file(ANALOG_CHANNELS_VIEW_KV) super(AnalogChannelsView, self).__init__(**kwargs) self.channel_title = 'Analog ' self.accordion_item_height = dp(80)
import kivy kivy.require('1.9.0') from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.app import Builder from kivy.uix.screenmanager import Screen, ScreenManager from kivy.clock import Clock from utils import kvFind from kivy.properties import ObjectProperty from autosportlabs.racecapture.views.dashboard.widgets.digitalgauge import DigitalGauge from kivy.properties import StringProperty from kivy.graphics import Color, Rectangle Builder.load_file('autosportlabs/racecapture/views/dashboard/rawchannelview.kv') NO_DATA_MSG = 'No Data' DATA_MSG = '' RAW_GRID_BGCOLOR_1 = [0 , 0 , 0 , 1.0] RAW_GRID_BGCOLOR_2 = [0.1, 0.1, 0.1, 1.0] RAW_NORMAL_COLOR = [0.0, 1.0, 0.0, 1.0] class RawGauge(DigitalGauge): backgroundColor = ObjectProperty(RAW_GRID_BGCOLOR_1) def __init__(self, **kwargs): super(RawGauge , self).__init__(**kwargs) self.normal_color = RAW_NORMAL_COLOR def update_colors(self): color = self.select_alert_color()
import kivy kivy.require('1.9.1') from iconbutton import IconButton from kivy.app import Builder from kivy.metrics import dp from kivy.uix.floatlayout import FloatLayout from kivy.uix.boxlayout import BoxLayout from kivy.uix.listview import ListView, ListItemButton from utils import kvFind from kivy.adapters.listadapter import ListAdapter from kivy.properties import ListProperty from kivy.logger import Logger Builder.load_file( 'autosportlabs/racecapture/views/channels/channelselectview.kv') class ChannelItemButton(ListItemButton): def __init__(self, **kwargs): super(ChannelItemButton, self).__init__(**kwargs) class ChannelSelectorView(BoxLayout): channels = ListProperty() def __init__(self, **kwargs): super(ChannelSelectorView, self).__init__(**kwargs) self.multi_select = False self.register_event_type('on_channel_selected') self.multi_select = kwargs.get('multi_select', self.multi_select)
import kivy kivy.require('1.8.0') from iconbutton import IconButton from kivy.app import Builder from kivy.metrics import dp from kivy.uix.popup import Popup from kivy.uix.floatlayout import FloatLayout from kivy.uix.relativelayout import RelativeLayout from fieldlabel import FieldLabel from kivy.uix.slider import Slider from utils import kvFind from autosportlabs.racecapture.views.color.colorpickerview import ColorBlock from autosportlabs.racecapture.settings.prefs import Range from autosportlabs.racecapture.views.color.colorpickerview import ColorPickerView Builder.load_file( 'autosportlabs/racecapture/views/channels/channelcustomizationview.kv') class RangeLabel(FieldLabel): pass class ChannelCustomizationView(FloatLayout): _popup = None def __init__(self, **kwargs): self.settings = None self.channel = None self.channelMeta = None self.warnRange = Range()
def __init__(self, **kwargs): Builder.load_file(ANALOG_PULSE_CHANNELS_VIEW_KV) super(AnalogPulseOutputChannelsView, self).__init__(**kwargs) self.channel_title = "Pulse / Analog Output " self.accordion_item_height = dp(100)
import kivy kivy.require('1.9.0') from kivy.uix.boxlayout import BoxLayout from kivy.app import Builder from kivy.metrics import dp from utils import kvFind, kvquery from kivy.properties import NumericProperty, ObjectProperty from autosportlabs.racecapture.views.dashboard.widgets.gauge import CustomizableGauge Builder.load_file('autosportlabs/racecapture/views/dashboard/widgets/digitalgauge.kv') DEFAULT_BACKGROUND_COLOR = [0, 0, 0, 0] class DigitalGauge(CustomizableGauge): alert_background_color = ObjectProperty(DEFAULT_BACKGROUND_COLOR) def __init__(self, **kwargs): super(DigitalGauge, self).__init__(**kwargs) self.normal_color = DEFAULT_BACKGROUND_COLOR def update_title(self, channel, channel_meta): try: self.title = channel if channel else '' except Exception as e: print('Failed to update digital gauge title ' + str(e)) def updateColors(self): self.alert_background_color = self.select_alert_color()
import kivy kivy.require('1.9.0') from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.app import Builder from kivy.uix.screenmanager import Screen, ScreenManager from kivy.clock import Clock from autosportlabs.racecapture.views.dashboard.widgets.tachometer import Tachometer from autosportlabs.racecapture.views.dashboard.widgets.bignumberview import BigNumberView from autosportlabs.racecapture.views.dashboard.widgets.laptime import Laptime from autosportlabs.racecapture.views.dashboard.widgets.timedelta import TimeDelta from autosportlabs.racecapture.views.dashboard.widgets.gauge import Gauge from utils import kvFind, kvFindClass Builder.load_file('autosportlabs/racecapture/views/dashboard/tachometerview.kv') class TachometerView(Screen): _databus = None _settings = None def __init__(self, databus, settings, **kwargs): super(TachometerView, self).__init__(**kwargs) self._databus = databus self._settings = settings self.initScreen() def on_meta(self, channelMetas): pass def initScreen(self):
def build(self): self.title="Convert Miles to Kilometres" self.root=Builder.load_file("km_converter.kv") return self.root
import math kivy.require('1.9.1') from autosportlabs.uix.color import colorgradient from kivy.uix.label import Label from kivy.uix.floatlayout import FloatLayout from kivy.uix.widget import Widget from kivy.uix.scatter import Scatter from kivy.app import Builder from kivy.metrics import sp from kivy.properties import ListProperty, NumericProperty from kivy.graphics import Color, Line, Bezier, Rectangle from autosportlabs.racecapture.geo.geopoint import GeoPoint from autosportlabs.uix.color.colorgradient import HeatColorGradient, SimpleColorGradient from utils import * Builder.load_file('autosportlabs/uix/track/trackmap.kv') class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y class MarkerPoint(Point): def __init__(self, color): super(MarkerPoint, self).__init__(0, 0) self.color = color class TrackPath(object): def __init__(self, path, color):
import kivy kivy.require('1.8.0') from kivy.uix.anchorlayout import AnchorLayout from kivy.uix.label import Label from kivy.app import Builder from collections import OrderedDict from kivy.metrics import dp from kivy.graphics import Color from autosportlabs.racecapture.views.dashboard.widgets.fontgraphicalgauge import FontGraphicalGauge Builder.load_file( 'autosportlabs/racecapture/views/dashboard/widgets/tachometer.kv') TACH_RANGES = OrderedDict([(7000, 'resource/fonts/tach_7000.ttf'), (10000, 'resource/fonts/tach_10000.ttf'), (15000, 'resource/fonts/tach_15000.ttf')]) class Tachometer(FontGraphicalGauge): def __init__(self, **kwargs): super(Tachometer, self).__init__(**kwargs) self.initWidgets() def initWidgets(self): pass def configureRangeFont(self, max): graphView = self.graphView lastRangeFont = None lastRange = 0
import kivy kivy.require('1.9.0') from kivy.uix.boxlayout import BoxLayout from kivy.app import Builder from kivy.properties import StringProperty, ListProperty, BooleanProperty from autosportlabs.racecapture.theme.color import ColorScheme from fieldlabel import FieldLabel from utils import kvFind import mainfonts Builder.load_file('autosportlabs/racecapture/menu/mainmenu.kv') class MainMenuItem(BoxLayout): disabledColor = (0.3, 0.3, 0.3, 1.0) enabledColor = (1.0, 1.0, 1.0, 1.0) rcid = None icon = StringProperty('') description = StringProperty('') enabled = BooleanProperty(True) def __init__(self, **kwargs): super(MainMenuItem, self).__init__(**kwargs) self.bind(icon = self.on_icon_text) self.bind(description = self.on_description_text) rcid = kwargs.get('rcid', None) self.register_event_type('on_main_menu_item_selected') def setEnabledDisabledColor(self, widget): if self.enabled: widget.color = self.enabledColor