dotfiles/.local/bin/comandos.py
2025-05-28 18:33:04 +02:00

64 lines
1.7 KiB
Python

#!/usr/bin/env python3
import sys
import subprocess
from gi.repository import Gtk, Gio
import gi
gi.require_version('Gtk', '4.0')
class MenuComandos(Gtk.Application):
def __init__(self):
app_id = "com.tuusuario.menucomandos" # Reemplaza con un ID único
super().__init__(application_id=app_id, flags=Gio.ApplicationFlags.FLAGS_NONE)
self.window = None
def do_activate(self):
if not self.window:
self.window = Gtk.ApplicationWindow(application=self)
self.window.set_title("comandos")
self.window.set_default_size(200, 100)
# Crear una caja vertical
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.window.set_child(vbox)
# Botón 1
boton1 = Gtk.Button(label="Comando 1")
boton1.connect("clicked", self.ejecutar_comando1)
vbox.append(boton1)
# Botón 2
boton2 = Gtk.Button(label="Comando 2")
boton2.connect("clicked", self.ejecutar_comando2)
vbox.append(boton2)
# Botón 3
boton3 = Gtk.Button(label="Comando 3")
boton3.connect("clicked", self.ejecutar_comando3)
vbox.append(boton3)
self.window.present()
def do_startup(self):
Gtk.Application.do_startup(self)
def ejecutar_comando1(self, widget):
subprocess.run(["comando1"])
def ejecutar_comando2(self, widget):
subprocess.run(["comando2"])
def ejecutar_comando3(self, widget):
subprocess.run(["comando3"])
def main():
app = MenuComandos()
return app.run(sys.argv)
if __name__ == "__main__":
sys.exit(main())