def set_touch_enabled(self, enabled): """Enable or disable the touchpads and update the indicator status and menu items. :param enabled: If True enable the touchpads.""" if enabled and not self.touchpad.are_all_touchpad_enabled(): if self.touchpad.enable_all_touchpads(): if self.show_notifications: self.show_notification('enabled') self.change_state_item.set_label(_('Disable Touchpad')) if self.indicator.get_status( ) != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status( appindicator.IndicatorStatus.ACTIVE) configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save() elif not enabled and self.touchpad.are_all_touchpad_enabled(): if self.touchpad.disable_all_touchpads(): if self.show_notifications: self.show_notification('disabled') self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status( ) != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status( appindicator.IndicatorStatus.ATTENTION) configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save()
def load_preferences(self): configuration = Configuration() self.a24h = configuration.get('24h') if self.widgetnumber == 0: x = configuration.get('wp1-x') y = configuration.get('wp1-y') self.location = configuration.get('location') self.showwidget = configuration.get('widget1') self.hideindicator = configuration.get('onwidget1hide') self.set_keep_above(configuration.get('onwidget1top')) self.is_set_keep_above(configuration.get('onwidget1top')) self.set_keep_below(not configuration.get('onwidget1top')) self.set_skip_taskbar_hint(not configuration.get('showintaskbar1')) if configuration.get('onalldesktop1'): self.stick() else: self.unstick() self.skin = configuration.get('skin1') else: x = configuration.get('wp2-x') y = configuration.get('wp2-y') self.location = configuration.get('location2') self.showwidget = configuration.get('widget2') self.hideindicator = configuration.get('onwidget2hide') self.set_keep_above(configuration.get('onwidget2top')) self.is_set_keep_above(configuration.get('onwidget2top')) self.set_keep_below(not configuration.get('onwidget2top')) self.set_skip_taskbar_hint(not configuration.get('showintaskbar2')) if configuration.get('onalldesktop2'): self.stick() else: self.unstick() self.skin = configuration.get('skin2') self.move(x, y)
def save(self): configuration = Configuration() stats = configuration.get('stats') for day in self.data.keys(): stats[day] = self.data[day] configuration.set('stats', stats) configuration.save()
def __init__(self, parent): wx.Notebook.__init__(self, parent, id=-1, style=wx.NB_LEFT, name='NotebookNameStr') # initialize notebook self.cfg = Configuration(self) # get default configuration settings self.configPanel = configPanel( self, mon_num=1, cfg=self.cfg) # create configuration page self.AddPage(self.configPanel, 'Configuration') self.maskPanel = maskPanel(self) # create mask maker page self.AddPage(self.maskPanel, 'Masks') self.acquirePanel = acquirePanel(self, self.cfg) # create acquire page self.AddPage(self.acquirePanel, 'Acquire') self.binningPanel = binningPanel(self) # create binning page self.AddPage(self.binningPanel, 'DAM File Scan 110X') self.SCAMPPanel = SCAMPPanel(self) # create SCAMP page self.AddPage(self.SCAMPPanel, 'SCAMP') # self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging) self.Layout()
def load(self): configuration = Configuration() preferences = configuration.get('preferences') projects = preferences['projects'] contexts = preferences['contexts'] project_store = self.project.get_model() project_store.clear() project_store.append(['-', '-']) if projects: for project in projects: project_store.append([project, project]) self.project.set_model(project_store) context_store = self.context.get_model() context_store.clear() context_store.append(['-', '-']) if contexts: for context in contexts: context_store.append([context, context]) self.context.set_model(context_store) select_value_in_combo(self.priority, -1) select_value_in_combo(self.project, '-') select_value_in_combo(self.context, '-') todo_file = Path(os.path.expanduser(preferences['todo-file'])) if not todo_file.exists(): if not todo_file.parent.exists(): os.makedirs(todo_file.parent) todo_file.touch() self.todo_file = todo_file.as_posix() self.load_todos()
def save_preferences(self): if os.path.exists(comun.TOKEN_FILE): configuration = Configuration() configuration.set('version', comun.VERSION) configuration.set('time', self.spin3.get_value()) if self.switch5.get_active(): configuration.set('theme', 'light') else: configuration.set('theme', 'dark') calendars = [] aiter = self.store.get_iter_first() while (aiter is not None): calendar = {} calendar['id'] = self.store.get_value(aiter, 3) calendar['background'] = self.store.get_value(aiter, 1) calendar['foreground'] = self.store.get_value(aiter, 2) calendar['visible'] = self.store.get_value(aiter, 4) calendar['name'] = self.store.get_value(aiter, 5) calendars.append(calendar) aiter = self.store.iter_next(aiter) configuration.set('calendars', calendars) configuration.save() filestart = os.path.join( os.getenv("HOME"), ".config/autostart/calendar-indicator-autostart.desktop") if self.switch4.get_active(): if not os.path.exists(filestart): if not os.path.exists(os.path.dirname(filestart)): os.makedirs(os.path.dirname(filestart)) shutil.copyfile( '/opt/extras.ubuntu.com/calendar-indicator/share/calendar-indicator/calendar-indicator-autostart.desktop', filestart) else: if os.path.exists(filestart): os.remove(filestart)
def save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['https_protocol'] = self.https_protocol.get_active() preferences['base_url'] = self.base_url.get_text() preferences['application_name'] = self.application_name.get_text() preferences['application_token'] = self.application_token.get_text() preferences['client_token'] = self.client_token.get_text() preferences['theme-light'] = self.theme_light.get_active() configuration.set('preferences', preferences) configuration.save() autostart_file = 'gotify-indicator-autostart.desktop' autostart_file = os.path.join(os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def show_statistics(self, widget): widget.set_sensitive(False) if self.is_monitoring and self.monitor is not None: self.monitor.save() title = _('Habits') subtitle = _('Mouse and keyboard') configuration = Configuration() stats = configuration.get('stats') days = [] distance = [] clics = [] keys = [] for day in stats: days.append(day) if 'distance' in stats[day].keys(): distance.append(stats[day]['distance']/1000.0) else: distance.append(0) if 'clics' in stats[day].keys(): clics.append(stats[day]['clics']) else: clics.append(0) if 'keys' in stats[day].keys(): keys.append(stats[day]['keys']) else: keys.append(0) graph = Graph(title, subtitle, days, distance, clics, keys) graph.run() graph.destroy() widget.set_sensitive(True)
def save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['theme-light'] = self.theme_light.get_active() preferences['todos'] = int(self.todos.get_value()) preferences['todo-file'] = self.todo_file.get_file().get_path() preferences['projects'] = self.projects.get_items() preferences['contexts'] = self.contexts.get_items() preferences['tags'] = self.tags.get_items() preferences['hide-completed'] = self.hide_completed.get_active() preferences['filter-projects'] = self.filter_projects.get_active() preferences['keybindings'] = [ { 'name': 'new_task', 'keybind': self.new_task_keybinding.get_text() }, { 'name': 'show_tasks', 'keybind': self.show_tasks_keybinding.get_text() }, ] configuration.set('preferences', preferences) configuration.save() autostart_file = 'todotxt-indicator-autostart.desktop' autostart_file = os.path.join(os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def show_statistics(self, widget): widget.set_sensitive(False) title = _('Tasker') subtitle = _('Tasks statistics') configuration = Configuration() preferences = self.configuration.get('preferences') mc = CURRENCIES[self.main_currency] currencies = [] for i in range(0, 5): currencies.append(CURRENCIES[self.currencies[i]]) days = [] c0 = [] c1 = [] c2 = [] c3 = [] c4 = [] for aday in self.exchange.data: days.append(aday['date']) mc = aday[self.main_currency.lower()] c0.append(round(aday[self.currencies[0].lower()] / mc)) c1.append(round(aday[self.currencies[1].lower()] / mc)) c2.append(round(aday[self.currencies[2].lower()] / mc)) c3.append(round(aday[self.currencies[3].lower()] / mc)) c4.append(round(aday[self.currencies[4].lower()] / mc)) graph = Graph(title, subtitle, currencies, days, c0, c1, c2, c3, c4) graph.run() graph.destroy() widget.set_sensitive(True)
def set_active(self): self.store.clear() configuration = Configuration() calendars_options = configuration.get('calendars') if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file=comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() for calendar in calendars: calendar_options = get_calendar_from_options( configuration.get('calendars'), calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex() foreground_color = contraste(background_color) visible = True calendar_name = calendar['summary'] self.store.append([ calendar['summary'], background_color, foreground_color, calendar['id'], visible, calendar_name ])
def save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['theme-light'] = self.theme_light.get_active() preferences['start-actived'] = self.start_actived.get_active() preferences['units'] = get_selected_value_in_combo(self.units) preferences['distance-color'] = convert_rgb2hex( self.distance_color.get_rgba()) preferences['clics-color'] = convert_rgb2hex( self.clics_color.get_rgba()) preferences['keys-color'] = convert_rgb2hex( self.keys_color.get_rgba()) configuration.set('preferences', preferences) configuration.save() autostart_file = 'habits-autostart.desktop' autostart_file = os.path.join( os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def __init__(self, *args, **kwds): wx.Frame.__init__(self, None, id=wx.ID_ANY, size=(1000, 200)) cfg = Configuration(self) acquirePanel(self, cfg, size=(1000, 300)) print('done.')
def load_preferences(self): configuration = Configuration() self.show_disks.set_active(configuration.get('show-hdd')) self.show_net.set_active(configuration.get('show-net')) filestart = os.path.join( os.getenv("HOME"), ".config/autostart/indicator-usb-autostart.desktop") self.autostart.set_active(os.path.exists(filestart))
def check_status_from_resume(self): configuration = Configuration() self.touchpad_enabled = configuration.get('touchpad_enabled') if self.touchpad_enabled != self.touchpad.are_all_touchpad_enabled(): self.set_touch_enabled(self.touchpad_enabled) if self.on_mouse_plugged and not self.touchpad_enabled: if not is_mouse_plugged(): self.set_touch_enabled(True)
def on_options_changed(self, widget, data): configuration = Configuration() configuration.set('time', self.options['time'].get_value()) if self.options['theme'].get_active(): configuration.set('theme', 'dark') else: configuration.set('theme', 'light') configuration.save()
def __init__(self, title=""): configuration = Configuration() preferences = configuration.get("preferences") self.todo_histoy = (Path(os.path.expanduser( preferences["todo-file"])).parent.as_posix() + os.sep + "todo.history.txt") BaseGraph.__init__(self, title, "") self.subtitle = ""
def set_active(self): configuration = Configuration() self.options['time'].set_value(configuration.get('time')) self.options['theme'].set_active(configuration.get('theme') == 'light') filestart = os.path.join( os.getenv("HOME"), ".config/autostart/calendar-indicator-autostart.desktop") self.options['autostart'].set_active(os.path.exists(filestart))
def load_preferences(self): configuration = Configuration() self.time = configuration.get('time') self.theme = configuration.get('theme') self.calendars = configuration.get('calendars') self.visible_calendars = [] for calendar in self.calendars: if calendar['visible']: self.visible_calendars.append(calendar['id'])
def __init__(self, title='', subtitle=''): self.title = _(title) self.configuration = Configuration() preferences = self.configuration.get('preferences') todo_file = Path(os.path.expanduser(preferences['todo-file'])) self.todo_file = todo_file.as_posix() self.subtitle = _(subtitle) BaseDialog.__init__(self, title, None, ok_button=False, cancel_button=False)
def _build_plugins(self, ): page06 = self._new_page("Plugins") plugins = ListBoxPlugins() configuration = Configuration() plugins.add_all(configuration.get_plugins()) plugins.set_size_request(300, 300) self.plugins = plugins page06.attach(plugins, 0, 0, 1, 1)