[Python] 纯文本查看 复制代码
import os
import tkinter as tk
import threading
import time
def gengxi1():
t.delete(1.0, tk.END)
with open('C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
print(b)
try:
c=os.system("TortoiseProc.exe /command:update /path:"+'"'+b+'"'+"/closeonend:1")
except:
print('更新失败')
t.insert('end','更新失败')
else:
if c==0:
print('更新成功')
t.insert('end', '更新成功')
a=(time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime()))
t.insert('end',a)
else:
print('更新失败')
t.insert('end', '更新失败')
def qingli():
t.delete(1.0, tk.END)
with open(r'C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
print(b)
try:
c = os.system("TortoiseProc.exe /command:cleanup /path:" + '"' + b + '"' + "/closeonend:1")
except:
t.insert('end', '清理失败')
else:
if c == 0:
t.insert('end', '清理成功')
else:
t.insert('end', '清理失败')
def rizhi():
t.delete(1.0, tk.END)
with open(r'C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
os.system("TortoiseProc.exe /command:log /path:" + '"' + b + '"' + "/closeonend:1")
def huanyuan():
t.delete(1.0, tk.END)
with open(r'C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
print(b)
os.system("TortoiseProc.exe /command:revert /path:" + '"' + b + '"' + "/closeonend:1")
a = (time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime()))
t.insert('end', a)
def dingwei():
t.delete(1.0, tk.END)
with open(r'C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
print(b)
os.system("TortoiseProc.exe /command:relocate /path:" + '"' + b + '"' + "/closeonend:1")
def bangzhu():
t.delete(1.0, tk.END)
with open(r'C:\gjg\svn.txt', 'w') as f:
f.write(txt.get())
b = txt.get()
print(b)
os.system("TortoiseProc.exe /command:help /path:" + '"' + b + '"' + "/closeonend:1")
def thread_it(func, *args):
'''将函数打包进线程'''
k = threading.Thread(target=func, args=args)
k.setDaemon(True)
k.start()
if __name__ == '__main__':
window=tk.Tk()
window.title('SVN')
window.geometry("200x250")
if not os.path.exists("C:/gjg"):
os.mkdir("C:/gjg")
try:
with open('C:\gjg\svn.txt', "r") as f:
e1=f.read()
print(e1)
except:
e1='地址,多个地址用*分隔'
t= tk.Text(window,width = '250', height=11,bg = 'LightBlue')
t.pack(side = 'bottom')
btn1 = tk.Button(window, text="更新svn", bg="orange", command=lambda: thread_it(gengxi1))
btn1.place(x=1, y=40)
btn2 = tk.Button(window, text="清理svn", bg="orange", command=qingli)
btn2.place(x=60, y=40)
btn3 = tk.Button(window, text="查看日志", bg="orange", command=lambda: thread_it(rizhi))
btn3.place(x=120, y=40)
btn4 = tk.Button(window, text="还原svn", bg="orange", command=lambda: thread_it(huanyuan))
btn4.place(x=1, y=70)
btn5 = tk.Button(window, text="重新定位", bg="orange", command=lambda: thread_it(dingwei))
btn5.place(x=60, y=70)
btn6 = tk.Button(window, text="帮助", bg="orange", command=lambda: thread_it(bangzhu))
btn6.place(x=130, y=70)
e1 = tk.StringVar(value=e1)
txt = tk.Entry(window, width=30,textvariable = e1)
txt.place(x =1,y=10)
window.mainloop()