mirror of
https://github.com/wassname/baukit.git
synced 2026-06-27 17:29:37 +08:00
Add event.location property.
This commit is contained in:
@@ -493,7 +493,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d58975ba",
|
||||
"id": "0e1adc74",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Handling PlotWidget clicks\n",
|
||||
@@ -504,14 +504,14 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ba3cbe25",
|
||||
"id": "439c2809",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from baukit import Textbox\n",
|
||||
"coord_b = Textbox()\n",
|
||||
"def handle_click(e):\n",
|
||||
" loc = pw.event_location(e)\n",
|
||||
" loc = e.target.event_location(e)\n",
|
||||
" coord_b.value = f'x,y=({loc.x:.2f}, {loc.y:.2f}) inside={loc.inside}'\n",
|
||||
"pw.on('click', handle_click)\n",
|
||||
"show(show.TIGHT, [['Click the previous plot to see coordinates here:', coord_b]])"
|
||||
|
||||
Reference in New Issue
Block a user