def __init__(self, id_serie, *args, **kw): super(VistaSerie, self).__init__(*args, **kw) self.res = xrc.XmlResource('../view/vistas_serie.xrc') self.frame = self.res.LoadFrame(None, 'VistaSerie') self.id_serie = id_serie self.series = Series() self.panel = xrc.XRCCTRL(self.frame, 'panelDif') self.text_name_serie = xrc.XRCCTRL(self.panel, 'textCtrlName') self.text_creator = xrc.XRCCTRL(self.panel, 'textCtrlCreator') self.text_gender_serie = xrc.XRCCTRL(self.panel, 'textCtrlGender') self.text_temporates_serie = xrc.XRCCTRL(self.panel, 'textCtrlTemporates') self.text_estate_serie = xrc.XRCCTRL(self.panel, 'textCtrlState') self.text_address_serie = xrc.XRCCTRL(self.panel, 'filePickerSerie') #Botones de acciones self.buttton_rent = xrc.XRCCTRL(self.panel, 'Rent') self.button_eliminte = xrc.XRCCTRL(self.panel, 'Eliminate') self.frame.Bind(wx.EVT_BUTTON, self.eliminate_serie, self.button_eliminte) self.button_modific = xrc.XRCCTRL(self.panel, 'modific') self.frame.Bind(wx.EVT_BUTTON, self.update_serie, self.button_modific) self.get_datos_serie() self.frame.Show()
def __init__(self, id_serie, id_user, *args, **kw): super(VistaUserSerie, self).__init__(*args, **kw) self.res = xrc.XmlResource('../view/vistas_serie_user.xrc') self.frame = self.res.LoadFrame(None, 'VistaUserSerie') self.panel = xrc.XRCCTRL(self.frame, 'panelOptions') self.id_serie = id_serie self.id_user = id_user self.rents = Rentas() self.series = Series() self.conect = Conection() self.text_name_serie = xrc.XRCCTRL(self.panel, 'staticTextName') self.text_creator = xrc.XRCCTRL(self.panel, 'staticTextCreator') self.text_gender_serie = xrc.XRCCTRL(self.panel, 'staticTextGenero') self.text_temporates_serie = xrc.XRCCTRL(self.panel, 'staticTextTemporates') self.text_estate_serie = xrc.XRCCTRL(self.panel, 'staticTextEstado') self.button_rent = xrc.XRCCTRL(self.panel, 'rent') self.frame.Bind(wx.EVT_BUTTON, self.rent_selected, self.button_rent) self.button_exit = xrc.XRCCTRL(self.panel, 'cancel') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_exit) self.get_datos_serie() self.frame.Show()
def __init__(self, frame_father=None, id_serie=None): super(RegistroSerie, self).__init__() self.res = xrc.XmlResource('../view/series.xrc') self.series = Series() self.conection = Conection() self.id_serie = id_serie self.frame = self.res.LoadFrame(None, 'RegistroSerie') self.panel = xrc.XRCCTRL(self.frame, 'm_panel6') self.titulo_serie = xrc.XRCCTRL(self.panel, 'textCtrlName') self.creador = xrc.XRCCTRL(self.panel, 'textCtrlCreator') self.genero = xrc.XRCCTRL(self.panel, 'textCtrlGender') self.no_temporadas = xrc.XRCCTRL(self.panel, 'textCtrlTemporates') self.estado = xrc.XRCCTRL(self.panel, 'textCtrlSate') self.imagen_url = xrc.XRCCTRL(self.panel, 'fileLocationSerie') self.button_save = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancel = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.create_serie, self.button_save) self.frame.Show() if frame_father is not None: self.frame_father = frame_father if self.id_serie is not None: self.load_data_serie()
class VistaSerie(wx.Frame): def __init__(self, id_serie, *args, **kw): super(VistaSerie, self).__init__(*args, **kw) self.res = xrc.XmlResource('../view/vistas_serie.xrc') self.frame = self.res.LoadFrame(None, 'VistaSerie') self.id_serie = id_serie self.series = Series() self.panel = xrc.XRCCTRL(self.frame, 'panelDif') self.text_name_serie = xrc.XRCCTRL(self.panel, 'textCtrlName') self.text_creator = xrc.XRCCTRL(self.panel, 'textCtrlCreator') self.text_gender_serie = xrc.XRCCTRL(self.panel, 'textCtrlGender') self.text_temporates_serie = xrc.XRCCTRL(self.panel, 'textCtrlTemporates') self.text_estate_serie = xrc.XRCCTRL(self.panel, 'textCtrlState') self.text_address_serie = xrc.XRCCTRL(self.panel, 'filePickerSerie') #Botones de acciones self.buttton_rent = xrc.XRCCTRL(self.panel, 'Rent') self.button_eliminte = xrc.XRCCTRL(self.panel, 'Eliminate') self.frame.Bind(wx.EVT_BUTTON, self.eliminate_serie, self.button_eliminte) self.button_modific = xrc.XRCCTRL(self.panel, 'modific') self.frame.Bind(wx.EVT_BUTTON, self.update_serie, self.button_modific) self.get_datos_serie() self.frame.Show() def eliminate_serie(self, evt): msg = "Is you sure to delete the Serie?" result = wx.MessageBox(msg, "Delete Serie", wx.YES_NO | wx.ICON_EXCLAMATION) if result == wx.YES: self.series.delete_serie(id_serie=self.id_serie) wx.MessageBox("The serie has been eliminated successfully!") self.frame.Close() def get_datos_serie(self): self.result = self.series.get_serie(id_serie=self.id_serie) self.text_name_serie.SetLabel(self.result.titulo_serie) self.text_creator.SetLabel(self.result.creador) self.text_gender_serie.SetLabel(self.result.genero) self.text_temporates_serie.SetLabel(str(self.result.no_temporadas)) self.text_estate_serie.SetLabel(self.result.estado) self.text_address_serie.SetPath(self.result.imagen_url) def update_serie(self, evt): titulo_serie = self.text_name_serie.GetValue() creador = self.text_creator.GetValue() genero = self.text_gender_serie.GetValue() no_temporadas = self.text_temporates_serie.GetValue() estado = self.text_estate_serie.GetValue() imagen_url = self.text_address_serie.GetPath() if titulo_serie and creador and genero and no_temporadas and estado and imagen_url: if self.id_serie is not None: data = { 'titulo_serie': titulo_serie, 'creador': creador, 'genero': genero, 'no_temporadas': no_temporadas, 'estado': estado, 'imagen_url': imagen_url } self.series.edit_series(self.id_serie, data) wx.MessageBox('The serie has been update successfully', 'Information', wx.OK | wx.ICON_INFORMATION) else: wx.MessageBox('Fields not entered', 'Error', wx.OK | wx.ICON_ERROR)
class VistaUserSerie(wx.Frame): def __init__(self, id_serie, id_user, *args, **kw): super(VistaUserSerie, self).__init__(*args, **kw) self.res = xrc.XmlResource('../view/vistas_serie_user.xrc') self.frame = self.res.LoadFrame(None, 'VistaUserSerie') self.panel = xrc.XRCCTRL(self.frame, 'panelOptions') self.id_serie = id_serie self.id_user = id_user self.rents = Rentas() self.series = Series() self.conect = Conection() self.text_name_serie = xrc.XRCCTRL(self.panel, 'staticTextName') self.text_creator = xrc.XRCCTRL(self.panel, 'staticTextCreator') self.text_gender_serie = xrc.XRCCTRL(self.panel, 'staticTextGenero') self.text_temporates_serie = xrc.XRCCTRL(self.panel, 'staticTextTemporates') self.text_estate_serie = xrc.XRCCTRL(self.panel, 'staticTextEstado') self.button_rent = xrc.XRCCTRL(self.panel, 'rent') self.frame.Bind(wx.EVT_BUTTON, self.rent_selected, self.button_rent) self.button_exit = xrc.XRCCTRL(self.panel, 'cancel') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_exit) self.get_datos_serie() self.frame.Show() def close_frame(self, evt): self.frame.Close() # Corregir los errores a la hora de eliminar las series rentadas. def rent_selected(self, evt): result = wx.MessageBox('Do you really want to rent this serie?', 'Information', wx.YES_NO | wx.ICON_EXCLAMATION) self.result = self.series.get_serie(id_serie=self.id_serie) if result == wx.YES: session = self.conect.connect_database() new_state = "Prestado" if self.result.estado == "Entregado": self.result.estado = new_state rent = Rentas(id_usuario=self.id_user, id_renta=self.id_serie, estado_renta=self.result.estado) session.add(rent) session.commit() session.close() wx.MessageBox('The rent has been rented correctly', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame.Close() if self.id_serie is not None: data = {'estado': self.result.estado} self.series.edit_state(self.id_serie, data) else: return None elif self.result.estado == "Prestado": rent = session.query(Rentas).filter_by(id_usuario=self.id_user).one_or_none() if rent is not None: self.rents.id_usuario = rent.id_usuario else: self.rents.id_usuario = rent if self.id_user == self.rents.id_usuario: result = wx.MessageBox('You have already rented this series. Do you want to return it now?', 'Information', wx.YES_NO | wx.ICON_EXCLAMATION) if result == wx.YES: session = self.conect.connect_database() rent_deliver = session.query(Rentas).filter_by(id_renta=self.id_serie).one() session.delete(rent_deliver) self.result.estado = 'Entregado' data = {'estado': self.result.estado} self.series.edit_state(self.id_serie, data) wx.MessageBox('The rent has been delivered correctly', 'Information', wx.OK | wx.ICON_INFORMATION) self.frame.Close() session.close() else: wx.MessageBox('You have not been the person who has rented this serie, therefore you cannot return or lend it until it is returned.', 'Information', wx.OK | wx.ICON_INFORMATION) session.close() def get_datos_serie(self): self.result = self.series.get_serie(id_serie=self.id_serie) self.text_name_serie.SetLabel(self.result.titulo_serie) self.text_creator.SetLabel(self.result.creador) self.text_gender_serie.SetLabel(self.result.genero) self.text_temporates_serie.SetLabel(str(self.result.no_temporadas)) self.text_estate_serie.SetLabel(self.result.estado)
class RegistroSerie(wx.Frame): def __init__(self, frame_father=None, id_serie=None): super(RegistroSerie, self).__init__() self.res = xrc.XmlResource('../view/series.xrc') self.series = Series() self.conection = Conection() self.id_serie = id_serie self.frame = self.res.LoadFrame(None, 'RegistroSerie') self.panel = xrc.XRCCTRL(self.frame, 'm_panel6') self.titulo_serie = xrc.XRCCTRL(self.panel, 'textCtrlName') self.creador = xrc.XRCCTRL(self.panel, 'textCtrlCreator') self.genero = xrc.XRCCTRL(self.panel, 'textCtrlGender') self.no_temporadas = xrc.XRCCTRL(self.panel, 'textCtrlTemporates') self.estado = xrc.XRCCTRL(self.panel, 'textCtrlSate') self.imagen_url = xrc.XRCCTRL(self.panel, 'fileLocationSerie') self.button_save = xrc.XRCCTRL(self.panel, 'wxID_OK') self.button_cancel = xrc.XRCCTRL(self.panel, 'wxID_CANCEL') self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.close_frame, self.button_cancel) self.frame.Bind(wx.EVT_BUTTON, self.create_serie, self.button_save) self.frame.Show() if frame_father is not None: self.frame_father = frame_father if self.id_serie is not None: self.load_data_serie() def close_frame(self, evt): self.frame.Close() def create_serie(self, evt): titulo_serie = self.titulo_serie.GetValue() creador = self.creador.GetValue() genero = self.genero.GetValue() no_temporadas = self.no_temporadas.GetValue() estado = self.estado.GetValue() imagen_url = self.imagen_url.GetPath() if titulo_serie and creador and genero and no_temporadas and estado and imagen_url: if self.id_serie is not None: data = { 'titulo_serie': titulo_serie, 'creador': creador, 'genero': genero, 'no_temporadas': no_temporadas, 'estado': estado, 'imagen_url': imagen_url } self.series.edit_series(self.id_serie, data) self.load_data_serie() else: self.series.create_serie(titulo_serie, creador, genero, no_temporadas, estado, imagen_url) wx.MessageBox('The serie has been created successfully', 'Information', wx.OK | wx.ICON_INFORMATION) self.clear_fields() self.frame_father.grid_sizer_series() else: wx.MessageBox('Fields not entered', 'Error', wx.OK | wx.ICON_ERROR) self.frame_father.grid_sizer_series() def clear_fields(self): self.titulo_serie.Clear() self.creador.Clear() self.genero.Clear() self.no_temporadas.Clear() self.estado.Clear() #self.imagen_url.Clear() def load_data_serie(self): serie = self.series.get_serie(self.id_serie) self.titulo_serie.SetValue(serie.titulo_serie) self.creador.SetValue(serie.creador) self.genero.SetValue(serie.genero) self.no_temporadas.SetValue(serie.no_temporadas) self.estado.SetValue(serie.estado) self.imagen_url.SetValue(serie.imagen_url)
def __init__(self): super(InicioFrame, self).__init__() self.res = xrc.XmlResource('../view/inicio.xrc') self.user_controller = UserController() self.conect = Conection() self.series = Series() self.games = VideoGame() self.grid_sizer = None self.add_user_frame = None self.update_users = None self.user_selected = None self.add_series = None self.add_games = None self.list_user = [] self.list_serie = [] self.frame = self.res.LoadFrame(None, 'InicioFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.listbook_menu = xrc.XRCCTRL(self.panel, 'listbook') self.panel_users = xrc.XRCCTRL(self.listbook_menu, 'panel2') self.listctrl_users = xrc.XRCCTRL(self.panel_users, 'listControl') self.button_add_user = xrc.XRCCTRL(self.panel_users, 'addUser') self.load_columns_listcrtl_user() self.load_data_listctrl_user() #Users self.frame.Bind(wx.EVT_BUTTON, self.create_user, self.button_add_user) self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_users) self.text_search = xrc.XRCCTRL(self.panel_users, 'textCtrlSearch') self.button_search = xrc.XRCCTRL(self.panel_users, 'search') self.frame.Bind(wx.EVT_BUTTON, self.search_user, self.button_search) # Exit Buttons self.button_exit = xrc.XRCCTRL(self.panel_users, 'logOut') self.frame.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit) #Series self.panel_serie = xrc.XRCCTRL(self.listbook_menu, 'panelSeries') self.grid_serie = xrc.XRCCTRL(self.panel_serie, 'scrolledWindowserie') self.grid_sizer_series() self.text_search_serie = xrc.XRCCTRL(self.panel_serie, 'textCtrlSerie') self.button_search_serie = xrc.XRCCTRL(self.panel_serie, 'searchSerie') self.frame.Bind(wx.EVT_BUTTON, self.search_serie, self.button_search_serie) self.button_exit_series = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_series) # Button Add series self.button_add_serie = xrc.XRCCTRL(self.panel_serie, 'addSerie') self.frame.Bind(wx.EVT_BUTTON, self.open_add_serie, self.button_add_serie) #Games self.panel_game = xrc.XRCCTRL(self.listbook_menu, 'panelGames') self.grid_game = xrc.XRCCTRL(self.panel_game, 'scrolledWindowGame') self.grid_sizer_games() self.text_search_game = xrc.XRCCTRL(self.panel_game, 'textCtrlGame') self.button_search_game = xrc.XRCCTRL(self.panel_game, 'searchGame') self.frame.Bind(wx.EVT_BUTTON, self.search_game, self.button_search_game) self.button_exit_games = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_games) #Button Add Games self.button_add_game = xrc.XRCCTRL(self.panel_game, 'addGame') self.frame.Bind(wx.EVT_BUTTON, self.open_add_game, self.button_add_game) self.frame.Show()
class InicioFrame(wx.Frame): def __init__(self): super(InicioFrame, self).__init__() self.res = xrc.XmlResource('../view/inicio.xrc') self.user_controller = UserController() self.conect = Conection() self.series = Series() self.games = VideoGame() self.grid_sizer = None self.add_user_frame = None self.update_users = None self.user_selected = None self.add_series = None self.add_games = None self.list_user = [] self.list_serie = [] self.frame = self.res.LoadFrame(None, 'InicioFrame') self.panel = xrc.XRCCTRL(self.frame, 'InicioPanel') self.listbook_menu = xrc.XRCCTRL(self.panel, 'listbook') self.panel_users = xrc.XRCCTRL(self.listbook_menu, 'panel2') self.listctrl_users = xrc.XRCCTRL(self.panel_users, 'listControl') self.button_add_user = xrc.XRCCTRL(self.panel_users, 'addUser') self.load_columns_listcrtl_user() self.load_data_listctrl_user() #Users self.frame.Bind(wx.EVT_BUTTON, self.create_user, self.button_add_user) self.frame.Bind(wx.EVT_LIST_ITEM_SELECTED, self.list_user_selected, self.listctrl_users) self.text_search = xrc.XRCCTRL(self.panel_users, 'textCtrlSearch') self.button_search = xrc.XRCCTRL(self.panel_users, 'search') self.frame.Bind(wx.EVT_BUTTON, self.search_user, self.button_search) # Exit Buttons self.button_exit = xrc.XRCCTRL(self.panel_users, 'logOut') self.frame.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit) #Series self.panel_serie = xrc.XRCCTRL(self.listbook_menu, 'panelSeries') self.grid_serie = xrc.XRCCTRL(self.panel_serie, 'scrolledWindowserie') self.grid_sizer_series() self.text_search_serie = xrc.XRCCTRL(self.panel_serie, 'textCtrlSerie') self.button_search_serie = xrc.XRCCTRL(self.panel_serie, 'searchSerie') self.frame.Bind(wx.EVT_BUTTON, self.search_serie, self.button_search_serie) self.button_exit_series = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_series) # Button Add series self.button_add_serie = xrc.XRCCTRL(self.panel_serie, 'addSerie') self.frame.Bind(wx.EVT_BUTTON, self.open_add_serie, self.button_add_serie) #Games self.panel_game = xrc.XRCCTRL(self.listbook_menu, 'panelGames') self.grid_game = xrc.XRCCTRL(self.panel_game, 'scrolledWindowGame') self.grid_sizer_games() self.text_search_game = xrc.XRCCTRL(self.panel_game, 'textCtrlGame') self.button_search_game = xrc.XRCCTRL(self.panel_game, 'searchGame') self.frame.Bind(wx.EVT_BUTTON, self.search_game, self.button_search_game) self.button_exit_games = xrc.XRCCTRL(self.panel_users, 'logOut') self.Bind(wx.EVT_BUTTON, self.close_frames, self.button_exit_games) #Button Add Games self.button_add_game = xrc.XRCCTRL(self.panel_game, 'addGame') self.frame.Bind(wx.EVT_BUTTON, self.open_add_game, self.button_add_game) self.frame.Show() # Se puede mejorar la funcion de buscar series de manera que retorne el boton de la serie mas no un mensaje solamente. def search_serie(self, evt): text_serie = str(self.text_search_serie.GetValue()) session = self.conect.connect_database() try: serie = session.query(Serie).filter_by( titulo_serie=text_serie).all() if text_serie != "": if serie: wx.MessageBox('The serie exist in this aplication.') else: wx.MessageBox( 'The serie does not exist in this aplication.') else: wx.MessageBox('Fields no entered.') session.close() except MultipleResultsFound: session.close() return False # Se puede mejorar la funcion de buscar juegos de manera que retorne el boton del juego mas no un mensaje solamente. def search_game(self, evt): text_game = str(self.text_search_game.GetValue()) session = self.conect.connect_database() try: game = session.query(Videojuego).filter_by( titulo_videojuego=text_game).all() if text_game != "": if game: wx.MessageBox('The videogame exist in this aplication.') else: wx.MessageBox( 'The videogame does not exist in this aplication.') else: wx.MessageBox('Fields no entered') session.close() except MultipleResultsFound: session.close() return False def grid_sizer_games(self): cols = 2 images_games = self.games.get_all_images_games() cantidad = len(images_games) filas = cantidad // cols if cantidad % cols != 0: filas += 1 grid_sizer = wx.GridSizer(filas, cols, 5, 5) indicador = 0 for i in range(grid_sizer.GetRows()): for j in range(grid_sizer.GetCols()): if indicador < len(images_games): button = wx.BitmapButton( self.grid_game, name=str(images_games[indicador].id), bitmap=wx.Bitmap(images_games[indicador].imagen_url)) grid_sizer.Add(button, 0, wx.EXPAND) self.grid_game.Bind(wx.EVT_BUTTON, self.click_images_game, button) self.grid_game.SetSizer(grid_sizer) indicador += 1 def grid_sizer_series(self): cols = 2 images_series = self.series.get_all_images() cantidad = len(images_series) filas = cantidad // cols if cantidad % cols != 0: filas += 1 grid_sizer = wx.GridSizer(filas, cols, 5, 5) indicador = 0 for i in range(grid_sizer.GetRows()): for j in range(grid_sizer.GetCols()): if indicador < len(images_series): button = wx.BitmapButton( self.grid_serie, name=str(images_series[indicador].id), bitmap=wx.Bitmap(images_series[indicador].imagen_url)) grid_sizer.Add(button, 0, wx.EXPAND) self.grid_serie.Bind(wx.EVT_BUTTON, self.click_images_serie, button) self.grid_serie.SetSizer(grid_sizer) indicador += 1 def click_images_serie(self, evt): id_serie = evt.GetEventObject().GetName() VistaSerie(id_serie=id_serie) def click_images_game(self, evt): id_game = evt.GetEventObject().GetName() vistaGame(id_game=id_game) def open_add_serie(self, evt): self.add_series = RegistroSerie(self) def open_add_game(self, evt): self.add_games = RegistroGame(self) def search_user(self, evt): text = str(self.text_search.GetValue()) session = self.conect.connect_database() try: user = session.query(User).filter_by(first_name=text).all() if text != "": if user: self.load_data_listctrl_name(text) return True else: wx.MessageBox('User does not exist in the database') return self.load_data_listctrl_user() else: wx.MessageBox('Fields no entered') self.load_data_listctrl_user() session.close() except MultipleResultsFound: session.close() return False def close_frames(self, evt): self.frame.Destroy() def load_columns_listcrtl_user(self): self.listctrl_users.InsertColumn(0, "Id", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(1, "First Name", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(2, "Last Name", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(3, "UserName", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) self.listctrl_users.InsertColumn(4, "Password", format=wx.LIST_FORMAT_CENTER, width=wx.LIST_AUTOSIZE) def load_data_listctrl_user(self): self.list_user = self.user_controller.get_all_users() self.listctrl_users.DeleteAllItems() for user in self.list_user: if len(self.list_user) > 1: self.listctrl_users.Append([ user.id, user.first_name, user.last_name, user.username, user.password ]) def load_data_listctrl_name(self, name): user = self.user_controller.get_first_name(name) self.listctrl_users.DeleteAllItems() for item in user: self.listctrl_users.Append([ item.id, item.first_name, item.last_name, item.username, item.password ]) def create_user(self, evt): self.add_user_frame = RegistroFrame(self) def list_user_selected(self, evt): current_item = evt.GetIndex() self.user_selected = self.list_user[current_item] menu = wx.Menu() id_item_menu_update = wx.NewId() id_item_menu_delete = wx.NewId() menu.Append(id_item_menu_update, UPDATE_USER) menu.Append(id_item_menu_delete, DELETE_USER) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected, id=id_item_menu_update) self.frame.Bind(wx.EVT_MENU, self.popup_item_selected, id=id_item_menu_delete) self.frame.PopupMenu(menu) menu.Destroy() def popup_item_selected(self, evt): id_item = evt.GetId() menu = evt.GetEventObject() menu_item = menu.FindItemById(id_item) if menu_item.GetLabel() == UPDATE_USER: self.add_user_frame = ModificFrame(self, self.user_selected.id) elif menu_item.GetLabel() == DELETE_USER: msg = "Is you sure to delete the User %s %s?" % ( self.user_selected.first_name, self.user_selected.last_name) result = wx.MessageBox(msg, "Delete User", wx.YES_NO | wx.ICON_EXCLAMATION) if result == wx.YES: self.user_controller.delete_user(self.user_selected.id) self.load_data_listctrl_user()