pygui: improvement for loading canvas backgrounds and checking if a gui file or specific path
This commit is contained in:
parent
b937e316c4
commit
2f9c169e66
1 changed files with 12 additions and 4 deletions
|
@ -1080,10 +1080,18 @@ class CanvasGraph(tk.Canvas):
|
||||||
|
|
||||||
def parse_metadata(self, config: Dict[str, Any]) -> None:
|
def parse_metadata(self, config: Dict[str, Any]) -> None:
|
||||||
fit_image = config.get("fit_image", False)
|
fit_image = config.get("fit_image", False)
|
||||||
wallpaper_style = config.get("wallpaper-style", 1)
|
|
||||||
wallpaper = config.get("wallpaper")
|
|
||||||
self.adjust_to_dim.set(fit_image)
|
self.adjust_to_dim.set(fit_image)
|
||||||
|
wallpaper_style = config.get("wallpaper_style", 1)
|
||||||
self.scale_option.set(wallpaper_style)
|
self.scale_option.set(wallpaper_style)
|
||||||
|
wallpaper = config.get("wallpaper")
|
||||||
if wallpaper:
|
if wallpaper:
|
||||||
wallpaper = str(appconfig.BACKGROUNDS_PATH.joinpath(wallpaper))
|
wallpaper = Path(wallpaper)
|
||||||
self.set_wallpaper(wallpaper)
|
if not wallpaper.is_file():
|
||||||
|
wallpaper = appconfig.BACKGROUNDS_PATH.joinpath(wallpaper)
|
||||||
|
logging.info("canvas(%s), wallpaper: %s", self.id, wallpaper)
|
||||||
|
if wallpaper.is_file():
|
||||||
|
self.set_wallpaper(str(wallpaper))
|
||||||
|
else:
|
||||||
|
self.app.show_error(
|
||||||
|
"Background Error", f"background file not found: {wallpaper}"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue