def __init__(self): self.dialogo = gtk.Dialog("Hola Mundo") self.aviso = Aviso() self.i = -1 self.ventana = gtk.Window() self.submit = gtk.Button ("Procesar") self._nombre = gtk.Label("Nombre:") self._precio = gtk.Label("Precio") self._fecha = gtk.Label("Fecha") self._tag = gtk.Label("Tag") self.nombre = gtk.Entry() self.precio = gtk.Entry() self.fecha = Calendario() self.tag = gtk.Entry() self.box = gtk.VBox()
class Interfaz(object): def cerrar(self, widget, data=None): gtk.main_quit() def __init__(self): self.dialogo = gtk.Dialog("Hola Mundo") self.aviso = Aviso() self.i = -1 self.ventana = gtk.Window() self.submit = gtk.Button ("Procesar") self._nombre = gtk.Label("Nombre:") self._precio = gtk.Label("Precio") self._fecha = gtk.Label("Fecha") self._tag = gtk.Label("Tag") self.nombre = gtk.Entry() self.precio = gtk.Entry() self.fecha = Calendario() self.tag = gtk.Entry() self.box = gtk.VBox() def mostrar(self): self.conectar_con_change() self._nombre.show() self.ventana.set_title("Cuanto gastas") self.box.pack_start(self._nombre, True, True, 5) self.nombre.show() self.box.pack_start(self.nombre, True, True, 5) self._precio.show() self.box.pack_start(self._precio, True, True, 5) self.precio.show() self.box.pack_start(self.precio, True, True, 5) self._fecha.show() self.box.pack_start(self._fecha, True, True, 5) self.fecha.show() self.box.pack_start(self.fecha, True, True, 5) self._tag.show() self.box.pack_start(self._tag, True, True, 5) self.tag.show() self.box.pack_start(self.tag, True, True, 5) self.submit.connect("clicked", self.__enviar_datos) self.submit.show() self.box.pack_start(self.submit, True, True, 5) self.aviso.set_text("Listo!") self.aviso.show() self.box.pack_start(self.aviso, True, True, 5) self.box.show() self.ventana.connect("delete_event", self.cerrar) self.ventana.add(self.box) self.ventana.show() def __enviar_datos(self, widget): self.aviso.stand() com = "'" #dir = os.getcwd() #direc = dir + '/database_gastos.dat' #print direc nombre = com+self.nombre.get_text()+com #c = com+self.fecha.get_text()+com tag = com+self.tag.get_text()+com self.db = dbapi.connect(db_produccion) indexador = self.db.cursor() indexador.execute("select max(id) from gasto_nuevo") for result in indexador: self.i = result for x in self.i: if x == None: self.i = -1 break self.i = x if self.i >= -1 : self.i += 1 d= self.fecha.ver_dia() m = self.fecha.ver_mes() a = self.fecha.ver_anio() sql = "insert into gasto_nuevo values("+str(self.i)+','+nombre+','+self.precio.get_text()+','+a+','+m+','+d+','+tag+')' #print sql self.i+=1 indexador.execute(sql) self.db.commit() #self.dialogo.add_button("Hola Mundo") #self.dialogo.run() self.aviso.hecho(sql) self.en_blanco() def en_blanco(self): self.nombre.set_text("") self.precio.set_text("") self.tag.set_text("") def change_aviso(self, widget, data = None): self.aviso.stand() def conectar_con_change(self): self.nombre.connect("activate", self.change_aviso)
def main(): equipos, costes = cargaDatos(sys.argv[1], sys.argv[2]) grupos = list() grupoA = list() grupoA.append(equipos[0]) grupoA.append(equipos[3]) grupoA.append(equipos[5]) grupoA.append(equipos[8]) grupoA.append(equipos[9]) grupoA.append(equipos[10]) grupoB = list() grupoB.append(equipos[1]) grupoB.append(equipos[2]) grupoB.append(equipos[3]) grupoB.append(equipos[6]) grupoB.append(equipos[7]) grupoB.append(equipos[11]) grupos.append([grupoA, grupoB]) gruposPosibles = [] i = 0 for posi in grupos: grupoA = posi[0] grupoB = posi[1] print("GrupoA") print(grupoA) print("GrupoB") print(grupoB) combinationsA = itertools.permutations(list(grupoA), 6) combinationsB = itertools.permutations(list(grupoB), 6) for combinationA in list(combinationsA): if (i % 1000000 == 0): print(i) i = i + 1 """ print(combinationB) """ if combinacionPosible(combinationA): """ print(combinacionPosible(combinationB)) """ for combinationB in list(combinationsB): """ print(combinationA) print(combinationB) """ gruposPosibles.append([combinationA, combinationB]) i = 0 print("Calendarios posibles " + str(len(gruposPosibles))) calendarios = [] for grupo in gruposPosibles: print("calendario numero" + str(i)) calendario = Calendario(grupo, costes) calendario.generar_calendario() calendarios.append(calendario) i = i + 1 calendarios.sort(key=lambda x: x.desviacion) minDesviacion = calendarios[0].desviacion maxDesviacion = calendarios[-1].desviacion calendarios.sort(key=lambda x: x.total) minKilometros = calendarios[0].total maxKilometros = calendarios[-1].total for calendario in calendarios: calendario.calculaIndice(minDesviacion, maxDesviacion, minKilometros, maxKilometros) calendarios.sort(key=lambda x: (x.desviacion)) workbook = xlsxwriter.Workbook('desviacionSinRestriccion.xlsx') i = 1 for calendario in calendarios[:500]: nombre = 'Opcion ' + str(i) worksheet = workbook.add_worksheet(nombre) calendario.imprime_resultado(workbook, worksheet) i = i + 1 workbook.close() print('Total calendario:' + str(i)) print('Plotting:') plt.plot([x.indiceDesviacion for x in calendarios], [y.indiceTotal for y in calendarios], 'ro') plt.ylabel('some numbers') plt.show()
N = i i += 1 num_squadre = N * 2 # genera lista di Giornate giornate = [] for row in range(0, df.shape[0], N + 1): for col in [0, 5]: g = df.iloc[row:row + N, col:col + 5] if (isinstance(g.iloc[0, -1], float)): if (math.isnan(g.iloc[0, -1])): break if (g.iloc[0, -1] == '-'): break giornate.append(Giornata(g)) # genera Calendario calendario = Calendario(giornate) team_points = calendario.get_team_points_map() # print(calendario.get_team_points_map()) # plot punti competizione a calendario colors = ['#808080', 'b', 'g', 'r', 'c', 'm', 'y', 'k'] markers = ['.', 's', '*', 'o', 'v', 'H', 'p', 'd'] try: split = args.file.split('_')[1:] title = '_'.join(split) title = title[:-5] except: title = '' legend = [] max_point = 0
def main(): c = Calendario() c.crearNota("") c.menu()