There is an accordion of many
Output member widgets. Each one has a title. In the beginning all are collapsed. It is expected that the user will probably examine at most one, or perhaps two, at a time.
Output member widget may have text in it, or it might be empty. Hence, the situation is like a shell game for the user. The user has to expand each and check to find the one with text. This is no good.
When a member
Output widget becomes non-empty, an asterisk is prepended to the title. When the member Output widget is cleared, the asterisk is removed from the corresponding title.
This would work fine.
This implementation did not work:
After an member
Output widget was written, a function was called to change the corresponding title.
This fails because there are function calls to library routines in
with blocks. Unexpected error messages are showing up asynchronously in member Output blocks. These are not recognized as writes to the blocks, so the asterisk does not end up in the title.
So then callbacks?
Consider this blocks of code:
w = widgets.Output() w2 = widgets.Output() def msg(a): with w2: print("msg") def disp(a): with w2: print("disp") w.on_msg(msg) w.on_displayed(disp) display(w2)
w is displayed,
disp is displayed in
w2. That is all well and good, but that doesn’t say when text has been written to an
Output, it just says when
w is displayed.
msg callback never occurs. I had hoped that indicated that the Output had received a message.
So bottom line, how can the program know when an
Output becomes non-empty? … are these callback registration methods documented somewhere? When I search the readthedocs doc, it does not find them.
The next thing to try will be a polling loop that checks the
out.get_state() on each member
Output. Apart from the latency, that will work. But am I missing the right way to do this?