-
Notifications
You must be signed in to change notification settings - Fork 0
/
IPselect.py
39 lines (31 loc) · 1 KB
/
IPselect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import tkinter as tk
print("IPselect.py launched")
dirname = os.path.dirname(__file__)
IP = open(dirname + '/config/ip.txt', 'r')
oldIP = str(IP.readlines()) # 192.168.13.106
oldIP = oldIP.replace("'", "")
oldIP = oldIP.replace("[", "")
oldIP = oldIP.replace("]", "")
IP.close()
def NewCB(self):
os.remove(dirname + '/config/ip.txt')
NewIP = open(dirname + '/config/ip.txt', 'w')
NewIP.write(Entry.get())
NewIP.close()
IPselect.destroy()
def OldCB():
IPselect.destroy()
IPselect = tk.Tk()
frame = tk.Frame(IPselect)
frame.pack()
BtnNew = tk.Button(IPselect, text="Enter new IP:", font="Helvetica 40 bold", command=NewCB, height=1, width=15)
BtnOld = tk.Button(IPselect, text="Keep old IP:", font="Helvetica 40 bold", command=OldCB, height=1, width=15)
Entry = tk.Entry(IPselect, width=15)
Entry.bind('<Return>', NewCB)
LableIP = tk.Label(IPselect, text=oldIP, font="Helvetica 25 bold", height=1, width=20)
BtnNew.pack()
Entry.pack()
BtnOld.pack()
LableIP.pack()
IPselect.mainloop()