Guest User

Untitled

a guest
Apr 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.28 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. from tkinter import *
  188. import tkinter.messagebox as tm
  189. import BatchFrame as bf
  190.  
  191. class LoginFrame():
  192.  
  193. def __init__(self):
  194. self.root = Tk()
  195. self.root.title("SBSHREG")
  196. self.root.geometry("235x120")
  197.  
  198. self.label_username = Label(self.root, text="Username")
  199. self.label_password = Label(self.root, text="Password")
  200. self.photo = PhotoImage(file="sbshreg.png")
  201.  
  202. self.label_image = Label(self.root, image=self.photo)
  203. self.label_image.image = self.photo
  204.  
  205. self.entry_username = Entry(self.root)
  206. self.entry_password = Entry(self.root, show="*")
  207.  
  208. self.label_image.grid(row=0, column=2, rowspan=2, columnspan=2, sticky=W, padx=10)
  209. self.label_username.grid(row=2, sticky=E)
  210. self.label_password.grid(row=3, sticky=E)
  211.  
  212. self.entry_username.grid(row=2, column=1, sticky=E)
  213. self.entry_password.grid(row=3, column=1, sticky=E)
  214.  
  215. self.logbtn = Button(self.root, text="Login", command=self._login_btn_clicked)
  216. self.logbtn.grid(row=4, column=1, columnspan=2, sticky=S+E+N+W)
  217.  
  218. self.root.grid()
  219. self.root.mainloop()
  220.  
  221. def _login_btn_clicked(self):
  222. username = self.entry_username.get()
  223. password = self.entry_password.get()
  224.  
  225. if username == "123" and password == "123":
  226. tm.showinfo("SBSHREG", "Welcome 123")
  227. #The sweet spot where all goes wrong...
  228. self.root.destroy()
  229. bf = bf.BatchFrame()
  230. else:
  231. tm.showerror("SBSHREG", "Incorrect username")
  232.  
  233. lf = LoginFrame()
  234.  
  235. from tkinter import *
  236. import tkinter.messagebox as tm
  237. from tkinter import ttk as ttk
  238.  
  239. class BatchFrame():
  240.  
  241. def __init__(self):
  242. self.root = Tk()
  243. self.root.title("SBSHREG")
  244. self.root.geometry("432x480")
  245.  
  246. self.photo = PhotoImage(file="sbshreg.png")
  247. self.label_photo = Label(self.root, image=self.photo)
  248. self.label_photo.image = self.photo
  249.  
  250. self.label_photo.grid(row=0, column=2, sticky=N, padx=10, pady=10)
  251.  
  252. #Add frame starting here
  253. frame = LabelFrame(self.root, text='Voeg batch toe')
  254. frame.grid (row=0, column=0, padx=10)
  255.  
  256. self.label_batch = Label(frame, text="Batchnummer")
  257. self.label_employee = Label(frame, text="Medewerker")
  258. self.label_material = Label(frame, text="Materiaalsoort")
  259. self.label_weight = Label(frame, text="Gewicht")
  260.  
  261. self.entry_batch = Entry(frame)
  262. self.entry_employee = Entry(frame)
  263. self.entry_material= Entry(frame)
  264. self.entry_weight = Entry(frame)
  265.  
  266. self.label_batch.grid(row=0, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  267. self.label_employee.grid(row=2, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  268. self.label_material.grid(row=4, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  269. self.label_weight.grid(row=6, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  270.  
  271. self.entry_batch.grid(row=1, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  272. self.entry_employee.grid(row=3, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  273. self.entry_material.grid(row=5, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  274. self.entry_weight.grid(row=7, column=0, sticky=S+E+N+W, columnspan=2, padx=10)
  275.  
  276. self.btnadd = Button(frame, text='Voeg toe', command=self._btn_add_clicked)
  277. self.btnadd.grid(column=0, row=8, pady=10)
  278.  
  279. #Search frame starting here
  280. framesearch = LabelFrame(self.root, text='Zoek')
  281. framesearch.grid(row=0, column=1, sticky=N)
  282.  
  283. self.label_batch = Label(framesearch, text="Batchnummer")
  284. self.label_employee = Label(framesearch, text="Medewerker")
  285.  
  286. self.entry_batch = Entry(framesearch)
  287. self.entry_employee = Entry(framesearch)
  288.  
  289. self.label_batch.grid(row=0, column=0, sticky=S, columnspan=2, padx=10)
  290. self.label_employee.grid(row=2, column=0, sticky=S, columnspan=2, padx=10)
  291.  
  292. self.entry_batch.grid(row=1, column=0, sticky=S + E + N + W, columnspan=2, padx=10, pady=10)
  293. self.entry_employee.grid(row=3, column=0, sticky=S + E + N + W, columnspan=2, padx=10, pady=10)
  294.  
  295. self.btnbatch = Button(framesearch, text="Zoek", command=self._btn_batch_clicked)
  296. self.btnemployee = Button(framesearch, text="Zoek", command=self._btn_employee_clicked)
  297.  
  298. self.btnbatch.grid(columnspan=1, column=2, row=1, sticky=W, padx=10)
  299. self.btnemployee.grid(columnspan=1, column=2, row=3, sticky=W, padx=10)
  300.  
  301. #This is the viewingarea for the data
  302. self.root.tree = ttk.Treeview (height=10, columns=("Batchnummer", "Medewerker", "Materiaalsoort", "Gewicht"))
  303. self.root.tree.grid (row=9, columnspan=10, padx=10, pady=10)
  304. self.root.tree.heading('#1', text='Batchnummer', anchor=W)
  305. self.root.tree.heading('#2', text='Medewerker', anchor=W)
  306. self.root.tree.heading('#3', text='Materiaalsoort', anchor=W)
  307. self.root.tree.heading('#4', text='Gewicht', anchor=W)
  308. self.root.tree.column('#0', stretch=NO, minwidth=0, width=0)
  309. self.root.tree.column('#1', stretch=NO, minwidth=0, width=100)
  310. self.root.tree.column('#2', stretch=NO, minwidth=0, width=100)
  311. self.root.tree.column('#3', stretch=NO, minwidth=0, width=100)
  312. self.root.tree.column('#4', stretch=NO, minwidth=0, width=100)
  313.  
  314. self.root.grid()
  315. self.root.mainloop()
  316.  
  317. def _btn_add_clicked(self):
  318. batch = self.entry_batch.get()
  319.  
  320. def _btn_batch_clicked(self):
  321. batch = self.entry_batch.get()
  322.  
  323. def _btn_employee_clicked(self):
  324. batch = self.entry_employee.get()
  325.  
  326. exec(open("./test2.py").read())
  327.  
  328. BatchFrame.BatchFrame(root)
  329.  
  330. self.label_photo = Label(root, image=self.photo)
  331.  
  332. self.label_photo = Label(master, image=self.photo)
  333.  
  334. class BatchFrame(Frame):
  335. def __init__(self, master):
  336. super().__init__(master)
  337. self.master = master # add this
  338. self.master.title("SBSHREG") # and this
  339. self.master.geometry("432x480") # and this
  340.  
  341. root = Tk()
  342. root.title("SBSHREG")
  343. root.geometry("432x480")
  344. lf = BatchFrame(root)
  345. root.mainloop()
  346.  
  347. class LoginFrame(Frame):
  348. def __init__(self, master):
  349. super().__init__(master)
  350. self.master = master # add this
  351.  
  352. BatchFrame.BatchFrame(root)
  353.  
  354. BatchFrame.BatchFrame(self.master)
Add Comment
Please, Sign In to add comment