51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import pystray
|
|
from pystray import MenuItem as item
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
import subprocess
|
|
import threading
|
|
|
|
|
|
def ejecutar_comando1(icon, item):
|
|
subprocess.run(['comando1'])
|
|
|
|
|
|
def ejecutar_comando2(icon, item):
|
|
subprocess.run(['comando2'])
|
|
|
|
|
|
def ejecutar_comando3(icon, item):
|
|
subprocess.run(['comando3'])
|
|
|
|
|
|
def salir(icon, item):
|
|
icon.stop()
|
|
|
|
|
|
def crear_icono():
|
|
# Crear una imagen de icono simple
|
|
image = Image.new('RGB', (64, 64), color=(255, 0, 0))
|
|
draw = ImageDraw.Draw(image)
|
|
font = ImageFont.load_default()
|
|
draw.text((10, 25), 'M', font=font, fill=(255, 255, 255))
|
|
return image
|
|
|
|
|
|
def iniciar_icono():
|
|
icono = pystray.Icon(
|
|
'menu_comandos_systray',
|
|
icon=crear_icono(),
|
|
menu=pystray.Menu(
|
|
item('Comando 1', ejecutar_comando1),
|
|
item('Comando 2', ejecutar_comando2),
|
|
item('Comando 3', ejecutar_comando3),
|
|
item('Salir', salir)
|
|
)
|
|
)
|
|
icono.run()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
threading.Thread(target=iniciar_icono).start()
|