0

Trying to convert my code to .exe file so that other users can make use of it.

The purpose of this code is to get an interface where the user can enable/disable LAN connection in a single click.

Kindly 'run as administrator' you IDLE to make this code work.

import tkinter as tk
import subprocess as sub
import os

WINDOW_SIZE = "350x100"
root = tk.Tk()
root.title("Windows Adapter Toggler")
root.geometry(WINDOW_SIZE)

#to execute bash command right from python script
tk.Button(root, text="DISABLE Internet", command=lambda: sub.call('netsh 
interface set interface name="Ethernet" admin=DISABLED')).pack()
tk.Button(root, text="ENABLE Internet", command=lambda: sub.call('netsh 
interface set interface name="Ethernet" admin=ENABLED')).pack()
#os.system(bashCommand)
root.mainloop()

SideNote:

1.Will work if your ethernet port name is 'ethernet',if something else then change the name in the code.Will implement this 'changing name of port'feature later in the code.

2.Already tried converting with pyinstaller and py2exe but didn't happen.

CodeManga
  • 43
  • 6
  • What exact version of python are you using? And why didn't it work when you tried to use pyinstaller and py2exe? – Jason S Jul 12 '17 at 16:37
  • Possible duplicate of [Best method of converting .py to .exe for Python 3.6?](https://stackoverflow.com/questions/41570359/best-method-of-converting-py-to-exe-for-python-3-6) – optimalic Jul 12 '17 at 22:25
  • @JasonS python 3.6.1 pyinstaller just didnt convert,was showing multiple errors which I had no idea. – CodeManga Jul 13 '17 at 19:41
  • @MushroomMauLa I will check it out then. – CodeManga Jul 13 '17 at 19:41

0 Answers0