def onClose(self, event): """Closes help dialog. Saves checkbox state as needed.""" if self.cb_show_at_start.GetValue() is True: current_settings = GeneralSettingsData() if current_settings.show_help is False: current_settings.show_help = True current_settings.save_settings() else: # Save that the help at start is not wanted. current_settings = GeneralSettingsData() show_help = current_settings.show_help if show_help: current_settings.show_help = False current_settings.save_settings() self.frame.Close(True)
def onSave(self, event): """Saves settings to file.""" current_settings = GeneralSettingsData() show_help = current_settings.show_help fname = os.path.join(CONFIG_PATH, "general_settings") general_settings_file = open(fname, "w") if self.cb_logging.GetValue(): general_settings_file.write("logging=true\n") else: general_settings_file.write("logging=false\n") if self.cb_usehotkeys.GetValue(): general_settings_file.write("use hotkeys=true\n") else: general_settings_file.write("use hotkeys=false\n") general_settings_file.write("next wallpaper hotkey=" + self.tc_hk_next.GetLineText(0) + "\n") general_settings_file.write("pause wallpaper hotkey=" + self.tc_hk_pause.GetLineText(0) + "\n") if show_help: general_settings_file.write("show_help_at_start=true\n") else: general_settings_file.write("show_help_at_start=false\n") general_settings_file.write("set_command=" + self.tc_setcmd.GetLineText(0)) general_settings_file.close() # after saving file apply in tray object self.parent_tray_obj.read_general_settings()
def read_general_settings(self): """Refreshes general settings from file and applies hotkey bindings.""" self.g_settings = GeneralSettingsData() self.register_hotkeys() msg = "New settings are applied after an application restart. \ New hotkeys are registered." show_message_dialog(msg, "Info")
def update_fields(self): """Updates dialog field contents.""" g_settings = GeneralSettingsData() self.cb_logging.SetValue(g_settings.logging) self.cb_usehotkeys.SetValue(g_settings.use_hotkeys) self.tc_hk_next.ChangeValue( self.show_hkbinding(g_settings.hk_binding_next)) self.tc_hk_pause.ChangeValue( self.show_hkbinding(g_settings.hk_binding_pause)) self.tc_setcmd.ChangeValue(g_settings.set_command)
def read_general_settings(self): """Refreshes general settings from file and applies hotkey bindings.""" self.g_settings = GeneralSettingsData() try: self.seen_binding except NameError: self.seen_binding = set() self.register_hotkeys() if self.g_settings.logging: msg = "Logging is enabled after an application restart." show_message_dialog(msg, "Info")
def __init__(self, frame): self.g_settings = GeneralSettingsData() self.frame = frame super(TaskBarIcon, self).__init__() self.set_icon(TRAY_ICON) # self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.configure_wallpapers) # Initialize display data # get_display_data() wpproc.refresh_display_data() # profile initialization self.job_lock = Lock() self.repeating_timer = None self.pause_item = None self.is_paused = False # if sp_logging.DEBUG: # sp_logging.G_LOGGER.info("START Listing profiles for menu.") self.list_of_profiles = list_profiles() # if sp_logging.DEBUG: # sp_logging.G_LOGGER.info("END Listing profiles for menu.") # Should now return an object if a previous profile was written or # None if no previous data was found if STARTUP_PROFILE: self.active_profile = open_profile(STARTUP_PROFILE) else: self.active_profile = read_active_profile() if self.active_profile: wpproc.G_ACTIVE_PROFILE = self.active_profile.name self.start_prev_profile(self.active_profile) # if self.active_profile is None: # sp_logging.G_LOGGER.info("Starting up the first profile found.") # self.start_profile(wx.EVT_MENU, self.list_of_profiles[0]) # self.hk = None # self.hk2 = None if self.g_settings.use_hotkeys is True: try: # import keyboard # https://github.com/boppreh/keyboard # This import is here to have the module in the class scope from system_hotkey import SystemHotkey self.hk = SystemHotkey(check_queue_interval=0.05) self.hk2 = SystemHotkey(consumer=self.profile_consumer, check_queue_interval=0.05) self.seen_binding = set() self.register_hotkeys() except ImportError as excep: sp_logging.G_LOGGER.info( "WARNING: Could not import keyboard hotkey hook library, \ hotkeys will not work. Exception: %s", excep) if self.g_settings.show_help is True: config_frame = ConfigFrame(self) help_frame = HelpFrame()
def __init__(self, parent): wx.Panel.__init__(self, parent) self.frame = parent self.sizer_main = wx.BoxSizer(wx.VERTICAL) self.sizer_helpcontent = wx.BoxSizer(wx.VERTICAL) self.sizer_buttons = wx.BoxSizer(wx.HORIZONTAL) current_settings = GeneralSettingsData() show_help = current_settings.show_help st_show_at_start = wx.StaticText(self, -1, "Show this help at start") self.cb_show_at_start = wx.CheckBox(self, -1, "") self.cb_show_at_start.SetValue(show_help) self.button_close = wx.Button(self, label="Close") self.button_close.Bind(wx.EVT_BUTTON, self.onClose) self.sizer_buttons.Add(st_show_at_start, 0, wx.CENTER | wx.ALL, 5) self.sizer_buttons.Add(self.cb_show_at_start, 0, wx.CENTER | wx.ALL, 5) self.sizer_buttons.Add(self.button_close, 0, wx.CENTER | wx.ALL, 5) help_str = """ How to use Superpaper: In the Profile Configuration you can adjust all your wallpaper settings. Only required options are name and wallpaper paths. Other application wide settings can be changed in the Settings menu. Both are accessible from the system tray menu. IMPORTANT NOTE: For the wallpapers to be set correctly, you must set in your OS the background fitting option to 'Span'. NOTE: If your displays are not in a horizontal row, the pixel density and offset corrections unfortunately do not work. In this case leave the 'Diagonal inches', 'Offsets' and 'Bezels' fields empty. Description of Profile Configuration options: In the text field description an example is shown in parantheses and in brackets the expected units of numerical values. "Diagonal inches": The diagonal diameters of your monitors in order starting from the left most monitor. These affect the wallpaper only in "Single" spanmode. "Spanmode": "Single" (span a single image across all monitors) "Multi" (set a different image on every monitor.) "Sort": Applies to slideshow mode wallpaper order. "Offsets": Wallpaper alignment correction offsets for your displays if using "Single" spanmode. Entered as "width,height" pixel value pairs, pairs separated by a semicolon ";". Positive offsets move the portion of the image on the monitor down and to the right, negative offets up or left. "Bezels": Bezel correction for "Single" spanmode wallpaper. Use this if you want the image to continue behind the bezels, like a scenery does behind a window frame. The expected values are the combined widths in millimeters of the two adjacent monitor bezels including a possible gap. "Hotkey": An optional key combination to apply/start the profile. Supports up to 3 modifiers and a key. Valid modifiers are 'control', 'super', 'alt' and 'shift'. Separate keys with a '+', like 'control+alt+w'. "display{N}paths": Wallpaper folder paths for the display in the Nth position from the left. Multiple can be entered with the browse tool using "Add". If you have more than one vertically stacked row, they should be listed row by row starting from the top most row. Tips: - You can use the given example profiles as templates: just change the name and whatever else, save, and its a new profile. - 'Align Test' feature allows you to test your offset and bezel settings. Display diagonals, offsets and bezels need to be entered. """ st_help = wx.StaticText(self, -1, help_str) self.sizer_helpcontent.Add(st_help, 0, wx.EXPAND | wx.CENTER | wx.ALL, 5) self.sizer_main.Add(self.sizer_helpcontent, 0, wx.CENTER | wx.EXPAND) self.sizer_main.Add(self.sizer_buttons, 0, wx.CENTER | wx.EXPAND) self.SetSizer(self.sizer_main) self.sizer_main.Fit(parent)