Exemple #1
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MainFrame.__init__

        cdb = Controller_DB()

        self.lst_cmb_CSV = [
            "Anos letivos em que funcionaram majors que incluem o termo computadores e informática",
            "quantidade de estudante que nestes se inscreveram ao longo dos Years",
            "quantidade de majors por nível de formação ao longo dos Years",
            "quantidade de students por nível de formação ao longo dos Years",
        ]
        try:
            self.lst_cmb_Major = cdb.query_major()
            self.lst_cmb_Degree = cdb.query_degree()
        except:
            self.lst_cmb_Major = []
            self.lst_cmb_Degree = []
            print "No such table!"
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.btnMakeDB = wx.Button(self, -1, "Importa dados para Basedados")
        self.CSV = wx.StaticText(self, -1, "CSV")
        self.cmbCSV = wx.ComboBox(self, -1, choices=self.lst_cmb_CSV, style=wx.CB_READONLY)
        self.btnCSV = wx.Button(self, -1, "Executar")
        self.Plot = wx.StaticText(self, -1, "Plot")
        self.cmbMajor = wx.ComboBox(self, -1, choices=self.lst_cmb_Major, style=wx.CB_READONLY)
        self.btnPlotMajor = wx.Button(self, -1, "Executar")
        self.cmbDegree = wx.ComboBox(self, -1, choices=self.lst_cmb_Degree, style=wx.CB_READONLY)
        self.btnPlotDegree = wx.Button(self, -1, "Executar")

        self.__set_properties()
        self.__do_layout()
def make_DB( event):
	"""
		Create Database when the buttun is clicked
	"""

	c_D = Controller_DB()
	c_D.create_db()
	c_xls = Controller_Xls()
	lista = c_xls.read_xls()
	for l in lista:
		c_D.insertBD_Major(name_University=l[1], name_School=l[2], name_Major=l[0], degree=l[3], l_Years=l[4])
def plot_degree( event, cmbox ):
	"""
		Plot the info about the degree selected on combobox
	"""
	
	sel = cmbox.GetStringSelection()
	title = sel.split(' | ')
	if sel != '':
		C_D = Controller_DB()
		lista = C_D.query_students_degrees()
		x=[]
		y=[]

		for i in lista:
		
			if i[0].find(sel.encode('utf-8')) >= 0:
				x.append(i[1])
				y.append(i[2])
		C_p = Controller_Plot(title[0],x, y)
		C_p.plot_data()

	pass
def plot_major( event, cmbox ):
	"""
		Plot the info about the major selected on combobox
	"""

	id_major = cmbox.GetCurrentSelection()
	name = cmbox.GetStringSelection()
	
	id_major = id_major + 1
	
	C_D = Controller_DB()
	lista = C_D.query_students_major_plot(id_major)

	x=[]
	y=[]
	for i in lista:
		x.append(i[1])
		y.append(i[2])
	
	C_p = Controller_Plot(name ,x, y)
	
	C_p.plot_data()

	pass
def make_csv( event, cmbox):
	"""
		Receicves data from main window to make csv file
		and create it
	"""

	C_D = Controller_DB()
	query = cmbox.GetCurrentSelection()
	if query == 0:
		l = C_D.query_major_funcionamento()
		C_S = Controller_stat('q1.csv')
		C_S.write_to_csv(l)
	elif query == 1:
		l = C_D.query_students_degrees()
		C_S = Controller_stat('q2.csv')
		C_S.write_to_csv(l)
	elif query == 2:
		l = C_D.query_students_major()
		C_S = Controller_stat('q3.csv')
		C_S.write_to_csv(l)
	elif query == 3:
		l = C_D.query_major_degree()
		C_S = Controller_stat('q4.csv')
		C_S.write_to_csv(l)