reworked the cursor
This commit is contained in:
+29
-9
@@ -2287,6 +2287,23 @@ class MonitorWidgets:
|
||||
|
||||
# add matplotlib toolbar (display_table, 2nd row)
|
||||
self.matplot_toolbar = matplotlib.backends.backend_gtk3.NavigationToolbar2GTK3( self.matplot_canvas )
|
||||
# remove subplots:
|
||||
#self.matplot_toolbar.DeleteToolByPos(1)
|
||||
#self.matplot_toolbar.remove(self.matplot_toolbar.get_nth_item(3))
|
||||
self.matplot_toolbar.remove(self.matplot_toolbar.get_nth_item(6))
|
||||
# now let's add a button to the toolbar
|
||||
button = gtk.ToggleButton(label='')
|
||||
try:
|
||||
image = gtk.Image.new_from_file("/usr/share/icons/breeze/actions/24/crosshairs-symbolic.svg")
|
||||
button.set_image(image)
|
||||
except:
|
||||
pass
|
||||
button.set_tooltip_text('Enable Crosshairs')
|
||||
button.show()
|
||||
button.connect('toggled', self.toggle_cursor)
|
||||
toolitem = gtk.ToolItem()
|
||||
toolitem.add(button)
|
||||
self.matplot_toolbar.insert(toolitem, 5)
|
||||
|
||||
# Make cursor position text bigger and bold - access message label directly
|
||||
try:
|
||||
@@ -2314,6 +2331,12 @@ class MonitorWidgets:
|
||||
# enable display scaling
|
||||
self.display_x_scaling_combobox.set_active( 0 )
|
||||
self.display_y_scaling_combobox.set_active( 0 )
|
||||
for i in ("lin", "log10"):
|
||||
self.display_x_scaling_combobox.append_text(i)
|
||||
self.display_y_scaling_combobox.append_text(i)
|
||||
self.display_x_scaling_combobox.append_text("ppm")
|
||||
self.display_x_scaling_combobox.set_active(0)
|
||||
self.display_y_scaling_combobox.set_active(0)
|
||||
self.display_x_scaling_combobox.set_sensitive( True )
|
||||
self.display_y_scaling_combobox.set_sensitive( True )
|
||||
|
||||
@@ -2720,19 +2743,16 @@ class MonitorWidgets:
|
||||
|
||||
def toggle_cursor(self, widget):
|
||||
"""Toggle matplotlib crosshair cursor"""
|
||||
from matplotlib.widgets import Cursor
|
||||
if widget.get_active():
|
||||
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||
self.matplot_cursor.disconnect_events()
|
||||
self.matplot_cursor = Cursor(self.matplot_axes, useblit=False, color='red', linewidth=1)
|
||||
self.matplot_cursor = matplotlib.widgets.Cursor(self.matplot_axes, useblit=False, color='red', linewidth=1)
|
||||
else:
|
||||
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||
self.matplot_cursor.disconnect_events()
|
||||
self.matplot_cursor = None
|
||||
if hasattr(self, 'matplot_cursor'):
|
||||
self.matplot_cursor = None
|
||||
self.matplot_canvas.draw_idle()
|
||||
|
||||
def on_canvas_button_press(self, widget, event):
|
||||
"""Handle button press events on matplotlib canvas"""
|
||||
|
||||
if event.button == 3: # Right click
|
||||
self.show_canvas_context_menu(event)
|
||||
return True
|
||||
@@ -2752,7 +2772,6 @@ class MonitorWidgets:
|
||||
toggle_cursor.connect("toggled", self.toggle_cursor)
|
||||
menu.append(toggle_cursor)
|
||||
|
||||
|
||||
# Copy as PNG
|
||||
item_copy_png = gtk.MenuItem(label="Copy as PNG")
|
||||
item_copy_png.connect("activate", self.copy_canvas_as_png)
|
||||
@@ -2843,9 +2862,10 @@ class MonitorWidgets:
|
||||
"""
|
||||
self.display_x_scaling_combobox.set_sensitive( True )
|
||||
self.display_y_scaling_combobox.set_sensitive( True )
|
||||
|
||||
x_scale = self.display_x_scaling_combobox.get_active_text()
|
||||
y_scale = self.display_y_scaling_combobox.get_active_text()
|
||||
|
||||
print(x_scale)
|
||||
if x_scale == "lin":
|
||||
self.matplot_axes.set_xscale("linear")
|
||||
elif x_scale == "log10":
|
||||
|
||||
+2
-15
@@ -1044,7 +1044,7 @@ Public License instead of this License.
|
||||
<object class="GtkLabel" id="label65">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Source </property>
|
||||
<property name="label" translatable="yes">Source:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@@ -1053,7 +1053,7 @@ Public License instead of this License.
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="display_source_combobox">
|
||||
<object class="GtkComboBox" id="display_source_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="add-tearoffs">True</property>
|
||||
@@ -1075,12 +1075,6 @@ Public License instead of this License.
|
||||
<property name="can-focus">False</property>
|
||||
<property name="focus-on-click">False</property>
|
||||
<signal name="changed" handler="on_display_y_scaling_combobox_changed" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="renderer1"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
@@ -1114,12 +1108,6 @@ Public License instead of this License.
|
||||
<property name="can-focus">False</property>
|
||||
<property name="focus-on-click">False</property>
|
||||
<signal name="changed" handler="on_display_x_scaling_combobox_changed" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="renderer2"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
@@ -1931,7 +1919,6 @@ Public License instead of this License.
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
||||
<object class="GtkComboBoxText" id="CompLibs">
|
||||
<property name="visible">True</property>
|
||||
<property name="model">model3</property>
|
||||
|
||||
Reference in New Issue
Block a user