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
8000
Prev Previous commit
Next Next commit
rename (de)activate, remove inconsistent active properties
  • Loading branch information
Matt Terry committed Jun 4, 2013
commit 4110887165739ee6aba97d794bc35f6458222cab
22 changes: 7 additions & 15 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,17 +1746,7 @@ def _mouse_activate(self, event):
else:
self.deactivate()

@property
def active(self):
return self._active

@active.setter
def active(self, isactive):
self._active = bool(isactive)
self.cursor.set_visible(self._active)
self.redraw()

def activate(self):
def begin_text_entry(self):
if self._cid not in self.canvas.callbacks.callbacks['key_press_event']:

if not hasattr(self,'old_callbacks'):
Expand All @@ -1768,16 +1758,18 @@ def activate(self):
self.old_callbacks[k] = self.canvas.callbacks.callbacks['key_press_event'].pop(k)

self._cid = self.canvas.mpl_connect('key_press_event', self.keypress)
self.active = True
self.cursor.set_visible(True)
self.redraw()

def deactivate(self):
def end_text_entry(self):
if self._cid in self.canvas.callbacks.callbacks['key_press_event']:
self.canvas.mpl_disconnect(self._cid)
if hasattr(self,'old_callbacks'):
for k in self.old_callbacks:
self.canvas.callbacks.callbacks['key_press_event'][k] = self.old_callbacks[k]

self.active = False
self.cursor.set_visible(False)
self.redraw()

def keypress(self, event):
"""
Expand All @@ -1801,7 +1793,7 @@ def keypress(self, event):
if self.enter_callback is not None:
try:
self.enter_callback(self.value)
self.deactivate()
self.end_text_entry()
except Exception as ex:
print(ex)

Expand Down
0