Bonsoir,
Quelqu'un utilise-t-il la fonction Destructor des widget sous wxPython.
Exemple pour un combobox: ~wxComboBox() (d'après la doc fourni avec wxPython).
Si oui comment s'en servir exactement.
Version imprimable
Bonsoir,
Quelqu'un utilise-t-il la fonction Destructor des widget sous wxPython.
Exemple pour un combobox: ~wxComboBox() (d'après la doc fourni avec wxPython).
Si oui comment s'en servir exactement.
Je ne suis pas sûr d'avoir compris ta question.
Si tu veux détruire un widget il suffit de faire:
Si tu veux repérer la destruction du comboBox pour effectuer une action lorsque le comboBox est detuit, c'est plus compliquer. Je ne pense pas que les destructeur soient implémentés dans la version python de wxWidget.Code:monCombo.Destroy()
Tu peux utiliser l'événement wx.EVT_WINDOW_DESTROY.
Voici un exemple:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #!/usr/bin/env python # -*- coding: iso-8859-15 -*- import wx class MaFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) self.monCombo = wx.ComboBox(self, -1, choices=('pomme', 'poire', 'carote', 'cerise')) boutonDestroy = wx.Button(self, -1, "destroy", (0,30)) self.Fit() self.Show(True) self.Bind(wx.EVT_BUTTON, self.detruire, boutonDestroy) self.Bind(wx.EVT_WINDOW_DESTROY, self.onDestroy, self.monCombo) def detruire(self, e): self.monCombo.Destroy() def onDestroy(self, e): print "le comboBox vient d'être detruit" #là tu met le code dont besoin lorsque le comboBox est détruit app = wx.App(0) frame = MaFrame(None, -1, 'test') app.MainLoop()