Untitled
unknown
plain_text
2 years ago
1.7 kB
15
Indexable
import subprocess
from tkinter import *
from tkinter import ttk
from tkinter.ttk import Style
commands = {
"a": "ssh dev all",
"b": "ssh dev common",
"c": "ssh qa all",
"d": "ssh qa common",
"e": "redis-cli.exe", # Replace with actual executable path if different
}
def button_click(option):
"""Handles button clicks and executes corresponding actions in separate windows."""
# Modify this dictionary to add new options and commands
if option in commands:
subprocess.Popen(["cmd", "/c", commands[option]], shell=True)
else:
print(f"Invalid option: {option}") # Handle unexpected options (optional)
# Create the main window
window = Tk()
window.title("SSH and Redis Launcher")
# Create a frame for buttons with padding
button_frame = ttk.Frame(window, padding=15)
button_frame.pack()
# Define button style (Material Design inspired)
button_style = Style()
button_style.configure(
"my.TButton",
font=("Arial", 14, "bold"), # Use a system font if desired
background="#3F51B5", # Material Blue
foreground="#424242", # Dark grey text
borderwidth=2,
relief="raised",
activebackground="#1A237E", # Material Blue (darker on hover)
)
# Create buttons dynamically based on the commands dictionary
for option, command in commands.items():
button_text = f"{command}" # Customize button text format
button = ttk.Button(
button_frame,
text=button_text,
style="my.TButton",
command=lambda opt=option: button_click(opt),
)
button.pack(pady=5)
# Run the main loop
window.mainloop()
Editor is loading...
Leave a Comment