def OnAddCards(self, addedcards):
        """Called when a card is inserted.
        Adds the smart card child to the reader node."""
        self.mutex.acquire()
        try:
            parentnode = self.root
            for cardtoadd in addedcards:
                (childReader, cookie) = self.GetFirstChild(parentnode)
                found = False
                while childReader.IsOk() and not found:
                    if self.GetItemText(childReader) == str(cardtoadd.reader):
                        (childCard, cookie2) = self.GetFirstChild(childReader)
                        self.SetItemText(childCard, toHexString(cardtoadd.atr))
                        self.SetPyData(childCard, cardtoadd)
                        found = True
                    else:
                        (childReader, cookie) = self.GetNextChild(
                            parentnode, cookie)

                # reader was not found, add reader node
                # this happens when card monitoring thread signals
                # added cards before reader monitoring thread signals
                # added readers
                if not found:
                    childReader = self.AppendItem(
                        parentnode, str(cardtoadd.reader))
                    self.SetPyData(childReader, cardtoadd.reader)
                    self.SetItemImage(
                        childReader,
                        self.readerimageindex,
                        wx.TreeItemIcon_Normal)
                    self.SetItemImage(
                        childReader,
                        self.readerimageindex,
                        wx.TreeItemIcon_Expanded)
                    childCard = self.AddATR(
                        childReader, toHexString(cardtoadd.atr))
                    self.SetPyData(childCard, cardtoadd)
                    self.Expand(childReader)

            self.Expand(self.root)
        finally:
            self.mutex.release()
        self.EnsureVisible(self.root)
        self.Repaint()
def OnAddCards ( self , addedcards ) : self . mutex . acquire ( ) try : parentnode = self . root for cardtoadd in addedcards : ( childReader , cookie ) = self . GetFirstChild ( parentnode ) found = False while childReader . IsOk ( ) and not found : if self . GetItemText ( childReader ) == str ( cardtoadd . reader ) : ( childCard , cookie2 ) = self . GetFirstChild ( childReader ) self . SetItemText ( childCard , toHexString ( cardtoadd . atr ) ) self . SetPyData ( childCard , cardtoadd ) found = True else : ( childReader , cookie ) = self . GetNextChild ( parentnode , cookie ) if not found : childReader = self . AppendItem ( parentnode , str ( cardtoadd . reader ) ) self . SetPyData ( childReader , cardtoadd . reader ) self . SetItemImage ( childReader , self . readerimageindex , wx . TreeItemIcon_Normal ) self . SetItemImage ( childReader , self . readerimageindex , wx . TreeItemIcon_Expanded ) childCard = self . AddATR ( childReader , toHexString ( cardtoadd . atr ) ) self . SetPyData ( childCard , cardtoadd ) self . Expand ( childReader ) self . Expand ( self . root ) finally : self . mutex . release ( ) self . EnsureVisible ( self . root ) self . Repaint ( )
Called when a card is inserted.
        Adds the smart card child to the reader node.