def main(): """ Точка входа в приложение :return: None """ app = QApplication(sys.argv) qb = View() qb.show() sys.exit(app.exec_())
def newRecordAction(self): from View.View import View debugStatement(2, 'adding record') view = View() recordFields = dict([(var._name, var.get()) for var in self._RecordField.__dict__.values()]) view.addRecord(recordFields) self._RecordField.clear() self._RecordField.productName.set("")
def __init__(self): self._Controller = Controller() self._View = View() self._Model = Model() self._Controller.addView(self._View) self._Controller.addModel(self._Model) self._View.addController(self._Controller) self._View.initMainView() self._Controller.startApp()
def __init__(self): #init view and model self.model = GameModel() self.view = View() # the things show in window self.gameState = [OPEN_PAGE] # correspond to left side buttons for next step self.nextStage = [] # map state self.map = HIDE self.showItem = [] self.itemBuf = None
def main(): # Initialize all objects view = View() counter = Counter() beeper = Beeper() maze = Maze(3, 3) origin_cell = maze.cells_grid[-1][-1] player = Player(origin_cell, beeper) winning_cell = False game_state = GameState(player, maze) # Make subscriptions counter.tick_event += beeper.count beeper.beep_event += game_state.beep_event game_state.sound_event += view.sound_event game_state.puddle_event += view.puddle_event game_state.whoosh_event += view.whoosh_event game_state.knock_event += view.knock_event game_state.walk_into_event += view.walk_into_event player.turn_event += view.turn_event player.no_beeper_event += view.no_beeper_event print("\nBegin!") while not winning_cell: counter.tick() movement = handle_input() if movement: try: movements[movement](player) except KeyError: continue winning_cell = player.current_cell.is_winning_cell print("Congrats! You win!")
def displayRecords(self): from View.View import View view = View() self._listingRecordsField.recordDisplay.delete(1.0, constants.END) headers, records = view.listRecords() tmp = [] tmp.append(*records) tmp.insert(0, headers) columns = [*zip(*tmp)] columnsSize = [self._maxLen(column) for column in columns] toDisplay = '' toDisplay += self._displayRow(headers, columnsSize) for record in records: toDisplay += self._displayRow(record, columnsSize) self._listingRecordsField.recordDisplay.insert(constants.INSERT, toDisplay)
def Release(): x, y, path = prs.Parse("check") nn = dlnet(x, y) Read(nn) Yh = nn.forward() Yh *= 100 view = View(Yh, path)
def __init__(self): ################################# # 全局变量 ################################# self.Conf = { 'url': None, 'urlFile': None, 'outFile': None, 'runMode': View.RunMode_Console } ################################# # 参数检查 ################################# self.usage_check() ################################# # Model & View ################################# ## Model self.model = Model.Model() ## View self.view = View(isinit=0) ################################# # 初始化 ################################# self.view.init(target=self.Conf['url'], mode=self.Conf['runMode']) ################################# # 连接 Model & View ################################# ## 设置回调函数 self.model.add_callback(self.finish) self.view.set_evt_start_work(self.do_work)
class Controll(): def __init__(self): #init view and model self.model = GameModel() self.view = View() # the things show in window self.gameState = [OPEN_PAGE] # correspond to left side buttons for next step self.nextStage = [] # map state self.map = HIDE self.showItem = [] self.itemBuf = None def run(self): self.view.initView() self.model.initilize() while len(self.gameState) != 0: crt = self.view.userInput() print(crt) # key: "map" ,"page", "type"("item","move","windowControll","showDetail","choose","action"),"name" if crt["type"] == "item": action = "showDetail" self.itemBuf = crt["name"] self.view.update({"name": crt['name'], "action": action}) elif crt["type"] == "move": # name: seashoreButton, investigationStationButton, plateauButton if crt["name"] == "seashoreButton": target = seashoreMap moveto = "seashoreMap" elif crt["name"] == "investigationStationButton": target = stationMap moveto = "stationMap" elif crt["name"] == "plateauButton": target = plateauMap moveto = "plateauMap" ### update(dir) dir = {target:,action:,status:{}} ### store the states in a dictionary self.view.update({"target": moveto, "action": "move"}) self.model.move(target) elif crt["type"] == "windowControll": self.view.update({ "name": crt["name"], "action": "windowControll" }) elif crt["type"] == "choose": action = "choose" if crt["result"] == "yes": self.showItem.append(self.itemBuf) self.model.update({ "part": "pack", "action": "take", "target": self.itemBuf }) elif crt["result"] == "no": itemBuf = None pass else: print("WTF is Henry doing?") self.view.update({ "name": self.showItem, "action": action, "counter": len(self.model.pack.items), "result": crt["result"] }) elif crt["type"] == "action": if "name" not in crt: print("WTF is Henry doing?") if crt["name"] == "startButton": self.gameState.append(MAIN_PAGE) self.model.initilize() self.view.update({"start": True}) if crt["name"] == "thatsAll": self.gameState.append(STORY_PAGE) self.view.update({"start": True}) if crt["name"] == "IGotIt": self.gameState.append(MAIN_PAGE) self.model.initilize() self.view.update({"start": True}) else: self.model.update({ "part": "action", "action": crt["name"] }) else: print("WTF is Henry doing?")
def on_clear_button_click(self): self.__init__(model=Model(), view=View())
def main(): view = View() view.run()
from View.View import View view = View() view.iniciar()
from Controller.Controller import Controller from View.View import View from View.UserInterface import UserInterface from ServiceLayer.ServiceLayer import ServiceLayer from Dao.Dao import Dao """ Hardcoding DI for now experimenting """ sl = ServiceLayer(Dao()) view = View() userInterface = UserInterface(view) controller = Controller(userInterface, sl) controller.run()
def __init__(self): self.Model = Model() self.View = View()
def __init__(self): self.model = Model() self.view = View()
class Controller: Version = 1.0 Website = "https://www.wangsansan.com" def __init__(self): ################################# # 全局变量 ################################# self.Conf = { 'url': None, 'urlFile': None, 'outFile': None, 'runMode': View.RunMode_Console } ################################# # 参数检查 ################################# self.usage_check() ################################# # Model & View ################################# ## Model self.model = Model.Model() ## View self.view = View(isinit=0) ################################# # 初始化 ################################# self.view.init(target=self.Conf['url'], mode=self.Conf['runMode']) ################################# # 连接 Model & View ################################# ## 设置回调函数 self.model.add_callback(self.finish) self.view.set_evt_start_work(self.do_work) def __del__(self): pass def run(self): self.view.run() def do_work(self, evt=None): # 业务逻辑的参数输入事件 target = self.Conf['url'] self.view.show("Input: " + str(target)) self.model.start(target) def finish(self, data): # 业务逻辑执行完成的结果输出回调函数 self.view.show("Result: " + data) def usage_check(self): weight = 0 # 参数权重总和 runWeight = 100 # 可运行条件最低权重值 unitWeight = 20 # 单位权重值, 用来给其它数值做加数 ################################# # Initialization self.Conf ################################# i = 1 while (i < len(sys.argv)): arg = sys.argv[i] if (arg == "show"): self.Conf['runMode'] = View.RunMode_GUI weight = runWeight elif (arg == "-h" or arg == "--help"): self.usage() elif (arg == "-u" or arg == "--url"): i = i + 1 self.Conf['url'] = sys.argv[i] weight = weight + runWeight elif (arg == "-m" or arg == "--multi"): i = i + 1 self.Conf['urlFile'] = sys.argv[i] weight = weight + runWeight elif (arg == "-o" or arg == "--output"): i = i + 1 self.Conf['outFile'] = sys.argv[i] weight = weight + unitWeight i = i + 1 ################################# # Check self.Conf ################################# if (weight < runWeight): self.usage() def usage(self): print("Version " + str(Controller.Version) + " - " + str(Controller.Website)) print("") print("Usage: python " + sys.argv[0] + " [show|<Options>]") print(" Example:") print(" python " + sys.argv[0] + " show") print(" python " + sys.argv[0] + " -m ./Target.list -o \"./save.txt\"") print(" python " + sys.argv[0] + " -u https://www.wangsansan.com -o \"./save.txt\"") print(" ---") print("") print(" show \t\t\t Start GUI") print(" ------") print(" Options: ") print(" -h, --help \t\t\t Help.") print("") print( " <Target>: \t\t\t\t Choose one of them, The priority of \"-u(--url)\" is greater than \"-m(--multi)\"" ) print(" -u, --url <url> \t\t Target link.") print( " -m, --multi <filename> \t Read target list from a file. The one row is a target." ) print("") print( " -o, --output <filename> \t\t Output result data to a file.") exit()
async def main(): m = Model() v = View() c = Controller(m, v) await run_tk(v, c)
def __init__(self, root): self.model = Model() # self.model.myMoney.addCallback(self.MoneyChanged) self.view1 = View(root)
class Controller: """ ********************************* * A controller for a store DB * ********************************* """ def __init__(self): self.model = Model() self.view = View() def start(self): self.view.start() self.main_menu() """ ********************************* * General Controller * ********************************* """ def main_menu(self): o = '0' while 0 != '3': self.view.main_menu() self.view.option('3') o = input() if o == '1': self.cita_menu() elif o == '2': self.contacto_menu() elif o == '3': self.view.end() else: self.view.not_valid_option() return def update_lists(self, fs, vs): fields = [] vals = [] for f, v in zip(fs, vs): if v != '': fields.append(f + ' = %s') vals.append(v) return fields, vals """ ********************************* * Controllers for dates * ********************************* """ def cita_menu(self): o = '0' while o != '8': self.view.cita_menu() self.view.option('13') o = input() if o == '1': self.create_cita() elif o == '2': self.read_a_cita() elif o == '3': self.read_all_citas() elif o == '4': self.read_citas_asunto() elif o == '5': self.read_cita_fecha() elif o == '6': self.update_cita() elif o == '7': self.delete_cita() elif o == '8': self.create_detalles_cita() elif o == '9': self.read_contactos_cita() elif o == '10': self.read_citas_contacto() elif o == '11': self.update_detalles_cita() elif o == '12': self.delete_usuario_cita() elif o == '13': self.main_menu() return else: self.view.not_valid_option() return def ask_cita(self): self.view.ask('Lugar: ') lugar = input() self.view.ask('Ciudad: ') ciudad = input() self.view.ask('Estado: ') estado = input() self.view.ask('Fecha: ') fecha = input() self.view.ask('Asunto: ') asunto = input() return [lugar, ciudad, estado, fecha, asunto] def create_cita(self): lugar, ciudad, estado, fecha, asunto = self.ask_cita() out = self.model.create_cita(lugar, ciudad, estado, fecha, asunto) # id_cita = self.read_a_cita(asunto) if out == True: self.view.ok(lugar + ' ' + fecha + ' ' + asunto, 'agrego') else: self.view.error('NO SE PUDO AGREGAR LA CITA. REVISA') return def read_a_cita(self): self.view.ask('ID cita: ') id_cita = input() cita = self.model.read_a_cita(id_cita) if type(cita) == tuple: self.view.show_cita_header(' Datos de la cita ' + id_cita + ' ') self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer() else: if cita == None: self.view.error('LA CITA NO EXISTE') else: self.view.error('PROBLEMA AL LEER LA CITA. REVISA') return def read_all_citas(self): citas = self.model.read_all_citas() if type(citas) == list: self.view.show_cita_header(' Todas las citas ') for cita in citas: self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer() else: self.view.error('PROBLEMA AL LEER LAS CITAS. REVISA') return def read_citas_asunto(self): self.view.ask('Asunto: ') asunto = input() citas = self.model.read_citas_asunto(asunto) if type(citas) == list: self.view.show_cita_header(' Asunto de la cita ' + asunto + ' ') for cita in citas: self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer else: self.view.error('PROBLEMA AL LEER LAS CITAS. REVISA') return def read_cita_fecha(self): self.view.ask('Fecha: ') fecha = input() citas = self.model.read_cita_fecha(fecha) if type(citas) == list: self.view.show_cita_header(' Fecha: ' + fecha + ' ') for cita in citas: self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer() else: self.view.error('PROBLEMA AL LEER La CITA. REVISA') return def update_cita(self): self.view.ask('ID de cita a modificar: ') id_cita = input() cita = self.model.read_a_cita(id_cita) if type(cita) == tuple: self.view.show_cita_header(' Datos del producto ' + id_cita + ' ') self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer() else: if cita == None: self.view.error('LA CITA NO EXISTE') else: self.view.error('PROBLEMA AL LEER LAS CITAS. REVISA') return self.view.msg( 'Ingresa los valores a modificar (vacio para dejarlo igual): ') whole_vals = self.ask_cita() fields, vals = self.update_lists( ['c_lugar', 'c_ciudad', 'c_estado', 'c_fecha', 'c_asunto'], whole_vals) vals.append(id_cita) vals = tuple(vals) out = self.model.update_cita(fields, vals) if out == True: self.view.ok(id_cita, 'actualizo') else: self.view.error('NO SE PUDO ACTUALIZAR LA CITA. REVISA') return def delete_cita(self): self.view.ask('Id de la cita a borrar: ') id_cita = input() count = self.model.delete_cita(id_cita) if count != 0: self.view.ok(id_cita, 'borro') else: if count == 0: self.view.error('LA CITA NO EXISTE') else: self.view.error('PROBLEMA AL BORRAR LA CITA. REVISA.') return """ *********************************** * Controllers for Contactos * *********************************** """ def contacto_menu(self): o = '0' while o != '6': self.view.contacto_menu() self.view.option('6') o = input() if o == '1': self.create_contacto() elif o == '2': self.read_a_contacto() elif o == '3': self.read_all_contactos() elif o == '4': self.update_contacto() elif o == '5': self.delete_contacto() elif o == '6': self.main_menu() return else: self.view.not_valid_option() return def ask_contacto(self): self.view.ask('Nombre: ') name = input() self.view.ask('Apellido paterno: ') apellidoP = input() self.view.ask('Apellido materno: ') apellidoM = input() self.view.ask('Calle: ') calle = input() self.view.ask('No. exterior: ') noext = input() self.view.ask('No interior: ') noint = input() self.view.ask('Colonia: ') col = input() self.view.ask('Ciudad: ') ciudad = input() self.view.ask('Estado: ') estado = input() self.view.ask('Email: ') email = input() self.view.ask('Telefono: ') phone = input() return [ name, apellidoP, apellidoM, calle, noext, noint, col, ciudad, estado, email, phone ] def create_contacto(self): name, apellidoP, apellidoM, calle, noext, noint, col, ciudad, estado, email, phone = self.ask_contacto( ) out = self.model.create_contacto(name, apellidoP, apellidoM, calle, noext, noint, col, ciudad, estado, email, phone) if out == True: self.view.ok(name + ' ' + apellidoP + ' ' + apellidoM, 'agrego') else: self.view.error('NO SE PUDO AGREGAR EL CONTACTO. REVISA') return def read_a_contacto(self): self.view.ask('ID Contacto: ') id_contacto = input() contacto = self.model.read_a_contacto(id_contacto) if type(contacto) == tuple: self.view.show_contacto_header(' Datos del contacto ' + id_contacto + ' ') self.view.show_a_contacto(contacto) self.view.show_contacto_midder() self.view.show_contacto_footer() else: if contacto == None: self.view.error('EL CONTACTO NO EXISTE') else: self.view.error('PROBLEMA AL LEER EL CONTACTO. REVISA') return def read_all_contactos(self): contactos = self.model.read_all_contactos() if type(contactos) == list: self.view.show_contacto_header(' Todos los contacto ') for contacto in contactos: self.view.show_a_contacto(contacto) self.view.show_contacto_midder() self.view.show_contacto_footer() else: self.view.error('PROBLEMA AL LEER LOS CONTACTOS. REVISA') return def update_contacto(self): self.view.ask('ID de contacto a modificar: ') id_contacto = input() contactos = self.model.read_a_contacto(id_contacto) if type(contactos) == tuple: self.view.show_contacto_header(' Datos del contacto ' + id_contacto + ' ') self.view.show_a_contacto(contactos) self.view.show_contacto_midder() self.view.show_contacto_footer() else: if contactos == None: self.view.error('EL CONTACTO NO EXISTE') else: self.view.error('PROBLEMA AL LEER EL CONTACTO. REVISA') return self.view.msg( 'Ingresa los valores a modificar (vacio para dejarlo igual): ') whole_vals = self.ask_contacto() fields, vals = self.update_lists([ 'c_nombre', 'c_apellidoP', 'c_apellidoM', 'c_calle', 'c_noext', 'c_noint', 'c_col', 'c_ciudad', 'c_estado', 'c_email', 'c_telefono' ], whole_vals) vals.append(id_contacto) vals = tuple(vals) out = self.model.update_contacto(fields, vals) if out == True: self.view.ok(id_contacto, 'actualizo') else: self.view.error('NO SE PUDO ACTUALIZAR EL CONTACTO. REVISA') return def delete_contacto(self): self.view.ask('ID de contacto a borrar: ') id_contacto = input() count = self.model.delete_contacto(id_contacto) if count != 0: self.view.ok(id_contacto, 'borro') else: if count == 0: self.view.error('EL CONTACTO NO EXISTE') else: self.view.error('PROBLEMA AL BORRAR EL CONTACTO. REVISA') return """ ************************************** * Controllers for Detalles-Cita * ************************************** """ def create_detalles_cita(self): self.read_all_citas() self.view.ask('ID cita: ') id_cita = input() if id_cita != '': cita = self.model.read_a_cita(id_cita) if type(cita) == tuple: self.view.show_cita_header(' Datos de la cita ' + id_cita + ' ') self.view.show_a_cita(cita) self.view.show_cita_footer() self.view.ask('Cita: ') nombre = input() self.view.ask('Notas: ') descripcion = input() self.read_all_contactos() self.view.ask('ID contacto: ') id_contacto = input() if id_contacto != '': contacto = self.model.read_a_contacto(id_contacto) self.view.show_contacto_header(' Datos del contacto ' + id_contacto + ' ') self.view.show_a_contacto(contacto) self.view.show_contacto_midder() self.view.show_contacto_footer() if type(contacto) == tuple: out = self.model.create_detalles_cita( id_cita, id_contacto, nombre, descripcion) if out == True: self.view.ok(contacto[1], 'Agrego') else: if out.errno == 1062: self.view.error( 'LA CITA YA NO ESTA PROGRAMADA') else: self.view.error( 'NO SE PUDO AGREGAR LA CITA. REVISA') else: if contacto == None: self.view.error('EL CONTACTO NO EXISTE') else: self.view.error( 'NO SE PUDO AGREGAR EL CONTACTO. REVISA') else: if cita == None: self.view.error('LA CITA NO EXISTE') else: self.view.error('NO SE PUDO AGREGAR LA CITA. REVISA') else: if cita == None: self.view.error('LA CITA NO EXISTE') else: self.view.error('PROBLEMA AL LEER LA CITA. REVISA') return def read_contactos_cita(self): self.view.ask('ID Cita: ') id_cita = input() contacto_cita = self.model.read_contactos_cita(id_cita) if type(contacto_cita) == list: self.view.show_contacto_cita_header('Usuarios dentro de Cita') for contacto in contacto_cita: self.view.show_a_contacto(contacto) self.view.show_contacto_midder() self.view.show_contacto_footer() else: if contacto_cita == None: self.view.error('LA CITA NO TIENE CONTACTOS') else: self.view.error( 'PROBLEMA AL LEER EL CONTACTO CON CITA. REVISA') return def read_citas_contacto(self): self.view.ask('ID Contacto: ') id_contacto = input() contactos_citas = self.model.read_citas_contacto(id_contacto) if type(contactos_citas) == list: self.view.show_contacto_cita_header( ' Todas la Citas para el contacto ') for cita in contactos_citas: self.view.show_a_cita(cita) self.view.show_cita_midder() self.view.show_cita_footer() else: self.view.error('PROBLEMA AL LEER LOS CONTACTOS Y CITAS. REVISA') return def ask_detalles_cita(self): self.view.ask('Nombre de Cita: ') nombre = input() self.view.ask('Nota: ') descripcion = input() return [nombre, descripcion] def update_detalles_cita(self): self.view.ask('ID de la cita a modificar: ') id_cita = input() cita = self.model.read_detalles_cita(id_cita) if type(cita) == tuple: self.view.show_cita_header('Detalles_Cita') self.view.show_a_detalles_cita(cita) self.view.show_contacto_cita_midder() self.view.show_contacto_cita_footer() else: if cita == None: self.view.error('La cita no existe') else: self.view.error('PROBLEMA AL LEER LA CITA. REVISA') return self.view.msg( 'Ingresa los valores a modificar (vacio para dejarlo igual): ') whole_vals = self.ask_detalles_cita() fields, vals = self.update_lists(['nombre', 'descripcion'], whole_vals) vals.append(id_cita) vals = tuple(vals) print('vals', vals) print('fiels', fields) out = self.model.update_detalles_cita(fields, vals) print(out) if out == True: self.view.ok(id_cita, 'actualizo') else: self.view.error( 'NO SE PUDO ACTUALIZAR EL CONTACTO CON LA CITA. REVISA') return def delete_usuario_cita(self): self.view.ask('ID de la cita a borrar contactos: ') id_cita = input() contacto_cita = self.model.read_contactos_cita(id_cita) contacto_cita = self.model.read_contactos_cita(id_cita) self.view.show_contacto_cita_header('Usuarios dentro de Cita') for contacto in contacto_cita: self.view.show_a_contacto(contacto) self.view.show_contacto_midder() self.view.show_contacto_footer() self.view.ask('ID del contacto a eliminar: ') id_contacto = input() count = self.model.delete_detalles_cita(id_cita, id_contacto) if count != 0: self.view.ok(id_contacto, 'borro') else: if count == 0: self.view.error('ERROR NO SE PUDO ELIMINAR') else: self.view.error( 'PROBLEMA AL BORRAR LA CITA DEL CONTACTO. REVISA') return