views:

44

answers:

1

I'm having some trouble with the procedure below. First pass through the procedure, everything appears to work OK. Subsequent passes, the labels overwrite the previous label w/o erasing, plus the initial loop that hides the buttons doesn't appear to function.

def drawbutton(self, event):

    rbuttons = [
     wx.RadioButton(self,-1,'xxxxxxxxxx', (190,60),style = wx.RB_GROUP),       
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,80)),
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,100)),
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,120)),
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,140)),
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,160)),
     wx.RadioButton(self, -1,'xxxxxxxxxx', (190,180)), ]

    for i in range(7):         
        rbuttons[i].Hide()   


    i = 0

    if self.combobox.GetValue() == "555-1212":
       voice1 = Voice()
       voice1.login("user1","abcdef")
       nphones = len(voice1.phones)



       for i in range(nphones):
           rbuttons[i].SetLabel(voice1.phones[i].name)
           rbuttons[i].Show()

       i = i + 1

       rbuttons[i].SetLabel('Voicemail')
       rbuttons[i].Show()


    else:
       voice2 = Voice()
       voice2.login("user2","abcdef")
       nphones = len(voice2.phones) 
       i = 0  

       for i in range(nphones):
           rbuttons[i].SetLabel(voice2.phones[i].name)
           rbuttons[i].Show()

       i = i + 1

       rbuttons[i].SetLabel('Voicemail')
       rbuttons[i].Show()
A: 

try calling self.Refresh() to force a repaint.

http://www.wxpython.org/docs/api/wx.Window-class.html#Refresh

BTW, the way you're using the 'i' is kinda confusing on the scope...

i = 0
....
for i in range(nphones):
           rbuttons[i].SetLabel(voice1.phones[i].name)
           rbuttons[i].Show()

i = i + 1

rbuttons[i].SetLabel('Voicemail')
rbuttons[i].Show()

try:

for i in range(nphones):
           rbuttons[i].SetLabel(voice1.phones[i].name)
           rbuttons[i].Show()

vm_idx = nphones    
rbuttons[vm_idx].SetLabel('Voicemail')
rbuttons[vm_idx].Show()
fseto