Guest User

Untitled

a guest
Apr 16th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.19 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox as tm
  3.  
  4. class LoginFrame(Frame):
  5. def __init__(self, master):
  6. super().__init__(master)
  7.  
  8. self.label_username = Label(self, text="Username")
  9. self.label_password = Label(self, text="Password")
  10. self.photo = PhotoImage(file="sbshreg.png")
  11.  
  12. self.label_image = Label(root, image=self.photo)
  13. self.label_image.image = self.photo
  14.  
  15. self.entry_username = Entry(self)
  16. self.entry_password = Entry(self, show="*")
  17.  
  18. self.label_username.grid(row=0, sticky=E)
  19. self.label_password.grid(row=1, sticky=E)
  20. self.label_image.grid(row=3, column=2, rowspan=2, columnspan=2, sticky=W, padx=10)
  21.  
  22. self.entry_username.grid(row=0, column=1, sticky=E)
  23. self.entry_password.grid(row=1, column=1, sticky=E)
  24.  
  25. self.logbtn = Button(self, text="Login", command=self._login_btn_clicked)
  26. self.logbtn.grid(columnspan=2, column=1, row=2, sticky=S+E+N+W)
  27.  
  28. self.grid()
  29.  
  30. def _login_btn_clicked(self):
  31. username = self.entry_username.get()
  32. password = self.entry_password.get()
  33.  
  34. if username == "123" and password == "123":
  35. tm.showinfo("SBSHREG", "Welcome 123")
  36. #The sweet spot where all goes wrong...
  37. self.destroy()
  38. exec(open("./BatchFrame.py").read())
  39. else:
  40. tm.showerror("SBSHREG", "Incorrect username")
  41.  
  42. root = Tk()
  43. root.title("SBSHREG")
  44. root.geometry("235x120")
  45. lf = LoginFrame(root)
  46. root.mainloop()
  47.  
  48. from tkinter import *
  49. import tkinter.messagebox as tm
  50. from tkinter import ttk as ttk
  51.  
  52. class BatchFrame(Frame):
  53. def __init__(self, master):
  54. super().__init__(master)
  55.  
  56. self.photo = PhotoImage(file="sbshreg.png")
  57. self.label_photo = Label(root, image=self.photo)
  58. self.label_photo.image = self.photo
  59.  
  60. self.label_photo.grid(row=0, column=2, sticky=N, padx=10, pady=10)
  61.  
  62. #Add frame starting here
  63. frame = LabelFrame(self.master, text='Voeg batch toe')
  64. frame.grid (row=0, column=0, padx=10)
  65.  
  66. self.label_batch = Label(frame, text="Batchnummer")
  67. self.label_employee = Label(frame, text="Medewerker")
  68. self.label_material = Label(frame, text="Materiaalsoort")
  69. self.label_weight = Label(frame, text="Gewicht")
  70.  
  71. self.entry_batch = Entry(frame)
  72. self.entry_employee = Entry(frame)
  73. self.entry_material= Entry(frame)
  74. self.entry_weight = Entry(frame)
  75.  
  76. self.label_batch.grid(row=0, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  77. self.label_employee.grid(row=2, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  78. self.label_material.grid(row=4, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  79. self.label_weight.grid(row=6, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  80.  
  81. self.entry_batch.grid(row=1, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  82. self.entry_employee.grid(row=3, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  83. self.entry_material.grid(row=5, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  84. self.entry_weight.grid(row=7, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  85.  
  86. self.btnadd = Button(frame, text='Voeg toe', command=self._btn_add_clicked)
  87. self.btnadd.grid(column=0, row=8, pady=10)
  88.  
  89. #Search frame starting here
  90. framesearch = LabelFrame(self.master, text='Zoek')
  91. framesearch.grid(row=0, column=1, sticky=N)
  92.  
  93. self.label_batch = Label(framesearch, text="Batchnummer")
  94. self.label_employee = Label(framesearch, text="Medewerker")
  95.  
  96. self.entry_batch = Entry(framesearch)
  97. self.entry_employee = Entry(framesearch)
  98.  
  99. self.label_batch.grid(row=0, column=0, sticky=S, columnspan=2, padx=10)
  100. self.label_employee.grid(row=2, column=0, sticky=S, columnspan=2, padx=10)
  101.  
  102. self.entry_batch.grid(row=1, column=0, sticky=S + E + N + W, columnspan=2, padx=10, pady=10)
  103. self.entry_employee.grid(row=3, column=0, sticky=S + E + N + W, columnspan=2, padx=10, pady=10)
  104.  
  105. self.btnbatch = Button(framesearch, text="Zoek", command=self._btn_batch_clicked)
  106. self.btnemployee = Button(framesearch, text="Zoek", command=self._btn_employee_clicked)
  107.  
  108. self.btnbatch.grid(columnspan=1, column=2, row=1, sticky=W, padx=10)
  109. self.btnemployee.grid(columnspan=1, column=2, row=3, sticky=W, padx=10)
  110.  
  111. #This is the viewingarea for the data
  112. self.tree = ttk.Treeview (height=10, columns=("Batchnummer", "Medewerker", "Materiaalsoort", "Gewicht"))
  113. self.tree.grid (row=9, columnspan=10, padx=10, pady=10)
  114. self.tree.heading('#1', text='Batchnummer', anchor=W)
  115. self.tree.heading('#2', text='Medewerker', anchor=W)
  116. self.tree.heading('#3', text='Materiaalsoort', anchor=W)
  117. self.tree.heading('#4', text='Gewicht', anchor=W)
  118. self.tree.column('#0', stretch=NO, minwidth=0, width=0)
  119. self.tree.column('#1', stretch=NO, minwidth=0, width=100)
  120. self.tree.column('#2', stretch=NO, minwidth=0, width=100)
  121. self.tree.column('#3', stretch=NO, minwidth=0, width=100)
  122. self.tree.column('#4', stretch=NO, minwidth=0, width=100)
  123.  
  124. self.grid()
  125.  
  126. def _btn_add_clicked(self):
  127. batch = self.entry_batch.get()
  128.  
  129. def _btn_batch_clicked(self):
  130. batch = self.entry_batch.get()
  131.  
  132. def _btn_employee_clicked(self):
  133. batch = self.entry_employee.get()
  134.  
  135.  
  136. root = Tk()
  137. root.title("SBSHREG")
  138. root.geometry("432x480")
  139. lf = BatchFrame(root)
  140. root.mainloop()
  141.  
  142. from tkinter import *
  143. import tkinter.messagebox as tm
  144. from tkinter import ttk as ttk
  145. from batchframe import BatchFrame
  146.  
  147. class LoginFrame(Frame):
  148. def __init__(self, master):
  149. super().__init__(master)
  150. self.master = master
  151.  
  152. self.label_username = Label(self, text="Username")
  153. self.label_password = Label(self, text="Password")
  154. self.photo = PhotoImage(file="icon.png")
  155.  
  156. self.label_image = Label(root, image=self.photo)
  157. self.label_image.image = self.photo
  158.  
  159. self.entry_username = Entry(self)
  160. self.entry_password = Entry(self, show="*")
  161.  
  162. self.label_username.grid(row=0, sticky=E)
  163. self.label_password.grid(row=1, sticky=E)
  164. self.label_image.grid(row=3, column=2, rowspan=2, columnspan=2, sticky=W, padx=10)
  165.  
  166. self.entry_username.grid(row=0, column=1, sticky=E)
  167. self.entry_password.grid(row=1, column=1, sticky=E)
  168.  
  169. self.logbtn = Button(self, text="Login", command=self._login_btn_clicked)
  170. self.logbtn.grid(columnspan=2, column=1, row=2, sticky=S+E+N+W)
  171.  
  172. self.grid()
  173.  
  174. def _login_btn_clicked(self):
  175. username = self.entry_username.get()
  176. password = self.entry_password.get()
  177.  
  178. if username == "123" and password == "123":
  179. tm.showinfo("SBSHREG", "Welcome 123")
  180. #The sweet spot where all goes wrong...
  181. self.destroy()
  182. # Create the instance of the BatchFrame class, passing in self.master
  183. self.batchframe = BatchFrame(self.master)
  184. else:
  185. tm.showerror("SBSHREG", "Incorrect username")
  186.  
  187. exec(open("./test2.py").read())
  188.  
  189. BatchFrame.BatchFrame(root)
  190.  
  191. self.label_photo = Label(root, image=self.photo)
  192.  
  193. self.label_photo = Label(master, image=self.photo)
Add Comment
Please, Sign In to add comment