8000 Added a TextBox widget by keflavich · Pull Request #1983 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Added a TextBox widget #1983

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

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lazy cursor
  • Loading branch information
Matt Terry committed Jun 4, 2013
commit 557adaa70bef25cc46387dd01083fec334243d9e
14 changes: 12 additions & 2 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,10 +1711,9 @@ def __init__(self, ax, s='', horizontalalignment='left',

self.region = self.canvas.copy_from_bbox(ax.bbox)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.region is not used by TextBox or Widget. Do other things assume it is there or can it be dropped? Dropping it would help appease macos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; I have no idea if other things will assume it. But perhaps a try/except around this would be the safest way to go, not knowing any better?


self._cursor = None
self._cursorpos = len(self.text.get_text())
r = self._get_text_right()

self.cursor, = ax.plot([r,r], [0.2, 0.8], transform=ax.transAxes)
self.active = False

self.redraw()
Expand All @@ -1724,6 +1723,17 @@ def __init__(self, ax, s='', horizontalalignment='left',

self.canvas.mpl_connect('button_press_event',self._mouse_activate)

@property
def cursor(self):
# Macos has issues with render objects. Lazily generating the cursor
# solve some of the problems associated
if self._cursor is None:
r = self.get_text_right() # needs a renderer
self._cursor, = self.ax.plot([r,r], [0.2, 0.8],
transform=self.ax.transAxes)
self._cursor.set_visible(False)
return self._cursor

def redraw(self):
# blitting doesn't clear old text
#self.ax.redraw_in_frame()
Expand Down
0