Exemplo n.º 1
0
    def add_controls(self):
        self.add_text("""
            Select the passwords you would like to update.
        """)

        # process logins for list
        Rule.attach_rules(GlobalState.logins)
        GlobalState.matched_logins = matched_logins = [
            login for login in GlobalState.logins if not login.get('error')
        ]

        parent = self

        class NotifyChecklistCtrl(CheckListCtrl):
            def OnCheckItem(self, index, flag):
                super(NotifyChecklistCtrl, self).OnCheckItem(index, flag)
                if self.selected_indexes:
                    parent.continue_button.Enable()
                else:
                    parent.continue_button.Disable()

        matched_logins.sort(key=lambda login: (login['rule'].name.lower(),
                                               login['label'].lower()))
        self.checklist = checklist = self.add_list(
            ("Site", "Account Title", "User"),
            [(l['rule'].name, l['label'], l.get('username', ''))
             for l in matched_logins],
            ListClass=NotifyChecklistCtrl)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.item_activated, checklist)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.item_selected, checklist)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.item_deselected, checklist)

        self.continue_button = self.add_button("Change Selected Passwords",
                                               self.change_passwords)
        self.continue_button.Disable()