-
-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Right-clicking legend does not pop up button #2409
Comments
import dearpygui.dearpygui as dpg
from math import sin
dpg.create_context()
sindatax = []
sindatay = []
for i in range(0, 100):
sindatax.append(i / 100)
sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
def toggle_drag_line_cb(sender, app_data, user_data):
dpg.configure_item(drag_line, show=app_data) # app_data in this case is checkbox's value
# dpg.show_item
# dpg.hide_item
with dpg.window(label="Tutorial", width=400, height=400):
dpg.add_checkbox(label="toggle drag_line", callback=lambda s, a, u: toggle_drag_line_cb(s, a, u))
with dpg.plot(label="Line Series", height=-1, width=-1):
dpg.add_plot_legend()
drag_line = dpg.add_drag_line() # drag_line is added to plot, not like series
dpg.add_plot_axis(dpg.mvXAxis, label="x")
dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="yaxis")
dpg.add_line_series(sindatax, sindatay, label="series 1", parent="yaxis", tag="series_1")
dpg.add_line_series(sindatax, sindatay, label="series 2", parent="yaxis", tag="series_2")
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
Thank you but my question is actually about "Delete Series 1"button. |
Ah, it's really that I've tested that DPG 1.11.1 showing fine, but not DPG2.0. |
Lines 502 to 513 in 65c2620
|
Temporary workaround for DPG 2.0 is toggle hide all drag items like using checkbox's callback above (after that you can right click legend to show buttons). # Here's some code anyone can copy and paste to reproduce your issue
import dearpygui.dearpygui as dpg
from math import sin
dpg.create_context()
dpg.show_item_registry()
sindatax = []
sindatay = []
for i in range(0, 100):
sindatax.append(i / 100)
sindatay.append(0.5 + 0.5 * sin(50 * i / 100))
with dpg.window(label="Tutorial", width=400, height=400):
# create plot
dpg.add_text("Right click a series in the legend!")
dpg.add_checkbox(label="toggle drag items", callback=lambda s, a, u: [
dpg.configure_item(a_drag_line, show=a), dpg.configure_item(a_drag_point, show=a)
]
)
with dpg.plot(label="Line Series", height=-1, width=-1) as plot_1:
dpg.add_plot_legend()
# show=True >> buttons won't show
a_drag_line = dpg.add_drag_line(parent=plot_1, show=True)
a_drag_point = dpg.add_drag_point()
# custom_series ?
dpg.add_plot_axis(dpg.mvXAxis, label="x")
dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="yaxis")
# series 1
dpg.add_line_series(sindatax, sindatay, label="series 1", parent="yaxis", tag="series_1")
btn_1 = dpg.add_button(label="Delete Series 1", parent=dpg.last_item(), callback=lambda: dpg.delete_item("series_1"))
# series 2
dpg.add_line_series(sindatax, sindatay, label="series 2", parent="yaxis", tag="series_2")
dpg.add_button(label="Delete Series 2", parent=dpg.last_item(), callback=lambda: dpg.delete_item("series_2"))
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
Likely that DPG 2.0 duplicate series items for each drag item - different hide/show each combination. 2 series + 2 drag item can result in: 4 or 6 series, (only 2 in that 4 or 6 get to show 2 buttons). |
Thank you very much for your job! |
Version of Dear PyGui
Version: 2.0.0
Operating System: Windows 11
My Issue/Question
After adding the dpg.add_drag_line(), right-clicking legend does not pop up button.
To Reproduce
The text was updated successfully, but these errors were encountered: