Advertisement
al33kappa

Untitled

Jun 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import messagebox
  3. root = Tk()
  4. root.geometry("800x600")
  5. lastrow = 0
  6. a = []
  7. matr = []
  8. massiv_intselect = []
  9. indeks_intselect = 0
  10. kolvo_yacheek = 0
  11. nomer = 0
  12. MyFile = "hello.txt"
  13. names = ["№","Наименование","Срок хранения","Страна","Цена","В наличии"]
  14. root.title("Продукты в магазине")
  15. intSelect = 0
  16. def defaultcells():
  17. global lastrow
  18. for i in range(6):
  19. b = Entry(root)
  20. b.grid(row=lastrow, column=i)
  21. a.append(b)
  22. lastrow += 1
  23. matr.append(a)
  24. matr[0][0].configure(width = 3)
  25. matr[0][1].configure(width=20)
  26. matr[0][2].configure(width=20)
  27. matr[0][3].configure(width=20)
  28. matr[0][4].configure(width=20)
  29. matr[0][5].configure(width=20)
  30. for i in range(6):
  31. matr[0][i].insert(END,names[i])
  32. matr[0][i].configure(readonlybackground='white',state='readonly')
  33. print(lastrow)
  34.  
  35. c = []
  36. b_mas = []
  37. kontent = []
  38. def addcells():
  39. global lastrow,intSelect,kolvo_yacheek,massiv_intselect,k,b_mas
  40. if lastrow==13:
  41. btnAdd.configure(state=DISABLED)
  42. for i in range(6):
  43. if i==0:
  44. b = Entry(root,width=a[i]['width'])
  45. b.insert(END,kolvo_yacheek+1)
  46. b.grid(row=lastrow, column=i)
  47. else:
  48. b = Entry(root,width = a[i]['width'],readonlybackground='white',state='readonly')
  49. b.grid(row=lastrow, column=i)
  50. c.append(b)
  51. intSelect += 1
  52. for i in range(len(txt_list)):
  53. txt_list[i].configure(state='normal')
  54. txt_list[0].focus()
  55. txt_list[-1].configure(readonlybackground='white',state='readonly')
  56. b_mas.append(c)
  57. lastrow += 1
  58. btnCopy.configure(state=NORMAL)
  59. btnAdd.configure(state=DISABLED)
  60. print("lastrow: " + str(lastrow))
  61. kolvo_yacheek+=1
  62. print("yacheiki: "+str(kolvo_yacheek))
  63. clearAll()
  64.  
  65. defaultcells()
  66. # def selectRow():
  67. # EnableAll()
  68. # clearAll()
  69. # asd = int(b_mas[0][0]['text'])*intSelect#разобраться почему работает и получать текст баттона
  70. # print('SELECT: '+str(intSelect))
  71. # print('ButtonTEXt: ' + str(asd))
  72. # for i in range(5,0,-1):
  73. # b_mas[1][asd-i].configure(state=NORMAL)
  74. # txt_list[-i].insert(END,b_mas[1][intSelect-i].get())
  75. # b_mas[1][asd- i].configure(readonlybackground='white',state='readonly')
  76. #
  77. # # disableAll()
  78.  
  79. def quit():
  80. root.destroy()
  81.  
  82. intS = 0
  83. intF = 1
  84.  
  85. def copy():
  86. global intF,txt_list,intS
  87. if (len(txt_list[0].get())==0 or len(txt_list[1].get())==0 or len(txt_list[2].get())==0 or len(txt_list[3].get())==0 or len(txt_list[4].get())==0):
  88. messagebox.showerror("Ошибка","Заполните все поля")
  89. else:
  90. for i in range(5):
  91. c[intS].configure(state=NORMAL)
  92. c[intS].insert(END,txt_list[i].get())
  93. c[intS].configure(readonlybackground='white',state='readonly')
  94. intS+=1
  95. btnAdd.configure(state=NORMAL)
  96. btnCopy.configure(state=DISABLED)
  97. clearAll()
  98. disableAll()
  99.  
  100. def EnableAll():
  101. for i in range(len(txt_list)):
  102. txt_list[i].delete(0, END)
  103. txt_list[i].configure(readonlybackground='white', state=NORMAL)
  104.  
  105. def clearAll():
  106. for i in range(len(txt_list)):
  107. txt_list[i].delete(0, END)
  108.  
  109. def disableAll():
  110. for i in range(len(txt_list)):
  111. txt_list[i].configure(readonlybackground='white',state='readonly')
  112. txt_list[-1].configure(disabledbackground = 'white',state=DISABLED)
  113.  
  114.  
  115. btnAdd = Button(text="Добавить",command = addcells,width = 10,font="Arial 12")
  116. btnAdd.place(x = 680,y=70)
  117. btnCopy = Button(text="Записать",width = 10,command = copy,font="Arial 12")
  118. btnCopy.place(x=680,y=110)
  119. btnCreate= Button(text="Создать",width= 10,font="Arial 12")
  120. btnCreate.place(x=680,y=150)
  121. btnSave = Button(text="Сохранить",width= 10,font="Arial 12")
  122. btnSave.place(x=680,y=190)
  123. btnDelete = Button(text="Удалить",width= 10,font="Arial 12")
  124. btnDelete.place(x=680,y=230)
  125. btnExit = Button(text="Выход",width=10,command = quit,font="Arial 12")
  126. btnExit.place(x=680,y=380)
  127. "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
  128. FamTxt= Entry()
  129. FamTxt.place(x=120,y=400)
  130. SrokTxt = Entry()
  131. SrokTxt.place(x=120,y=450)
  132. CountryTxt = Entry()
  133. CountryTxt.place(x=420,y=400)
  134. PriceTxt = Entry()
  135. PriceTxt.place(x=420,y=450)
  136. "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
  137. lblFam = Label(text="Наименование: ",font="Arial 12")
  138. lblFam.place(x=0,y=395)
  139. lblSro = Label(text="Срок хранения: ", font = "Arial 12")
  140. lblSro.place(x=0,y=445)
  141. lblCountry = Label(text="Страна: ",font = "Arial 12")
  142. lblCountry.place(x=350,y=395)
  143. lblPrice = Label(text="Цена: ",font = "Arial 12")
  144. lblPrice.place(x=365,y=445)
  145. "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
  146. myspinbox = Spinbox(values=("Имеется","Не имеется"))
  147. txt_list = [FamTxt,SrokTxt,CountryTxt,PriceTxt,myspinbox]
  148. myspinbox.place(x=350,y=500)
  149. disableAll()
  150. btnCopy.configure(state=DISABLED)
  151. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement