Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import messagebox
- root = Tk()
- names = ["№","Наименование","Срок хранения","Страна","Цена","В наличии"]
- root.title("Продукты в магазине")
- root.geometry("800x600")
- lastrow = 0
- a = []
- present_row = 0
- massiv_a = []
- indeks_intselect = 0
- kolvo_yacheek = 0
- MyFile = "hello.txt"
- def defaultcells():
- global lastrow
- a=[]
- for i in range(6):
- b = Entry(root)
- b.grid(row=lastrow, column=i)
- a.append(b)
- lastrow += 1
- massiv_a.append(a)
- a[0].configure(width = 3)
- a[1].configure(width=20)
- a[2].configure(width=20)
- a[3].configure(width=20)
- a[4].configure(width=20)
- a[5].configure(width=20)
- for i in range(6):
- a[i].insert(END,names[i])
- a[i].configure(readonlybackground='white',state='readonly')
- print('lastrow + ' + str(lastrow))
- nomer_row = 0
- kontent = []
- def addcells():
- global kolvo_yacheek,massiv_a,lastrow,a,nomer_row
- c=[]
- if lastrow==13:
- btnAdd.configure(state=DISABLED)
- for i in range(6):
- if i==0:
- b = Entry(root,width=massiv_a[0][i]['width'])
- b.insert(END,kolvo_yacheek+1)
- nomer_row+=1
- # b.bind("<Button-1>", lambda event, i=i: show_row(event, nomer_row))
- b.grid(row=lastrow, column=i)
- else:
- b = Entry(root,width = massiv_a[0][i]['width'],readonlybackground='white',state='readonly')
- b.grid(row=lastrow, column=i)
- c.append(b)
- print("last1: "+str(lastrow))
- massiv_a.append(c)
- lastrow += 1
- for i in range(lastrow):
- if i ==0:
- pass
- else:
- massiv_a[i][0].bind("<Button-1>", lambda event, i=i: show_row(event, i))
- massiv_a[i][1].bind("<Button-1>", lambda event, i=i: show_row(event, i))
- massiv_a[i][2].bind("<Button-1>", lambda event, i=i: show_row(event, i))
- massiv_a[i][3].bind("<Button-1>", lambda event, i=i: show_row(event, i))
- massiv_a[i][4].bind("<Button-1>", lambda event, i=i: show_row(event, i))
- print("last2: " + str(lastrow))
- EnableAll()
- txt_list[0].focus()
- txt_list[-1].configure(readonlybackground='white',state='readonly')
- btnCopy.configure(state=NORMAL)
- btnAdd.configure(state=DISABLED)
- print("lastrow: " + str(lastrow))
- kolvo_yacheek+=1
- print("kolvo_yacheek: "+str(kolvo_yacheek))
- clearAll()
- defaultcells()
- def quit():
- root.destroy()
- intS = 1
- intF = 0
- def copy():
- global intF,txt_list,intS
- print("intF: "+str(intF))
- 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):
- txt_list[0].focus()
- messagebox.showerror("Ошибка","Заполните все поля")
- return
- else:
- for i in range(5):
- massiv_a[intS][intF].configure(state=NORMAL)
- massiv_a[intS][intF].insert(END,txt_list[i].get())
- massiv_a[intS][intF].configure(readonlybackground='white',state='readonly')
- print("intF: " + str(intF))
- intF+=1
- btnAdd.configure(state=NORMAL)
- btnCopy.configure(state=DISABLED)
- clearAll()
- disableAll()
- intF = 0#индекс 0 - первый после номера
- print("intS1: "+str(intS))
- intS +=1
- print("intS2: " + str(intS))
- def EnableAll():
- for i in range(len(txt_list)):
- txt_list[i].delete(0, END)
- txt_list[i].configure(readonlybackground='white', state=NORMAL)
- def clearAll():
- for i in range(len(txt_list)):
- txt_list[i].delete(0, END)
- def disableAll():
- for i in range(len(txt_list)):
- txt_list[i].configure(readonlybackground='white',state='readonly')
- txt_list[-1].configure(disabledbackground = 'white',state=DISABLED)
- def show_row(event,number):
- global present_row
- print("numberclick: " + str(number))
- past_row = present_row
- present_row = number
- btnAdd = Button(text="Добавить",command = addcells,width = 10,font="Arial 12")
- btnAdd.place(x = 680,y=70)
- btnCopy = Button(text="Записать",width = 10,command = copy,font="Arial 12")
- btnCopy.place(x=680,y=110)
- btnCreate= Button(text="Создать",width= 10,font="Arial 12")
- btnCreate.place(x=680,y=150)
- btnSave = Button(text="Сохранить",width= 10,font="Arial 12")
- btnSave.place(x=680,y=190)
- btnDelete = Button(text="Удалить",width= 10,font="Arial 12")
- btnDelete.place(x=680,y=230)
- btnExit = Button(text="Выход",width=10,command = quit,font="Arial 12")
- btnExit.place(x=680,y=380)
- "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
- FamTxt= Entry()
- FamTxt.place(x=120,y=400)
- SrokTxt = Entry()
- SrokTxt.place(x=120,y=450)
- CountryTxt = Entry()
- CountryTxt.place(x=420,y=400)
- PriceTxt = Entry()
- PriceTxt.place(x=420,y=450)
- "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||0||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
- lblFam = Label(text="Наименование: ",font="Arial 12")
- lblFam.place(x=0,y=395)
- lblSro = Label(text="Срок хранения: ", font = "Arial 12")
- lblSro.place(x=0,y=445)
- lblCountry = Label(text="Страна: ",font = "Arial 12")
- lblCountry.place(x=350,y=395)
- lblPrice = Label(text="Цена: ",font = "Arial 12")
- lblPrice.place(x=365,y=445)
- "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
- myspinbox = Spinbox(values=("Имеется","Не имеется"))
- txt_list = [FamTxt,SrokTxt,CountryTxt,PriceTxt,myspinbox]
- myspinbox.place(x=350,y=500)
- disableAll()
- btnCopy.configure(state=DISABLED)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement