Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.messagebox as tm
- import tkinter
- from tkinter.colorchooser import *
- import gettext
- root = Tk()
- root.geometry("400x400")
- root.title("tk")
- #root.configure(background=myColour)
- '''
- def color1():
- color = colorchooser.askcolor()
- color_name = color[1]#to pick up the color name in HTML notation, i.e. the 2nd element of the tuple returned by the colorchooser
- root.configure(background=color_name)
- '''
- class LoginFrame(Frame):
- def __init__(self, master):
- super().__init__(master)
- myColour = "#80e5ff"
- root.configure(background=myColour)
- menu = Menu(self.master)
- self.master.config(menu=menu)
- file = Menu(menu)
- file.add_command(label = 'Change Language')
- file.add_command(label = 'Change Colour', command = self.change_color)
- menu.add_cascade(label='Settings', menu=file)
- self.label_1 = Label(self, text="Username")
- self.label_2 = Label(self, text="Password")
- self.entry_1 = Entry(self)
- self.entry_2 = Entry(self, show="*")
- self.label_1.grid(row=0, sticky=E)
- self.label_2.grid(row=1, sticky=E)
- self.entry_1.grid(row=0, column=1)
- self.entry_2.grid(row=1, column=1)
- self.checkbox = Checkbutton(self, text="Keep me logged in")
- self.checkbox.grid(columnspan=10)
- self.logbtn = Button(self, text="Login", command = self._login_btn_clickked)
- self.logbtn.grid(columnspan=2)
- self.logbtn = Button(self, text="Forgot Password",
- command = lambda: contoller.show_frame(ForgotPassword))
- #self.logbtn.grid(columnspan=2)
- self.pack()
- self.place(x=100,y=100)
- def _login_btn_clickked(self):
- username = self.entry_1.get()
- password = self.entry_2.get()
- if username == "John" and password == "password":
- tm.showinfo("Login info", "Welcome to Webcourses John")
- else:
- tm.showerror("Login error", "Incorrect username")
- #def ForgotPassword(self):
- def change_color(self, master):
- color = colorchooser.askcolor()
- print(color)
- color = str(color)
- colour1 = color.split("'")
- colour2 = colour1
- #myLabel = Label(LoginFrame, text = myColour).pack()
- #self.master.configure(background=myColour)
- self.master['bg'] = colour2
- lf = LoginFrame(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement