#7379 closed enhancement (fixed)
layout interact controls
Reported by: | jason | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-4.5 |
Component: | notebook | Keywords: | |
Cc: | mpatel, robert.marik, timdumol, mhansen, was, mhampton | Merged in: | sage-4.5.rc1 |
Authors: | Jason Grout | Reviewers: | Marshall Hampton |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
A user should be able to specify a layout for interact controls.
Attachments (2)
Change History (22)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
- Cc mpatel added
comment:3 Changed 13 years ago by
- Cc robert.marik added
- Report Upstream set to N/A
comment:4 Changed 12 years ago by
- Cc timdumol mhansen was added
- Status changed from new to needs_review
Two patches are attached: one for sagenb, and one for sage devel repository.
CCing timdumol (naturally, for the notebook/decorator stuff), and mhansen (for the decorator trickery) and was
comment:5 Changed 12 years ago by
- Cc mhampton added
CCing mhampton, who has expressed interest in looking at this patch before.
comment:6 Changed 12 years ago by
See #8959 for further extensions of this idea that allow arbitrary HTML in the layout.
comment:7 Changed 12 years ago by
The patch at #8959 doesn't quite allow the user to specify arbitrary HTML yet, but does allow the controls to be placed on any of the four sides of the interact.
Please, please review the patch at #8959 after reviewing this patch. The patch there extends the functionality of the patch here, and should be easy to review after you've looked at this patch.
comment:8 Changed 12 years ago by
This is great, thanks very much for working on it. The only problem I've seen so far is the following doctest failure for the notebook:
sage -t "local/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/interact.py" ********************************************************************** File "/Users/mh/sagestuff/sage-4-x/local/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/interact.py", line 2205: sage: @interact def _(n=(Integer(10),Integer(100),Integer(1)), auto_update=False): show(factor(x**n - Integer(1))) Exception raised: Traceback (most recent call last): File "/Users/mh/sagestuff/sage-4-x/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Users/mh/sagestuff/sage-4-x/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Users/mh/sagestuff/sage-4-x/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_99[9]>", line 2, in <module> def _(n=(Integer(10),Integer(100),Integer(1)), auto_update=False): File "/Users/mh/sagestuff/sage-4-x/local/lib/python/site-packages/sage/misc/misc.py", line 2632, in my_wrap return func(*args) File "/Users/mh/sagestuff/sage-4-x/local/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/interact.py", line 2519, in interact html(C.render()) File "/Users/mh/sagestuff/sage-4-x/local/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/interact.py", line 2058, in render s = "%s%s"%(self.render_controls(), self.render_output()) File "/Users/mh/sagestuff/sage-4-x/local/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/interact.py", line 1994, in render_controls layout = [[c.var()] for c in self.__controls] AttributeError: 'UpdateButton' object has no attribute 'var'
I'll try to do a little more testing and look at #8959 this weekend.
comment:9 Changed 12 years ago by
mhampton: that's a corner case in the @interact functionality (a magic parameter). I see two possible fixes: fix @interact to make this not a corner case (i.e., not a magic parameter), or move the auto_update switch into the @interact arguments:
@interact(auto_update=False) def _(...) ...
comment:10 Changed 12 years ago by
The reason auto_update was included in the function arguments, rather than the @interact arguments, is given here: http://groups.google.com/group/sage-devel/browse_thread/thread/9ff935e0d6a729b3/b295d52d195ac9ec?lnk=gst&q=interact#b295d52d195ac9ec
However, with this patch is a decorator that transparently and easily takes care of the objection. Are there any objections now to moving the auto_update argument up to the @interact decorator (other than backwards compatibility)?
Mike? William? You guys were the ones that objected to @interact(auto_update=False) in the thread listed above.
comment:11 Changed 12 years ago by
I think it's fine with the decorator defaults patch.
comment:12 Changed 12 years ago by
I just posted a long message to sage-notebook for a vote.
comment:13 Changed 12 years ago by
- Owner changed from boothby to jason
I'm posting a fix to the auto_update doctest that Marshall mentioned on #8959.
comment:14 Changed 12 years ago by
- Status changed from needs_review to positive_review
OK, with the fix in 8959 I see no problems with this. I've tested a bunch of interacts from the wiki, and there seem to be no back-compatibility issues. So I think I can give this a positive review.
comment:15 Changed 12 years ago by
- Reviewers set to M
- Status changed from positive_review to needs_work
The patch causes the followinger doctest error:
File "/opt/sage/local/lib/python2.6/site-packages/sagenb-0.8.1-py2.6.egg/sagenb/notebook/interact.py", line 2209: sage: @interact def _(n=(Integer(10),Integer(100),Integer(1)), auto_update=False): show(factor(x**n - Integer(1))) Exception raised: Traceback (most recent call last): File "/opt/sage/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/opt/sage/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/opt/sage/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_99[9]>", line 2, in <module> def _(n=(Integer(10),Integer(100),Integer(1)), auto_update=False): File "/opt/sage/local/lib/python/site-packages/sage/misc/misc.py", line 2666, in my_wrap return func(*args) File "/opt/sage/local/lib/python2.6/site-packages/sagenb-0.8.1-py2.6.egg/sagenb/notebook/interact.py", line 2523, in interact html(C.render()) File "/opt/sage/local/lib/python2.6/site-packages/sagenb-0.8.1-py2.6.egg/sagenb/notebook/interact.py", line 2062, in render s = "%s%s"%(self.render_controls(), self.render_output()) File "/opt/sage/local/lib/python2.6/site-packages/sagenb-0.8.1-py2.6.egg/sagenb/notebook/interact.py", line 1998, in render_controls layout = [[c.var()] for c in self.__controls] AttributeError: 'UpdateButton' object has no attribute 'var'
Marking this as "needs work."
comment:16 Changed 12 years ago by
- Status changed from needs_work to needs_info
In the two comments above yours, it says that the doctest is fixed in #8959. Did you apply that patch as well?
comment:17 Changed 12 years ago by
- Status changed from needs_info to needs_review
I didn't notice the comment. Sorry! The doctests do pass now. Marking as positive review (we really do need to add a pathway from needs_info to positive review).
comment:18 Changed 12 years ago by
- Reviewers changed from M to Marshall Hampton
- Status changed from needs_review to positive_review
comment:19 Changed 12 years ago by
- Merged in set to SageNB 0.8.1
- Resolution set to fixed
- Status changed from positive_review to closed
comment:20 Changed 12 years ago by
- Merged in changed from SageNB 0.8.1 to sage-4.5.rc1
Merged the sage-devel patch in sage-4.5.rc1.
Here is a patch to the sagenb directory which allows for the following: