class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, title=u"My Frame")
self.model = WatchableDict()
self.model["text"] = ""
sizer = wx.BoxSizer(wx.VERTICAL)
self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
sizer.Add(self.text_ctrl, 0, 0, 0)
pywatch.wx.TextCtrlWatcher(self.text_ctrl,self.model,"text")
self.static_text = wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
sizer.Add(self.static_text, 0, 0, 0)
pywatch.wx.LabelWatcher(self.static_text, self.model, ["text"])
self.SetSizer(sizer)
self.Centre(wx.BOTH)
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I had a quick look, but before spending time learning the WHOLE frame work is it possible to do things such as this:
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
import wx
from easyDialog import Ctrl
class Panel(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, *args, **kwargs):
wx.Frame.__init__(self, parent, id, *args, **kwargs)
self.gauge = Ctrl.Gauge(0, maxvalue=100, horz=wx.HORIZONTAL)
self.result = Ctrl.StaticText('0')
self.spin1 = Ctrl.SpinCtrl(0, 50, 0).\
Bind(wx.EVT_SPINCTRL, lambda evt: self.gauge.SetValue( self.spin1.Value+self.spin2.Value)).\
Bind(wx.EVT_SPINCTRL, lambda evt: self.result.SetValue( str( self.spin1.Value+self.spin2.Value)))
self.spin2 = Ctrl.SpinCtrl(0, 50, 0).\
Bind(wx.EVT_SPINCTRL, lambda evt: self.gauge.SetValue( self.spin1.Value+self.spin2.Value)).\
Bind(wx.EVT_SPINCTRL, lambda evt: self.result.SetValue( str( self.spin1.Value+self.spin2.Value)))
# ----- > The layout
mp = Ctrl.MakePairs
sizer= mp([
(self.spin1, Ctrl.StaticText( '+'), self.spin2), # first controls row
mp( [self.result], horzCenter=True, proportion=1), # second controls row
self.gauge, # third controls row
], # The controls as list or tuple
horz=wx.VERTICAL, # the Layout
title='Hello', # an staticboxsizer with a string
flag=wx.ALL|wx.EXPAND, # control's flag
horzCenter=True) # to horizontally center the sizer container
# ----- <
self.SetSizer( sizer( self)) # sizer(self) do the stuff, i.e. the callbacks, the Layout, ....
self.Layout()
import wx
from easyDialog import Ctrl
class Panel(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, *args, **kwargs):
wx.Frame.__init__(self, parent, id, *args, **kwargs)
self.gauge = Ctrl.Gauge(0, maxvalue=100, horz=wx.HORIZONTAL)
self.result = Ctrl.StaticText('0')
self.spin1 = Ctrl.SpinCtrl(0, 50, 0).Bind(wx.EVT_SPINCTRL, self.On_change)
self.spin2 = Ctrl.SpinCtrl(0, 50, 0).Bind(wx.EVT_SPINCTRL, self.On_change)
# ----- > The layout
mp = Ctrl.MakePairs
sizer= mp([
(self.spin1, Ctrl.StaticText( '+'), self.spin2),
mp( [self.result], horzCenter=True, proportion=1),
self.gauge,
],
horz=wx.VERTICAL,
title='Hello',
flag=wx.ALL|wx.EXPAND,
horzCenter=True)
# ----- <
self.SetSizer( sizer( self))
self.Layout()
def On_change(self, evt):
self.gauge.SetValue( self.spin1.Value + self.spin2.Value)
self.result.SetValue( str( self.spin1.Value + self.spin2.Value))
Ahh! Something like this:
value_events = { wx.SpinCtrl: wx.EVT_SPIN, wx.Slider: wx.EVT_SLIDER, wx.CheckBox: wx.EVT_CHECKBOX, wx.ToggleButton: wx.EVT_TOGGLEBUTTON, wx.TextCtrl: wx.EVT_TEXT}
class ValueChanger(ValueWatcher): def __init__(self, widget, watchable, watcher): event = [value_events[widget_class] for widget_class in value_events if isinstance(widget,widget_class)] if not event: raise Exception('Widget type is not recognised') ValueWatcher.__init__(self, widget, watchable, watcher) widget.Bind(event[0], self.on_change)
def on_change(self, event): self.set_value(self.widget.GetValue()) event.Skip()
from easyDialog import Ctrl
from Modulos.coreMod import _BasePanel
from imagenes import imageEmbed
import wx
_ = wx.GetTranslation
imag= imageEmbed(size=(16, 16))class Panel(_BasePanel): name = _('FOR-MAN-001')# formato de mantenimiento image = imag.dashboard def __init__(self, parent, id = wx.ID_ANY, *args, **kwargs): _BasePanel.__init__(self, parent, id, *args, **kwargs) mp, st, tc, bm = Ctrl.MakePairs, Ctrl.StaticText, Ctrl.TextCtrl, Ctrl.BitmapButton sb, spa, flex, grid = Ctrl.StaticBitmap, Ctrl.Spacer, Ctrl.FlexGridSizer, Ctrl.GridSizer imag = imageEmbed(size=(590, 80)) header = mp([sb(imag.formulario), mp([st('Especificaciones')], horzCenter=True), ], horz=wx.VERTICAL, flag=wx.EXPAND|wx.ALL) flexi = flex([st('Año del modelo'), st('Odómetro'), Ctrl.IntTextCtrl('2016').tooltip(_('Año de fabricación')), mp([tc(size=(125,-1)).tooltip(_('Valor inicial\ndel odómetro')), Ctrl.Choice(['Kilometros','Millas'],0)], border=0), st('Fabricante'), st('Placa'), tc('').tooltip(_('Del vehículo')), tc('', size=wx.Size(210, -1)).tooltip(_('Número de la\nplaca del automotor')), st('Modelo'), st('Código'), tc('').tooltip(_('Modelo acorde\ncon el fabricante')), tc('', size=wx.Size(210, -1)).tooltip(_('Que se le asignará\nen la empresa para\nidentificarlo')), st('Color'), st('Conductor'), tc('Negro').tooltip(_('Color actual')), Ctrl.User().tooltip(_('Seleccione un usuario\nRegistrado en la base')), ], 2) body_left = mp([flexi], proportion=0, horzCenter=True, title= _('Información del vehículo'), flag=wx.ALL, ) imag = imageEmbed(size=(200, 200)) body_rigth = mp([sb(imag.equipo)], title=_('Imágen del vehículo'), flag=wx.ALL|wx.EXPAND) body = mp([body_left, body_rigth], flag=wx.ALL|wx.EXPAND, horzCenter=True) body_midle_top = mp([flex([st(_('Numero de Tarjeta')), tc(size=wx.Size(117,-1)).tooltip(_('Tarjete de operación')), st(_('Fecha de vencimiento')), Ctrl.DatePickerCtrl(size=wx.Size(117, -1)), ],2)], horz=wx.VERTICAL, flag=wx.EXPAND, title=_('Licencia')) body_midle_bottom = mp([flex([st(_('Empresa/compañía')), tc(size=wx.Size(125,-1)).tooltip(_('Empresa que aseguró\nel vehículo')), st(_('Número de\nla cuenta')), tc(size=wx.Size(125,-1)).tooltip(_('O el número\ndel seguro')), st(_('Fecha Vencimiento')), Ctrl.DatePickerCtrl(size=wx.Size(125,-1)).\ tooltip(_('Fecha de vencimiento\ndel seguro')), ],2) ], title=_('Aseguradora')) body_midle_left = mp([body_midle_top, body_midle_bottom], horz=wx.VERTICAL, flag=wx.EXPAND) body_mid_rigtop = mp([flex([st(_('Motor')), tc(size=wx.Size(205,-1)).tooltip(_('cm cúbicos\nnúmero de válvulas')), st(_('Transmisión')), Ctrl.Choice(['Mecánica', 'Automática'],0, size=wx.Size(205,-1)).\ tooltip(_('tipo de transmisión\ndel vehículo')), st(_('Tamaño de\nla llanta')), tc(size=wx.Size(205,-1)), ],2) ], title=_('Mecanica')) body_mid_rigbottom = mp([tc(style=wx.TE_MULTILINE,size=wx.Size(290, 56)).\ tooltip(_('Observaciones con respecto\nal vehículo'))], flag=wx.EXPAND|wx.ALL, title=_('Observaciones')) body_midle_rigth = mp([body_mid_rigtop, body_mid_rigbottom], horz=wx.VERTICAL, flag=wx.EXPAND) body_midle = mp([body_midle_left, body_midle_rigth], flag=wx.ALL, horzCenter=True) main_sizer = mp([header, body, body_midle], title=_('Datos básicos'), horzCenter=True, horz=wx.VERTICAL) self.Sizer= main_sizerpnl= Panel(ntb)ntb.AddPage(pnl, pnl.name, True)wx.MessageBox('{}'.format(pnl.Value))
from easyDialog import wxsimport wx
from Modulos.coreMod import _BasePanelfrom imagenes import imageEmbed
imag= imageEmbed(size=(16, 16))class Panel(_BasePanel):
name = 'FOR-MAN-001'# formato de mantenimiento
image = imag.dashboard def __init__(self, parent, id = wx.ID_ANY, *args, **kwargs): _BasePanel.__init__(self, parent, id, *args, **kwargs)
st, tc, bm = wxs.StaticText, wxs.TextCtrl, wxs.BitmapButton sb, spa, flex = wxs.StaticBitmap, wxs.Spacer, wxs.FlexGridSizer, wxs.GridSizer imag = imageEmbed(size=(590, 80)) header = wxs.Sizer([sb(imag.formulario), wxs.Sizer(st('Especificaciones'), horzCenter=True)],
horz=wx.VERTICAL, flag=wx.EXPAND|wx.ALL) flexi = flex([st('Año del modelo'), st('Odómetro'),
wxs.IntTextCtrl('2016').tooltip('Año de fabricación'), wxs.Sizer([tc(size=(125,-1)).tooltip('Valor inicial\ndel odómetro'), wxs.Choice(['Kilometros','Millas'],0)],
border=0), st('Fabricante'), st('Placa'),
tc('').tooltip('Del vehículo'), tc('', size=wx.Size(210, -1)).tooltip('Número de la\nplaca del automotor'),
st('Modelo'), st('Código'),
tc('').tooltip('Modelo acorde\ncon el fabricante'), tc('', size=wx.Size(210, -1)).tooltip('Que se le asignará\nen la empresa para\nidentificarlo'),
st('Color'), st('Conductor'),
tc('Negro').tooltip('Color actual'), wxs.User().tooltip('Seleccione un usuario\nRegistrado en la base'), ], 2) b_left = wxs.Sizer(flexi, proportion=0, horzCenter=True, title='Información del vehículo', flag=wx.ALL) imag = imageEmbed(size=(200, 200)) b_rigth = wxs.Sizer(sb(imag.equipo), title='Imágen del vehículo', flag=wx.ALL|wx.EXPAND) body = wxs.Sizer([b_left, b_rigth], flag=wx.ALL|wx.EXPAND, horzCenter=True) bm_top = wxs.Sizer(flex([st('Numero de Tarjeta'), tc(size=wx.Size(117,-1)).tooltip('Tarjete de operación'), st('Fecha de vencimiento'), wxs.DatePickerCtrl(size=wx.Size(117, -1)), ], 2), horz=wx.VERTICAL, flag=wx.EXPAND, title='Licencia') bm_bottom = wxs.Sizer(flex([st('Empresa/compañía'), tc(size=wx.Size(125,-1)).tooltip('Empresa que aseguró\nel vehículo'), st('Número de\nla cuenta'), tc(size=wx.Size(125,-1)).tooltip('O el número\ndel seguro'), st('Fecha Vencimiento'), wxs.DatePickerCtrl(size=wx.Size(125,-1)).tooltip('Fecha de vencimiento\ndel seguro'), ], 2), title='Aseguradora') bm_left = wxs.Sizer([bm_top, bm_bottom], horz=wx.VERTICAL, flag=wx.EXPAND) bm_rigtop = wxs.Sizer(flex([st('Motor'), tc(size=wx.Size(205,-1)).tooltip('cm cúbicos\nnúmero de válvulas'), st('Transmisión'), wxs.Choice(['Mecánica', 'Automática'],0, size=wx.Size(205,-1)).tooltip('tipo de transmisión\ndel vehículo'), st('Tamaño de\nla llanta'), tc(size=wx.Size(205,-1)), ], 2), title='Mecanica') bm_rigbottom = wxs.Sizer(tc(style=wx.TE_MULTILINE,size=wx.Size(290, 56)).tooltip('Observaciones con respecto\nal vehículo'), flag=wx.EXPAND|wx.ALL, title='Observaciones') bm_rigth = wxs.Sizer([bm_rigtop, bm_rigbottom], horz=wx.VERTICAL, flag=wx.EXPAND) body_midle = wxs.Sizer([bm_left, bm_rigth], flag=wx.ALL, horzCenter=True) main_sizer = wxs.Sizer([header, body, body_midle], title='Datos básicos', horzCenter=True, horz=wx.VERTICAL) self.Sizer = main_sizer