Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.27 KB | None | 0 0
  1. from tkinter import*
  2. import sqlite3
  3. import os
  4. from tkinter import *
  5. from tkinter import messagebox as mb
  6.  
  7. conn = sqlite3.connect("mydatabase.db") # или :memory: чтобы сохранить в RAM
  8. cursor = conn.cursor()
  9.  
  10. # Создание таблицы
  11. cursor.execute("""CREATE TABLE albums
  12. (title text, artist text, release_date text,
  13. publisher text, media_type text)
  14. """)
  15.  
  16. trip_date=0
  17. kategori_ticket = 0
  18. mesto_ticket = 0
  19. persons_name = 0
  20. persons_surname = 0
  21. persons_Date_of_Birth = 0
  22. persons_pass_seria = 0
  23. persons_pass_number = 0
  24. persons_patronymic=0
  25.  
  26.  
  27. def form5():
  28. def data_validation():
  29. print("пока ничего")
  30. window5 = Tk()
  31. window5.title("Форма5")
  32. window5.geometry("350x450")
  33. window5.resizable(False, False)
  34. form5_text = Label(window5, text = "Распечатка билета", justify=CENTER)
  35. form5_text.configure(font = "Arial, 15", fg = "black")
  36. form5_text.pack()
  37. name_text= Label(window5, text = "Имя:")
  38. name_text.configure(font = "Arial, 10", fg = "black")
  39. name_text.place (y=50)
  40. surname_text= Label(window5, text = "Фамилия:")
  41. surname_text.configure(font = "Arial, 10", fg = "black")
  42. surname_text.place (y=80)
  43. patronymic_text= Label(window5, text = "Отчество:")
  44. patronymic_text.configure(font = "Arial, 10", fg = "black")
  45. patronymic_text.place (y=110)
  46. Date_of_Birth_text= Label(window5, text = "Дата рождения:")
  47. Date_of_Birth_text.configure(font = "Arial, 10", fg = "black")
  48. Date_of_Birth_text.place (y=140)
  49. pass_text = Label(window5, text = "Паспорт (серия -> номер):")
  50. pass_text.configure(font = "Arial, 10", fg = "black")
  51. pass_text.place (y=170)
  52. ############################################################################
  53. persons_name_text_form5 = Label(window5)
  54. persons_name_text_form5.place(x= 30, y=50)
  55. persons_name_text_form5.configure(font = "Arial, 10", fg = "black", text=persons_name)
  56. persons_surname_text_form5 = Label(window5)
  57. persons_surname_text_form5.place(x= 60, y=80)
  58. persons_surname_text_form5.configure(font = "Arial, 10", fg = "black", text=persons_surname)
  59. persons_patronymic_text_form5 = Label(window5)
  60. persons_patronymic_text_form5.place(x= 60, y=110)
  61. persons_patronymic_text_form5.configure(font = "Arial, 10", fg = "black", text=persons_patronymic)
  62. persons_Date_of_Birth_text_form5 = Label(window5)
  63. persons_Date_of_Birth_text_form5.place(x= 100, y=140)
  64. persons_Date_of_Birth_text_form5.configure(font = "Arial, 10", fg = "black", text=persons_Date_of_Birth)
  65. persons_pass_seria_form5 = Label(window5)
  66. persons_pass_seria_form5.place(x= 160, y=170)
  67. persons_pass_seria_form5.configure(font = "Arial, 10", fg = "black", text=persons_pass_seria)
  68. persons_number_seria_form5 = Label(window5)
  69. persons_number_seria_form5.place(x= 210, y=170)
  70. persons_number_seria_form5.configure(font = "Arial, 10", fg = "black", text=persons_pass_number)
  71. ############################################################################
  72. buttransition3=Button(window5, text = "Подтвердить", command = data_validation, width=15, height=2, font=("Arial, 10"), bg ="#00c3ff")
  73. buttransition3.place(x=210, y=400)
  74. def form4():
  75. window4 = Tk()
  76. window4.title("Форма4")
  77. window4.geometry("350x450")
  78. window4.resizable(False, False)
  79. form4_text = Label(window4, text = "Ввод личных данных", justify=CENTER)
  80. form4_text.configure(font = "Arial, 15", fg = "black")
  81. form4_text.pack()
  82. name_text= Label(window4, text = "Имя:")
  83. name_text.configure(font = "Arial, 10", fg = "black")
  84. name_text.place (y=50)
  85. surname_text= Label(window4, text = "Фамилия:")
  86. surname_text.configure(font = "Arial, 10", fg = "black")
  87. surname_text.place (y=80)
  88. patronymic_text= Label(window4, text = "Отчество:")
  89. patronymic_text.configure(font = "Arial, 10", fg = "black")
  90. patronymic_text.place (y=110)
  91. Date_of_Birth_text= Label(window4, text = "Дата рождения:")
  92. Date_of_Birth_text.configure(font = "Arial, 10", fg = "black")
  93. Date_of_Birth_text.place (y=140)
  94. pass_text = Label(window4, text = "Паспорт (серия -> номер):")
  95. pass_text.configure(font = "Arial, 10", fg = "black")
  96. pass_text.place (y=170)
  97. textboxname = Entry(window4, width=20)
  98. textboxname.focus_set()
  99. textboxname.place(x= 100, y=50)
  100. textboxsurname = Entry(window4, width=20)
  101. textboxsurname.focus_set()
  102. textboxsurname.place(x= 100, y=80)
  103. textboxpatronymic = Entry(window4, width=20)
  104. textboxpatronymic.focus_set()
  105. textboxpatronymic.place(x= 100, y=110)
  106. textboxDate_of_Birth = Entry(window4, width=20)
  107. textboxDate_of_Birth.focus_set()
  108. textboxDate_of_Birth.place(x= 100, y=140)
  109. textboxpassseria = Entry(window4, width=6)
  110. textboxpassseria.focus_set()
  111. textboxpassseria.place(x= 170, y=170)
  112. textboxpassnumber = Entry(window4, width=4)
  113. textboxpassnumber.focus_set()
  114. textboxpassnumber.place(x= 220, y=170)
  115. def data_transmission():
  116. global persons_name; global persons_surname; global persons_Date_of_Birth; global persons_pass_seria; global persons_pass_number; global persons_patronymic;
  117. persons_name = textboxname.get()
  118. persons_surname = textboxsurname.get()
  119. persons_patronymic = textboxpatronymic.get()
  120. persons_Date_of_Birth = textboxDate_of_Birth.get()
  121. persons_pass_seria = textboxpassseria.get()
  122. persons_pass_number = textboxpassnumber.get()
  123. window4.destroy()
  124. form5()
  125. buttransition2=Button(window4, text = "Подтвердить", command = data_transmission, width=15, height=2, font=("Arial, 10"), bg ="#00c3ff")
  126. buttransition2.place(x=210, y=400)
  127.  
  128. def form3():
  129. def proverka2():
  130. if(mesto_ticket==0):
  131. exception = mb.showerror(title="Ошибка", message="Выбор места является обязательным")
  132. if(kategori_ticket==0):
  133. exception = mb.showerror(title="Ошибка", message="Выбор категории места является обязательным")
  134. if(kategori_ticket!=0 and mesto_ticket!=0):
  135. window3.destroy()
  136. form4()
  137.  
  138. ###########################---Категория билета---#######################################
  139. def kategori_click():
  140. global kategori_ticket
  141. kategori_ticket = listboxkategori.curselection()[0]+1
  142. if(kategori_ticket==1):
  143. textkategori1="Обычный "
  144. if(kategori_ticket==2):
  145. textkategori1 = "Детский "
  146. if(kategori_ticket==3):
  147. textkategori1 ="Льготный "
  148. kategori_text_2 = Label(window3)
  149. kategori_text_2.place(x=150, y=300)
  150. kategori_text_2.configure(font = "Arial, 13", fg = "black", text=textkategori1)
  151. ##################################################################
  152. ###########################---МЕСТО билета---#######################################
  153. def mesto_click():
  154. global mesto_ticket
  155. mesto_ticket = listboxmesto.curselection()[0]+1
  156. if(mesto_ticket==1):
  157. textmesto1="Верхнее "
  158. if(mesto_ticket==2):
  159. textmesto1="Нижнее "
  160. if(mesto_ticket==3):
  161. textmesto1="Верхнее-боковое "
  162. if(mesto_ticket==4):
  163. textmesto1="Нижнее-боковое "
  164. mesto_text_2 = Label(window3)
  165. mesto_text_2.place(x=60, y=350)
  166. mesto_text_2.configure(font = "Arial, 13", fg = "black", text=textmesto1)
  167. ##################################################################
  168. window3 = Tk()
  169. window3.title("Форма3")
  170. window3.geometry("350x450")
  171. window3.resizable(False, False)
  172. buttransition2=Button(window3, text = "Подтвердить", command = proverka2, width=15, height=2, font=("Arial, 10"), bg ="#00c3ff")
  173. buttransition2.place(x=210, y=400)
  174. form3_text = Label(window3, text = " Выбор категории билета и места ", bg="#00c3ff",justify=CENTER)
  175. form3_text.configure(font = "Arial, 15", fg = "black")
  176. form3_text.pack()
  177. ###############################---КАТЕГОРИЯ БИЛЕТА---###################################################
  178. textkategoti = Label(window3, text = "Категория билета:", bg="#00c3ff")
  179. textkategoti.place(relx = 0, rely = 0.220)
  180. textkategoti.configure(font = "Arial, 13", fg = "black")
  181. butkategori=Button(window3, text = "Окей", command = kategori_click, width=11, bg ="#00c3ff")
  182. butkategori.place(relx = 0, rely = 0.395)
  183. butkategori_text = Label(window3, text = "Категория билета: ")
  184. butkategori_text.place(x=0, y=300)
  185. butkategori_text.configure(font = "Arial, 13", fg = "black")
  186. listboxkategori=Listbox(window3, height=3,width=15,selectmode=SINGLE, bg="#00c3ff", selectbackground="#006da3")
  187. listboxkategori.place(relx = -0.005, rely = 0.275)
  188. listkategori=[u"Обычный", u"Детский", u"Льготный"]
  189. for i in listkategori:
  190. listboxkategori.insert(END,i)
  191. ############################################################################################
  192.  
  193. ###############################---МЕСТО---###################################################
  194. textmesto = Label(window3, text = "Место: ", bg="#00c3ff")
  195. textmesto.place(relx = 0.7, rely = 0.220)
  196. textmesto.configure(font = "Arial, 13", fg = "black")
  197. butmesto=Button(window3, text = "Окей", command = mesto_click, width=11, bg ="#00c3ff")
  198. butmesto.place(relx = 0.7, rely = 0.43)
  199. butmesto_text = Label(window3, text = "Место: ")
  200. butmesto_text.place(x=0, y=350)
  201. butmesto_text.configure(font = "Arial, 13", fg = "black")
  202. listboxmesto=Listbox(window3, height=4,width=17,selectmode=SINGLE, bg="#00c3ff", selectbackground="#006da3")
  203. listboxmesto.place(relx = 0.7, rely = 0.275)
  204. listmesto=[u"Верхнее", u"Нижнее", u"Верхнее-боковое", u"Нижнее-боковое"]
  205. for i in listmesto:
  206. listboxmesto.insert(END,i)
  207. ############################################################################################
  208.  
  209. def form2(): # ================= ФОРМА 2
  210. window.destroy()
  211. window2 = Tk()
  212. window2.title("Форма2")
  213. window2.geometry("350x450")
  214. window2.resizable(False, False)
  215. ###########################---МЕСТО ОТПРАВКИ---#######################################
  216. def butdispatchcity_click():
  217. global dispatch_city
  218. dispatch_city = listbox1.curselection()[0]+1
  219. if(dispatch_city==1):
  220. textcity="Москва "
  221. if(dispatch_city==2):
  222. textcity="Казань "
  223. if(dispatch_city==3):
  224. textcity="Киев "
  225. if(dispatch_city==4):
  226. textcity="Минск "
  227. butdispatchcity_text_city = Label(window2)
  228. butdispatchcity_text_city.place(x=70, y=300)
  229. butdispatchcity_text_city.configure(font = "Arial, 13", fg = "black", text=textcity)
  230. ##################################################################
  231.  
  232. ###########################---ДАТА---#######################################
  233. def butdata_click():
  234. global trip_date
  235. trip_date = listbox3.curselection()[0]+1
  236. if(trip_date==1):
  237. textcity3="30.05.2019 "
  238. if(trip_date==2):
  239. textcity3="02.06.2019 "
  240. butdata_text_city = Label(window2)
  241. butdata_text_city.place(x=50, y=400)
  242. butdata_text_city.configure(font = "Arial, 13", fg = "black", text=textcity3)
  243. ##################################################################
  244.  
  245.  
  246. ###########################---МЕСТО НАЗНАЧЕНИЯ---#######################################
  247. def butdestinationcity_click():
  248. global destination_city
  249. destination_city = listbox2.curselection()[0]+1
  250. if(destination_city==1):
  251. textcity2="Москва "
  252. if(destination_city==2):
  253. textcity2="Казань "
  254. if(destination_city==3):
  255. textcity2="Киев "
  256. if(destination_city==4):
  257. textcity2="Минск "
  258. butdestinationcity_text_city = Label(window2)
  259. butdestinationcity_text_city.place(x=50, y=350)
  260. butdestinationcity_text_city.configure(font = "Arial, 13", fg = "black", text=textcity2)
  261. ##################################################################
  262.  
  263.  
  264. ###############################---МЕСТО ОТПРАВЛЕНИЯ---###################################################
  265. textvibormestao = Label(window2, text = "Откуда: ", bg="#00c3ff")
  266. textvibormestao.place(relx = 0, rely = 0.220)
  267. textvibormestao.configure(font = "Arial, 13", fg = "black")
  268. butdispatchcity=Button(window2, text = "Окей", command = butdispatchcity_click, width=11, bg ="#00c3ff")
  269. butdispatchcity.place(relx = 0, rely = 0.450)
  270. butdispatchcity_text = Label(window2, text = "Откуда: ")
  271. butdispatchcity_text.place(x=0, y=300)
  272. butdispatchcity_text.configure(font = "Arial, 13", fg = "black")
  273. ############################################################################################
  274.  
  275. ###############################--ДАТА--###################################################
  276. textdata = Label(window2, text = "Дата: ", bg="#00c3ff")
  277. textdata.place(relx = 0.36, rely = 0.220)
  278. textdata.configure(font = "Arial, 13", fg = "black")
  279. butdata=Button(window2, text = "Окей", command = butdata_click, width=11, bg ="#00c3ff")
  280. butdata.place(relx = 0.36, rely = 0.450)
  281. butdata_text = Label(window2, text = "Дата: ")
  282. butdata_text.place(x=0, y=400)
  283. butdata_text.configure(font = "Arial, 13", fg = "black")
  284. ############################################################################################
  285.  
  286. ###############################---МЕСТО НАЗНАЧЕНИЯ---###################################################
  287. textvibormestan = Label(window2, text = "Куда: ",bg="#00c3ff")
  288. textvibormestan.place(relx = 0.75, rely = 0.220)
  289. textvibormestan.configure(font = "Arial, 13", fg = "black")
  290. butdestinationcity=Button(window2, text = "Окей", command = butdestinationcity_click, width=11, bg ="#00c3ff")
  291. butdestinationcity.place(x=263, y=200)
  292. butdestinationcity_text = Label(window2, text = "Куда: ")
  293. butdestinationcity_text.place(x=0, y=350)
  294. butdestinationcity_text.configure(font = "Arial, 13", fg = "black")
  295. ############################################################################################
  296.  
  297. #################################---ПРОЧЕЕ---###############################################
  298. text = Label(window2, text = " Заказ железнодорожных билетов ", bg="#00c3ff",justify=CENTER)
  299. text.configure(font = "Arial, 13", fg = "black")
  300. text.pack()
  301. listbox1=Listbox(window2, height=4,width=15,selectmode=SINGLE, bg="#00c3ff", selectbackground="#006da3")
  302. listbox1.place(relx = -0.005, rely = 0.268)
  303. list1=[u"Москва", u"Казань", u"Киев", u"Минск"]
  304. for i in list1:
  305. listbox1.insert(END,i)
  306. listbox2=Listbox(window2, height=4,width=15,selectmode=SINGLE,bg="#00c3ff", selectbackground="#006da3")
  307. listbox2.place(relx = 0.75, rely = 0.268)
  308. list2=[u"Москва", u"Казань", u"Киев", u"Минск"]
  309. for i in list2:
  310. listbox2.insert(END,i)
  311. listbox3=Listbox(window2, height=2,width=15,selectmode=SINGLE, bg="#00c3ff", selectbackground="#006da3")
  312. listbox3.place(relx = 0.36, rely = 0.268)
  313. list3=[u"30.05.2019", u"02.06.2019"]
  314. for i in list3:
  315. listbox3.insert(END,i)
  316.  
  317. def proverka():
  318. if(trip_date==0):
  319. exception = mb.showerror(title="Ошибка", message="Выбор даты является обязательным")
  320. if(dispatch_city==destination_city):
  321. exception = mb.showerror(title="Ошибка", message="Пункты отправления и прибытия должны различаться")
  322. if((dispatch_city!=destination_city)and(trip_date!=0)):
  323. window2.destroy()
  324. form3()
  325. buttransition1=Button(window2, text = "Подтвердить", command = proverka, width=15, height=2, font=("Arial, 10"), bg ="#00c3ff")
  326. buttransition1.place(x=210, y=400)
  327.  
  328.  
  329. ###################---ФОРМА 1---############################################
  330. window = Tk()
  331. window.title("Форма1")
  332. window.geometry("350x300")
  333. window.resizable(False, False)
  334. booking_text = Label(window, text = "Здравствуйте, на нашем портале\n вы можете осуществить покупку билета", justify=CENTER)
  335. booking_text.configure(font = "Arial, 13", fg = "black")
  336. booking_text.pack()
  337. butappend=Button(window, text = "Купить билет", command = form2, justify=CENTER)
  338. butappend.pack()
  339. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement