def pb_Mascotas_Clicked(self): self.table_Paseadores.setCurrentCell(self.table_Paseadores.currentRow(), 2) item = self.table_Paseadores.currentItem() paseador = Funciones.get_paseador(self.__paseadores, int(item.text().strip())) mascotas_paseador = Funciones.get_mascotas_paseador(self.__mascotas, paseador) table_mascotas = TableMascotas(mascotas_paseador, self.__clientes, self.__paseadores) table_mascotas.exec_()
def update_Table(self): self.table_Mascotas.setRowCount(0) self.table_Mascotas.setColumnHidden(5,False) for mascota in self.__mascotas_objects: nombre = mascota.get_Nombre() raza = mascota.get_Raza() peso = str(mascota.get_Peso()) duenio = Funciones.get_cliente(self.__clientes, mascota.get_Dni_Duenio()) nombre_duenio = duenio.get_Nombre() paseador = Funciones.get_paseador(self.__paseadores, mascota.get_Dni_Paseador()) nombre_paseador = paseador.get_Nombre() codigo = str(mascota.get_Codigo()) item_nombre = QTableWidgetItem(nombre) item_raza = QTableWidgetItem(raza) item_peso = QTableWidgetItem(peso) item_duenio = QTableWidgetItem(nombre_duenio) item_paseador = QTableWidgetItem(nombre_paseador) item_codigo = QTableWidgetItem(codigo) rowCount = self.table_Mascotas.rowCount() self.table_Mascotas.insertRow(rowCount) self.table_Mascotas.setItem(rowCount,0,item_nombre) self.table_Mascotas.setItem(rowCount,1,item_raza) self.table_Mascotas.setItem(rowCount,2,item_peso) self.table_Mascotas.setItem(rowCount,3,item_duenio) self.table_Mascotas.setItem(rowCount,4,item_paseador) self.table_Mascotas.setItem(rowCount,5,item_codigo) self.table_Mascotas.resizeColumnsToContents() self.table_Mascotas.setColumnHidden(5,True) self.table_Mascotas.horizontalHeader().setStretchLastSection(True)
def show_Map(self): self.table_Activos.setCurrentCell(self.table_Activos.currentRow(), 3) item = self.table_Activos.currentItem() paseo = Funciones.get_paseo(self.paseos_activos, int(item.text().strip())) if(item!=None): mapa = WebView(Url(self.direccion, Funciones.get_recorrido(self.direccion, paseo.get_Espacio(), self.mascotas,self.clientes, int(item.text().strip())), "14")) mapa.exec_()
def edit_Triggered(self): self.table_Mascotas.setCurrentCell(self.table_Mascotas.currentRow(), 5) item = self.table_Mascotas.currentItem() mascota = Funciones.get_mascota(self.__mascotas, int(item.text().strip())) form = FormAltaMascota(self.__mascotas, self.__paseadores, self.__clientes, None, mascota) form.exec_() if (form.get_Mascota()!=None): self.__mascotas = Funciones.add_mascota(self.__mascotas, form.get_Mascota()) self.update_Table()
def edit_Triggered(self): self.table_Clientes.setCurrentCell(self.table_Clientes.currentRow(), 2) item = self.table_Clientes.currentItem() cliente = Funciones.get_cliente(self.__clientes, int(item.text().strip())) form = FormAltaCliente(self.__clientes, self.__paseadores, self.__mascotas, cliente) form.exec_() if (form.get_Cliente()!=None): self.__clientes = Funciones.add_cliente(self.__clientes, form.get_Cliente()) self.update_Table()
def edit_Triggered(self): self.table_Paseadores.setCurrentCell(self.table_Paseadores.currentRow(), 2) item = self.table_Paseadores.currentItem() paseador = Funciones.get_paseador(self.__paseadores, int(item.text().strip())) form = FormAltaPaseador(self.__paseadores, paseador) form.exec_() if (form.get_Paseador()!=None): self.__paseadores = Funciones.add_paseador(self.__paseadores, form.get_Paseador()) self.update_Table()
def pb_Aceptar_Clicked(self): p = Paseador(self.lineEdit_Apellido.text().strip().title(), self.lineEdit_Nombre.text().strip().title(), self.lineEdit_DNI.text().strip(), self.lineEdit_Telefono.text().strip()) msgbox = MsgBox() valid = Funciones.validar_paseador(self.__paseadores, p, (self.__paseador!=None)) if (valid[0]): msgbox.set_Text("Paseador Registrado") msgbox.setWindowTitle("Informacion") msgbox.exec_() self.__paseador = Funciones.format_paseador(p) self.close() else: msgbox.set_Title("Error") msgbox.set_Text(valid[1]) msgbox.exec_()
def pb_Aceptar_Clicked(self): valid = Funciones.validar_configuracion(self.lineEdit_Direccion.text().strip(), self.combo_Espacios) msgbox = MsgBox() if (valid[0]): self.__direccion = self.lineEdit_Direccion.text().strip().title() self.__espacios = Funciones.get_combo_items(self.combo_Espacios) msgbox.set_Text("Cambios Guardados") msgbox.set_Title("Informacion") msgbox.exec_() self.close() self.setResult(1) else: msgbox.set_Title("Error") msgbox.set_Text(valid[1]) msgbox.exec_()
def update_Table_Historial(self,paseos): self.table_Historial.setColumnHidden(4,False) for i in range(0,self.table_Historial.rowCount()): self.table_Historial.removeRow(i) self.table_Historial.setRowCount(0) for paseo in paseos: salida = str(paseo.get_Salida().hour) + ":" + str(paseo.get_Salida().minute) + ":" + str(paseo.get_Salida().second) print(salida,type(salida)) arribo = paseo.get_Arribo() fecha = paseo.get_Fecha() codigo = str(paseo.get_Paseador()) paseador = Funciones.get_paseador(self.paseadores, paseo.get_Paseador()) itemSalida = QTableWidgetItem(salida) itemArribo = QTableWidgetItem(arribo) itemCodigo = QTableWidgetItem(codigo) itemPaseador = QTableWidgetItem(paseador.get_Nombre()) itemFecha = QTableWidgetItem(fecha) rowCount = self.table_Historial.rowCount() self.table_Historial.insertRow(rowCount) self.table_Historial.setItem(rowCount,0,itemFecha) self.table_Historial.setItem(rowCount,1,itemSalida) self.table_Historial.setItem(rowCount,2,itemArribo) self.table_Historial.setItem(rowCount,3,itemPaseador) self.table_Historial.setItem(rowCount,4,itemCodigo) self.table_Historial.resizeColumnsToContents() self.table_Historial.setColumnHidden(4,True) self.table_Historial.horizontalHeader().setStretchLastSection(True)
def pb_Aceptar_Clicked(self): c = Cliente( self.lineEdit_Apellido.text().strip().title(), self.lineEdit_Nombre.text().strip().title(), self.lineEdit_DNI.text().strip(), self.lineEdit_Telefono.text().strip(), self.lineEdit_Direccion.text().strip().title()) msgbox = MsgBox() valid = Funciones.validar_cliente(self.__clientes, c, self.combo_Mascotas, self.__cliente!=None) if (valid[0]): msgbox.set_Text("Cliente Registrado") msgbox.setWindowTitle("Informacion") msgbox.exec_() self.__cliente = Funciones.format_cliente(c) self.__mascotas = Funciones.set_cliente(self.__mascotas, self.__mascotas_alta, self.__cliente) self.close() else: msgbox.set_Title("Error") msgbox.set_Text(valid[1]) msgbox.exec_()
def pb_Aceptar_Clicked(self): paseador = Funciones.get_paseador(self.__paseadores, self.combo_Paseadores.itemData(self.combo_Paseadores.currentIndex())) paseo = Paseo(paseador.get_Dni(), self.spinBox_Horas.value(), self.spinBox_Minutos.value(), self.combo_Espacios.itemData(self.combo_Espacios.currentIndex())) valid = Funciones.validar_paseo(self.__paseos, paseo) msgbox = MsgBox() if (valid[0]): msgbox.set_Text("Paseo Registrado") msgbox.set_Title("Informacion") msgbox.exec_() self.__paseo = paseo self.close() self.setResult(1) else: msgbox.set_Title("Error") msgbox.set_Text(valid[1]) msgbox.exec_()
def __init__(self,parent = None): QtGui.QMainWindow.__init__(self,parent) self.setupUi(self) self.clientes = Funciones.crear_lista_cliente() self.paseadores = Funciones.crear_lista_paseadores() self.mascotas = Funciones.crear_lista_mascota() self.paseos_activos = {} self.paseos_historial = [] self.espacios = [] self.direccion = "9 de Julio 50 Concepcion del Uruguay" self.actionAltaCliente.triggered.connect(self.alta_Cliente) self.actionAltaMascota.triggered.connect(self.alta_Mascota) self.actionAltaPaseador.triggered.connect(self.alta_Paseador) self.actionListadoCliente.triggered.connect(self.listado_Clientes) self.actionListadoPaseador.triggered.connect(self.listado_Paseadores) self.actionListadoMascota.triggered.connect(self.listado_Mascotas) self.actionConfiguracion.triggered.connect(self.configuracion) self.pb_Salida.clicked.connect(self.alta_Paseo) self.pb_Arribo.clicked.connect(self.registro_Arribo) self.tab_Paseos.currentChanged.connect(self.tab_Change) self.table_Activos.cellDoubleClicked.connect(self.show_Map)
def pb_Aceptar_Clicked(self): valid = Funciones.validar_espacio(self.lineEdit_Direccion.text().strip()) msg = MsgBox() if (valid[0]): self.__espacio = self.lineEdit_Direccion.text().strip().title() msg.set_Title("Informacion") msg.set_Text("Espacio Registrado") msg.exec_() self.close() else: msg.set_Title("Error") msg.set_Text(valid[1]) msg.exec_()
def registro_Arribo(self): self.table_Activos.setCurrentCell(self.table_Activos.currentRow(), 3) item = self.table_Activos.currentItem() if(item!=None): paseo = Funciones.get_paseo(self.paseos_activos, int(item.text().strip())) msg_confirm = MsgBoxConfirm() msg_confirm.set_Text("¿Registra el arribo del paseador?") msg_confirm.set_Title("Confirmar") msg_confirm.exec_() if (msg_confirm.get_Result()==1): self.paseos_activos[paseo.get_Paseador()].set_Arribo(time.strftime("%H:%M:%S")) self.paseos_historial.append(self.paseos_activos.pop(paseo.get_Paseador())) self.update_Table_Activos(self.paseos_activos.values()) self.update_Table_Historial(self.paseos_historial)
def __init__(self, paseos, paseadores, mascotas, espacios, parent = None): QtGui.QDialog.__init__(self,parent) self.setupUi(self) self.setResult(0) self.__espacios = espacios self.__mascotas = mascotas self.__paseos = paseos self.__paseo = None self.__paseadores = paseadores self.__paseadores_object = self.__paseadores.values() for espacio in self.__espacios: self.combo_Espacios.addItem(espacio, espacio) for p in self.__paseadores_object: if ((len(Funciones.get_mascotas_paseador(self.__mascotas, p)))>0): self.combo_Paseadores.addItem(p.get_Nombre(), p.get_Dni()) self.pb_Aceptar.clicked.connect(self.pb_Aceptar_Clicked)
def pb_Aceptar_Clicked(self): if (self.__mascota!=None): codigo = self.__mascota.get_Codigo() else: codigo = len(self.__mascotas_object) mascota = Mascota(self.lineEdit_Nombre.text().strip().title(), self.lineEdit_Raza.text().strip().title(), self.spinBox_Peso.value(), self.combo_Duenio.itemData(self.combo_Duenio.currentIndex()), Funciones.select_paseador(self.__paseadores), codigo) msgbox = MsgBox() valid = Funciones.validar_mascota(mascota) if (valid[0]): msgbox.set_Text("Mascota Registrada") msgbox.setWindowTitle("Informacion") msgbox.exec_() self.__mascota = mascota self.close() else: msgbox.set_Title("Error") msgbox.set_Text(valid[1]) msgbox.exec_()
def update_Table_Activos(self,paseos): self.table_Activos.setColumnHidden(3,False) for i in range(0,self.table_Activos.rowCount()): self.table_Activos.removeRow(i) self.table_Activos.setRowCount(0) for paseo in paseos: salida = str(paseo.get_Salida().hour) + ":" + str(paseo.get_Salida().minute) + ":" + str(paseo.get_Salida().second) tentativo = str(paseo.get_Tentativo().hour) + ":" + str(paseo.get_Tentativo().minute) + ":" + str(paseo.get_Tentativo().second) codigo = str(paseo.get_Paseador()) paseador = Funciones.get_paseador(self.paseadores, paseo.get_Paseador()) itemSalida = QTableWidgetItem(salida) itemTentativo = QTableWidgetItem(tentativo) itemCodigo = QTableWidgetItem(codigo) itemPaseador = QTableWidgetItem(paseador.get_Nombre()) rowCount = self.table_Activos.rowCount() self.table_Activos.insertRow(rowCount) self.table_Activos.setItem(rowCount,0,itemSalida) self.table_Activos.setItem(rowCount,1,itemTentativo) self.table_Activos.setItem(rowCount,2,itemPaseador) self.table_Activos.setItem(rowCount,3,itemCodigo) self.table_Activos.resizeColumnsToContents() self.table_Activos.setColumnHidden(3,True) self.table_Activos.horizontalHeader().setStretchLastSection(True)
def __init__(self, clientes, paseadores, mascotas, cliente = None, parent = None): QtGui.QDialog.__init__(self,parent) self.setupUi(self) self.__cliente = cliente self.__clientes = clientes self.__paseadores = paseadores self.__mascotas = mascotas self.__mascotas_alta = [] if (self.__cliente!=None): self.lineEdit_Nombre.setText(cliente.get_Nombre()) self.lineEdit_Apellido.setText(cliente.get_Apellido()) self.lineEdit_Direccion.setText(cliente.get_Direccion()) self.lineEdit_DNI.setText(str(cliente.get_Dni())) self.lineEdit_Telefono.setText(str(cliente.get_Telefono())) self.lineEdit_DNI.setEnabled(False) dic_mascotas_cliente = Funciones.get_mascotas_cliente(self.__mascotas, self.__cliente) list_mascotas_cliente = dic_mascotas_cliente.values() for value in list_mascotas_cliente: self.combo_Mascotas.addItem(value.get_Nombre(), value.get_Codigo()) self.combo_Mascotas.setEnabled(True) self.pb_Add_Mascota.setEnabled(True) self.pb_Aceptar.clicked.connect(self.pb_Aceptar_Clicked) self.pb_Add_Mascota.clicked.connect(self.pb_Add_Mascota_Clicked) self.lineEdit_DNI.editingFinished.connect(self.enable_Combo)
def main(): des = {'font': ("Current", 16), 'size': (16, 2)} layout = [[ sg.Text( 'NOMBRE:', font=("Current", 20), text_color='saddlebrown', ), sg.InputText(key='__nombre__', size=(30, 5), pad=(0, 30), font=("Current", 20)) ], [sg.Button('Jugar', **des), sg.Button('Configuración', **des)], [sg.Image(filename='Imagenes/1.png', pad=(0, 30))]] window = sg.Window('¡Bienvenido!', layout, size=(630, 350), element_justification='center') cant_rondas = 1 cant_cambios = 0 diccTablero = {} jugadores = [] ultima_palabra = [] default = True while True: event, values = window.Read() if event is None: break if event is 'Configuración': default = False config = c.configuracion(default) default = config[1] if event is 'Jugar': nom = values['__nombre__'] print(len(nom)) if len(nom) < 3 or len(nom) > 10: sg.popup('El nombre debe tener entre 3 y 10 letras.', title='Error', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) else: window.Close() if default: config = c.configuracion(default) bag = Bag((dict(list(config[0].items())[0:8])), dict(list(config[0].items())[8:16])) board = Board(bag, config[0]['__dificultad__']) jugadores = f.instanciar_jugadores(bag, nom, jugadores) random.shuffle(jugadores) jugador_actual = jugadores[0] carga = False tp_inicial = config[0]['__tiempoPartida__'] tr_inicial = config[0]['__tiempoTurno__'] j.jugar(bag, board, diccTablero, jugadores, jugador_actual, config[0]['__dificultad__'], cant_rondas, ultima_palabra, carga, config[0]['__tiempoPartida__'], config[0]['__tiempoTurno__'], cant_cambios, int(tp_inicial), int(tr_inicial))
def alta_Paseador(self): form = FormAltaPaseador(self.paseadores) form.exec_() if (form.get_Paseador()!=None): self.paseadores = Funciones.add_paseador(self.paseadores, form.get_Paseador())
def alta_Mascota(self): form = FormAltaMascota(self.mascotas, self.paseadores, self.clientes) form.exec_() if (form.get_Mascota()!=None): self.mascotas = Funciones.add_mascota(self.mascotas, form.get_Mascota())
def alta_Cliente(self): form = FormAltaCliente(self.clientes, self.paseadores, self.mascotas) form.exec_() if (form.get_Cliente()!=None): self.clientes = Funciones.add_cliente(self.clientes, form.get_Cliente()) self.mascotas.update(form.get_Mascotas())
def test_menor_5_True(self): f = Funciones() self.assertTrue(f.menor_5(3))
def test_menor_5_False(self): f = Funciones() self.assertFalse(f.menor_5(7))
def test_Hola(self): f = Funciones() self.assertEqual("Hola",f.dime_Hola())
def turno(window, jugador, tiempo_partida, tiempo_ronda, board, diccTablero, cant_rondas, jugadores, nivel, ultima_palabra, bag, carga, cant_cambios, tp_inicial, tr_inicial): ''' Función que desarrolla cada turno, tanto los de la Pc como los del usuario. ''' atril = [] fila = True columna = True cant_cambios = cant_cambios fun.completo_atril(window, jugador) sg.popup('Comienza el jugador: ', jugador.get_name(), title='Primer turno', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) if carga: temp = fun.cargo(jugadores, window.FindElement('_puntajeUser_'), window.FindElement('_puntajePC_'), window.FindElement('_ultimaPalabra_'), ultima_palabra, window.FindElement('__n__'), nivel, tiempo_partida, tiempo_ronda, tp_inicial, tr_inicial, window.FindElement('__tp__'), window.FindElement('__tr__')) ficha_central = diccTablero[( 7, 7)] if nivel == 'Facil' else diccTablero[( 8, 8)] if nivel == 'Medio' else diccTablero[(9, 9)] tiempo_ronda = temp[0] tiempo_partida = temp[1] tronda_inicial = (int(tp_inicial) * 100) else: ficha_central = board.ficha_centro centro = board.get_medio() diccTablero[(centro[0], centro[1])] = ficha_central ultima_palabra = [''] tiempo_partida = (int(tiempo_partida) * 60) * 100 #359999 una hora tiempo_ronda = (int(tiempo_ronda) * 100) #5999 un minuto tronda_inicial = tiempo_ronda while True and tiempo_partida != 0: window['__tiempoTurno__'].update('{:02d}:{:02d}'.format( ((tiempo_ronda // 100) % 60), tiempo_ronda % 100)) window['__tiempoPartida__'].update('{:02d}:{:02d}'.format( (tiempo_partida // 100) // 60, (tiempo_partida // 100) % 60)) tiempo_partida -= 1 tiempo_ronda -= 1 window.FindElement('__nombreAtril__').update(jugador.get_name()) dicc = jugador.get_dicc() lista_coordenadas = board.lista_coordenadas() #-----TURNO PC----- if jugador.get_name() == 'PC': ai.juega_PC(dicc, diccTablero, ficha_central, jugador, board, window, jugadores, cant_rondas, window.FindElement('_puntajeUser_'), window.FindElement('_puntajePC_'), window.FindElement('_ultimaPalabra_'), nivel, ultima_palabra, bag, lista_coordenadas) jugador = fun.next_player(jugador, jugadores) cant_rondas = cant_rondas + 1 fun.completo_atril(window, jugador) tiempo_partida -= 1 columna = True fila = True else: #-----TURNO USER----- event, values = window.read(timeout=10) if event in (None, 'Salir'): break elif event in (0, 1, 2, 3, 4, 5, 6): if event in atril: sg.popup('Ya usó esta ficha.', title=':(', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) else: atril.append(event) aux = jugador.atril_array()[event] vacio = copy.deepcopy(event) event, values = window.read() if type(event) is tuple: if event not in dicc.keys( ) and event not in diccTablero.keys(): posicion = fun.armar_palabra( dicc, event, aux, window, vacio, fila, columna, cant_rondas, board, diccTablero, lista_coordenadas) columna = posicion[0] fila = posicion[1] else: sg.popup('El casillero ya se encuentra ocupado.', title=':(', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) atril.pop() elif event in (None, 'Salir'): break else: sg.popup( 'Movimiento no válido. Debe poner la ficha en el tablero.', title='No válido', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) atril.pop() del atril[:] #-----VALIDAR PALABRA----- if event is 'Validar': if len(dicc) == 1: sg.popup('No se pueden formar palabras de una sóla letra.', title='Error', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) else: fun.validar_palabra(window, jugadores, diccTablero, dicc, jugador, window.FindElement('_puntajeUser_'), window.FindElement('_puntajePC_'), window.FindElement('_ultimaPalabra_'), cant_rondas, board, nivel, ultima_palabra, bag) jugador = fun.next_player(jugador, jugadores) fun.completo_atril(window, jugador) cant_rondas = cant_rondas + 1 tiempo_ronda = tronda_inicial fila = True columna = True #del atril[:] #-----PASAR TURNO----- if event == 'Pasar turno': fun.reset(window, jugador, cant_rondas, diccTablero, board) jugador = fun.next_player(jugador, jugadores) cant_rondas = cant_rondas + 1 tiempo_ronda = tronda_inicial del atril[:] #-----CAMBIAR FICHAS----- if event == 'Cambiar fichas': fun.reset(window, jugador, cant_rondas, diccTablero, board) if cant_cambios != 3: fun.cambiar_fichas(window, jugador) jugador = fun.next_player(jugador, jugadores) tiempo_ronda = tronda_inicial cant_cambios += 1 else: sg.popup('Ya hizo uso de los tres cambios permitidos.', title='Error', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) #-----POSPONER JUEGO----- if event is 'Posponer': fun.reset(window, jugador, cant_rondas, diccTablero, board) fun.guardar_partida(diccTablero, jugadores, bag, cant_rondas, ultima_palabra, nivel, cant_cambios, tiempo_partida, tiempo_ronda, tr_inicial, tp_inicial) sg.popup('¡Partida guardada!', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) break #-----TERMINAR JUEGO----- if event == 'Terminar juego': fun.reset(window, jugador, cant_rondas, diccTablero, board) fun.termino_juego(jugadores, bag, nivel) diccTablero.clear() window.close() break if event is 'REGLAS': fun.reglas() #-----SI TERMINA EL TIEMPO DE LA RONDA----- if tiempo_ronda == 0: fun.reset(window, jugador, cant_rondas, diccTablero, board) cant_rondas = cant_rondas + 1 sg.popup('Se quedó sin tiempo, ha perdido el turno.', title='Se quedó sin tiempo', background_color='#E5CEAC', text_color='#8B4513', button_color=('white', '#8B4513')) jugador = fun.next_player(jugador, jugadores) #-----SI TERMINA EL TIEMPO DE LA PARTIDA----- if tiempo_partida == 0: fun.reset(window, jugador, cant_rondas, diccTablero, board) fun.termino_juego(jugadores, bag, nivel) diccTablero.clear() window.close()