Aplicação gráfica para Wake-on-LAN com Python 3 + GUI Tk/Tcl
Publicado por Fernando (última atualização em 18/11/2013)
[ Hits: 5.245 ]
Homepage: https://github.com/phoemur/
Estou começando a aprender programar GUI e fiz essa interface para o protocolo Wake-on-LAN em Python 3 utilizando Tkinter + Ttk.
Peguei a função WOL já pronta e implementei a GUI.
Requer: Python > 3.1.
Façam bom uso.
#!/bin/env python3 # # Written by phoemur - nov / 2013 # # Thanks to ActiveState Code Recipes: # http://code.activestate.com/recipes/358449-wake-on-lan/ # and # http://code.activestate.com/recipes/577609-wake-on-lan-for-python-3/ import socket, struct from tkinter import * from tkinter import ttk, messagebox def wake_on_lan(*args): """ Switches on remote computers using WOL. """ try: macaddress = str(mac.get()).upper() broadcast = str(broad.get()) except: pass # Check macaddress format and try to compensate if len(macaddress) == 12: pass elif len(macaddress) == 12 + 5: sep = macaddress[2] macaddress = macaddress.replace(sep,'') else: messagebox.showinfo(message='Incorrect MAC Address format', title='Warning') return # Pad the synchronization stream data = b'FFFFFFFFFFFF' + (macaddress * 20).encode() send_data = b'' # Split up the hex values in pack for i in range(0, len(data), 2): send_data += struct.pack('B', int(data[i: i + 2], 16)) # Broadcast it to the LAN sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.sendto(send_data, (broadcast, 7)) def make_menu(w): global the_menu the_menu = Menu(w, tearoff=0) the_menu.add_command(label="Cut") the_menu.add_command(label="Copy") the_menu.add_command(label="Paste") def show_menu(e): w = e.widget the_menu.entryconfigure("Cut", command=lambda: w.event_generate("<<Cut>>")) the_menu.entryconfigure("Copy", command=lambda: w.event_generate("<<Copy>>")) the_menu.entryconfigure("Paste", command=lambda: w.event_generate("<<Paste>>")) the_menu.tk.call("tk_popup", the_menu, e.x_root, e.y_root) # Start our GUI root = Tk() root.title("Py3k - Wake-On-LAN") root.resizable(FALSE,FALSE) make_menu(root) mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) mainframe['relief'] = 'raised' mac = StringVar() mac.set('AA:BB:CC:DD:EE:FF') broad = StringVar() broad.set('255.255.255.255') mac_entry = ttk.Entry(mainframe, width=17, textvariable=mac) mac_entry.grid(column=2, row=1, sticky=(W, E)) broad_entry = ttk.Entry(mainframe, width=15, textvariable=broad) broad_entry.grid(column=2, row=2, sticky=(W, E)) ttk.Button(mainframe, text="Wake-On-LAN", command=wake_on_lan).grid(column=3, row=3, sticky=W) ttk.Button(mainframe, text = "QUIT", command=root.quit).grid(column=1, row=3, sticky=E) ttk.Label(mainframe, text="MAC Address: ").grid(column=1, row=1, sticky=(W, E)) ttk.Label(mainframe, text="Broadcast Address: ").grid(column=1, row=2, sticky=(W, E)) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) mac_entry.focus() root.bind('<Return>', wake_on_lan) root.bind("<Button-3><ButtonRelease-3>", show_menu) root.mainloop()
ArpRequest - requisição arp para endereço físico
Nenhum comentário foi encontrado.
Passkeys: A Evolução da Autenticação Digital
Instalação de distro Linux em computadores, netbooks, etc, em rede com o Clonezilla
Título: Descobrindo o IP externo da VPN no Linux
Armazenando a senha de sua carteira Bitcoin de forma segura no Linux
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Instalando Brave Browser no Linux Mint 22
vídeo pra quem quer saber como funciona Proteção de Memória:
Encontre seus arquivos facilmente com o Drill
Mouse Logitech MX Ergo Advanced Wireless Trackball no Linux
Compartilhamento de Rede com samba em modo Público/Anônimo de forma simples, rápido e fácil
VMs e Interfaces de Rede desapareceram (11)
Instalação do drive do adaptador wiffi (7)