42 lines
1.8 KiB
Python
42 lines
1.8 KiB
Python
from tools import *
|
|
|
|
|
|
|
|
|
|
class login(tk.Frame):
|
|
def __init__(self,master,bg="./sys/wallpaper/森林1.png",width=1000,height=900,callback=lambda x,y:print(x,y),e=True):
|
|
super().__init__(master=master)
|
|
self.bg=bg
|
|
self.width=width
|
|
self.height=height
|
|
self.callback=callback
|
|
self.e=e
|
|
self.pack(fill="both",expand=True)
|
|
self.layer = tk.Canvas(self)
|
|
self.layer.pack(fill="both",expand=True)
|
|
|
|
self.tranimg = Image.open('./sys/wallpaper/translucent.png')
|
|
self.tranimg = self.tranimg.resize((width-20,height-20))
|
|
self.tranimg = ImageTk.PhotoImage(self.tranimg)
|
|
|
|
self.bgimg = Image.open(bg)
|
|
self.bgimg = self.bgimg.resize((width,height))
|
|
self.bgimg = ImageTk.PhotoImage(self.bgimg)
|
|
self.layer.create_image(0, 0, anchor='nw', image=self.bgimg)
|
|
self.layer.create_image(width//2,height//2, image=self.tranimg)
|
|
add_xy=0
|
|
for i in ["black","dark gray","gray","gray","light gray","white"]:
|
|
text=self.layer.create_text(245+add_xy,105+add_xy, text="Welcome to MikOS",font=('arial',25),fill=i)
|
|
#(self.layer.bbox(text)[2] - self.layer.bbox(text)[0])
|
|
self.layer.move(text, self.width//2-(self.layer.bbox(text)[2] - self.layer.bbox(text)[0])+27.5+add_xy, 0+add_xy)
|
|
add_xy+=0.5
|
|
self.button = tk.Button(self, text="登录", bg="sky blue", command=self.login,width = 15,overrelief='sunken',bd=4,cursor="hand2",activebackground="sky blue")
|
|
self.button.update()
|
|
self.button.place(x=self.winfo_width()//2-self.button.winfo_width()//2, y=180, anchor="center")
|
|
def login(self):
|
|
username="root"
|
|
userpwd="ROOT"
|
|
if self.e:
|
|
self.destroy()
|
|
self.callback(username,userpwd)
|