INNER CODE UNIT · Python

show_toast

Qwejay/Qflow · main.py:234

    def show_toast(message, duration=2000, use_sound=False, position='center'):
        try:
            top = tk.Toplevel()
            top.overrideredirect(True)
            top.attributes("-topmost", True, "-alpha", 0.9)
            top.configure(bg="#333333")
            
            lbl = tk.Label(top, text=message, fg="white", bg="#333333", padx=20, pady=10, font=("Microsoft YaHei", 12, "bold"))
            lbl.pack()
            
            top.update_idletasks()
            w, h = top.winfo_reqwidth(), top.winfo_reqheight()
            sw, sh = top.winfo_screenwidth(), top.winfo_screenheight()
            
            if position == 'bottom_right':
                top.geometry(f"+{sw - w - 20}+{sh - h - 60}")
            else:
                top.geometry(f"+{sw//2 - w//2}+{sh//2 - h//2}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…