Move make_icon func to MedTrackerApp class
This commit is contained in:
26
src/main.py
26
src/main.py
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user