Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. from tkinter import *
  2. import sqlite3
  3. import time
  4. #import RPi.GPIO as GPIO
  5. import tkinter.font
  6.  
  7. db = sqlite3.connect('Automat111.db')
  8.  
  9.  
  10. class FullScreenApp(object):
  11. def __init__(self, master, **kwargs):
  12. self.master=master
  13. pad=3
  14. self._geom = '200x200+0+0'
  15. master.geometry("{0}x{1}+0+0".format(master.winfo_screenwidth()-pad,master.winfo_screenheight()-pad))
  16. master.bind('<Escape>',self.toggle_geom)
  17. self.state = False
  18. self.master.bind("<F11>", self.toggle_fullscreen)
  19. self.master.bind("<Escape>", self.end_fullscreen)
  20.  
  21. def toggle_geom(self, event):
  22. geom = self.master.winfo_geometry()
  23. print(geom,self._geom)
  24. self.geom = geom
  25.  
  26. def toggle_fullscreen(self, event = None):
  27. self.state = not self.state
  28. self.master.attributes("-fullscreen", self.state)
  29. return "break"
  30.  
  31. def end_fullscreen(self, event = None):
  32. self.state = False
  33. self.master.attributes("-fullscreen", False)
  34. return "brak"
  35.  
  36.  
  37. root=Tk()
  38. app=FullScreenApp(root)
  39. root.configure(background="teal")
  40.  
  41. textin1 = StringVar()
  42. textin2 = StringVar()
  43. textin3 = StringVar()
  44. textin4 = StringVar()
  45. textin5 = StringVar()
  46.  
  47.  
  48.  
  49. def Rejestracja():
  50. window1 = Tk()
  51.  
  52. #windowWidth = window1.winfo.reqwidth()
  53. # windowHeight = window1.winfo_reqheight()
  54. #positionRight = int(root.winfo_screenwidth()/2 - windowWidth/2)
  55. # positionDown = int(root.winfo_screenheight()/2 - windowHeight/2)
  56.  
  57. window1.title('Rejestracja')
  58.  
  59. window1.geometry("500x500")
  60. # window1.geometry("400x400+{}+{}".format(positionRight, positionDown))
  61.  
  62. lab=Label(window1,text='Login:',font=('none 13 bold'))
  63. lab.place(x=0,y=0)
  64.  
  65. ent_Login=Entry(window1,width=20,font=('none 13 bold'),textvar=textin1)
  66. ent_Login.place(x=80,y=0)
  67.  
  68. lab1=Label(window1,text='Haslo:',font=('none 13 bold'))
  69. lab1.place(x=0,y=40)
  70.  
  71. ent_Haslo=Entry(window1,width=20,font=('none 13 bold'),textvar=textin2)
  72. ent_Haslo.place(x=80,y=40)
  73.  
  74. lab2=Label(window1,text='Wiek:',font=('none 13 bold'))
  75. lab2.place(x=0,y=80)
  76.  
  77. ent_Wiek=Entry(window1,width=20,font=('none 13 bold'),textvar=textin3)
  78. ent_Wiek.place(x=80,y=80)
  79.  
  80. lab3=Label(window1,text='Plec:',font=('none 13 bold'))
  81. lab3.place(x=0,y=120)
  82.  
  83. ent_Plec=Entry(window1,width=20,font=('none 13 bold'),textvar=textin4)
  84. ent_Plec.place(x=80,y=120)
  85.  
  86. lab4=Label(window1,text='Waga:',font=('none 13 bold'))
  87. lab4.place(x=0,y=160)
  88.  
  89. ent_Waga=Entry(window1,width=20,font=('none 13 bold'),textvar=textin5)
  90. ent_Waga.place(x=80,y=160)
  91.  
  92. but=Button(window1,padx=2,pady=2,text='Submit',command=insert,font=('none 13 bold'))
  93. but.place(x=60,y=190)
  94.  
  95. ##SHOW DO WYJEBANIA BEDZIE (TERAZ JEST TYLKO DO TESTOW)
  96.  
  97. res=Button(window1,padx=2,pady=2,text='Show',command=show,font=('none 13 bold'))
  98. res.place(x=160,y=190)
  99.  
  100. window1.mainloop()
  101.  
  102. Btn1 = Button(text='Rejestracja',font=('none 13 bold'), command=Rejestracja)
  103. Btn1.place(x=100,y=50)
  104.  
  105. Factor1=0.7
  106. Factor2=0.6
  107.  
  108. def insert():
  109.  
  110. Login = textin1.get()
  111. Haslo = textin2.get()
  112. Wiek = textin3.get()
  113. Plec = textin4.get()
  114. Waga = textin5.get()
  115.  
  116.  
  117. conn = sqlite3.connect('Automat111.db')
  118. print(Login,Haslo,Wiek,Plec,Waga)
  119. with conn:
  120. cursor = conn.cursor()
  121. cursor.execute('INSERT INTO Uzytkownicy(Login, Haslo, Wiek, Plec, Waga) VALUES (?,?,?,?,?)',(Login, Haslo, Wiek, Plec, Waga))
  122. db.close()
  123.  
  124.  
  125. def show():
  126. connt = sqlite3.connect('Automat111.db')
  127. cursor = connt.cursor()
  128. cursor.execute('SELECT * FROM Uzytkownicy')
  129. for row in cursor.fetchall():
  130. print(row)
  131.  
  132.  
  133. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement