Commit d8c0554d by BellCodeEditor

save project

parent 711f8e4a
Showing with 216 additions and 0 deletions
import codecs
from tkinter import *
import json
from os import *
from tkinter.messagebox import *
from tkinter.scrolledtext import ScrolledText
class cmds:
def __init__(self,state):
self.state=state
self.bglist=["#FFFFFF","#101010","#FFFAE0","#50FF50","#FF5050","#5050FF"]
self.bg="#101010"
self.n=1
self.index=1
self.strindex=self.readsys()[1]
def showcode(self):
global es
text=es.get()
if self.n==1:
self.n=0
v.set(0)
es=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22)
es.insert(0,text)
es.place(x=100,y=160)
else:
self.n=1
v.set(1)
es=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22,show="·")
es.insert(0,text)
es.place(x=100,y=160)
def ent(self):
global e
global es
dat={e.get():es.get()}
print(json.dumps(dat),type(json.dumps(dat)))
data=codecs.open("user.txt","w",encoding="utf-8")
data.write(json.dumps(dat))
data.close()
Label(w,text="注册成功",font=("",10),bg=self.bg,fg="#50FF50").place(x=120,y=20)
w.destroy()
self.w_c()
def denl(self):
global e
global es
global w
dat={e.get():es.get()}
data=codecs.open("user.txt","r",encoding="utf-8")
dat1=json.loads(data.read())
data.close()
for ind in dat1:
pass
if e.get() != ind:
Label(w,text="账号无效!",font=("",10),bg=self.bg,fg="#FF5050").place(x=120,y=20)
elif dat[e.get()] != dat1[ind]:
Label(w,text="密码错误!",font=("",10),bg=self.bg,fg="#FF5050").place(x=120,y=20)
else:
Label(w,text="登录成功!",font=("",10),bg=self.bg,fg="#50FF50").place(x=120,y=20)
w.destroy()
self.w_c()
def change_color(self,text):
global es
global e
self.index+=1
if self.index > len(self.bglist)-1:
self.index=0
self.bg=self.bglist[self.index]
if self.bg=="#FFFAE0" or self.bg=="#50FF50" or self.bg=="#FFFFFF":
fg="#000000"
else:
fg="#FFFFFF"
w.config(bg=self.bg)
Label(w,text=text,font=("",30),bg=self.bg,fg=fg).place(x=20,y=15)
Label(w,text="——"*50,font=("",20),bg=self.bg,fg=fg).place(x=0,y=60)
Label(w,text="账号:",font=("",25),bg=self.bg,fg=fg).place(x=20,y=100)
e=Entry(w,font=("",25),bg=self.bg,fg=fg,width=22)
e.place(x=100,y=100)
Label(w,text="密码:",font=("",25),bg=self.bg,fg=fg).place(x=20,y=160)
es=Entry(w,font=("",25),bg=self.bg,fg=fg,width=22,show="·")
es.place(x=100,y=160)
def zhux(self):
global w
data=codecs.open("user.txt","w",encoding="utf-8")
data.write("")
data.close()
w.destroy()
self.w_a()
def infocheck(self):
global vn
if vn == 0:
vn=1
showwarning("提示","信息查看已开启!")
elif vn == 1:
vn=0
showwarning("提示","信息查看已关闭!")
def cmdecho(self):
global ce
global echo_entry
echo=system("cmd /c "+ce.get())
print(echo)
echo_entry.delete(0.0,END)
echo_entry.insert(0.0,str(echo))
def readsys(self):
user=listdir("C:\\Users")
user.remove("Public")
user=user[2]
user1="C:\\Users\\"+user+"\\Desktop\\"
desktop=listdir("C:\\Users\\"+user+"\\Desktop")
return [desktop,user1]
def w_a(self):
global w
global v
global es
global e
w=Tk()
m=Menu(w)
op=Menu(m,tearoff=False)
op.add_command(label="更改颜色",command=lambda: self.change_color("注册"))
m.add_cascade(menu=op,label="选项")
v=IntVar()
v.set(1)
w.title("用户注册")
w.resizable(False,False)
w.geometry("500x350+400+300")
w.config(bg=self.bg,menu=m)
Label(w,text="注册",font=("",30),bg=self.bg,fg="#FFFFFF").place(x=20,y=15)
Label(w,text="——"*50,font=("",20),bg=self.bg,fg="#FFFFFF").place(x=0,y=60)
Label(w,text="账号:",font=("",25),bg=self.bg,fg="#FFFFFF").place(x=20,y=100)
e=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22)
e.place(x=100,y=100)
Label(w,text="密码:",font=("",25),bg=self.bg,fg="#FFFFFF").place(x=20,y=160)
es=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22,show="·")
es.place(x=100,y=160)
br=Radiobutton(w,text="隐藏密码",variable=v,value=self.n,command=self.showcode,bg="#FFFFFF",font=("",15))
br.place(x=190,y=210)
b=Button(w,text="确认",bg="#FFFFFF",font=("",20),width=10,command=self.ent)
b.place(x=170,y=270)
w.mainloop()
def w_b(self):
global w
global v
global es
global e
w=Tk()
v=IntVar()
v.set(1)
w.title("用户登录")
w.geometry("500x350+400+300")
w.resizable(False,False)
m=Menu(w)
op=Menu(m,tearoff=False)
m.add_cascade(menu=op,label="选项")
op.add_command(label="更改颜色",command=lambda: self.change_color("登录"))
op.add_command(label="注销账号",command=self.zhux)
w.config(bg=self.bg,menu=m)
Label(w,text="登录",font=("",30),bg=self.bg,fg="#FFFFFF").place(x=20,y=15)
Label(w,text="——"*50,font=("",20),bg=self.bg,fg="#FFFFFF").place(x=0,y=60)
Label(w,text="账号:",font=("",25),bg=self.bg,fg="#FFFFFF").place(x=20,y=100)
e=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22)
e.place(x=100,y=100)
Label(w,text="密码:",font=("",25),bg=self.bg,fg="#FFFFFF").place(x=20,y=160)
es=Entry(w,font=("",25),bg=self.bg,fg="#FFFFFF",width=22,show="·")
es.place(x=100,y=160)
br=Radiobutton(w,text="隐藏密码",variable=v,value=self.n,command=self.showcode,bg="#FFFFFF",font=("",15))
br.place(x=190,y=210)
b=Button(w,text="确认",bg="#FFFFFF",font=("",20),width=10,command=self.denl)
b.place(x=170,y=270)
w.mainloop()
def w_c(self):
global vn
vn=0
global w
global ce
global lsb
global echo_entry
w=Tk()
w.title("管理")
w.geometry("500x350+400+300")
w.resizable(False,False)
m=Menu(w)
op=Menu(m,tearoff=False)
m.add_cascade(menu=op,label="选项")
op.add_command(label="退出程序",command=w.quit)
op.add_checkbutton(label="信息查看",command=self.infocheck)
w.config(bg=self.bg,menu=m)
w.resizable(False,False)
Label(w,text="系统管理",font=("",20),bg="#101010",fg="#FFFFFF").place(x=20,y=15)
Label(w,text="DOS指令:",font=("",10),bg="#101010",fg="#FFFFFF").place(x=200,y=22)
ce=Entry(w,font=("",10),bg="#101010",fg="#10FF10",width=25)
ce.place(x=260,y=22)
Button(w,text="确认",font=("",10),bg="#101010",fg="#10FF10",activebackground="#101010",activeforeground="#00AA00",command=self.cmdecho).place(x=450,y=20)
lsb=Listbox(w,bg="#101010",fg="#FFFFFF",font=("",15),width=20,height=12)
user=self.readsys()[0]
for i in user:
lsb.insert(END,i)
lsb.place(x=20,y=77)
Button(w,text="打开",font=("",10),bg="#101010",fg="#10FF10",activebackground="#101010",activeforeground="#00AA00",command=self.openf).place(x=20,y=50)
Label(w,text="指令反馈:",font=("",10),bg="#101010",fg="#FFFFFF").place(x=260,y=45)
echo_entry=ScrolledText(w,bg="#101010",fg="#10FF10",width=29,height=20,font=("",10))
echo_entry.place(x=260,y=70)
w.mainloop()
window=cmds(1)
window.w_b()
#C:\Users\Administrator\Desktop
{"111": "123456"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment