LinuxMint: Pannello pulsanti, Python

Openvpn3, finger print, wakeonlan e sessione Krdc

Tkinter non è più distribuito tramite pip, adesso è necesario il comando:

$ sudo apt-get install python3-tk

Di seguito il codice per python


from tkinter import * # libreria GUI

window = Tk()

# Finestra, titolo e dimensioni 

window.title(“Tools”)
window.geometry(‘230×93’)

# Etichetta della sessione openvpn3

lbl = Label(window, text=”OpenVpn3 Client “, bg=”black”, fg=”orange”)
lbl.grid(column=0, row=0)

# Avvio vpn, conf del bottone e comando console

def clicked_start():

    import subprocess
    subprocess.call(["openvpn3 session-start --config /home/"username"/Documenti/conffile.ovpn"],shell=True)         
    lbl.configure(bg="green")

btn = Button(window, text="Start", command=clicked_start)
btn.grid(column=1, row=0)

# Stop vpn, conf del bottone e comando console

def clicked_stop():

   import subprocess
   subprocess.call([“openvpn3 session-manage -I tun0 --disconnect”],shell=True)
   lbl.configure(bg=”black”)

btn = Button(window, text=”Stop”, command=clicked_stop)
btn.grid(column=2, row=0)

# Etichetta del servizio finger print

lbl1 = Label(window, text=”Finger Print “, bg=”green”, fg=”orange”)
lbl1.grid(column=0, row=1)

def clicked_start():

   import subprocess
   subprocess.call([“systemctl start fprintd.service”],shell=True)
   lbl1.configure(bg=”green”)

btn = Button(window, text=”Start”, command=clicked_start)
btn.grid(column=1, row=1)

def clicked_stop():

   import subprocess
   subprocess.call([“systemctl stop fprintd.service”],shell=True)
   lbl1.configure(bg=”black”)

btn = Button(window, text=”Stop”, command=clicked_stop)
btn.grid(column=2, row=1)

# Avviare pc Windows con wakeonlan e avviare sessione Krdc

lbl2 = Label(window, text=”WoL&krdc “, bg=”black”, fg=”orange”)
lbl2.grid(column=0, row=2)

def clicked_wake():

   import subprocess
   subprocess.call([“wakeonlan 1C:83:41:29:A8:10”],shell=True)
   lbl2.configure(bg=”green”)

btn = Button(window, text=”Wake”, command=clicked_wake)
btn.grid(column=1, row=2)

def clicked_krdc():

   import subprocess
   subprocess.call(["krdc rdp://username@10.10.10.10"],shell=True)

btn = Button(window, text="Krdc", command=clicked_krdc)
btn.grid(column=2, row=2)

window.mainloop()