-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Text box widget #5375
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
Text box widget #5375
Conversation
It looks like I messed up some formatting. This is my first pull request, is the procedure to close this, fix the formatting, then open a new pull request? |
No, you created a separate branch for this PR, so you can just add on to it and push. If it becomes too long, we might request that you rebase too. |
There is at least one other quasi-dead PR open which tries to add this. #1983 |
A GUI neutral text input box. | ||
|
||
For the text box to remain responsive | ||
you must keep a reference to it. |
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.
Please make lines in docstrings as long as will fit in 80 columns.
This is cool work, and as you say, has been requested many times. A couple of other things I'd like to see: The mouse cursor should change to an I-beam when hovering over the text widget. Clicking within the string should move the insertion cursor. |
I went through and fixed the formatting issues you pointed out. Thanks! To my knowledge, there isn't currently a backend-agnostic way to set the cursor, so implementing the hover I-beam would require writing different code for each backend. All the other widgets light up when moused over, so I mimicked that behavior to indicate that this is a clickable element. I will look into adding the ability to move the cursor by clicking, and moving to pixel coordinates for the cursor. |
You can call
It shouldn't be too much trouble to add that in all backends, though. They all follow the same pattern.
What do you mean, specifically? |
I've been wanting a textbox widget for a while, and I'm excited to see that there is already a PR in place! Any chance that this will move forward soon? EDIT: This widget seems to work very well on OSX. The typing is a little bit laggy, and there is the above-mentioned problem that when you click on the text the cursor does not move, which may frustrate some people. But these are minor details in my opinion – the basic functionality is great! |
Yeah, it's good to hear that there's interest! I'll work on it this On Fri, Jan 15, 2016 at 1:36 PM, Danhickstein [email protected]
|
One other small issue: the label text seems a little bit too close to the textbox, and adding spaces to the string has no effect. An example: import matplotlib.pyplot as plt
from matplotlib.widgets import TextBox
TextBox(plt.axes([0.5, 0.5, .2, .2]),'This is the label ')
TextBox(plt.axes([0.5, 0.2, .2, .2]),'This is the label')
plt.show() Thanks again for making this feature. I am using it make a quick-and-easy MPL-widgets based GUI and it's working nicely. EDIT: I would suggest to include an option to set the padding between the label and the axes. Something like changing line 683 or widgets.py to: self.label = ax.text(-label_pad, 0.5, label, and including def __init__(self, ax, label, initial='',label_pad=0.05, |
What should I do to fix the failed check "AppVeyor was unable to build non-mergable pull request" ? |
You will need to fetch master and rebase this branch to fix the merge conflicts. |
If you are using the GitHub Desktop app, then you just hit the button "Update from matplotlib/master". I think that the only conflict is with the Is |
Pleas make sure you rebase + forcepush rather than merging master into your feature branch. |
Oh yes, I suppose that rebasing avoids a lot of clutter in the git history. Anyway, @QuadmasterXLII, you should go ahead and do that so that this can be merged. |
…ed when text changes or text is submitted
…to aid readability
…and text from getting misaligned
626feae
to
b26ec58
Compare
@QuadmasterXLII - you should rebase this so that it can be merged. I've been using these textboxes all the time for the last few months and they work great. (Well, pretty well. It's annoying that you can't click on move the cursor. But nothing's perfect...) |
I did a rebase but appveyor is saying it fails. What should I do next? |
You can click on the appveyor build that failed and see the error. Unfortunately, it's not clear to me what's going wrong. It's a build from 18 days ago, so it hasn't been updated in a while. I'm not sure how to get it to rebuild aside from making some small commit to this fork. |
I think it's ready for merger now! |
Nice work @QuadmasterXLII! It might also need a unit test in /lib/matplotlib/tests/test_widgets.py? |
You should add a set_val function, similar to the set_val function for Slider.
|
Really nice, one last thing @QuadmasterXLII can you squash the commits? |
Hi! I just tested this PR, it looks lovely, I don't know why this is not yet in matplotlib (yeah, nobody had taken care of this I guess :) ). I have just one small request: When the user click outside of the text box, the Anyway, thanks for this, it still get the work done ! Edit: I tested by copy/paste the code with py3, matploblib 1.5.2, debian 8 and commented out two lines because of |
@fariza Can you be responsible for getting this merged? I am not super worried about squashing the commits, but the changes from @smithsp should probably get included (modulo the We have not heard from @QuadmasterXLII , it might be most expedient if @fariza just took over and opened a new PR. @Nodraak Yes, development is mostly by volunteers with day jobs, things can fall through the cracks 😞 . Could you work with @fariza and @QuadmasterXLII to get that change integrated with this PR? |
Replaced by #6988 |
Several users (myself included) have wanted the ability to do text input as a widget. This text box widget is implemented by capturing keystrokes and adding them to a string, with special cases for keys like "enter", "left", "right" etc.
http://stackoverflow.com/questions/25231449/do-text-number-input-fields-exist-in-matplotlib
http://stackoverflow.com/questions/25449398/matplotlib-user-enters-numeric-input-through-figure