@@ -342,14 +342,23 @@ Querying
342342--------
343343
344344Querying allows the user to select a region of the plot by
345- holding with the right mouse button and clicking with the left one.
345+ **Ctrl + dragging the right mouse button ** and dragging five
346+ circles of the query rectangle with left mouse button.
347+
348+ Double left click inside a drag rect will remove it (if *min_query_rects * allows).
349+ If number of rects exceed *max_query_rects * when create new drag rect, it will replace the last one.
350+
351+ Since DearPyGui 2.0, *query_mod * changes to *query_toggle_mod * for swapping the Ctrl key above.
352+ *query_button * is removed, so **dragging the right mouse button ** is hardcoded.
353+ *min_query_rects, max_query_rects * limit the number of drag rects.
346354
347355Querying requires setting *query * to **True ** when creating the plot.
348356
349- The callback of the plot will run when the plot is being queried.
357+ The callback of the plot will run when the plot is being queried (dragging five circles).
358+ Or not using plot's callback but drag rect's callback *dpg.add_drag_rect(callback=...) *.
350359
351360All the query areas are sent through the *app_data * argument as
352- *[( x_min, x_max, y_min , y_max), (x_min, x_max, y_min , y_max), ...] *.
361+ *(( x_min, y_min, x_max , y_max), (x_min, y_min, x_max , y_max), ...) *.
353362
354363It is also possible to poll the plot for the query areas by calling:
355364:py:func: `get_plot_query_rects <dearpygui.dearpygui.get_plot_query_rects> ` and
@@ -370,16 +379,22 @@ Below is an example using the callback
370379 sindatay.append(0.5 + 0.5 * sin(50 * i / 100 ))
371380
372381 with dpg.window(label = " Tutorial" , width = 400 , height = 600 ):
373- dpg.add_text(" Click and drag the middle mouse button over the top plot!" )
382+ dpg.add_text(" Ctrl and drag the right mouse button over the top plot!" )
374383
375384
376385 def query (sender , app_data , user_data ):
377- dpg.set_axis_limits(" xaxis_tag2" , app_data[0 ], app_data[1 ])
378- dpg.set_axis_limits(" yaxis_tag2" , app_data[2 ], app_data[3 ])
386+ # TODO : handle for when app_data is empty - IndexError: tuple index out of range.
387+ rect_0 = app_data[0 ]
388+ # other_rects = app_data[1:]
389+ dpg.set_axis_limits(" xaxis_tag2" , rect_0[0 ], rect_0[2 ])
390+ dpg.set_axis_limits(" yaxis_tag2" , rect_0[1 ], rect_0[3 ])
379391
380392
381393 # plot 1
382- with dpg.plot(no_title = True , height = 200 , callback = query, query = True , no_menus = True , width = - 1 ):
394+ with dpg.plot(
395+ no_title = True , height = 200 , callback = query, query = True , no_menus = True , width = - 1 ,
396+ min_query_rects = 0 , max_query_rects = 3 ,
397+ ):
383398 dpg.add_plot_axis(dpg.mvXAxis, label = " x" )
384399 dpg.add_plot_axis(dpg.mvYAxis, label = " y" )
385400 dpg.add_line_series(sindatax, sindatay, parent = dpg.last_item())
@@ -593,4 +608,4 @@ Gallery
593608
594609.. image :: https://raw.githubusercontent.com/wiki/epezent/implot/screenshots3/heat.gif
595610
596- .. image :: https://raw.githubusercontent.com/wiki/epezent/implot/screenshots3/tables.gif
611+ .. image :: https://raw.githubusercontent.com/wiki/epezent/implot/screenshots3/tables.gif
0 commit comments