Layout issues / caption location in GlowScript

24 views
Skip to first unread message

Daniel Schroeder

unread,
Dec 31, 2017, 9:27:04 AM12/31/17
to VPython-users
This is just a cosmetic issue, and I've found a way to fix it, but it drove me nuts for a long time so I thought I'd share what I've learned and ask if there's a better solution.

I want a scene/canvas and a graph side by side, and the documentation says to set scene.align to "left" and set the graph's align attribute to "right". But I also want a caption underneath the canvas, and it appears above the graph instead. Here's a stripped-down example:

scene.width = 400
scene.align = "left"
box()
scene.append_to_caption("Here's the caption")
theGraph = graph(align="right", width=400, height=400)
theData = gdots(pos=[[0,0]])

The solution I've found is to create the graph first, and *not* set scene.align to "left":

theGraph = graph(align="right", width=400, height=400)
theData = gdots(pos=[[0,0]])
scene.width = 400
# scene.align = "left"
box()
scene.append_to_caption("Here's the caption")
 
Is this a bug or a feature? Are there other undocumented layout tricks I should know about?

Bruce Sherwood

unread,
Dec 31, 2017, 10:47:29 AM12/31/17
to VPython-users
Nice! It's not a bug or a feature, just a consequence of my lack of expertise with jquery.

Bruce

Bruce Sherwood

unread,
Dec 31, 2017, 10:50:07 AM12/31/17
to VPython-users
To be clear: The scheme you found is clearly useful, and I don't consider it a bug to be "fixed".

Bruce

Daniel Schroeder

unread,
Dec 31, 2017, 11:49:48 AM12/31/17
to VPython-users
Fair enough. What I think I would suggest, then, is adding a couple sentences to the documentation, both to mention explicitly that scene.align="left" puts the caption to the right of the canvas, and to mention that you can put a graph (or another canvas, I guess) on the right by inserting it first (with align="right"), in which case you don't need to set scene.align="left". Or maybe you can think of a higher-level way to concisely address some of these layout issues. (I know that layout is a pain in any environment!)

Another layout quirk that puzzles me is slider placement within a caption. The way it works is totally usable (at least for what I've done so far), but it sure is hard to understand why a slider appears at the left of the current line while other widgets (afaik) appear in the order in which they're created.

Dan

Bruce Sherwood

unread,
Jan 1, 2018, 11:43:34 AM1/1/18
to VPython-users
I've updated the documentation accordingly. I've also added comments to the documentation of mouse events and widgets the following information about functions that are bound to events:

Important limitation of GlowScript VPython: The bound function cannot contain the statements rate, sleep, pause, waitfor, get_library, or read_local_file, statements that require pausing during execution. This limitation does not apply to VPython 7.

Bruce

Bruce Sherwood

unread,
Jan 1, 2018, 11:47:01 AM1/1/18
to VPython-users
As for slider positioning, I wrestled with this a lot, unsuccessfully. However, I'll point out an extraordinary little-known fact. The RapydScript-NG Python-to-JavaScript transpiler accepts jquery statements intermingled with Python statements! So if you who is reading this note is expert in the use of jquery, you might experiment with positioning sliders using jquery and report what you find.

Bruce

Reply all
Reply to author
Forward
0 new messages