Estos son los Widgets que venimos aprendiendo hasta el momento.
Le saque foto a cada cosa para qe qede mas lindo..
espero ke les guste..
WX.FRAME
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
self.ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.PANEL
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
self.ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.STATICTEXT
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.TEXTCTRL
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.TEXTCTRL (con multilinea)
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
observaciones = wx.StaticText(panel, -1, u'Obs: ', pos = (20,110))
cuadro_obs = wx.TextCtrl(panel, -1, '', pos = (90,105), size = (150,80), style = wx.TE_MULTILINE)
self.ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.BUTTON
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,350))
boton_cancelar = wx.Button(panel, -1, u'Cancelar', pos = (100,350))
ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.COMBOBOX
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
sexo = wx.StaticText(panel, -1, u'Sexo: ', pos = (20,80))
sexolista = [u'F', u'M']
cuadro_sexo = wx.ComboBox(panel, -1, '', (90,75), (150,-1), sexolista, wx.CB_DROPDOWN | wx.CB_READONLY)
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,350))
boton_cancelar = wx.Button(panel, -1, u'Cancelar', pos = (100,350))
ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.COMBOBOX (editable.. se puede agregar algo)
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
sexo = wx.StaticText(panel, -1, u'Sexo: ', pos = (20,80))
sexolista = [u'F', u'M']
cuadro_sexo = wx.ComboBox(panel, -1, '', (90,75), (150,-1), sexolista, wx.CB_DROPDOWN )
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,350))
boton_cancelar = wx.Button(panel, -1, u'Cancelar', pos = (100,350))
ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.MESSADEDIALOG y WX.EVT.BUTTON (ponerle funcion a los botones!)
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
sexo = wx.StaticText(panel, -1, u'Sexo: ', pos = (20,80))
sexolista = [u'F', u'M']
cuadro_sexo = wx.ComboBox(panel, -1, '', (90,75), (150,-1), sexolista, wx.CB_DROPDOWN)
observaciones = wx.StaticText(panel, -1, u'Obs: ', pos = (20,110))
cuadro_obs = wx.TextCtrl(panel, -1, '', pos = (90,105), size = (150,80), style = wx.TE_MULTILINE)
edad = wx.StaticText(panel, -1, u'Edad: ', pos = (20,200))
self.cuadro_edad = wx.SpinCtrl(panel, -1, pos = (90,195))
self.cuadro_edad.SetRange(0,100)
fecha_nacimiento = wx.StaticText(panel, -1, 'F Nac', pos = (20,230))
cuadro_nacimiento = wx.DatePickerCtrl(panel, -1, pos = (90,225), size = (150, -1))
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,350))
boton_cancelar = wx.Button(panel, -1, u'Cancelar', pos = (100,350))
self.Bind(wx.EVT_BUTTON, self.OnSalir, boton_cancelar)
self.Bind(wx.EVT_BUTTON, self.OnAceptar, boton_aceptar)
self.ventana.Show()
return True
def OnSalir(self, evt):
self.ventana.Close()
def OnAceptar(self, evt):
ingresoapellido = self.cuadro_apellido.GetValue()
dialogo = wx.MessageDialog(self.ventana, u'Estimado/a %s, sus datos fueron guardados' % (ingresoapellido), u'Información', wx.OK | wx.ICON_INFORMATION)
dialogo.ShowModal()
dialogo.Destroy()
aplicacion = App()
aplicacion.MainLoop()
WX.SPINCTRL
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
ventana = wx.Frame(parent = None , title = u'Ingreso' , size = (300,300) , pos = (250,250))
panel = wx.Panel(ventana , -1)
texto_edad = wx.StaticText(panel, -1, u'Edad: ', pos = (20,25))
cuadro_edad = wx.SpinCtrl(panel, -1, pos = (90,20))
cuadro_edad.SetRange(0,110)
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,240))
ventana.Show()
return True
aplicacion = App()
aplicacion.MainLoop()
WX.DATEPICKERCTRL
# -*- coding: UTF8 -*-
import wx
class App(wx.App):
def OnInit(self):
self.ventana = wx.Frame(parent = None, title = u'Examen Medico', size = (300,400), pos = (320,150))
panel = wx.Panel(self.ventana, -1)
datos = wx.StaticText(panel, -1, u'Datos del empleado: ', pos = (20,20))
apellido = wx.StaticText(panel, -1, u'Apellido: ', pos = (20,50))
self.cuadro_apellido = wx.TextCtrl(panel, -1, '', pos = (90 , 45), size = (150,-1))
sexo = wx.StaticText(panel, -1, u'Sexo: ', pos = (20,80))
sexolista = [u'F', u'M']
cuadro_sexo = wx.ComboBox(panel, -1, '', (90,75), (150,-1), sexolista, wx.CB_DROPDOWN)
observaciones = wx.StaticText(panel, -1, u'Obs: ', pos = (20,110))
cuadro_obs = wx.TextCtrl(panel, -1, '', pos = (90,105), size = (150,80), style = wx.TE_MULTILINE)
edad = wx.StaticText(panel, -1, u'Edad: ', pos = (20,200))
self.cuadro_edad = wx.SpinCtrl(panel, -1, pos = (90,195))
self.cuadro_edad.SetRange(0,100)
fecha_nacimiento = wx.StaticText(panel, -1, 'F Nac', pos = (20,230))
cuadro_nacimiento = wx.DatePickerCtrl(panel, -1, pos = (90,225), size = (150, -1))
boton_aceptar = wx.Button(panel, -1, u'Aceptar', pos = (200,350))
boton_cancelar = wx.Button(panel, -1, u'Cancelar', pos = (100,350))
self.Bind(wx.EVT_BUTTON, self.OnSalir, boton_cancelar)
self.Bind(wx.EVT_BUTTON, self.OnAceptar, boton_aceptar)
self.ventana.Show()
return True
def OnSalir(self, evt):
self.ventana.Close()
def OnAceptar(self, evt):
ingresoapellido = self.cuadro_apellido.GetValue()
dialogo = wx.MessageDialog(self.ventana, u'Estimado/a %s, sus datos fueron guardados' % (ingresoapellido), u'Información', wx.OK | wx.ICON_INFORMATION)
dialogo.ShowModal()
dialogo.Destroy()
aplicacion = App()
aplicacion.MainLoop()