Skip to content

Commit

Permalink
High DPI Fix & Some Adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
faishalkc authored Jun 20, 2024
1 parent 6ff6f63 commit ccbc15a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions YuukoAlert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import ctypes
import pygame
import tkinter as tk
import tkinter.font as tkFont
from PIL import Image,ImageTk

def get_default_system_font_and_size():
root = tk.Tk()
default_font = tkFont.nametofont("TkDefaultFont")
system_font = default_font.actual()['family']
system_font_size = default_font.actual()['size']
root.destroy()
return system_font, system_font_size

ctypes.windll.user32.SetProcessDPIAware()

default_system_font, default_font_size = get_default_system_font_and_size()

pygame.init()
root = tk.Tk()
root.resizable(False,False)
root.geometry("250x150")
root.geometry("350x160")
root.eval('tk::PlaceWindow . center')
root.iconbitmap("files/icon.ico")
root.title("Yuuko Alert")
Expand All @@ -17,13 +31,15 @@
resized_image= img.resize((80,72), Image.LANCZOS)
new_image= ImageTk.PhotoImage(resized_image)
canvas.create_image(10,10, anchor="nw", image=new_image)
canvas.create_text(170, 50, text="Selamat Pagi !", fill="black", font=('Segoe UI', '11'))
canvas.create_text(170, 50, text="Selamat Pagi !", fill="black", font=(default_system_font, default_font_size))

close = tk.Button(root, text=" OK ", font=("Segoe UI", "10"), command=root.destroy)
close = tk.Button(root, text=" OK ", font=(default_system_font, default_font_size), command=root.destroy)
close.pack(padx=5, pady=5)

my_sound = pygame.mixer.Sound('files/sound.mp3')
my_sound.play()
my_sound.set_volume(0.8)

root.attributes('-toolwindow', True)
root.attributes('-topmost', True)
root.mainloop()

0 comments on commit ccbc15a

Please sign in to comment.