| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3c0f3c6 commit 7208f3f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | 34 | # module definitions, mostly colors | |
| 35 | 35 | legend_border_color = '#777' | |
| 36 | - legend_fill_color = '#6668' | ||
| 36 | + legend_fill_color = '#666a' | ||
| 37 | 37 | legend_text_color = '#ddd6' | |
| 38 | 38 | soft_colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf'] | |
| 39 | 39 | hard_colors = ['#000000', '#772211', '#000066', '#555555', '#0022cc', '#ffcc00'] | |
@@ -1857,16 +1857,21 @@ def remove_primitive(primitive): | |||
| 1857 | 1857 | ax.vb.removeItem(txt) | |
| 1858 | 1858 | ||
| 1859 | 1859 | ||
| 1860 | - def set_time_inspector(inspector, ax=None, when='click'): | ||
| 1861 | - '''Callback when clicked like so: inspector(x, y).''' | ||
| 1860 | + def set_mouse_callback(callback, ax=None, when='click'): | ||
| 1861 | + '''Callback when clicked like so: callback(x, y).''' | ||
| 1862 | 1862 | ax = ax if ax else last_ax | |
| 1863 | 1863 | master = ax.ax_widget if hasattr(ax, 'ax_widget') else ax.vb.win | |
| 1864 | 1864 | if when == 'hover': | |
| 1865 | - master.proxy_hover = pg.SignalProxy(master.scene().sigMouseMoved, rateLimit=15, slot=partial(_inspect_pos, ax, inspector)) | ||
| 1865 | + master.proxy_hover = pg.SignalProxy(master.scene().sigMouseMoved, rateLimit=15, slot=partial(_mcallback_pos, ax, callback)) | ||
| 1866 | 1866 | elif when in ('dclick', 'double-click'): | |
| 1867 | - master.proxy_dclick = pg.SignalProxy(master.scene().sigMouseClicked, slot=partial(_inspect_clicked, ax, inspector, True)) | ||
| 1867 | + master.proxy_dclick = pg.SignalProxy(master.scene().sigMouseClicked, slot=partial(_mcallback_click, ax, callback, True)) | ||
| 1868 | 1868 | else: | |
| 1869 | - master.proxy_click = pg.SignalProxy(master.scene().sigMouseClicked, slot=partial(_inspect_clicked, ax, inspector, False)) | ||
| 1869 | + master.proxy_click = pg.SignalProxy(master.scene().sigMouseClicked, slot=partial(_mcallback_click, ax, callback, False)) | ||
| 1870 | + | ||
| 1871 | + | ||
| 1872 | + def set_time_inspector(callback, ax=None, when='click'): | ||
| 1873 | + print('Warning: set_time_inspector() is a misnomer from olden days. Please use set_mouse_callback() instead.') | ||
| 1874 | + set_mouse_callback(callback, ax, when) | ||
| 1870 | 1875 | ||
| 1871 | 1876 | ||
| 1872 | 1877 | def add_crosshair_info(infofunc, ax=None): | |
@@ -2616,14 +2621,14 @@ def _wheel_event_wrapper(self, orig_func, ev): | |||
| 2616 | 2621 | orig_func(self, ev) | |
| 2617 | 2622 | ||
| 2618 | 2623 | ||
| 2619 | - def _inspect_clicked(ax, inspector, when_double_click, evs): | ||
| 2624 | + def _mcallback_click(ax, callback, when_double_click, evs): | ||
| 2620 | 2625 | if evs[-1].accepted or when_double_click != evs[-1].double(): | |
| 2621 | 2626 | return | |
| 2622 | 2627 | pos = evs[-1].scenePos() | |
| 2623 | - return _inspect_pos(ax, inspector, (pos,)) | ||
| 2628 | + return _mcallback_pos(ax, callback, (pos,)) | ||
| 2624 | 2629 | ||
| 2625 | 2630 | ||
| 2626 | - def _inspect_pos(ax, inspector, poss): | ||
| 2631 | + def _mcallback_pos(ax, callback, poss): | ||
| 2627 | 2632 | if not ax.vb.datasrc: | |
| 2628 | 2633 | return | |
| 2629 | 2634 | point = ax.vb.mapSceneToView(poss[-1]) | |
@@ -2634,7 +2639,7 @@ def _inspect_pos(ax, inspector, poss): | |||
| 2634 | 2639 | if clamp_grid: | |
| 2635 | 2640 | t = ax.vb.datasrc.x.iloc[-1 if t > 0 else 0] | |
| 2636 | 2641 | try: | |
| 2637 | - inspector(t, point.y()) | ||
| 2642 | + callback(t, point.y()) | ||
| 2638 | 2643 | except OSError as e: | |
| 2639 | 2644 | pass | |
| 2640 | 2645 | except Exception as e: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,7 +54,7 @@ def update_crosshair_text(x, y, xtext, ytext): | |||
| 54 | 54 | ytext = '%s (Close%+.2f)' % (ytext, (y - df.iloc[x].Close)) | |
| 55 | 55 | return xtext, ytext | |
| 56 | 56 | ||
| 57 | - fplt.set_time_inspector(update_legend_text, ax=ax, when='hover') | ||
| 57 | + fplt.set_mouse_callback(update_legend_text, ax=ax, when='hover') | ||
| 58 | 58 | fplt.add_crosshair_info(update_crosshair_text, ax=ax) | |
| 59 | 59 | ||
| 60 | 60 | fplt.show() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments