Python - "Product" Object has no atribute "get"

 
Vista:

"Product" Object has no atribute "get"

Publicado por mauro (1 intervención) el 30/04/2020 05:49:30
hola! necesito ayuda con esta app de escritorio. soy principiante y no logro encontrar donde me equivoqué.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from tkinter import ttk
from tkinter import *
 
import sqlite3
 
class Product:
 
	db_name = 'database.db'
 
	def __init__(self, window):
	  self.wind = window
	  self.wind.title('ALAS Y RAICES')
 
	  #creating a Frame Container
	  frame = LabelFrame(self.wind, text = 'PRODUCCION')
	  frame.grid(row = 0, column = 0, columnspan = 3, pady = 20)
 
	  #model input
	  Label(frame, text = 'Cliente: ').grid(row = 1, column = 0)
	  self.client = Entry(frame)
	  self.client.focus()
	  self.client.grid(row = 1, column = 1)
 
 	  # capas
	  Label(frame, text = 'Modelo: ').grid(row = 2, column = 0)
	  self.model = Entry(frame)
	  self.model.grid(row = 2, column = 1)
 
	  Label(frame, text= 'Capas').grid(row=3, column=0)
	  self.layer = Entry(frame)
	  self.layer.grid(row=3, column=1)
 
	  Label(frame, text= 'Detalle').grid()
	  self.detail = Entry(frame)
	  self.detail.grid(row=4, column=1)
 
	  #button
	  ttk.Button(frame, text = 'Guardar', command = self.add_product).grid(row = 5, columnspan = 2, sticky = W + E)
 
	  self.message = Label(text = '', fg = 'red')
	  self.message.grid(row = 6, column = 0, columnspan = 2, sticky = W + E)
 
	  self.tree = ttk.Treeview(height = 10, columns=4)
	  self.tree.grid(row=6, column=0, columnspan=2)
	  self.tree["columns"]=("one","two","three")
	  self.tree.column("#0", width=270, minwidth=270, anchor=CENTER)
	  self.tree.column("one", width=150, minwidth=150, anchor=CENTER)
	  self.tree.column("two", width=400, minwidth=200, anchor=CENTER)
	  self.tree.column("three", width=80, minwidth=50, anchor=CENTER)
 
	  self.tree.heading("#0",text="Cliente", anchor=CENTER)
	  self.tree.heading("one", text="Modelo", anchor=CENTER)
	  self.tree.heading("two", text="Capas", anchor=CENTER)
	  self.tree.heading("three", text="Detalle", anchor=CENTER)
 
	  self.get_products()
 
	def run_query(self, query, parameters = ()):
	  	with sqlite3.connect(self.db_name) as conn:
	  		cursor=conn.cursor()
	  		result = cursor.execute(query, parameters)
	  		conn.commit()
	  		return result
 
	def get_products(self):
 
		records = self.tree.get_children()
		for element in records:
			self.tree.delete(element)
 
		query='SELECT * FROM product'
		db_rows = self.run_query(query)
		for row in db_rows:
		  self.tree.insert('',0, text = row[0], values = (row[1], row[2], row[3]))
 
	def validation(self):
		return len(self.model.get()) != 0 and len(self.client.get()) != 0 and len(self.layer.get()) != 0
 
	def add_product(self):
		if self.validation():
		  query = 'INSERT INTO product VALUES (?, ?, ?, ?)'
		  parameters = (self.client.get(), self.model.get(), self.layer.get(), self.detail.get())
		  self.run_query(query, parameters)
		  self.message['text'] = 'El producto {} se agregó a la lista de fabricación'.format(self.model.get())
		  self.message.delete(0, END)
		  self.client.delete(0, END)
		  self.model.delete(0, END)
		  self.layer.delete(0, END)
		  self.detail.delete(0, END)
		else:
		  self.message['text'] = 'Cliente, Modelo y Capas, son requeridos'
		self.get.products()
 
if __name__ == '__main__':
	window = Tk()
	application = Product(window)
	window.mainloop()


el error es el siguiente:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Users\Admin\Desktop\products_desktop\index.py", line 92, in add_product
self.get.products()
AttributeError: 'Product' object has no attribute 'get'
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.475
Oro
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

"Product" Object has no atribute "get"

Publicado por joel (901 intervenciones) el 30/04/2020 12:59:52
Hola Mauro, en el error te lo indica, lo tienes en la linea 92

en vez de
1
self.get.products()
creo que tiene que ser
1
self.get_products()
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar