Merge pull request #3157 from gcmurphy/issue/3147

Adjust options when changed
This commit is contained in:
Aldo Cortesi 2018-05-26 10:51:24 +12:00 committed by GitHub
commit 8a76970944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -107,6 +107,7 @@ class OptManager:
choices: typing.Optional[typing.Sequence[str]] = None choices: typing.Optional[typing.Sequence[str]] = None
) -> None: ) -> None:
self._options[name] = _Option(name, typespec, default, help, choices) self._options[name] = _Option(name, typespec, default, help, choices)
self.changed.send(self, updated={name})
@contextlib.contextmanager @contextlib.contextmanager
def rollback(self, updated, reraise=False): def rollback(self, updated, reraise=False):

View File

@ -106,6 +106,8 @@ class OptionListWalker(urwid.ListWalker):
self.master.options.changed.connect(self.sig_mod) self.master.options.changed.connect(self.sig_mod)
def sig_mod(self, *args, **kwargs): def sig_mod(self, *args, **kwargs):
self.opts = sorted(self.master.options.keys())
self.maxlen = max(len(i) for i in self.opts)
self._modified() self._modified()
self.set_focus(self.index) self.set_focus(self.index)