added crosshair cursor and better cursor position display
This commit is contained in:
@@ -2322,6 +2322,24 @@ class MonitorWidgets:
|
|||||||
# Matplot Toolbar hinzufuegen (Display_Table, 2. Zeile)
|
# Matplot Toolbar hinzufuegen (Display_Table, 2. Zeile)
|
||||||
self.matplot_toolbar = matplotlib.backends.backend_gtk3.NavigationToolbar2GTK3( self.matplot_canvas )
|
self.matplot_toolbar = matplotlib.backends.backend_gtk3.NavigationToolbar2GTK3( self.matplot_canvas )
|
||||||
|
|
||||||
|
# Make cursor position text bigger and bold - access message label directly
|
||||||
|
try:
|
||||||
|
# The coordinate label is stored in the toolbar's message attribute
|
||||||
|
if hasattr(self.matplot_toolbar, 'message'):
|
||||||
|
self.matplot_toolbar.message.modify_font(pango.FontDescription("sans bold 16"))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Add cursor toggle button to toolbar
|
||||||
|
self.matplot_cursor = None
|
||||||
|
separator = gtk.SeparatorToolItem()
|
||||||
|
self.matplot_toolbar.insert(separator, self.matplot_toolbar.get_n_items())
|
||||||
|
cursor_btn = gtk.ToggleToolButton()
|
||||||
|
cursor_btn.set_label("Cursor")
|
||||||
|
cursor_btn.set_tooltip_text("Toggle crosshair cursor")
|
||||||
|
cursor_btn.connect("toggled", self.toggle_cursor)
|
||||||
|
self.matplot_toolbar.insert(cursor_btn, self.matplot_toolbar.get_n_items())
|
||||||
|
|
||||||
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 )
|
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 )
|
||||||
self.matplot_toolbar.show( )
|
self.matplot_toolbar.show( )
|
||||||
|
|
||||||
@@ -2743,6 +2761,15 @@ class MonitorWidgets:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def toggle_cursor(self, widget):
|
||||||
|
"""Toggle matplotlib crosshair cursor"""
|
||||||
|
from matplotlib.widgets import Cursor
|
||||||
|
if widget.get_active():
|
||||||
|
self.matplot_cursor = Cursor(self.matplot_axes, useblit=False, color='red', linewidth=1)
|
||||||
|
else:
|
||||||
|
self.matplot_cursor = None
|
||||||
|
self.matplot_canvas.draw()
|
||||||
|
|
||||||
def on_canvas_button_press(self, widget, event):
|
def on_canvas_button_press(self, widget, event):
|
||||||
"""Handle button press events on matplotlib canvas"""
|
"""Handle button press events on matplotlib canvas"""
|
||||||
if event.button == 3: # Right click
|
if event.button == 3: # Right click
|
||||||
|
|||||||
Reference in New Issue
Block a user