Example #1
0
	def cargar_grid(self):
		"""función que muestra los empleados de un local en específico, usando su id_local"""
		empleados = c.obtener_empleados_por_local(self.ui.idlocal.text())
		#Creamos el modelo asociado a la tabla
		self.model = QtGui.QStandardItemModel(len(empleados), 6)
		self.model.setHorizontalHeaderItem(0, QtGui.QStandardItem(u"RUT"))
		self.model.setHorizontalHeaderItem(1, QtGui.QStandardItem(u"Nombre"))
		self.model.setHorizontalHeaderItem(2, QtGui.QStandardItem(u"Cargo"))
		self.model.setHorizontalHeaderItem(3, QtGui.QStandardItem(u"Genero"))
		self.model.setHorizontalHeaderItem(4, QtGui.QStandardItem(u"Sueldo"))
		self.model.setHorizontalHeaderItem(5, QtGui.QStandardItem(u"local"))
		r = 0
		for row in empleados:
			#print row
			index = self.model.index(r, 0, QtCore.QModelIndex()) 
			self.model.setData(index, row[0])
			index = self.model.index(r, 1, QtCore.QModelIndex()) 
			self.model.setData(index, row[1])
			index = self.model.index(r, 2, QtCore.QModelIndex()) 
			self.model.setData(index, row[2])
			index = self.model.index(r, 3, QtCore.QModelIndex())
			self.model.setData(index, row[3])
			index = self.model.index(r, 4, QtCore.QModelIndex())
			self.model.setData(index, row[4])
			index = self.model.index(r, 5, QtCore.QModelIndex())
			self.model.setData(index, row[5])
			r = r+1
		self.ui.tableView.setModel(self.model)

		self.ui.tableView.setColumnWidth(0, 120)
		self.ui.tableView.setColumnWidth(1, 120)
		self.ui.tableView.setColumnWidth(2, 120)
		self.ui.tableView.setColumnWidth(3, 120)
		self.ui.tableView.setColumnWidth(4, 120)
		self.ui.tableView.setColumnWidth(5, 120)
Example #2
0
    def load_datos(self, locales=None):
        """función que carga todos los locales en la ventana principal"""   
                
        if locales is None:                                    
            locales = controller_local.get_locales()
            
        self.model = QtGui.QStandardItemModel(len(locales), 7)
        self.model.setHorizontalHeaderItem(0, QtGui.QStandardItem(u"id_local"))
        self.model.setHorizontalHeaderItem(1, QtGui.QStandardItem(u"Nombre"))
        self.model.setHorizontalHeaderItem(2, QtGui.QStandardItem(u"Direccion"))
        self.model.setHorizontalHeaderItem(3, QtGui.QStandardItem(u"Ciudad"))
	self.model.setHorizontalHeaderItem(4, QtGui.QStandardItem(u"N° empleados"))
	self.model.setHorizontalHeaderItem(5, QtGui.QStandardItem(u"hombres"))
	self.model.setHorizontalHeaderItem(6, QtGui.QStandardItem(u"mujeres"))

        r = 0
        for row in locales:
                index = self.model.index(r, 0, QtCore.QModelIndex()); 
                self.model.setData(index, row['id_local'])
                index = self.model.index(r, 1, QtCore.QModelIndex()); 
                self.model.setData(index, row['nombre'])
                index = self.model.index(r, 2, QtCore.QModelIndex()); 
                self.model.setData(index, row['direccion'])
                index = self.model.index(r, 3, QtCore.QModelIndex()); 
                self.model.setData(index, row['ciudad'])
		index = self.model.index(r, 4, QtCore.QModelIndex()); 
		empleados = c.obtener_empleados_por_local(row['id_local'])
                self.model.setData(index, len(empleados));
		index = self.model.index(r, 5, QtCore.QModelIndex()); 
                self.model.setData(index, c.obtener_hombres(row['id_local']))
		index = self.model.index(r, 6, QtCore.QModelIndex()); 
                self.model.setData(index, c.obtener_mujeres(row['id_local']))
                r = r+1
	
        self.ui.table_win.setModel(self.model)
        self.ui.table_win.setColumnWidth(1, 200)
        self.ui.table_win.setColumnWidth(2, 300)
        self.ui.table_win.setColumnWidth(3, 140)
	self.ui.table_win.setColumnWidth(4, 100)
	self.ui.table_win.setColumnWidth(5, 80)
	self.ui.table_win.setColumnWidth(6, 80)
        self.ui.table_win.hideColumn(0)
        self.update_search()