@@ -111,24 +111,9 @@ def _add_keypress(self, callback):
111
111
self ._callback = callback
112
112
113
113
def _trigger_keypress (self , key ):
114
+ # note: this doesn't actually simulate a keypress, it just calls the
115
+ # callback function directly because this is not yet possible
114
116
self ._callback (key )
115
- # TO DO: actually simulate the keypress, see code below not yet working
116
- '''
117
- # trigger to a vbox which will be present because the _AppWindow is
118
- # a vbox, this doesn't trigger specifically for the widget but this
119
- # is just for testing
120
- # note: ipywidgets.HTML does not execute javascript but
121
- # IPython.display.HTML does
122
- key_str = key.title() if len(key) > 1 else key
123
- display(IPython.display.HTML("""
124
- <script>
125
- let element = document.getElementsByClassName("widget-vbox")[0];
126
- element.dispatchEvent(
127
- new KeyboardEvent( 'keydown' , {'key':'%s'} ));
128
- element.dispatchEvent(
129
- new KeyboardEvent( 'keyup' , {'key':'%s'} ));
130
- </script>""" % (key_str, key_str)))
131
- '''
132
117
133
118
def _set_focus (self ):
134
119
if hasattr (self , 'focus' ): # added in ipywidgets 8.0
@@ -591,7 +576,7 @@ def _add_widget(self, widget):
591
576
# if pyvista plotter, needs to be shown
592
577
if isinstance (widget , Plotter ):
593
578
widget = widget .show (
594
- jupyter_backend = " ipyvtklink" , return_viewer = True )
579
+ jupyter_backend = ' ipyvtklink' , return_viewer = True )
595
580
widget .layout .width = None # unlock the fixed layout
596
581
if hasattr (widget , 'layout' ):
597
582
widget .layout .margin = "2px 0px 2px 0px"
0 commit comments