Add Battery Icon To Taskbar Info

def show_battery_info(self): percent, is_charging = self.get_battery_status() status = f"Battery: percent%\n" status += "Charging" if is_charging else "Discharging" # Create popup window root = tk.Tk() root.title("Battery Status") root.geometry("300x150") label = tk.Label(root, text=status, font=("Arial", 12)) label.pack(pady=20) progress = ttk.Progressbar(root, length=200, mode='determinate') progress['value'] = percent progress.pack(pady=10) tk.Button(root, text="Close", command=root.destroy).pack(pady=10) root.mainloop()

def update_icon(self): percent, is_charging = self.get_battery_status() if percent is not None: icon_image = self.create_battery_icon(percent, is_charging) if self.icon: self.icon.icon = icon_image # Update every 5 seconds threading.Timer(5, self.update_icon).start() add battery icon to taskbar

def exit_app(self): if self.icon: self.icon.stop() if == " main ": BatteryTrayIcon() Linux (GTK) #!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') gi.require_version('AppIndicator3', '0.1') from gi.repository import Gtk, AppIndicator3 import psutil import threading import time class BatteryIndicator: def init (self): self.indicator = AppIndicator3.Indicator.new( "battery-indicator", "battery-full", AppIndicator3.IndicatorCategory.SYSTEM_SERVICES ) self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) def show_battery_info(self): percent, is_charging = self

self.menu = Gtk.Menu() self.create_menu() self.indicator.set_menu(self.menu) self.update_icon() def get_battery_info(self): battery = psutil.sensors_battery() if battery: percent = battery.percent is_charging = battery.power_plugged return percent, is_charging return None, None def show_battery_info(self): percent

Меню
0Корзина
Товар добавлен в корзину!
Товар добавлен в список сравнения
Товар добавлен в список избранных
Профиль