You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2dc3027
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: v3/docs/embedding-HOWTO.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,14 @@ Look at the Git history to see when this document was last updated; the more tim
9
9
elapsed since that date, the more likely things are out-of-date.
10
10
11
11
I'm assuming that you're competent in Python, JavaScript, command-line-fu, and Google-fu,
12
-
and general [command-line BS](http://www.pgbovine.net/command-line-bullshittery.htm),
13
-
so I won't do much hand-holding in these directions.
14
-
15
-
This guide isn't meant to be comprehensive; you will undoubtedly still
12
+
and [command-line BS](http://www.pgbovine.net/command-line-bullshittery.htm). This guide isn't meant to be comprehensive; you may still
16
13
be confused about details after reading it, so feel free to email
17
14
philip@pgbovine.net if you have questions.
18
15
19
16
20
17
## iframe embedding
21
18
22
-
An easy (although somewhat limited) way to embed an OPT visualization on your website is to enclose it within an [iframe](http://www.w3schools.com/tags/tag_iframe.asp).
19
+
An easy way to embed an OPT visualization on your website is to enclose it within an [iframe](http://www.w3schools.com/tags/tag_iframe.asp).
23
20
24
21
If you generate a visualization (e.g., <ahref="http://pythontutor.com/visualize.html#code=x+%3D+5%0Ay+%3D+10%0Az+%3D+x+%2B+y&mode=display&cumulative=false&py=2&curInstr=3">click here</a>)
25
22
and then click the "Generate embed code" button at the bottom of the page, the following code will be generated:
@@ -32,7 +29,9 @@ and then click the "Generate embed code" button at the bottom of the page, the f
32
29
33
30
If you copy-and-paste the above code into your HTML webpage, then it will embed the given visualization as an iframe.
34
31
35
-
See `v3/iframe-embed-demo.html` for a working demo showing several embedded iframes ([online here](http://pythontutor.com/iframe-embed-demo.html)).
32
+
Change `http://` to `https://` in the `src` attribute if you want to embed it in a webpage served over https.
33
+
34
+
See [v3/iframe-embed-demo.html](../iframe-embed-demo.html) for a working demo showing several embedded iframes ([online here](http://pythontutor.com/iframe-embed-demo.html)).
36
35
37
36
38
37
### iframe embedding parameters
@@ -42,7 +41,7 @@ after the hash mark (`#` character) in the `src=` URL string. Note that OPT uses
42
41
question mark `?` query string. Here are the currently-supported parameters:
43
42
44
43
-`code` - The Python code to visualize (mandatory: URL-encoded string)
45
-
-`py` - Python interpreter version (mandatory: `2` for Python 2.7 or `3` for Python 3.2)
44
+
-`py` - Language version (mandatory: `2` for Python 2.7 or `3` for Python 3.3, other languages: js, ts, ruby, java, c, cpp)
46
45
-`verticalStack` - Set to `true` if you want the code and visualization to stack atop one another (optional)
47
46
-`curInstr` - A (zero-indexed) integer of the execution point to directly jump to in the visualization (optional)
48
47
-`cumulative` - Set to `true` if you want exited functions to be displayed (optional)
@@ -76,6 +75,7 @@ or, say, a USB drive), they can play with the visualization without an Internet
76
75
Finally, multiple visualizations can be embedded in a single HTML webpage, although you need to be careful
77
76
to redraw the SVG arrows when page elements are resized or moved.
78
77
78
+
79
79
### The Nitty-Gritty
80
80
81
81
Let's attempt to go [literate programming](http://en.wikipedia.org/wiki/Literate_programming) style now ... load up
0 commit comments