Python urwid.disconnect_signal() Examples

The following are 27 code examples of urwid.disconnect_signal(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urwid , or try the search function .
Example #1
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def _edit_ok(self, form, newtext, entry):
        try:
            self.row.update_attribute(self.session, entry.attrname, newtext)
        except:
            ex, val, tb = sys.exc_info()
            self.session.rollback()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
            return
        urwid.disconnect_signal(form, 'ok', self._edit_ok, entry)
        urwid.disconnect_signal(form, 'cancel', self._edit_cancel, entry)
        saveentry = self._saveentryval
        del self._saveentryval
        newval = self.row.get_attribute(self.session, entry.attrname)
        saveentry.base_widget[1].base_widget.set_text(unicode(newval).encode("utf-8"))
        entry._w = saveentry

    # create attrib 
Example #2
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def _add_new_testequipment_ok(self, frm, data):
        eq, roles, uut = data
        dbrow = models.create(models.TestEquipment, environment=self.environmentrow, equipment=eq, UUT=uut, roles=roles)
        self.session.add(dbrow)
        try:
            self.session.commit()
        except:
            self.session.rollback()
            ex, val, tb = sys.exc_info()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        entry = ListEntry(urwid.Text(self._stringify_te(dbrow)))
        urwid.connect_signal(entry, 'activate', self._edit_testequipment)
        urwid.connect_signal(entry, 'delete', self._delete_testequipment)
        entry.testequipment = dbrow
        listbox = self._w.contents[1][0].base_widget
        listbox.body.append(entry)
        urwid.disconnect_signal(frm, 'ok', self._add_new_testequipment_ok)
        urwid.disconnect_signal(frm, 'cancel', self._add_new_testequipment_cancel)
        frm._emit("popform") 
Example #3
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def _delete_ok(self, dlg, listentry):
        listbox = self._w.contents[1][0].base_widget
        assert type(listbox) is urwid.ListBox
        listbox.body.remove(listentry)
        urwid.disconnect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.disconnect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        del self._oldw
        try:
            self.session.delete(listentry.testequipment)
            self.session.commit()
        except:
            ex, val, tb = sys.exc_info()
            self.session.rollback()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        listentry.testequipment = None
        urwid.disconnect_signal(listentry, 'activate', self._edit_testequipment)
        urwid.disconnect_signal(listentry, 'delete', self._delete_testequipment) 
Example #4
Source File: gazua.py    From ec2-gazua with MIT License 6 votes vote down vote up
def on_aws_changed(self):
        # aws
        self.aws_view.update_focus()

        # group
        urwid.disconnect_signal(self.group_view.get_walker(), "modified",
                                self.on_group_changed)
        aws_name = self.aws_view.get_selected_name()
        self.group_view.update_widgets(
            list(self.manager.instances[aws_name].keys()))
        urwid.connect_signal(self.group_view.get_walker(), "modified",
                             self.on_group_changed)

        # instance
        group_name = self.group_view.get_selected_name()
        self.instance_view.update_widgets(
            self.manager.instances[aws_name][group_name]) 
Example #5
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def _delete_ok(self, dlg, listentry):
        urwid.disconnect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.disconnect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        del self._oldw
        self.session.delete(listentry.interface)
        try:
            self.session.commit()
        except:
            ex, val, tb = sys.exc_info()
            self.session.rollback()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        else:
            listbox = self._w.contents[1][0].base_widget
            assert type(listbox) is urwid.ListBox
            listbox.body.remove(listentry)
            listentry.interface = None
            urwid.disconnect_signal(listentry, 'activate', self._edit_interface)
            urwid.disconnect_signal(listentry, 'delete', self._delete_interface) 
Example #6
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete_interface(self, listentry):
        urwid.disconnect_signal(listentry, 'activate', self._edit_interface)
        urwid.disconnect_signal(listentry, 'delete', self._delete_interface)
        text, attr = listentry._w.base_widget.get_text()
        dlg = DeleteDialog(text)
        urwid.connect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.connect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        self._oldw = listentry._w
        listentry._w = dlg 
Example #7
Source File: screenElements.py    From alertR with GNU Affero General Public License v3.0 5 votes vote down vote up
def __del__(self):

        # Disconnect callback function.
        if self.edit is not None and self.callbackFunction is not None:
            urwid.disconnect_signal(self.edit, "change", self.callbackFunction, "")

    # This function returns the final urwid widget that is used
    # to render this object. 
Example #8
Source File: host_credentials.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def next_page(self):
        # disconnect the signal handler setup by __init__
        urwid.disconnect_signal(self.common_password.base_widget,
                                'change',
                                callback=self.common_pswd_change)
        app = self.parent
        app.next_page() 
Example #9
Source File: components.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def header(self, header):
        urwid.disconnect_signal(self.body, 'set_date', self._header.on_set_date)
        self._header = header
        urwid.connect_signal(self.body, 'set_date', self._header.on_set_date)
        self.set_header(self._header) 
Example #10
Source File: app.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def go_to_sidebar(self):
        if len(self.columns.contents) > 2:
            self.columns.contents.pop()
        self.columns.focus_position = 0

        if self.store.state.editing_widget:
            self.leave_edit_mode()

        if self.quick_switcher:
            urwid.disconnect_signal(self.quick_switcher, 'go_to_channel', self.go_to_channel)
            self.urwid_loop.widget = self._body
            self.quick_switcher = None 
Example #11
Source File: app.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def handle_close_set_snooze(self):
        """
        Close set_snooze
        :return:
        """
        if self.set_snooze_widget:
            urwid.disconnect_signal(self.set_snooze_widget, 'set_snooze_time', self.handle_set_snooze_time)
            urwid.disconnect_signal(self.set_snooze_widget, 'close_set_snooze', self.handle_close_set_snooze)
            self.urwid_loop.widget = self._body
            self.set_snooze_widget = None 
Example #12
Source File: app.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def go_to_channel(self, channel_id):
        if self.quick_switcher:
            urwid.disconnect_signal(self.quick_switcher, 'go_to_channel', self.go_to_channel)
            self.urwid_loop.widget = self._body
            self.quick_switcher = None
        loop.create_task(self._go_to_channel(channel_id)) 
Example #13
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete_ok(self, dlg, data):
        listentry, row = data
        msg = "Deleted {!r}".format(str(row))
        try:
            self.session.delete(row)
            self.session.commit()
        except IntegrityError as ierr:
            self.session.rollback()
            self._emit("message", str(ierr))
        else:
            urwid.disconnect_signal(listentry, 'activate', self._edit, row.id)
            urwid.disconnect_signal(listentry, 'delete', self._delete, row.id)
            listentry._w =  urwid.Text(("deleted", msg))
        ovl = self._w
        self._w = ovl.bottom_w 
Example #14
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def invalidate(self):
        listbox = urwid.ListBox(self.get_items())
        self._w.body = urwid.AttrMap(listbox, 'body')
        # TODO disconnect old, existing signals
            #urwid.disconnect_signal(le, 'activate', self._edit, pk)
            #urwid.disconnect_signal(le, 'delete', self._delete, pk) 
Example #15
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _select(self, selb):
#        for b in self.primlist:
#            urwid.disconnect_signal(b, 'activate', self._select)
        form = get_list_form(self.session, getattr(models, selb.modelname))
        self._emit("pushform", form) 
Example #16
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _popform(self, form, *extra):
        urwid.disconnect_signal(form, 'popform', self._popform)
        urwid.disconnect_signal(form, 'message', self._message)
        ovl = self._w
        self._w = ovl.bottom_w 
Example #17
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _edit_complete(self, form, pkval, listentry):
        urwid.disconnect_signal(form, 'popform', self._edit_complete, listentry)
        urwid.disconnect_signal(form, 'message', self._message)
        listentry._w.base_widget.set_text(unicode(listentry.interface).encode("utf-8"))
        #self._invalidate()
        form._emit("popform") 
Example #18
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete_cancel(self, dlg, listentry):
        urwid.disconnect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.disconnect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        listentry._w = self._oldw
        del self._oldw
        # restore sig handlers
        urwid.connect_signal(listentry, 'activate', self._edit_interface)
        urwid.connect_signal(listentry, 'delete', self._delete_interface) 
Example #19
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete_cancel(self, dlg, listentry):
        urwid.disconnect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.disconnect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        listentry._w = self._oldw
        del self._oldw
        # restore sig handlers
        urwid.connect_signal(listentry, 'activate', self._edit_testequipment)
        urwid.connect_signal(listentry, 'delete', self._delete_testequipment) 
Example #20
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _edit_testequipment_ok(self, form, entry):
        try:
            self.session.commit()
        except:
            self.session.rollback()
            ex, val, tb = sys.exc_info()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        entry._w.base_widget.set_text(self._stringify_te(entry.testequipment))
        urwid.disconnect_signal(form, 'ok', self._edit_testequipment_ok, entry)
        urwid.disconnect_signal(form, 'cancel', self._edit_testequipment_cancel, entry)
        form._emit("popform")

    # deleting 
Example #21
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _edit_testequipment_cancel(self, form, entry):
        try:
            self.session.rollback()
        except:
            ex, val, tb = sys.exc_info()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        urwid.disconnect_signal(form, 'ok', self._edit_testequipment_ok, entry)
        urwid.disconnect_signal(form, 'cancel', self._edit_testequipment_cancel, entry)
        form._emit("popform") 
Example #22
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _add_new_testequipment_cancel(self, frm):
        urwid.disconnect_signal(frm, 'ok', self._add_new_testequipment_ok)
        urwid.disconnect_signal(frm, 'cancel', self._add_new_testequipment_cancel)
        frm._emit("popform")

    # editing 
Example #23
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete_cancel(self, dlg, listentry):
        urwid.disconnect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.disconnect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        listentry._w = self._oldw
        del self._oldw
        # restore sig handlers
        urwid.connect_signal(listentry, 'activate', self._edit_attribute)
        urwid.connect_signal(listentry, 'delete', self._delete) 
Example #24
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _delete(self, listentry):
        urwid.disconnect_signal(listentry, 'activate', self._edit_attribute)
        urwid.disconnect_signal(listentry, 'delete', self._delete)
        text, attr = listentry._w.base_widget[0].get_text()
        dlg = DeleteDialog(text)
        urwid.connect_signal(dlg, 'ok', self._delete_ok, listentry)
        urwid.connect_signal(dlg, 'cancel', self._delete_cancel, listentry)
        self._oldw = listentry._w
        listentry._w = dlg 
Example #25
Source File: widgets.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _edit_cancel(self, form, entry):
        urwid.disconnect_signal(form, 'ok', self._edit_ok, entry)
        urwid.disconnect_signal(form, 'cancel', self._edit_cancel, entry)
        saveentry = self._saveentryval
        del self._saveentryval
        entry._w = saveentry 
Example #26
Source File: runner.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _runtest(self, b):
        if not self._tclist:
            self._emit("message", "No tests selected")
            return
        urwid.disconnect_signal(b, "click", self._runtest) # prevent running again until test ends
        environmentname = self._envsel.value
        reportname = self._repsel.value
        options = self._get_options()
        testlist = [tw.base_widget.text for tw in self._tclist]
        self.runtest(testlist, environmentname, reportname, options)
        self._w.set_focus("body") 
Example #27
Source File: main.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def _popform(self, form):
        if form is not None:
            urwid.disconnect_signal(form, 'pushform', self._pushform)
            urwid.disconnect_signal(form, 'popform', self._popform)
            urwid.disconnect_signal(form, 'message', self._message)
        if self._formtrail:
            self.form = self._formtrail.pop()
            #self.form.invalidate()
            self.top.body = self.form
        else:
            raise urwid.ExitMainLoop()