-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Added a TextBox widget #1983
Conversation
@keflavich - I've looked at doing something similar in the past, so I'm definitely in favour of this addition. I plan to have a good look through this PR in the coming weeks - but I'm hopeful we can squeeze this into v1.3.0. Thanks for submitting! |
@pelson - I'm sure I can come up with some tests. Yes, MPL shortcuts directly interfere: the |
What about this as a middle option?
|
I like that approach. How can this be accomplished? i.e., is there any way to know which connections in the |
There is a single callback that handles all of the default keys in matplotlib in We could certainly add Then, when a TextWidget is added to the canvas, it could set a flag. In
But all of that is off the top of my head -- we'd have to really try this out, I think, and run it by some users who build applications using these key press callbacks to make sure we're not breaking anything in the process. |
On 2013/05/08 7:23 AM, Michael Droettboom wrote:
That sounds reasonable to me. |
This may be fixed in master, but this doesn't work with the macos backend on v1.2.0 due to the FigureCanvasMac not having a copy_from_bbox() method. It is also calling Text.get_window_extents() in init and failing with a RuntimeError "RuntimeError: Cannot get window extent w/o renderer" Runs great with tkAgg backend, though. |
Should the mac backend have a |
This has been a long-running issue, related to blitting. With the way |
ax.set_navigate(False) | ||
self.canvas.draw() | ||
|
||
self.region = self.canvas.copy_from_bbox(ax.bbox) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
https://gist.github.com/mrterry/5703912 I've done some surgery on your TextBox. I make no promise regarding the quality of my practice : ) This TextBox variant does a few things
There is something buggy in the callback twiddling section when using the macos backend. The callbacks seem to be twiddled correctly (it works for TkAgg). |
@mterry want to submit that as a PR on this PR? |
Textboxwidget
This also needs an entry in the |
I haven't forgotten about this. All the backends ought to accept backspace |
Sooo this would be a really awesome feature to have...whats the status? |
@mrterry What is the status of making sure everything will take backspace? |
Note: Whilst we can't do too much integration testing on this, it'd be good to get some unit tests for the TextBox class. |
@pelson - are there any unit tests for other widgets we could use as a template/starting point? I don't see any in the tests directory now. |
Afraid not. matplotlib was virtually test free just a few years ago 😒. |
Hey, still not merged??? Damn! |
😄 - it just needs a few unit tests and an entry in the "what's new" documentation and it will make it into v1.4... |
This has issues with unicode literals and py3k |
@keflavich Are you going to have time to work on this in the near future? |
Unlikely, sorry. I'll readily accept PRs on it, but you can take over |
I am to punting this to 1.5 unless someone volunteers to take it over. |
Replaced by #6988 |
This PR adds an editable TextBox widget based on the text box on some ancient mailing list threads. It adds some features:
activate
callback (so you click on it to edit)enter
callback (pressing enter does something)s
doesn't activate the save dialog)I can add some example usage, but it would be helpful to have some initial feedback. It would certainly be preferable to have a fully-active text box (i.e., one where mouse-highlighting, shift-selection, etc.) can be used to edit the text, but frankly that seems overwhelming at the moment.
The main use-case for this text box is changing numbers directly. I've used it specifically for communication with a slider: changing the slider value & limits via text entry.
I'd also like to see or create a drop-down text menu, but given the difficulty in getting this to work at all (and not very prettily), I think backend-specific approaches may prove better.