def __init__(self, parent, lista_clases, idioma=None): '''Constructor de clase''' wx.Frame.__init__(self, parent, title=t(u"Seleccione clase a eliminar", idioma), size=wx.Size(500, 142), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) # Idioma. self.l = idioma self.padre = parent bSizer1 = wx.BoxSizer(wx.VERTICAL) m_choice1Choices = lista_clases self.m_choice1 = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0) self.m_choice1.SetSelection(0) bSizer1.Add(self.m_choice1, 0, wx.ALL | wx.EXPAND, 10) bSizer2 = wx.BoxSizer(wx.HORIZONTAL) self.m_button_aceptar = wx.Button(self, wx.ID_ANY, t(u"Aceptar", self.l), wx.DefaultPosition, wx.DefaultSize, 0) bSizer2.Add(self.m_button_aceptar, 0, wx.ALL | wx.EXPAND, 10) self.m_button_cancelar = wx.Button(self, wx.ID_ANY, t(u"Cancelar", self.l), wx.DefaultPosition, wx.DefaultSize, 0) self.m_button_cancelar.SetDefault() bSizer2.Add(self.m_button_cancelar, 0, wx.ALL | wx.EXPAND, 10) bSizer1.Add(bSizer2, 0, wx.ALL | wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() self.Centre(wx.BOTH) # Binding. self.m_button_aceptar.Bind(wx.EVT_BUTTON, self.OnAceptar) self.m_button_cancelar.Bind(wx.EVT_BUTTON, self.OnCancelar)
def __aviso(self, msj0): '''Mensaje de aviso''' msj1 = t(u'(Se perderán los datos que no haya guardado)', self.l) msj = msj0 + '\n' + msj1 i = wx.MessageBox(msj, t(u"Atención", self.l), wx.YES_NO) if i != wx.YES: return False return True
def __init__(self, parent, idioma = None): '''Constructor de clase''' # Definimos parámetros. wx.Dialog.__init__(self, parent, title = t(u'Registros', idioma),style=wx.DEFAULT_DIALOG_STYLE) # Sizer principal. sizer = wx.BoxSizer(wx.VERTICAL) # Primer elemento. box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, t("Campo", idioma)) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.text_clave = wx.TextCtrl(self, -1, "", size=(80,-1)) self.text_clave.SetFocus() box.Add(self.text_clave, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) # Segundo elemento. box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, t("Valor por defecto", idioma)) box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.text_valor = wx.TextCtrl(self, -1, "", size=(80,-1)) box.Add(self.text_valor, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) # Línea de separación y botones. line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(self, wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
def OnCrearClase(self, event): '''Event Handler para crear clase''' # Nombre de la clase. i = self.__pedir_datos() if i is None or len(i.strip()) == 0: return # Si existe el nombre de la clase, nos vamos. if self.modelo.existe_clase(i): msj = t(u'¡La clase ya existe!', self.l) wx.MessageBox(msj, t(u"Atención", self.l), wx.OK) return # Creamos caja. shape = DividedShape(140, 150, self, i, [], [], []) # Coordenadas. valor_x = 100.0 valor_y = 100.0 # Posición de la caja. shape.SetX(valor_x) shape.SetY(valor_y) # Añadimos la caja al canvas. self.panel.canvas.AddShape(shape) # Lo mostramos. self.panel.diagram.ShowAll(1) # Manejadores de eventos. # [20-06-2011] Parametrización del manejador de eventos. if self.__params is None: evthandler = self.__manejador() else: evthandler = self.__manejador(self.__params[0], self.__params[1]) evthandler.SetShape(shape) evthandler.SetPreviousHandler(shape.GetEventHandler()) shape.SetEventHandler(evthandler) # Refrescamos el frame, para que salga todo. self.Refresh() # Y creamos en el modelo el dividedshape. self.modelo.crear_clase(i, shape)
def OnModificar(self, event): '''Modificar módulo''' if self.m_notebook_import.GetSelection() == 0: aux = self.m_listCtrl_import a = dialogo(self, idioma=self.l) if self.m_notebook_import.GetSelection() == 1: aux = self.m_listCtrl_from a = dialogo(self, 1, idioma=self.l) if aux.GetSelectedItemCount() > 1: wx.MessageBox( t(u"Seleccione solo un elemento a modificar", self.l), t(u"Atención", self.l), wx.OK) a.Destroy() return # Obtenemos el elemento seleccionado. Si no hay nada seleccionado, nos vamos. item_sel = aux.GetFirstSelected() if item_sel == -1: a.Destroy() return # Mostramos el diálogo. a.Show() if a.ShowModal() == wx.ID_OK: self.__datos_imports(a, 1, item_sel) # Limpiamos memoria y nos vamos. a.Destroy()
def OnCrearModulo(self, event): '''Manejador de eventos para creación de un módulo''' if self.m_treeCtrl_packages.GetCount() != 0: # Si estamos en un directorio, creamos otro anidado. aux = self.pedir_datos('modulo') if aux is None or len(aux.strip()) == 0: return # ID del elemento seleccionado. id_sel = self.m_treeCtrl_packages.GetSelection() # [12-08-2011] Si no hay nada seleccionado, no se puede insertar nada. if id_sel.IsOk() == False: wx.MessageBox( t(u"Tiene que seleccionar un elemento del árbol", self.l), t(u"Atención", self.l), wx.OK) return -1 # Si no estamos encima de un directorio nos vamos al padre. if self.m_treeCtrl_packages.GetItemImage( id_sel, wx.TreeItemIcon_Normal) == self.fileidx: # ID padre del elemento seleccionado. id_padre = self.m_treeCtrl_packages.GetItemParent(id_sel) id_sel = id_padre # Comprobamos que no haya módulos repetidos en el mismo nivel. if self.__existe_item(aux, 'modulo', id_sel): return # Creamos el hijo. hijo = self.m_treeCtrl_packages.AppendItem(id_sel, aux) # Configuramos iconos. self.m_treeCtrl_packages.SetItemImage(hijo, self.fileidx, wx.TreeItemIcon_Normal) else: wx.MessageBox(t(u"Se debe de crear primero un directorio", self.l), t(u"Atención", self.l), wx.OK)
def __mover_item(self): '''Movimiento de elementos''' if self.m_notebook_cte.GetSelection() == 0: aux = self.m_lista_cte if self.m_notebook_cte.GetSelection() == 1: # Obtenemos número de hoja actual. hoja_actual = self.m_aui_nb_dicc_cte.GetSelection() # Obtenemos panel de la hoja actual. panel = self.m_aui_nb_dicc_cte.GetPage(hoja_actual) # Y la lista. aux = panel.m_lista_cte if aux.GetSelectedItemCount() > 1: wx.MessageBox( t(u"Seleccione solo un elemento a desplazar", self.l), t(u"Atención", self.l), wx.OK) return None, None # Obtenemos el elemento seleccionado. item_sel = aux.GetFirstSelected() if item_sel == -1: return None, None else: # Guardamos el valor. cadena = aux.GetItemText(item_sel) # Eliminamos el valor. aux.DeleteItem(item_sel) # Devolvemos el contenido del elemento. return cadena, aux
def OnModificarCte(self, event): '''Modificar constante''' if self.m_notebook_cte.GetSelection() == 0: aux = self.m_lista_cte # Creamos el diálogo. a = dialogo(self, idioma=self.l) if self.m_notebook_cte.GetSelection() == 1: # Obtenemos número de hoja actual. hoja_actual = self.m_aui_nb_dicc_cte.GetSelection() # Obtenemos panel de la hoja actual. panel = self.m_aui_nb_dicc_cte.GetPage(hoja_actual) # Y la lista. aux = panel.m_lista_cte # Creamos el diálogo. a = dialogo(self, 1, idioma=self.l) if aux.GetSelectedItemCount() > 1: wx.MessageBox( t(u"Seleccione solo un elemento a modificar", self.l), t(u"Atención", self.l), wx.OK) a.Destroy() return # Obtenemos el elemento seleccionado. Si no hay nada seleccionado, nos vamos. item_sel = aux.GetFirstSelected() if item_sel == -1: a.Destroy() return # Mostramos el diálogo. a.Show() if a.ShowModal() == wx.ID_OK: self.__datos_ctes(a, 1, item_sel) # Limpiamos memoria y nos vamos. a.Destroy()
def OnRenombrarFuncion(self, event): '''Manejador de eventos para cambiar el nombre de la función''' nom_func_original = self.panel_principal.m_choice_funciones.GetStringSelection() if len(nom_func_original) == 0: wx.MessageBox(t(u"Se debe de elegir una función a renombrar", self.l), t(u"Atención", self.l), wx.OK) return # Pedimos nombre de función. i = self.__pedir_datos(1) if i is None: return nom_func = unicode(i).strip() if len(nom_func) == 0: return # ¿Función ya existe? for funcion in self.modelo: if funcion[0] == nom_func: wx.MessageBox(t(u"¡La función ya existe!", self.l), t(u"Atención", self.l), wx.OK) return # Cambiamos el nombre en el modelo. indice = -1 for funcion in self.modelo: indice += 1 if funcion[0] == nom_func_original: self.modelo[indice][0] = nom_func break # Cambiamos el nombre en el choice. j = self.panel_principal.m_choice_funciones.GetCurrentSelection() self.panel_principal.m_choice_funciones.SetString(j, nom_func) self.panel_principal.m_choice_funciones.SetSelection(j)
def __init__(self, parent, dato_packages=None, idioma=None): '''Constructor de clase''' # Llamamos al constructor del padre. panel_packages.__init__(self, parent) # Idioma. self.l = idioma # Cambiamos idioma de widgets generados con wxFB. self.m_button_add_file.SetToolTipString(t(u'Añadir módulo', self.l)) self.m_button_package.SetToolTipString(t(u'Añadir directorio', self.l)) self.m_button_eliminar.SetToolTipString( t(u'Eliminar módulo / directorio seleccionado', self.l)) # Configuramos imágenes (iconos) de la jerarquía del árbol. isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) self.fldridx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) self.fldropenidx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) self.fileidx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)) self.m_treeCtrl_packages.SetImageList(il) self.il = il # Datos de packages a cargar. if dato_packages is not None: self.__cargar_datos(dato_packages)
def OnPageChangedListBookDesigner(self, event): '''Event Handler de cambio de paneles del diseñador''' # Salvamos lo que está en edición, ¡siempre!. self.salvar_ultimos_cambios() self.guardar_datos_modulo() # Obtenemos datos de la hoja en la que estamos y el nombre del módulo actual. nhoja = self.m_listbook_designer.GetSelection() modulo = self.m_choice_modulos.GetStringSelection() # Panel de configuración de código y hay módulo en edición. if nhoja == 2 and len(modulo.strip()) != 0: # Generamos de forma automática el código Python asociado al módulo. self.panel_editor.generar_codigo_python() # Panel de módulos y no hay módulo en edición. if nhoja == 1 and len(modulo.strip()) == 0: msj = u"Para comenzar haga click en 'Crear' para crear un módulo" + \ u" y a continuación selecciónelo del combo" msj = t(msj, self.l) x, y, x1, y1 = self.GetScreenRect() self.ayuda_toasterbox(x, y1, msj, t(u"Ayuda vipera", self.l)) # Panel de configuración de proyecto. try: if nhoja == 0: # Cargamos nombres de módulos en área de documentación. self.panel_conf_vipera.cargar_nombres_modulos_en_doc() # ...y no hay nombre de proyecto. if len(self.panel_conf_vipera.m_textCtrl_nproy.GetValue().strip()) == 0: msj = u"Para salvar el proyecto es necesario incluir como mínimo" + \ u" un nombre de proyecto en la 'Pestaña Definición' campo 'Nombre de proyecto'" msj = t(msj, self.l) x, y, x1, y1 = self.GetScreenRect() self.ayuda_toasterbox(x, y1, msj, t(u"Ayuda vipera", self.l)) except: pass event.Skip()
def __init__(self, parent, f_cod, f_sal, f_err, interprete, lanzadera, idioma = None): '''Constructor de clase''' # Constructor padre. panel_codigo.__init__(self, parent) # Idioma. self.l = idioma # Cambiamos el idioma a los widgets generados con wxFB. self.m_bpButton_codigo.SetToolTipString(t(u'Ejecutar código Python', self.l)) self.m_bpButton_stop_eje.SetToolTipString(t(u'Parar script en ejecución', self.l)) # Editor STC. self.__editor = EditorSTC(self.m_panel_codigo) # Sizer. sizer = wx.BoxSizer(wx.VERTICAL) # Incluimos editor en el sizer. sizer.Add(self.__editor, 1, wx.ALL|wx.EXPAND, 10) # Añadimos el sizer al panel. self.m_panel_codigo.SetSizer(sizer) # El editor STC será de solo lecura. self.__editor.SetReadOnly(True) # Demás atributos. self.__f_cod = f_cod self.__f_sal = f_sal self.__f_err = f_err self.__lanzadera = lanzadera self.__interprete = interprete
def __init__(self, parent, idioma = None): '''Constructor de clase''' panel_estruc.__init__(self, parent) #Idioma. self.l = idioma # Cambiamos idioma en widgets de wxFB. self.m_crear.SetLabel(t(u'Crear', self.l)) self.m_renombrar.SetLabel(t(u'Renombrar', self.l))
def __init__(self, parent, idioma = None): '''Constructor de clase''' hoja_estruc.__init__(self, parent) # Cambiamos idioma en widgets de wxFB. self.m_staticText_emular.SetLabel(t(u'Emular con', idioma)) # Creamos columnas. self.m_listCtrl_estruc.InsertColumn(0, t(u'Campos', idioma)) self.m_listCtrl_estruc.SetColumnWidth(0, 500)
def __init__(self, parent, idioma=None): '''Constructor de clase''' panel_oper_proy.__init__(self, parent) # Cambiamos idioma. self.m_bitmap_logo.SetToolTipString( t(u'vipera, un diseñador de aplicaciones para Python', idioma)) self.m_bpButton_nuevo.SetToolTipString(t(u'Nuevo proyecto', idioma)) self.m_bpButton_abrir.SetToolTipString(t(u'Abrir proyecto', idioma)) self.m_bpButton_salvar.SetToolTipString(t(u'Salvar proyecto', idioma))
def __init__(self, parent, idioma=None): '''Constructor de clase''' panel_ing_inversa.__init__(self, parent) # Idioma. self.m_button_designer.SetToolTipString( t(u'Diseñador de clases', idioma)) self.m_button_editor.SetToolTipString(t(u'Editor Python', idioma)) self.m_choicebook.SetPageText(0, t(u'Diagrama de clases', idioma)) self.m_choicebook.SetPageText(1, t(u'Funciones', idioma))
def f_acercade_vipera(padre, idioma=None): '''Función que devuelve el "Acerca de" de la aplicación''' info = wx.AboutDialogInfo() info.Name = proy_por_defecto["NOMBRE_APLIC"] info.Version = proy_por_defecto["VERSION"] info.Copyright = u"(C) 2011 Ángel Luis García García" info.Description = wordwrap(t(descripcion, idioma), 350, wx.ClientDC(padre)) info.WebSite = ("http://code.google.com/p/vipera/") info.Developers = [u"Ángel Luis García García"] info.License = wordwrap(t(licenseText, idioma), 500, wx.ClientDC(padre)) wx.AboutBox(info)
def OnEliminar(self, event): '''Elimina el nodo actual, así como sus descendientes''' if self.m_treeCtrl_packages.GetCount() != 0: # ¿Eliminar? i = wx.MessageBox(t(u"¿Eliminar?", self.l), t(u"Atención", self.l), wx.YES_NO) if i != wx.YES: return # ID del elemento seleccionado. id_nodo = self.m_treeCtrl_packages.GetSelection() self.m_treeCtrl_packages.Delete(id_nodo) else: wx.MessageBox(t(u"No hay módulo o directorio a eliminar", self.l), t(u"Atención", self.l), wx.OK)
def __init__(self, parent, idioma=None): '''Constructor de clase''' scrolled.ScrolledPanel.__init__(self, parent, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER) # Idioma. self.l = idioma # Creamos panel de widgets. self.panel = panel_doc_modulo(self) # Cambiamos idioma de widgets de wxFB. self.panel.m_checkBox_activar.SetLabel( t(u'Crear documentación de módulo', self.l)) self.panel.m_button_borrar.SetLabel(t(u'Borrar todo', self.l)) self.panel.m_staticText_nombre.SetLabel(t(u'Nombre', self.l)) self.panel.m_staticText_proposito.SetLabel(t(u'Propósito', self.l)) self.panel.m_staticText_autor.SetLabel(t(u'Autor', self.l)) self.panel.m_staticText_creado.SetLabel(t(u'Creado', self.l)) self.panel.m_staticText_copyright.SetLabel(t(u'Copyright', self.l)) self.panel.m_staticText_licencia.SetLabel(t(u'Licencia', self.l)) # Sizer principal. sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.panel, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer(sizer) self.SetupScrolling() # Hacemos re-binding. self.panel.m_button_borrar.Bind(wx.EVT_BUTTON, self.OnBorrarTODO)
def __pedir_datos(self, opcion = 0): '''Pedir datos mediante un wx.TextEntryDialog.''' if opcion == 0: cadena = t(u'Nombre del nuevo registro: ', self.l) if opcion == 1: cadena = t(u'Modificar nombre de registro: ', self.l) dialogo = wx.TextEntryDialog(self, cadena, t('Registros', self.l)) dialogo.Show() if dialogo.ShowModal() == wx.ID_OK: ret = dialogo.GetValue() else: # Botón cancelar. Nada que devolver. ret = None # Limpiamos memoria y nos vamos. dialogo.Destroy() return ret
def __init__(self, parent, frame_principal, print_data, fich_imp, fich_html, idioma=None): '''Constructor de clase''' dialogo_impresion.__init__(self, parent) # Idioma. self.l = idioma # Cambiamos idioma de clases en wxFB. self.SetTitle(t(u'Área de impresión', self.l)) self.m_radioBtn_diagrama.SetLabel(t(u'Diagrama uml de módulo', self.l)) self.m_radioBtn_codigo.SetLabel(t(u'Código Python generado', self.l)) self.m_checkBox_codigo_html.SetLabel(t(u'Exportar a HTML', self.l)) self.m_radioBtn_diagrama_ing_inv.SetLabel(t(u'Diagrama uml', self.l)) self.m_checkBox_editor.SetLabel(t(u'Exportar a HTML', self.l)) self.m_button_conf.SetLabel(t(u'Configurar', self.l)) self.m_button_imprimir.SetLabel(t(u'Imprimir', self.l)) # Recogemos datos... self.__fich_imp = fich_imp self.__fich_html = fich_html self.print_data = print_data # Referencia al frame principal. self.__padre = frame_principal # Referencia del editor de ingeniería inversa. self.__editor_ing_inv = frame_principal.ing_inversa.panel_editor.panel.editor # Referencia al editor que muestra el código Python generado. self.__codigo = frame_principal.panel.panel_editor.get_editor() # Referencia al ogl de ingeniería inversa. self.__ogl_ing_inv = frame_principal.ing_inversa.panel_designer.panel.panel # OGL's de módulos. self.__modulos = frame_principal.panel.lista_modulos
def OnEliminarModulo(self, event): '''Manejador de eventos para eliminar un módulo''' modulo_actual = self.m_choice_modulos.GetStringSelection() if len(modulo_actual.strip()) == 0: wx.MessageBox(t(u"Seleccione el módulo a eliminar", self.l), t(u"Atención", self.l), wx.OK) return # Buscamos... indice = -1 centinela = True for modulo in self.lista_modulos: indice += 1 if modulo[0].strip() == modulo_actual: # Cambiamos en estructura. msj = t(u"¿Eliminar el módulo?", self.l) k = wx.MessageBox(msj, t(u"Atención", self.l), wx.YES_NO) if k != wx.YES: break self.lista_modulos.remove(modulo) # Limpiamos módulo. self.limpiar_widget_modulo() centinela = False break if centinela: wx.MessageBox(t(u"El módulo no se eliminó", self.l),t(u"Atención", self.l),wx.OK) else: # Cambiamos en choice. j = self.m_choice_modulos.GetCurrentSelection() self.m_choice_modulos.Delete(j) wx.MessageBox(t(u"El módulo se eliminó", self.l),t(u"Atención", self.l),wx.OK)
def OnEliminarTexto(self, event): '''Se elimina un texto del OGL''' # Detectamos el shape seleccionado. shapeList = self.panel.canvas.GetDiagram().GetShapeList() contador = 0 for s in shapeList: if s.Selected(): shape = s contador += 1 # Evaluamos el resultado de la selección. if contador > 1: msj = t(u'No se puede eliminar con multiselección', self.l) wx.MessageBox(msj, t(u"Atención", self.l), wx.OK) return if contador == 0: msj = t(u'Primero se debe seleccionar el texto a eliminar', self.l) wx.MessageBox(msj, t(u"Atención", self.l), wx.OK) return if not isinstance(shape, ogl.TextShape): msj = t(u'El elemento seleccionado no es un texto', self.l) wx.MessageBox(msj, t(u"Atención", self.l), wx.OK) return # Preguntamos si se quiere eliminar... i = wx.MessageBox(t(u"¿Eliminar texto?", self.l), t(u"Atención", self.l), wx.YES_NO) if i != wx.YES: return # Cambiamos texto en el OGL. # shape.Delete() # Cambiamos el modelo. self.mensajes_texto.eliminar_texto(shape) self.Refresh()
def __init__(self, parent, idioma=None): '''Constructor de clase''' wx.Panel.__init__(self, parent, id=-1, size=wx.Size(500, 234), style=wx.TAB_TRAVERSAL) # Idioma. self.l = idioma bSizer1 = wx.BoxSizer(wx.VERTICAL) self.m_staticText1 = wx.StaticText(self, wx.ID_ANY, t(u"ELIMINAR RELACIÓN", self.l), wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText1.Wrap(-1) bSizer1.Add(self.m_staticText1, 0, wx.ALIGN_CENTER | wx.ALL, 15) bSizer2 = wx.BoxSizer(wx.VERTICAL) fgSizer1 = wx.FlexGridSizer(1, 1, 5, 5) fgSizer1.AddGrowableCol(0) fgSizer1.AddGrowableRow(0) fgSizer1.SetFlexibleDirection(wx.BOTH) fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) m_comboBox_relacionChoices = [] self.m_comboBox_relacion = wx.ComboBox(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_comboBox_relacionChoices, wx.CB_READONLY) fgSizer1.Add(self.m_comboBox_relacion, 0, wx.ALL | wx.EXPAND, 5) bSizer2.Add(fgSizer1, 0, wx.ALL | wx.EXPAND, 5) bSizer4 = wx.BoxSizer(wx.HORIZONTAL) self.m_button_aceptar = wx.Button(self, wx.ID_ANY, t(u"ACEPTAR", self.l), wx.DefaultPosition, wx.DefaultSize, 0) bSizer4.Add(self.m_button_aceptar, 0, wx.ALL | wx.EXPAND, 5) self.m_button_cancelar = wx.Button(self, wx.ID_ANY, t(u"CANCELAR", self.l), wx.DefaultPosition, wx.DefaultSize, 0) bSizer4.Add(self.m_button_cancelar, 0, wx.ALL | wx.EXPAND, 5) bSizer2.Add(bSizer4, 0, wx.EXPAND | wx.ALL, 15) bSizer1.Add(bSizer2, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() # Binding. self.m_button_aceptar.Bind(wx.EVT_BUTTON, self.OnAceptar) self.m_button_cancelar.Bind(wx.EVT_BUTTON, self.OnCancelar)
def __pedir_datos(self, opcion=0): '''Pedir datos mediante un wx.TextEntryDialog.''' if opcion == 0: cadena = t(u'Nombre de la nueva clase: ', self.l) if opcion == 1: cadena = t(u'Texto (use \\n para nueva línea): ', self.l) dialogo = wx.TextEntryDialog(self, cadena, t(u'Clase', self.l)) dialogo.Show() if dialogo.ShowModal() == wx.ID_OK: ret = dialogo.GetValue() else: # Botón cancelar. Nada que devolver. ret = None # Limpiamos memoria y nos vamos. dialogo.Destroy() return ret
def OnCrearModulo(self, event): '''Crear un módulo''' # Pedimos nombre del módulo. i = self.__pedir_datos() if i is None: return nom_mod = unicode(i).strip() if len(nom_mod) == 0: return # ¿Existe el módulo? if self.existe_modulo(nom_mod): wx.MessageBox(t(u"El módulo ya existe", self.l), t(u"Atención", self.l), wx.OK) return # Creamos módulo. self.lista_modulos.append([nom_mod,[ {}, {}, {}, {}, {}, {}, {}]]) # Lo incluimos en el componente gráfico. self.m_choice_modulos.Append(nom_mod)
def __init__(self, parent, idioma=None): '''Constructor de clase''' panel_cte.__init__(self, parent) # Idioma. self.l = idioma # Cambiamos idioma en widgets generados por wxFB. self.m_notebook_cte.SetPageText(0, t(u'Constantes', self.l)) self.m_notebook_cte.SetPageText( 1, t(u'Diccionarios de constantes', self.l)) self.m_crear.SetLabel(t(u'Crear', self.l)) self.m_renombrar.SetLabel(t(u'Renombrar', self.l)) # Creamos columnas. self.__conf_lista_cte(self.m_lista_cte, t(u"constante = 'valor'", self.l)) # Binding. self.m_panel_const.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
def OnCargarFichero(self, event): '''Carga de fichero en el diseñador de clases''' # Abrimos diálogo para cargar fichero Python. if not self.__aviso(t(u'¿Abrir un fichero Python?', self.l)): return ruta, nombre_fichero = f_abrir_fichero(idioma=self.l) if ruta is None: return -1 self.__cargar_fichero(ruta, nombre_fichero)
def OnCrearFuncion( self, event ): '''Manejador de eventos para creación de función''' # Nombre de la función. i = self.__pedir_datos() if i is None: return nom_func = unicode(i).strip() if len(nom_func) == 0: return # ¿Función ya existe? for funcion in self.modelo: if funcion[0] == nom_func: wx.MessageBox(t(u"¡La función ya existe!", self.l), t(u"Atención", self.l), wx.OK) return # Creamos función en modelo. self.modelo.append([nom_func,'','','','',list()]) # Inluimos función en el choice. self.panel_principal.m_choice_funciones.Append(nom_func)
def __init__(self, parent, lista_clases, idioma=None): '''Constructor de clase''' dialogo_orden_clases.__init__(self, parent) # Idioma. self.l = idioma # Cambiamos en widgets generados por wxFB. self.SetTitle(t(u'Orden de instanciación de clases', self.l)) # Creamos columnas. self.m_listCtrl_orden.InsertColumn( 0, t(u'Especificar el orden de creación de clases', self.l)) self.m_listCtrl_orden.SetColumnWidth(0, 500) # Incluismo lista de clases. for i in lista_clases: self.m_listCtrl_orden.InsertStringItem(0, unicode(i).strip()) # Binding. self.m_listCtrl_orden.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)