Ejemplo n.º 1
0
    def load_products(self, products=None):
    #Loads Products from database for display
        if products is None:
            products = controller.get_products()
        self.model = QtGui.QStandardItemModel(len(products), 4)
        
        self.model.setHorizontalHeaderItem(0, QtGui.QStandardItem(u"Producto"))
        self.model.setHorizontalHeaderItem(1, QtGui.QStandardItem(u"Descripción"))
        self.model.setHorizontalHeaderItem(2, QtGui.QStandardItem(u"Color"))
        self.model.setHorizontalHeaderItem(3, QtGui.QStandardItem(u"Precio"))
        self.model.setHorizontalHeaderItem(4, QtGui.QStandardItem(u"Marca"))

        r = 0
        for row in products:
            index = self.model.index(r, 0, QtCore.QModelIndex())
            self.model.setData(index, row['prod'])
            index = self.model.index(r, 1, QtCore.QModelIndex())
            self.model.setData(index, row['description'])
            index = self.model.index(r, 2, QtCore.QModelIndex())
            self.model.setData(index, row['color'])
            index = self.model.index(r, 3, QtCore.QModelIndex())
            self.model.setData(index, row['price'])
            index = self.model.index(r, 4, QtCore.QModelIndex())
            self.model.setData(index, row['brands'])
            r = r+1

        self.ui.table.setModel(self.model)
        self.ui.table.setColumnWidth(0, 120)
        self.ui.table.setColumnWidth(1, 300)
        self.ui.table.setColumnWidth(2, 145)
        self.ui.table.setColumnWidth(3, 110)
        self.ui.table.setColumnWidth(4, 110)
Ejemplo n.º 2
0
    def load_products(self, products=None):
        #Loads Products from database for display
        if products is None:
            products = controller.get_products()
        self.model = QtGui.QStandardItemModel(len(products), 4)

        self.model.setHorizontalHeaderItem(0, QtGui.QStandardItem(u"Producto"))
        self.model.setHorizontalHeaderItem(1,
                                           QtGui.QStandardItem(u"Descripción"))
        self.model.setHorizontalHeaderItem(2, QtGui.QStandardItem(u"Color"))
        self.model.setHorizontalHeaderItem(3, QtGui.QStandardItem(u"Precio"))
        self.model.setHorizontalHeaderItem(4, QtGui.QStandardItem(u"Marca"))

        r = 0
        for row in products:
            index = self.model.index(r, 0, QtCore.QModelIndex())
            self.model.setData(index, row['prod'])
            index = self.model.index(r, 1, QtCore.QModelIndex())
            self.model.setData(index, row['description'])
            index = self.model.index(r, 2, QtCore.QModelIndex())
            self.model.setData(index, row['color'])
            index = self.model.index(r, 3, QtCore.QModelIndex())
            self.model.setData(index, row['price'])
            index = self.model.index(r, 4, QtCore.QModelIndex())
            self.model.setData(index, row['brands'])
            r = r + 1

        self.ui.table.setModel(self.model)
        self.ui.table.setColumnWidth(0, 120)
        self.ui.table.setColumnWidth(1, 300)
        self.ui.table.setColumnWidth(2, 145)
        self.ui.table.setColumnWidth(3, 110)
        self.ui.table.setColumnWidth(4, 110)
Ejemplo n.º 3
0
 def load_products_by_brand(self):
 #Sets up the search by brand with a ComboBox
     id_brand = self.ui.selectBrand.itemData(self.ui.selectBrand.currentIndex())
     if id_brand == -1: #if option selected is "todos" loads all products
         products = controller.get_products()
     else: #loads products by brands
         products = controller.get_products_by_brand(id_brand)
     self.load_products(products)
Ejemplo n.º 4
0
 def load_products_by_brand(self):
     #Sets up the search by brand with a ComboBox
     id_brand = self.ui.selectBrand.itemData(
         self.ui.selectBrand.currentIndex())
     if id_brand == -1:  #if option selected is "todos" loads all products
         products = controller.get_products()
     else:  #loads products by brands
         products = controller.get_products_by_brand(id_brand)
     self.load_products(products)
Ejemplo n.º 5
0
	def __init__(self,**kwargs):
		#Inicializacion de la interfaz
		super(Interfaz, self).__init__(**kwargs)
		#Definicion de Variables
		listB = []
		aux = 1
		Checkout = PayUi()
		box = ObjectProperty(None)
		txt = ObjectProperty(None)
		grid = ObjectProperty(None)
		discount = ObjectProperty(None)
		total = ObjectProperty(None)
		save = ObjectProperty(None)
		printAct = ObjectProperty(None)
		send = ObjectProperty(None)
		money = ObjectProperty(None)
		self.discount.bind(is_open = self.addDiscount)
		products = controller.get_products()
		users = controller.get_users()
		self.save.background_color = 0,147,0,.5
		self.save.bind(on_press = self.press)
		self.save.bind(on_release = self.release)
		self.send.background_color = 162,0,170,.5
		self.send.bind(on_press = self.DisplaySale)#Interfaz de venta unida a este boton
		self.send.bind(on_release = self.releaseB)
		self.printAct.background_color = 162,0,170,.5
		self.printAct.bind(on_press = self.pressB)
		self.printAct.bind(on_release = self.releaseB)
		#Ingreso de usuarios al Spinner
		for i in users:
			listB.append(i.username)
		self.txt.text = listB[0]
		self.txt.values = listB
		#Ingreso de productos a la listA deslizante
		for fila in products:
			Q = CBoton()
			Q.background_color = 1,1,1,(aux%2+0.5)
			aux = aux+1
			Q.name = fila.name
			Q.text = fila.name[:20]
			Q.code = fila.supplier_code
			Q.precio = fila.gross_price
			Q.bind(on_press = self.addRow)
			self.grid.add_widget(Q)
			self.grid.bind(minimum_width=self.grid.setter('width'))
Ejemplo n.º 6
0
	def __init__(self,**kwargs):
		#Inicializacion de la interfaz
		super(Interfaz, self).__init__(**kwargs)
		#Definicion de Variables
		listB = []
		aux = 1
		box = ObjectProperty(None)
		txt = ObjectProperty(None)
		grid = ObjectProperty(None)
		discount = ObjectProperty(None)
		total = ObjectProperty(None)
		save = ObjectProperty(None)
		printAct = ObjectProperty(None)
		send = ObjectProperty(None)
		money = ObjectProperty(None)
		self.discount.bind(is_open = self.addDiscount)
		products = controller.get_products()
		users = controller.get_users()
		self.save.background_color = 0,147,0,.5
		self.send.background_color = 162,0,170,.5
		self.printAct.background_color = 162,0,170,.5
		#Ingreso de usuarios al Spinner
		for i in users:
			listB.append(i[0])
		self.txt.text = listB[0]
		self.txt.values = listB
		#Ingreso de productos a la listA deslizante
		for fila in products:
			Q = CBoton()
			Q.background_color = 1,1,1,(aux%2+0.5)
			aux = aux+1
			Q.name = fila[0]
			Q.text = fila[0][:20]
			Q.code = fila[1]
			Q.precio = fila[2]
			Q.bind(on_press = self.addRow)
			self.grid.add_widget(Q)
			self.grid.bind(minimum_width=self.grid.setter('width'))