Move make_icon func to MedTrackerApp class
This commit is contained in:
10
src/main.py
10
src/main.py
@@ -48,8 +48,7 @@ class MedTrackerApp:
|
|||||||
f" Using default file: {self.filename}"
|
f" Using default file: {self.filename}"
|
||||||
)
|
)
|
||||||
|
|
||||||
make_icon(
|
self.make_icon(
|
||||||
app=self.root,
|
|
||||||
img="/home/will/Code/thechart/chart-671.png",
|
img="/home/will/Code/thechart/chart-671.png",
|
||||||
logger=logger,
|
logger=logger,
|
||||||
)
|
)
|
||||||
@@ -595,16 +594,15 @@ class MedTrackerApp:
|
|||||||
self.fig.autofmt_xdate()
|
self.fig.autofmt_xdate()
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
|
def make_icon(self, img: str, logger: logging.Logger) -> None:
|
||||||
def make_icon(app: tk.Tk, img: str, logger: logging.Logger) -> None:
|
|
||||||
try:
|
try:
|
||||||
icon_image = Image.open(img)
|
icon_image = Image.open(img)
|
||||||
icon_image = icon_image.resize(
|
icon_image = icon_image.resize(
|
||||||
size=(32, 32), resample=Image.Resampling.NEAREST
|
size=(32, 32), resample=Image.Resampling.NEAREST
|
||||||
)
|
)
|
||||||
icon_photo = ImageTk.PhotoImage(image=icon_image)
|
icon_photo = ImageTk.PhotoImage(image=icon_image)
|
||||||
app.iconphoto(True, icon_photo)
|
self.root.iconphoto(True, icon_photo)
|
||||||
app.wm_iconphoto(True, icon_photo)
|
self.root.wm_iconphoto(True, icon_photo)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logger.warning("Icon file not found.")
|
logger.warning("Icon file not found.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user