I have written my code so that when the button "SignIn" is pressed it calls the function "Login". However, every time I run the code and press the button, the error message "_tkinter.TclError: image "pyimage2" doesn't exist" is displayed and I cannot seem to find a solution which fixes my code.
import tkinter
def Login():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
UsernameLbl = tkinter.Label(window, text = "Username", fg= "white", bg= "black")
Utext = tkinter.Entry(window)
PasswordLbl = tkinter.Label(window, text = "Password", fg = "white", bg= "black")
Ptext = tkinter.Entry(window, show="*")
Login = tkinter.Button(window, text = "Login", fg = "black", bg = "honeydew", command = window.destroy )
window.configure(background= "#008bb5")
Photo = tkinter.PhotoImage(file = "Eating.gif")
w = tkinter.Label(window, image = Photo)
w.pack()
UsernameLbl.pack()
Utext.pack()
PasswordLbl.pack()
Ptext.pack()
Login.pack()
window.mainloop()
def Mainscreen():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
Question = tkinter.Label(window, text = "Would you like to create an account or login?", fg = "black", bg = "white")
Create = tkinter.Button(window, text = "Create an account", fg = "white", bg = "black")
SignIn = tkinter.Button(window, text = "Login", fg = "white", bg = "black", command = Login)
Quit = tkinter.Button(window, text = "Quit", fg = "white", bg = "black", command = window.destroy)
window.configure(background = "#008bb5")
Photo = tkinter.PhotoImage(file = "Eating.gif")
w = tkinter.Label(window, image = Photo)
w.pack()
Question.pack()
Create.pack()
SignIn.pack()
Quit.pack()
window.mainloop()
Mainscreen()
When the SignIn button is pressed, the MainScreen should be destroyed and the Login screen should be opened. However, currently whenever the login button is pressed on the main screen, the MainScreen remains open and the Login screen is displayed as a blank screen.
This should work. Notice the use of
`tkinter.Toplevel()
and Image.open. This is because the button that calls the function is itself sitting in an active window.
import tkinter
from PIL import Image, ImageTk
def Login():
window = tkinter.Toplevel()
window.title("Eat Well")
window.geometry("295x400")
UsernameLbl = tkinter.Label(window, text = "Username", fg= "white", bg= "black")
Utext = tkinter.Entry(window)
PasswordLbl = tkinter.Label(window, text = "Password", fg = "white", bg= "black")
Ptext = tkinter.Entry(window, show="*")
Login = tkinter.Button(window, text = "Login", fg = "black", bg = "honeydew", command = window.destroy )
window.configure(background= "#008bb5")
im = Image.open("Eating.gif")
Photo = ImageTk.PhotoImage(im)
w = tkinter.Label(window)
w.pack()
UsernameLbl.pack()
Utext.pack()
PasswordLbl.pack()
Ptext.pack()
Login.pack()
window.mainloop()
def Mainscreen():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
Question = tkinter.Label(window, text = "Would you like to create an account or login?", fg = "black", bg = "white")
Create = tkinter.Button(window, text = "Create an account", fg = "white", bg = "black")
SignIn = tkinter.Button(window, text = "Login", fg = "white", bg = "black", command = Login)
Quit = tkinter.Button(window, text = "Quit", fg = "white", bg = "black", command = window.destroy)
window.configure(background = "#008bb5")
im = Image.open("Eating.gif")
Photo = ImageTk.PhotoImage(im)
w = tkinter.Label(window)
w.pack()
Question.pack()
Create.pack()
SignIn.pack()
Quit.pack()
window.mainloop()
Okay so the problem is you are trying to run two instances of Tk() simultaneously which you should not. Reasons are described here and here also
Instead of window = tkinter.Tk() in your Login() you can use window = tkinter.Toplevel() to solve the problem like following:
import tkinter
def Login():
# window = tkinter.Tk()
window = tkinter.Toplevel()
window.title("Eat Well")
window.geometry("295x400")
user_name_label = tkinter.Label(window, text="Username", fg="white", bg="black")
user_name_text = tkinter.Entry(window)
password_label = tkinter.Label(window, text="Password", fg="white", bg="black")
password_text = tkinter.Entry(window, show="*")
login = tkinter.Button(window, text="Login", fg="black", bg="honeydew", command=window.destroy)
window.configure(background="#008bb5")
photo = tkinter.PhotoImage(file="Eating.gif")
w = tkinter.Label(window, image=photo)
w.pack()
user_name_label.pack()
user_name_text.pack()
password_label.pack()
password_text.pack()
login.pack()
window.mainloop()
def Mainscreen():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
question = tkinter.Label(window, text="Would you like to create an account or login?", fg="black", bg="white")
create = tkinter.Button(window, text="Create an account", fg="white", bg="black")
sign_in = tkinter.Button(window, text="Login", fg="white", bg="black", command=Login)
quit = tkinter.Button(window, text="Quit", fg="white", bg="black", command=window.destroy)
window.configure(background="#008bb5")
photo = tkinter.PhotoImage(file="Eating.gif")
w = tkinter.Label(window, image=photo)
w.pack()
question.pack()
create.pack()
sign_in.pack()
quit.pack()
window.mainloop()
Mainscreen()
Related
im working on this tkinter project im close to finishing but i cant seem to find a way to change the button color when i hover on it so can you help here is my code
import tkinter as tk
window = tk.Tk()
img = tk.PhotoImage(file='C:\\Users\\laithmaree\\PycharmProjects\\create_apps_with_python\\brainicon.ico.png')
window.title("Quiz Game")
# i created an icon
# i made a title
window.geometry("800x600")
window.resizable(width=False, height=False)
window.iconphoto(False, img)
label1 = tk.Label(window, text='Quiz App', font=("Arial Bold", 25))
label1.pack()
txtbox = tk.Entry(window, width=50)
def playbuttonclicked():
label1.destroy()
playbtn.destroy()
quitbtn.destroy()
label2 = tk.Label(window, text='What is the short form of computer science', font=("Arial Bold", 25))
label2.pack()
txtbox.place(x=250, y=200, height=40)
def chkanswer():
useranswer = txtbox.get() # Get contents from Entry
if useranswer == 'cs':
lblcorrect = tk.Label(window, text='correct')
lblcorrect.pack()
def delete():
lblcorrect.destroy()
lblcorrect.after(1000, delete)
else:
lblwrong = tk.Label(window, text='Try Again')
lblwrong.pack()
def deletefunction():
lblwrong.destroy()
lblwrong.after(1000, deletefunction)
submitbtn = tk.Button(window, text='Submit', font=('Arial Bold', 30), command=chkanswer, bg='red')
submitbtn.place(x=305, y=400)
playbtn = tk.Button(window, text='Play', font=("Arial Bold", 90), bg='red', command=playbuttonclicked)
playbtn.place(x=10, y=200)
def quitbuttonclicked():
window.destroy()
quitbtn = tk.Button(window, text='Quit', font=("Arial Bold", 90), bg='red', command=quitbuttonclicked)
quitbtn.place(x=400, y=200)
window.mainloop()
the buttons are submitbtn,playbtn,quitbtn i want the hover over buttons to be black there already red i just want them to be black when i hover over them thx
Bind each of the buttons to entering and leaving events (when mouse enters and leaves the widget) and based on which one is triggered, change the background color of the button:
btn.bind('<Enter>', lambda e: e.widget.config(bg='black'))
btn.bind('<Leave>', lambda e: e.widget.config(bg='red'))
from tkinter import *
def spaces(int1,int2):
if int1 == 1:
return(int2*"\n")
else:
return(int2*" ")
def submitButton():
subButton_text = subButton.get()
try:
informationText.destroy()
except UnboundLocalError:
print("an error has occured.")
print("Attempting to run with the error.")
pass
informationText = Label(window, text=subButton_text, bg = "grey",
fg = "white", font = "none 12 bold")
informationText.grid(row=4,column=0,sticky=W)
#informationText.destroy()
#return informationText
def exit_Button():
window.destroy()
window = Tk()
window.title("Learning tkinter")
window.configure(background="grey")
subButton = StringVar()
#pic1 = PhotoImage(file="test.png")
#Label(window, image=pic1, bg = "grey").grid(row = 0, column = 0, sticky=W)
Label(window, text="Please enter a value", bg = "grey",
fg = "white", font = "none 12 bold").grid(row=0,column=0,sticky=W)
Entry(window, width=50, bg="white",textvariable=subButton).grid(row=1,column=0,stick=W)
subButton.set("default value")
Button(window, text="Submit", width=10,
command = submitButton).grid(row=2,column=0, sticky=W)
Label (window, text="\nInformation:", bg="grey", fg="white",
font="none 12 bold").grid(row=3,column=0, sticky=W)
Button (window, text="Save\nand exit", width=8,
command=exit_Button).grid(row=0,column=2,sticky=NW)
Label(window, text=spaces(1,10), bg = "grey",
fg = "white", font = "none 12 bold").grid(row=100,column=0,sticky=W)
Label(window, text=spaces(2,20), bg = "grey",
fg = "white", font = "none 12 bold").grid(row=0,column=1,sticky=W)
window.mainloop()
This is my code for a simple tkinter program. When the "submitButton" it creates create a Label called "informationText". But when the button is clicked again with new text I want it to destroy the old text, but it doesn't work. If I destroy the text immediately after creating it (commented out) it works.
Is it because I declared it in a function? If so how can I destroy it after the function has finished?
(first ask, tips appreciated for better questions in the future)
If you write you code in a class you will be able to use class attributes to store your label and update it later.
Going off what you code is trying to do the below code would be the class equivalent that works. That said I think you should update the label instead of destroying it.
import tkinter as tk
class MyApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.information_text = None
self.title("Learning tkinter")
self.configure(background="grey")
self.subButton = tk.StringVar()
tk.Label(self, text="Please enter a value", bg = "grey", fg = "white", font = "none 12 bold").grid(row=0,column=0,sticky="w")
tk.Entry(self, width=50, bg="white",textvariable=self.subButton).grid(row=1,column=0,stick="w")
self.subButton.set("default value")
tk.Button(self, text="Submit", width=10, command = self.submitButton).grid(row=2,column=0, sticky="w")
tk.Label (self, text="\nInformation:", bg="grey", fg="white", font="none 12 bold").grid(row=3,column=0, sticky="w")
tk.Button (self, text="Save\nand exit", width=8, command=self.exit_Button).grid(row=0,column=2,sticky="nw")
tk.Label(self, text=self.spaces(1,10), bg = "grey", fg = "white", font = "none 12 bold").grid(row=100,column=0,sticky="w")
tk.Label(self, text=self.spaces(2,20), bg = "grey", fg = "white", font = "none 12 bold").grid(row=0,column=1,sticky="w")
def spaces(self, int1, int2):
if int1 == 1:
return(int2*"\n")
else:
return(int2*" ")
def submitButton(self):
try:
self.information_text.destroy()
self.information_text = None
except:
print("an error has occured.")
print("Attempting to run with the error.")
self.information_text = tk.Label(self, text=self.subButton.get(), bg = "grey", fg = "white", font = "none 12 bold")
self.information_text.grid(row=4,column=0,sticky="w")
def exit_Button(self):
self.destroy()
if __name__ == "__main__":
app = MyApp()
app.mainloop()
My 2nd example will use config() to update the label instead of having to destroy it. I think this might work better for your needs here.
import tkinter as tk
class MyApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.title("Learning tkinter")
self.configure(background="grey")
self.subButton = tk.StringVar()
tk.Label(self, text="Please enter a value", bg = "grey", fg = "white", font = "none 12 bold").grid(row=0,column=0,sticky="w")
tk.Entry(self, width=50, bg="white",textvariable=self.subButton).grid(row=1,column=0,stick="w")
self.subButton.set("default value")
tk.Button(self, text="Submit", width=10, command = self.submitButton).grid(row=2,column=0, sticky="w")
tk.Label (self, text="\nInformation:", bg="grey", fg="white", font="none 12 bold").grid(row=3,column=0, sticky="w")
tk.Button (self, text="Save\nand exit", width=8, command=self.exit_Button).grid(row=0,column=2,sticky="nw")
tk.Label(self, text=self.spaces(1,10), bg = "grey", fg = "white", font = "none 12 bold").grid(row=100,column=0,sticky="w")
tk.Label(self, text=self.spaces(2,20), bg = "grey", fg = "white", font = "none 12 bold").grid(row=0,column=1,sticky="w")
self.information_text = tk.Label(self, text="", bg = "grey", fg = "white", font = "none 12 bold")
self.information_text.grid(row=4,column=0,sticky="w")
def spaces(self, int1, int2):
if int1 == 1:
return(int2*"\n")
else:
return(int2*" ")
def submitButton(self):
self.information_text.config(text=self.subButton.get())
def exit_Button(self):
self.destroy()
if __name__ == "__main__":
app = MyApp()
app.mainloop()
I need help. I need to bring out the image background to my new created frame in genkeymenu function. But the problem is, once the frame is created, the image background only seems to change in the first created frame. I tried to search for solutions but nothing works. Can I ask what's the problem?
import Tkinter as tk
from Tkinter import *
from PIL import Image, ImageTk
def genkeymenu():
generatemenu = tk.Toplevel(mainmenu)
bg1 = ImageTk.PhotoImage(file="key2.jpg")
background_label = Label(image=bg1)
background_label.place(x=0, y=0)
background_label.image = bg1
keynamelabel = Label(generatemenu, text="Enter your key name")
keynameEntry = Entry(generatemenu)
keynameButton = Button(generatemenu, text="Enter")
check1024= Checkbutton(generatemenu, text="1024 bit")
check2048= Checkbutton(generatemenu, text="2048 bit")
check4096= Checkbutton(generatemenu, text="4096 bit")
tk.background_label.grid(row=0)
keynamelabel.grid(row=0)
keynameEntry.grid(row=1)
keynameButton.grid(row=2)
check1024.grid(row=3, column=0)
check2048.grid(row=3, column=1)
check4096.grid(row=3, column=2)
generatemenu.title("Generate Key")
generatemenu.mainloop()
mainmenu = tk.Tk()
bg = ImageTk.PhotoImage(file="key.jpg")
background_label = Label(image=bg)
background_label.place(x=0, y=0)
genkeybutton = Button(mainmenu, text= "Generate Key Pair", fg="black", command=genkeymenu)
encryptbutton = Button(mainmenu, text= "Encrypt your message", fg="black")
decryptbutton = Button(mainmenu, text= "Decrypt your message", fg="black")
background_label.grid(row=0)
genkeybutton.grid(row=0, column=0, sticky = N, rowspan=2)
encryptbutton.grid(row=0, column=0)
decryptbutton.grid(row=0, column=0, sticky=S)
mainmenu.title("RSA ENCRYPTION")
mainmenu.mainloop()
You specify all the widget to appear in the toplevel window but didn't do that for the background. background_label = Label(generatemenu, image=bg1)
import Tkinter as tk
from Tkinter import *
PIL import Image, ImageTk
def genkeymenu():
generatemenu = tk.Toplevel(mainmenu)
bg1 = ImageTk.PhotoImage(file="key2.jpg")
background_label = Label(generatemenu, image=bg1)# specify the window you it to appear.
background_label.place(x=0, y=0)
background_label.image = bg1
keynamelabel = Label(generatemenu, text="Enter your key name")
keynameEntry = Entry(generatemenu)
keynameButton = Button(generatemenu, text="Enter")
check1024= Checkbutton(generatemenu, text="1024 bit")
check2048= Checkbutton(generatemenu, text="2048 bit")
check4096= Checkbutton(generatemenu, text="4096 bit")
tk.background_label.grid(row=0)
keynamelabel.grid(row=0)
keynameEntry.grid(row=1)
keynameButton.grid(row=2)
check1024.grid(row=3, column=0)
check2048.grid(row=3, column=1)
check4096.grid(row=3, column=2)
generatemenu.title("Generate Key")
generatemenu.mainloop()
mainmenu = tk.Tk()
bg = ImageTk.PhotoImage(file="key.jpg")
background_label = Label(image=bg)
background_label.place(x=0, y=0)
genkeybutton = Button(mainmenu, text= "Generate Key Pair", fg="black",
command=genkeymenu)
encryptbutton = Button(mainmenu, text= "Encrypt your message", fg="black")
decryptbutton = Button(mainmenu, text= "Decrypt your message", fg="black")
background_label.grid(row=0)
genkeybutton.grid(row=0, column=0, sticky = N, rowspan=2)
encryptbutton.grid(row=0, column=0)
decryptbutton.grid(row=0, column=0, sticky=S)
mainmenu.title("RSA ENCRYPTION")
mainmenu.mainloop()
does anyone know any alternatives for:
root = tk()
when i run my program, multiple windows run at the same time, just wondering whether there is an alternative so that they both dont open at the same time. The second window that opens as soon as the program is run should be launched when a button on the initial window is pressed. I also tried using:
root = Toplevel()
but the results are the same.
any ideas? thanks
def Search_Inventory():
#---First Window----
root = Toplevel()
root.title("Warehouse Inventory Control System")
root.configure(bg = "black")
#----Title displayed under the company logo on the first window----
Title_Screen = Label(root,
text="Warehouse Inventory Control System",
fg="grey",
bg="black",
font="Helevetica 25 bold",
pady = "50",
padx = "50",
).grid(row=3, column=4)
#----Interactive Input Boxes for the User----
#----Label to Notify what is needed in the entry box----
PN_Info_Label = Label(root,
text = "Part Number:",
fg="white",
bg="black",
font="Helevetica 15 bold",
padx = 50,
).grid(row=14, column=3, rowspan = 2)
#----Input Box for Part Number
PN_Display = StringVar()
Input_PartNumber = Entry(root,
textvariable=PN_Display,
fg = "blue",
font = "Helevtica 25 bold",
).grid(row=14, column=4)
#----A button that will proceed to the next part of the program----
Search_Button = Button(root,
text = "Search Inventory",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 15 bold",
command=lambda:Search_Prod(PN_Display.get()),
height = 1,
width = 15,
).grid(row=16, column=4,pady = 25,padx = 25,)
#----Information regarding how to enter the part number---
Info = Label(root,
text="Please Use Capitals to Enter Part Number",
fg= "red",
bg = "black",
font = "helevetica 12 bold",
).grid(row = 15, column = 4)
#----Adding the company logo to the first window----
photo = PhotoImage(file="image.gif")
photoLabel = Label(image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=4, pady = 10)
#----Linking the Help Document----
Help_Button = Button(root,
text = "Help",
command=Help_PDF,
fg = "Red",
bg = "Black",
height = "1",
bd = "2",
font = "Helevetica 20 bold",
width = "4",
).grid(row=0, column=5, pady= 10,padx = 50, sticky = E)
#----Saying who the program was made by----
Credits = Label(root,
text = "Created By: Me",
fg = "White",
bg = "Black",
font = "Helevetica 10 underline",
).grid(row = 19, column = 5)
#To Make Sure that the window doesn't close
root.mainloop()
thats the subroutine that meant to run later but runs straight away.
root_menu = frame()
root_menu.title("Warehouse Inventory Control System")
root_menu.configure(bg = "black")
photo = PhotoImage(file="logo.gif")
photoLabel = Label(image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=3,columnspan = 4, sticky = N)
Title_Screen = Label(root_menu,
text="Welcome to the SsangYong\n Warehouse Inventory Control System",
fg="grey",
bg="black",
font="Helevetica 25 bold",
pady = "50",
padx = "50",
).grid(row=2, column=3)
Search_Inventory = Button(root_menu,
command = Search_Inventory(),
text = "Search Inventory",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 50,
).grid(row=16, column=3,pady = 25,padx = 25,)
Add_Stock = Button(root_menu,
text = "Add New Items",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 60,
).grid(row=15, column=3,pady = 25,padx = 25,)
Print_Report = Button(root_menu,
text = "Print Stock Report",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 70,
).grid(row=17, column=3,pady = 25,padx = 25,)
Help_Button = Button(root_menu,
text = "Help",
command=Help_PDF,
fg = "Red",
bg = "Black",
height = "1",
bd = "2",
font = "Helevetica 20 bold",
width = "4",
).grid(row=1, column=3,rowspan = 2, sticky= NE)
Credits = Label(root,
text = "Created By:mk",
fg = "White",
bg = "Black",
font = "Helevetica 10 underline",
).grid(row = 19, column = 5)
root_menu.mainloop()
this is what is meant to pop up initially but comes completely mixed up with the other one.
does anyone know any alternatives for: root = tk() [sic]
There is no alternative. A tkinter application absolutely must have a single root window. If you do not explicitly create one (and you should), one will be created for you the first time you create any other widget.
The second window that opens as soon as the program is run should be launched when a button on the initial window is pressed.
The reason for this is that you are telling it to open immediately. Take a look at this code:
Search_Inventory = Button(root_menu,
command = Search_Inventory(),
The above code is identical to this:
result = Search_Inventory()
Search_Inventory = Button(root_menu, command=result)
Notice the lack of () on the command. The command attribute requires a reference to a function.
command= needs function name - callback - it means without ()
But you have () in
command = Search_Inventory()
and this is why this is executed at start, not when you click button
BTW: tkinter need only one mainloop() - if you use two mainloop() then it works incorrectly.
EDIT: Problem with image is because you didn't set parent for Label in second window
photoLabel = Label(image=photo)
so it used main window as default
You need
photoLabel = Label(root, image=photo)
EDIT: minimal working code
from tkinter import *
def Help_PDF():
pass
def Search_Inventory():
#--- Second Window ----
root = Toplevel()
Title_Screen = Label(root, text="Warehouse Inventory Control System")
Title_Screen.grid(row=3, column=4)
PN_Info_Label = Label(root, text="Part Number:")
PN_Info_Label.grid(row=14, column=3, rowspan=2)
PN_Display = StringVar()
Input_PartNumber = Entry(root, textvariable=PN_Display)
Input_PartNumber.grid(row=14, column=4)
Search_Button = Button(root, text="Search Inventory",
command=lambda:Search_Prod(PN_Display.get()))
Search_Button.grid(row=16, column=4, pady=25, padx=25)
Info = Label(root, text="Please Use Capitals to Enter Part Number")
Info.grid(row=15, column=4)
photo = PhotoImage(file="image.gif")
photoLabel = Label(root, image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=4, pady=10)
Help_Button = Button(root, text="Help",
command=Help_PDF)
Help_Button.grid(row=0, column=5, pady=10, padx=50, sticky=E)
Credits = Label(root, text="Created By: Me")
Credits.grid(row=19, column=5)
# --- First Window ---
root_menu = Tk()
photo = PhotoImage(file="logo.gif")
photoLabel = Label(root_menu, image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=3, columnspan=4, sticky=N)
Title_Screen = Label(root_menu, text="Welcome to the SsangYong\n Warehouse Inventory Control System",)
Title_Screen.grid(row=2, column=3)
Search_Inventory = Button(root_menu, text="Search Inventory",
command=Search_Inventory)
Search_Inventory.grid(row=16, column=3, pady=25, padx=25)
Add_Stock = Button(root_menu, text="Add New Items")
Add_Stock.grid(row=15, column=3, pady=25, padx=25)
Print_Report = Button(root_menu, text="Print Stock Report")
Print_Report.grid(row=17, column=3, pady=25, padx=25)
Help_Button = Button(root_menu, text="Help",
command=Help_PDF)
Help_Button.grid(row=1, column=3, rowspan=2, sticky=NE)
Credits = Label(root_menu, text="Created By:mk")
Credits.grid(row=19, column=5)
root_menu.mainloop()
I would like to play a video from my documents and have this tkinter code already but I cannot work out how to play a video when this button is pressed, can anyone help?
import Tkinter as tkinter
import time
import webbrowser
import pygame
window = tkinter.Tk()
window.title("Matthew's Login")
window.wm_iconbitmap('matt.ico')
window.configure(background='#3399FF')
username = ['Matthew']
password = ['123']
def callback():
global username
global password
usr = ent.get()
pas = ent2.get()
x = 0
for i in range (0,len(username)):
if usr == username[x]:
time.sleep(1)
if pas == password[x]:
window2 = tkinter.Tk()
window2.title("Matthew's Window")
window2.wm_iconbitmap('favicon.ico')
def click():
#THIS IS THE PLACE WHERE I WANT THE VIDEO TO PLAY IN THE WINDOW
button = tkinter.Button(window2, text = 'click me plz', command=click)
button.pack()
window2.mainloop()
else:
time.sleep(0.1)
else:
time.sleep(0.1)
x += 1
return
def newuser():
global username
global password
usr2 = ent.get()
pas2 = ent2.get()
username.append(usr2)
password.append(pas2)
lbl0 = tkinter.Label(window, text="Please login to continue", bg='#3399FF', font=("Comic Sans MS", 16))
lbl0.pack()
lbl = tkinter.Label(window, text ="Username", bg='#3399FF', font=("Comic Sans MS", 10))
ent = tkinter.Entry(window, bg='#99CCFF')
lbl2 = tkinter.Label(window, text ="Password", bg='#3399FF', font=("Comic Sans MS", 10))
ent2 = tkinter.Entry(window, bg='#99CCFF')
btm = tkinter.Button(window, text = "Login", bg='#99CCFF', font=("Comic Sans MS", 10), command = callback)
btm2 = tkinter.Button(window, text = "Create new account", bg='#99CCFF', font=("Comic Sans MS", 10), command = newuser)
lbl.pack()
ent.pack()
lbl2.pack()
ent2.pack()
btm.pack()
btm2.pack()
window.mainloop()