[問題] 製作bat檔的程式會卡住,求救!已刪文
我現在想做一個 ip自動設定的bat檔製作程式
我把同事的ip都設定到sqlite
同事只要打上名字 就會製做出bat檔 然後按開始執行 就會執行bat檔設定ip
功能都可以用 但按製作bat檔時狂當 要轉圈圈超久 然後電腦介於要當與不當之間
之前沒有GUI前都不會這樣
程式碼如下 是不是哪裡寫得很耗效能? 求解
def see_data():
global ipname
while True:
name =ipname.get()
sqlstr="select * from password where name='{}'" .format(name)
cursor=conn.execute(sqlstr)
row = cursor.fetchone()
#print(row)
content=str('netsh interface ip set address "區域連線" static')+"
"+(row[1])+" "+"255.255.255.0"+" "+"192.168.1.254"+'\nnetsh interface ip set
dns "區域連線" static 210.69.1.1'
f = open('test.bat','w+')
f.write(content)
f.close()
def GO_data():
win32api.ShellExecute(0, 'open', 'D:\\code\\ip\\test.bat', '',
'', 1) # 執行程式
### 主程式從這裡開始 ###
import os,sqlite3
import tkinter as tk
import win32api
conn = sqlite3.connect('Sqlite01.sqlite')
win=tk.Tk()
win.geometry("260x100") #設定主視窗解析度
win.title("請先按製作bat再按開始設定")
ipname = tk.StringVar()
label1=tk.Label(win, text="您的大名:")
label1.place(x=60, y=30)
entryUrl = tk.Entry(win, textvariable=ipname)
entryUrl.config(width=15)
entryUrl.place(x=120, y=30)
btnDown = tk.Button(win, text="製作bat檔", command=see_data)
btnDown.place(x=60, y=60)
btnDown = tk.Button(win, text="開始設定", command=GO_data)
btnDown.place(x=150, y=60)
win.mainloop()
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 117.56.227.246 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1576743639.A.3BD.html