daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Apr 27th, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. import tkinter.messagebox as tm
  3. import tkinter
  4. from tkinter.colorchooser import *
  5. import gettext
  6.  
  7.  
  8. root = Tk()
  9. root.geometry("400x400")
  10. root.title("tk")
  11. #root.configure(background=myColour)
  12. '''
  13. def color1():
  14.     color = colorchooser.askcolor()
  15.     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
  16.  
  17. root.configure(background=color_name)
  18. '''
  19.  
  20. class LoginFrame(Frame):
  21.     def __init__(self, master):
  22.         super().__init__(master)
  23.  
  24.         myColour = "#80e5ff"
  25.         root.configure(background=myColour)
  26.  
  27.  
  28.         menu = Menu(self.master)
  29.         self.master.config(menu=menu)
  30.  
  31.         file = Menu(menu)
  32.  
  33.         file.add_command(label = 'Change Language')
  34.         file.add_command(label = 'Change Colour', command = self.change_color)
  35.         menu.add_cascade(label='Settings', menu=file)
  36.  
  37.         self.label_1 = Label(self, text="Username")
  38.         self.label_2 = Label(self, text="Password")
  39.  
  40.         self.entry_1 = Entry(self)
  41.         self.entry_2 = Entry(self, show="*")
  42.  
  43.         self.label_1.grid(row=0, sticky=E)
  44.         self.label_2.grid(row=1, sticky=E)
  45.         self.entry_1.grid(row=0, column=1)
  46.         self.entry_2.grid(row=1, column=1)
  47.  
  48.         self.checkbox = Checkbutton(self, text="Keep me logged in")
  49.         self.checkbox.grid(columnspan=10)
  50.  
  51.         self.logbtn = Button(self, text="Login", command = self._login_btn_clickked)
  52.         self.logbtn.grid(columnspan=2)
  53.  
  54.         self.logbtn = Button(self, text="Forgot Password",
  55.                              command = lambda: contoller.show_frame(ForgotPassword))
  56.         #self.logbtn.grid(columnspan=2)
  57.  
  58.         self.pack()
  59.  
  60.         self.place(x=100,y=100)
  61.  
  62.  
  63.     def _login_btn_clickked(self):
  64.  
  65.         username = self.entry_1.get()
  66.         password = self.entry_2.get()
  67.  
  68.         if username == "John" and password == "password":
  69.             tm.showinfo("Login info", "Welcome to Webcourses John")
  70.         else:
  71.             tm.showerror("Login error", "Incorrect username")
  72.  
  73.     #def ForgotPassword(self):
  74.  
  75.  
  76.     def change_color(self, master):
  77.  
  78.         color = colorchooser.askcolor()
  79.         print(color)
  80.         color = str(color)
  81.         colour1 = color.split("'")
  82.         colour2 = colour1
  83.         #myLabel = Label(LoginFrame, text = myColour).pack()
  84.         #self.master.configure(background=myColour)
  85.         self.master['bg'] = colour2
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. lf = LoginFrame(root)
  93. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top