Move make_icon func to MedTrackerApp class

This commit is contained in:
William Valentin
2025-07-20 13:34:00 -07:00
parent 351d3633fe
commit 4ba4b1b7c5

View File

@@ -48,8 +48,7 @@ class MedTrackerApp:
f" Using default file: {self.filename}"
)
make_icon(
app=self.root,
self.make_icon(
img="/home/will/Code/thechart/chart-671.png",
logger=logger,
)
@@ -595,18 +594,17 @@ class MedTrackerApp:
self.fig.autofmt_xdate()
self.canvas.draw()
def make_icon(app: tk.Tk, img: str, logger: logging.Logger) -> None:
try:
icon_image = Image.open(img)
icon_image = icon_image.resize(
size=(32, 32), resample=Image.Resampling.NEAREST
)
icon_photo = ImageTk.PhotoImage(image=icon_image)
app.iconphoto(True, icon_photo)
app.wm_iconphoto(True, icon_photo)
except FileNotFoundError:
logger.warning("Icon file not found.")
def make_icon(self, img: str, logger: logging.Logger) -> None:
try:
icon_image = Image.open(img)
icon_image = icon_image.resize(
size=(32, 32), resample=Image.Resampling.NEAREST
)
icon_photo = ImageTk.PhotoImage(image=icon_image)
self.root.iconphoto(True, icon_photo)
self.root.wm_iconphoto(True, icon_photo)
except FileNotFoundError:
logger.warning("Icon file not found.")
if __name__ == "__main__":