python - Why can't I destroy my StaticText in wxPython? -
I am trying to remove statattext from the list and I get an error: AttributeError: 'tuple' object Not attribute 'deleted'
I can not seem to find a way around it. My code:
import wx square orange (wx.frame): def __init __ (self, guardian, id): wx.frame .__ init __ (self, guardian, id, 'test ', Size = (300,300) self.frame = wx.Panel (self) subtract = wx.Button (self.frame, label =' - ', pos = (80,200), size = (30,30)) self. Bind (wx .EVT_BUTTON, self.sub, subtract) self.trying = [] self.Something = 0 def sub (self, event): for zip (self.trying): i.Destroy () self.something + = 1 self .trying.append (wx.StaticText (self.frame, -1, str (self.something), pos = (200,200)) self.trying.append (wx.StaticText (self.frame, -1, str) (Self). (Some), pos = (250,200)) if __name__ == '__ main__': app = wx.PySimpleApp () window = orange (parent = none, id = -1) and Show () app.MainLoop ()
I am really confused why the static text is in a tuple, thanks a lot beforehand! Looking forward to the answer!
You only need But if you delete Do you want to delete and re-create for yourself. Code>.
? StringText
, then you have to remove it from the self.trying
list.
def sub (self, incident): in self.trying for: i.Destroy () self.trying = [] # Remove all StaticText from the list self.something + = 1 self .trying.append (wx.StaticText (self.frame, -1, str (self.something), pos = (200,200)) self.trying.append (wx.StaticText (self.frame, -1, str (self. Something), pos = (250,200))
static text
? > StaticText >> set label
wx class orange (wx.frame): def __init __ (self, guardian, id): wx .frame .__ init __ (self, guardian, id, 'test', size = (300,300)) self.frame = wx.pan Decrease el (self) = wx.button (self.frame, label = '-', pos = (80,200), size = (30,30) itself .bund (wx.EVT_BUTTON, self., Subtract) self.trying = [] Self.trying.append (wx.StaticTe Xt (self.frame, -1, '', pos = (200,200)) self.trying.append (wx.StaticText (self.frame, -1, '', Pos = (250,200) self.something = 0 df sub (self, incident): self = some + = 1 for self In Self.trying: i.SetLabel (str (self.something) if __name__ == '__ main__': app = wx.PySimpleApp () window = orange (original = none, id = -1) window Show () app Main Loop ()
Comments
Post a Comment