Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/03/2013, 18:50
Avatar de cufu8583
cufu8583
 
Fecha de Ingreso: enero-2013
Ubicación: North Miami Beach
Mensajes: 24
Antigüedad: 11 años, 3 meses
Puntos: 1
Respuesta: Duda sobre wxPython

Código Python:
Ver original
  1. # -*- coding: utf-8 -*-
  2.  
  3. import wx
  4. import math
  5.  
  6. class Calculadora(wx.Frame):
  7.  
  8.     #posicion de las etiquetas
  9.     LABEL_POSX  = 10
  10.     LABEL_POSX2 = 155
  11.  
  12.     #posicion del textctrl
  13.     TEXTCTRL_POSX = 80
  14.     TEXTCTRL_POSX2 = 220
  15.  
  16.     def __init__(self,parent,id,title):
  17.         wx.Frame.__init__(self,parent,id,title,size=(300,150))
  18.  
  19.         #establecer el color de fondo
  20.         self.SetBackgroundColour(wx.Colour(255,255,255))
  21.  
  22.         #crear los cuadros donde se introducen los Numeros.
  23.         self.a = wx.TextCtrl(self, pos=(Calculadora.TEXTCTRL_POSX,10), size=(60,20))
  24.         self.b = wx.TextCtrl(self, pos=(Calculadora.TEXTCTRL_POSX,35), size=(60,20))
  25.         self.d = wx.TextCtrl(self, pos=(Calculadora.TEXTCTRL_POSX2,10), size=(60,20))
  26.  
  27.         #crear las etiquetas para los textcrtl
  28.         wx.StaticText(self, label='Primer Numero', pos=(Calculadora.LABEL_POSX,10))
  29.         wx.StaticText(self, label='Segundo Numero', pos=(Calculadora.LABEL_POSX,35))
  30.         wx.StaticText(self, label='Respuesta:', pos=(Calculadora.LABEL_POSX2,10))
  31.  
  32.         #crear botón de calcular
  33.         self.btnSumar = wx.Button(self, label='Sumar', pos=(15,85), size=(60, 30))
  34.         self.Bind(wx.EVT_BUTTON, self.ecuacion, self.btnSumar)
  35.         self.btnSalir = wx.Button(self, label='Salir', pos=(80,85), size=(60, 30))
  36.         self.Bind(wx.EVT_BUTTON, self.sal, self.btnSalir)
  37.         self.btnAyuda = wx.Button(self, label='Ayuda', pos=(145,85), size=(60, 30))
  38.         self.Bind(wx.EVT_BUTTON, self.ayud, self.btnAyuda)
  39.         self.btnInfo = wx.Button(self, label='Info', pos=(210,85), size=(60,30))
  40.         self.Bind(wx.EVT_BUTTON, self.inf, self.btnInfo)
  41.         self.a.SetFocus()
  42.         self.Show(True)
  43.  
  44.  
  45.     def ecuacion(self, event):
  46.         try:
  47.             a = int(self.a.GetValue())
  48.             b = int(self.b.GetValue())
  49.             solu = str(a + b)
  50.             self.d.SetValue(solu)
  51.         except:
  52.             self.d.SetValue('Sin solucion')
  53.         wx.MessageBox('Gracias por usar el programa')
  54.  
  55.     def sal(self, event):
  56.         self.Destroy()
  57.  
  58.     def ayud(self, event):
  59.         wx.MessageBox('Introduzca a,b,c respectivamente y presione calcular para obtener las dos soluciones')
  60.  
  61.     def inf(self, event):
  62.          wx.MessageBox('Autor: FGUM')
  63.          wx.MessageBox('Fecha de creacion: 03/03/13')
  64.  
  65. #end class Herr
  66.  
  67. if __name__ == '__main__':
  68.     app = wx.App()
  69.     frame = Calculadora(None,-1,'Sumas')
  70.     frame.Show(True)
  71.     app.MainLoop()

Alli esta el codigo de lo que estaba haciendo pero salen las letras montadas y no puedo hacer que se muevan los cuadros de textos.