wxPython Widget destruction

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elias Alhanatis
    New Member
    • Aug 2007
    • 56

    wxPython Widget destruction

    Hello everybody!!!
    ( Here is a tough one.... )

    I made an app for a dance studio using wxPython. In order to save space in a certain "screen"
    of my app , i use combo-boxes or choice-boxes ( in order to show the present students in each group lesson that took place that day ).
    I have managed to create these widgets ( according to how many group lessons took place that day ( for example 2 lessons > 2 combo-boxes) ) , but i cannot
    "destroy" them when i refresh the screen by choosing another date....

    The progress i made so far is that i understand that each widget has an ID which
    somehow i can retreive , but how can i make the app understand that i want to destroy the widgets that have these ID's?

    Here is the part which creates the widgets ( in the future i will make a special Class for these... )

    Code:
    Group_Lessons_That_Day=MyConnection("""SELECT GroupLessonType,StudentsCodes FROM grouplessons WHERE Date='%s' order by Time """ % Form)
            increment=0
            for Lesson in Group_Lessons_That_Day:
                Choices=[]
                Choices.append(Lesson[0])
                for id in Lesson[1].strip(",").split(","):
                    id=int(id.strip("[]"))
                    Students_Name=MyConnection("""SELECT StudentName FROM students WHERE StudentCode='%s' """ % id)[0][0].split()[0]
                    Choices.append(Students_Name)
                
                self.Lesson_List=wx.Choice(choices=Choices,id=increment+3000, parent=self,pos=wx.Point(20+increment, 462), size=wx.Size(120, 21), style=0)            
                self.Lesson_List.SetSelection(0)
                increment+=125
    Any guidelines will be very welcomed!!!!

    Thank you all in advance!!

    Elias
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    Since you know the ids you can use a combination of the function FindWindowById( self, id) and Destroy() ... it would look something like this:
    [code=python]
    # In your choice creation loop you can use a list to keep track of the ids
    for idx in id_list:
    self.FindWindow ById(idx).Destr oy()
    [/code]

    Comment

    • Elias Alhanatis
      New Member
      • Aug 2007
      • 56

      #3
      Thank you so much for the fast and hopefully
      usefull reply! I realy wasnt aware of such a function. I will do some
      research to see were it is "hidden".

      Thanks again!!!!

      Elias

      Comment

      Working...