def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, "Rechercher un enfant", wx.DefaultPosition, wx.DefaultSize) self.sizer = wx.BoxSizer(wx.VERTICAL) self.fields_sizer = wx.FlexGridSizer(0, 2, 5, 10) self.fields_sizer.AddGrowableCol(1, 1) self.liste = Liste() self.choices = sorted(self.liste.keys()) self.text = wx.TextCtrl(self) self.combo = wx.ListBox(self) self.combo.SetItems(self.choices) self.text.Bind(wx.EVT_TEXT, self.OnText) self.combo.Bind(wx.EVT_LEFT_DCLICK, self.OnOK) self.fields_sizer.AddMany([(wx.StaticText(self, -1, "Recherche :"), 0, wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5), (self.text, 0, wx.EXPAND|wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5)]) self.sizer.Add(self.fields_sizer, 0, wx.EXPAND|wx.ALL, 5) self.sizer.Add(self.combo, 0, wx.EXPAND|wx.ALL, 5) self.btnsizer = wx.StdDialogButtonSizer() self.ok = wx.Button(self, wx.ID_OK) self.btnsizer.AddButton(self.ok) btn = wx.Button(self, wx.ID_CANCEL) self.btnsizer.AddButton(btn) self.btnsizer.Realize() self.sizer.Add(self.btnsizer, 0, wx.ALL, 5) self.SetSizer(self.sizer) self.sizer.Fit(self)
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, u"Rechercher un enfant", wx.DefaultPosition, wx.DefaultSize) self.sizer = wx.BoxSizer(wx.VERTICAL) self.fields_sizer = wx.FlexGridSizer(0, 2, 5, 10) self.fields_sizer.AddGrowableCol(1, 1) self.liste = Liste() self.choices = sorted(self.liste.keys()) self.text = wx.TextCtrl(self) self.combo = wx.ListBox(self) self.combo.SetItems(self.choices) self.text.Bind(wx.EVT_TEXT, self.OnText) self.combo.Bind(wx.EVT_LEFT_DCLICK, self.OnOK) self.fields_sizer.AddMany([(wx.StaticText(self, -1, u"Recherche :"), 0, wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5), (self.text, 0, wx.EXPAND|wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5)]) self.sizer.Add(self.fields_sizer, 0, wx.EXPAND|wx.ALL, 5) self.sizer.Add(self.combo, 0, wx.EXPAND|wx.ALL, 5) self.btnsizer = wx.StdDialogButtonSizer() self.ok = wx.Button(self, wx.ID_OK) self.btnsizer.AddButton(self.ok) btn = wx.Button(self, wx.ID_CANCEL) self.btnsizer.AddButton(btn) self.btnsizer.Realize() self.sizer.Add(self.btnsizer, 0, wx.ALL, 5) self.SetSizer(self.sizer) self.sizer.Fit(self)
class RechercherDialog(wx.Dialog): def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, u"Rechercher un enfant", wx.DefaultPosition, wx.DefaultSize) self.sizer = wx.BoxSizer(wx.VERTICAL) self.fields_sizer = wx.FlexGridSizer(0, 2, 5, 10) self.fields_sizer.AddGrowableCol(1, 1) self.liste = Liste() self.choices = sorted(self.liste.keys()) self.text = wx.TextCtrl(self) self.combo = wx.ListBox(self) self.combo.SetItems(self.choices) self.text.Bind(wx.EVT_TEXT, self.OnText) self.combo.Bind(wx.EVT_LEFT_DCLICK, self.OnOK) self.fields_sizer.AddMany([(wx.StaticText(self, -1, u"Recherche :"), 0, wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5), (self.text, 0, wx.EXPAND|wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5)]) self.sizer.Add(self.fields_sizer, 0, wx.EXPAND|wx.ALL, 5) self.sizer.Add(self.combo, 0, wx.EXPAND|wx.ALL, 5) self.btnsizer = wx.StdDialogButtonSizer() self.ok = wx.Button(self, wx.ID_OK) self.btnsizer.AddButton(self.ok) btn = wx.Button(self, wx.ID_CANCEL) self.btnsizer.AddButton(btn) self.btnsizer.Realize() self.sizer.Add(self.btnsizer, 0, wx.ALL, 5) self.SetSizer(self.sizer) self.sizer.Fit(self) def OnOK(self, event): self.EndModal(wx.ID_OK) def OnText(self, event): value = event.GetString().lower() items = [tmp for tmp in self.choices if value in tmp.lower()] self.combo.SetItems(items) if items: self.combo.SetSelection(0) self.ok.Enable(len(items) > 0)
class RechercherDialog(wx.Dialog): def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, "Rechercher un enfant", wx.DefaultPosition, wx.DefaultSize) self.sizer = wx.BoxSizer(wx.VERTICAL) self.fields_sizer = wx.FlexGridSizer(0, 2, 5, 10) self.fields_sizer.AddGrowableCol(1, 1) self.liste = Liste() self.choices = sorted(self.liste.keys()) self.text = wx.TextCtrl(self) self.combo = wx.ListBox(self) self.combo.SetItems(self.choices) self.text.Bind(wx.EVT_TEXT, self.OnText) self.combo.Bind(wx.EVT_LEFT_DCLICK, self.OnOK) self.fields_sizer.AddMany([(wx.StaticText(self, -1, "Recherche :"), 0, wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5), (self.text, 0, wx.EXPAND|wx.ALIGN_CENTRE_VERTICAL|wx.ALL-wx.BOTTOM, 5)]) self.sizer.Add(self.fields_sizer, 0, wx.EXPAND|wx.ALL, 5) self.sizer.Add(self.combo, 0, wx.EXPAND|wx.ALL, 5) self.btnsizer = wx.StdDialogButtonSizer() self.ok = wx.Button(self, wx.ID_OK) self.btnsizer.AddButton(self.ok) btn = wx.Button(self, wx.ID_CANCEL) self.btnsizer.AddButton(btn) self.btnsizer.Realize() self.sizer.Add(self.btnsizer, 0, wx.ALL, 5) self.SetSizer(self.sizer) self.sizer.Fit(self) def OnOK(self, event): self.EndModal(wx.ID_OK) def OnText(self, event): value = event.GetString().lower() items = [tmp for tmp in self.choices if value in tmp.lower()] self.combo.SetItems(items) if items: self.combo.SetSelection(0) self.ok.Enable(len(items) > 0)