我需要一些关于我的工具的帮助,因为我是初学者。我希望我的密码 gui 在输入正确的密码后关闭。然后打开我的主 gui(Password.py 和 Main.py)。
没有帮助我做不到>我已经在互联网上搜索了3天但没有成功。
我必须将其写在1个程序中还是也可以?代码会是什么样子?
...
请帮助我。
`import customtkinter as ctk
import tkinter.messagebox as tkmb
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
app = ctk.CTk()
app.geometry("400x400")
app.title("MultiTool Login")
def login():
username = "Admin"
password = "1111"
if user_entry.get() == username and user_pass.get() == password:
tkmb.showinfo(title="Login Successful", message="Login Erfolgreich")and quit(app)
elif user_entry.get() == username and user_pass.get() != password:
tkmb.showwarning(title='Wrong password', message='Bitte prüfe dein Passwort')
elif user_entry.get() != username and user_pass.get() == password:
tkmb.showwarning(title='Wrong username', message='Bitte prüfe dein Benutzernamee')
else:
tkmb.showerror(title="Login Failed", message="Benutzername und Passwort Falsch")
label = ctk.CTkLabel(app, text="MultiTool By D.N.")
label.pack(pady=20)
frame = ctk.CTkFrame(master=app)
frame.pack(pady=20, padx=40, fill='both', expand=True)
label = ctk.CTkLabel(master=frame, text='Bitte Anmelden')
label.pack(pady=12, padx=10)
user_entry = ctk.CTkEntry(master=frame, placeholder_text="Username")
user_entry.pack(pady=12, padx=10)
user_pass = ctk.CTkEntry(master=frame, placeholder_text="Password", show="*")
user_pass.pack(pady=12, padx=10)
button = ctk.CTkButton(master=frame, text='Login', command=login)
button.pack(pady=12, padx=10)
cV1 = ctk.IntVar(value=0)
def my_show():
if cV1.get() != 1:
user_pass.configure(show='*')
else:
user_pass.configure(show='')
CheckPW = ctk.CTkCheckBox(app, text='Show Password', variable=cV1,
onvalue=1, offvalue=0, command=my_show)
CheckPW.pack(pady=12, padx=10)
app.mainloop()
# The Main is:
import customtkinter
import time
App = customtkinter.CTk()
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")
App.title("MultiTool BY D.Nguyen")
label = customtkinter.CTkLabel(master=App, text="Version 2.0")
label.place(relx=0.5, rely=0.95, anchor=customtkinter.CENTER)
def optionmenu_callback(choice):
print("optionmenu dropdown clicked:", choice)
combobox = customtkinter.CTkOptionMenu(master=App,
values=["Autostart", "Automover", "Kalender", "Zeit Rechner"],
command=optionmenu_callback("Fuck"))
combobox.pack(padx=50, pady=10,)
combobox.set("Menü")
combobox.place(relx=0.1, rely=0.1)
progressbar = customtkinter.CTkProgressBar(master=App)
progressbar.pack(padx=20, pady=10)
progressbar.place(relx=0.7, rely=0.9)
def slider_event(value):
print(value)
slider = customtkinter.CTkSlider(master=App, from_=0, to=100, command=slider_event)
slider.place(relx=0.2, rely=0.9, anchor="center")
def button_event():
print("button pressed")
button = customtkinter.CTkButton(master=App,
width=120,
height=32,
border_width=0,
corner_radius=8,
text="Enter",
command=button_event)
button.place(relx=0.84, rely=0.8, anchor=customtkinter.CENTER)
button = customtkinter.CTkButton(master=App,
width=120,
height=32,
border_width=0,
corner_radius=8,
text="Start",
command=button_event)
button.place(relx=0.2, rely=0.5, anchor=customtkinter.CENTER)
App.geometry("700x400")
sv = customtkinter.StringVar()
uhr = customtkinter.CTkLabel(master=App,
width=15,
height=3)
uhr.pack()
zeit = ''
def tick():
global zeit
neuezeit = time.strftime('%H:%M:%S')
if neuezeit != zeit:
zeit = neuezeit
uhr.configure(text=zeit)
uhr.after(200, tick)
uhr.place(relx=0.92, rely=0.01)
tick()
App.mainloop()
`