2
2
3
3
# 📰 Presenter 📰
4
4
5
- SeleniumBase Presenter allows you to create an HTML presentation with only a few lines of Python.
5
+ SeleniumBase Presenter allows you to create HTML presentations with Python.
6
6
The Reveal-JS library is used for running the presentations.
7
7
8
- ** Here's a sample slide :**
8
+ ** Here's a sample presentation :**
9
9
10
- <img width =" 90% " src =" https://seleniumbase.io/other/presenter_screen.png " title =" Screenshot " ><br >
10
+ <a href = " https://seleniumbase.io/other/presenter.html " >< img width =" 500 " src =" https://seleniumbase.io/other/presenter.gif " title =" Screenshot " ></ a ><br >
11
11
12
12
Slides can include HTML, code, images, and iframes.
13
13
@@ -21,11 +21,15 @@ pytest my_presentation.py
21
21
### Creating a new presentation:
22
22
23
23
``` python
24
- self .create_presentation(name = None , show_notes = True )
24
+ self .create_presentation(name = None , theme = " serif " , show_notes = True )
25
25
""" Creates a Reveal-JS presentation that you can add slides to.
26
26
@Params
27
27
name - If creating multiple presentations at the same time,
28
28
use this to specify the name of the current presentation.
29
+ theme - Set a theme with a unique style for the presentation.
30
+ Valid themes: "serif" (default), "sky", "white", "black",
31
+ "simple", "league", "moon", "night",
32
+ "beige", "blood", and "solarized".
29
33
show_notes - When set to True, the Notes feature becomes enabled,
30
34
which allows presenters to see notes next to slides.
31
35
"""
@@ -40,14 +44,15 @@ Notes are enabled by default unless you specify:
40
44
41
45
``` python
42
46
self .add_slide(content = None , image = None , code = None , iframe = None ,
43
- notes = None , name = None )
47
+ content2 = None , notes = None , name = None )
44
48
""" Allows the user to add slides to a presentation.
45
49
@Params
46
50
content - The HTML content to display on the presentation slide.
47
51
image - Attach an image (from a URL link) to the slide.
48
52
code - Attach code of any programming language to the slide.
49
53
Language-detection will be used to add syntax formatting.
50
54
iframe - Attach an iFrame (from a URL link) to the slide.
55
+ content2 - HTML content to display after adding an image or code.
51
56
notes - Additional notes to include with the slide.
52
57
ONLY SEEN if show_notes is set for the presentation.
53
58
name - If creating multiple presentations at the same time,
@@ -59,11 +64,19 @@ self.add_slide(content=None, image=None, code=None, iframe=None,
59
64
### Running a presentation:
60
65
61
66
``` python
62
- self .begin_presentation(filename = " my_presentation.html" , name = None )
63
- """ Begin a Reveal-JS Presentation in the web browser. """
67
+ self .begin_presentation(filename = " my_presentation.html" , interval = 0 )
68
+ """ Begin a Reveal-JS Presentation in the web browser.
69
+ @Params
70
+ name - If creating multiple presentations at the same time,
71
+ use this to select the one you wish to add slides to.
72
+ filename - The name of the HTML file that you wish to
73
+ save the presentation to. (filename must end in ".html")
74
+ interval - The delay time between autoplaying slides. (in seconds)
75
+ If set to 0 (default), autoplay is disabled.
76
+ """
64
77
```
65
78
66
- Before the presentation is run, the full HTML is saved to the `` presentations_saved /`` folder.
79
+ Before the presentation is run, the full HTML is saved to the `` saved_presentations /`` folder.
67
80
68
81
69
82
All methods have the optional `` name `` argument, which is only needed if you're creating multiple presentations at once.
@@ -77,22 +90,44 @@ from seleniumbase import BaseCase
77
90
class MyPresenterClass (BaseCase ):
78
91
79
92
def test_presenter (self ):
80
- self .create_presentation()
93
+ self .create_presentation(theme = " serif" )
94
+ self .add_slide(
95
+ ' <h1>Welcome</h1><br />\n '
96
+ ' <h3>Press the <b>Right Arrow</b></h3>' )
81
97
self .add_slide(
82
- " <h2>Welcome!</h2>"
83
- " <h4>Enjoy the Presentation!</h4>" )
98
+ ' <h3>SeleniumBase Presenter</h3><br />\n '
99
+ ' <img width="240" src="https://seleniumbase.io/img/logo3a.png" />'
100
+ ' <span style="margin:144px;" />'
101
+ ' <img src="https://seleniumbase.io/other/python_3d_logo.png" />'
102
+ ' <br /><br />\n <h4>Create presentations with <b>Python</b></h4>' )
84
103
self .add_slide(
85
- ' <h3>SeleniumBase "Presenter"</h3>'
86
- ' <img src="https://seleniumbase.io/img/logo3a.png"></img>'
87
- ' <h4>A tool for creating presentations</h4>' )
104
+ ' <h3>Make slides using <b>HTML</b>:</h3><br />\n '
105
+ ' <table style="padding:10px;border:4px solid black;font-size:50;">'
106
+ ' \n <tr style="background-color:CDFFFF;">\n '
107
+ ' <th>Row ABC</th><th>Row XYZ</th></tr>\n '
108
+ ' <tr style="background-color:DCFDDC;">'
109
+ ' <td>Value ONE</td><td>Value TWO</td></tr>\n '
110
+ ' <tr style="background-color:DFDFFB;">\n '
111
+ ' <td>Value THREE</td><td>Value FOUR</td></tr>\n '
112
+ ' </table><br />\n <h4>(HTML <b>table</b> example)</h4>' )
88
113
self .add_slide(
89
- ' <h3>You can add HTML to any slide:</h3><br />'
90
- ' <table style="padding:10px;border:4px solid black;font-size:60;">'
91
- ' <tr><th>Row 1</th><th>Row 2</th></tr>'
92
- ' <tr><td>Value 1</td><td>Value 2</td></tr></table><br />'
93
- ' <h4>(HTML table example)</h4>' )
114
+ ' <h3>Keyboard Shortcuts:</h3>\n '
115
+ ' <table style="padding:10px;border:4px solid black;font-size:30;'
116
+ ' background-color:FFFFDD;">\n '
117
+ ' <tr><th>Key</th><th>Action</th></tr>\n '
118
+ ' <tr><td><b>=></b></td><td>Next Slide (N also works)</td></tr>\n '
119
+ ' <tr><td><b><=</b></td><td>Previous Slide (P also works)</td></tr>'
120
+ ' \n <tr><td>F</td><td>Full Screen Mode</td></tr>\n '
121
+ ' <tr><td>O</td><td>Overview Mode Toggle</td></tr>\n '
122
+ ' <tr><td>esc</td><td>Exit Full Screen / Overview Mode</td></tr>\n '
123
+ ' <tr><td><b>.</b></td><td>Pause/Resume Toggle</td></tr>\n '
124
+ ' <tr><td>space</td><td>Next Slide (alternative)</td></tr></table>'
125
+ )
94
126
self .add_slide(
95
- " <h3>You can display code:</h3>" ,
127
+ ' <h3>Add <b>images</b> to slides:</h3>' ,
128
+ image = " https://seleniumbase.io/other/seagulls.jpg" )
129
+ self .add_slide(
130
+ ' <h3>Add <b>code</b> to slides:</h3>' ,
96
131
code = (
97
132
' from seleniumbase import BaseCase\n\n '
98
133
' class MyTestClass(BaseCase):\n\n '
@@ -107,26 +142,60 @@ class MyPresenterClass(BaseCase):
107
142
' self.assert_text("free to copy and reuse")\n '
108
143
' self.go_back()\n '
109
144
' self.click_link_text("About")\n '
110
- ' self.assert_exact_text("xkcd.com", "h2")\n ' ))
145
+ ' self.assert_exact_text("xkcd.com", "h2")' ))
111
146
self .add_slide(
112
- " <h3>You can highlight code :</h3>" ,
147
+ " <h3>Highlight <b>code</b> in slides :</h3>" ,
113
148
code = (
114
149
' from seleniumbase import BaseCase\n\n '
115
150
' <mark>class MyTestClass(BaseCase):</mark>\n\n '
116
151
' def test_basic(self):\n '
117
152
' self.open("https://store.xkcd.com/search")\n '
118
- ' self.type(\' input[name="q"]\' , "xkcd book\\ n")\n ' ))
153
+ ' self.type(\' input[name="q"]\' , "xkcd book\\ n")\n '
154
+ ' self.assert_text("xkcd: volume 0", "h3")' ))
119
155
self .add_slide(
120
- " <h3>You can add notes to slides:</h3>" ,
121
- notes = " <h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2> " )
156
+ ' <h3>Add <b>iFrames</b> to slides:</h3>' ,
157
+ iframe = " https://seleniumbase.io/demo_page " )
122
158
self .add_slide(
123
- " <h3>You can add images to slides:</h3>" ,
124
- image = " https://seleniumbase.io/img/sb_logo_10.png" )
159
+ ' <h3>Getting started is <b>easy</b>:</h3>' ,
160
+ code = (
161
+ ' from seleniumbase import BaseCase\n\n '
162
+ ' class MyPresenterClass(BaseCase):\n\n '
163
+ ' def test_presenter(self):\n '
164
+ ' self.create_presentation()\n '
165
+ ' self.add_slide("Welcome to Presenter!")\n '
166
+ ' self.add_slide(\n '
167
+ ' "Add code to slides:",\n '
168
+ ' code=(\n '
169
+ ' "from seleniumbase import BaseCase\\ n\\ n"\n '
170
+ ' "class MyPresenterClass(BaseCase):\\ n\\ n"\n '
171
+ ' " def test_presenter(self):\\ n"\n '
172
+ ' " self.create_presentation()\\ n"))\n '
173
+ ' self.begin_presentation(filename="demo.html")' ))
125
174
self .add_slide(
126
- " <h3>You can add iframes to slides:</h3>" ,
127
- iframe = " https://seleniumbase.io/demo_page" )
128
- self .add_slide(" <h1>The End</h1>" )
129
- self .begin_presentation()
175
+ ' <h3>Include <b>notes</b> with slides:</h3><br />' ,
176
+ code = (' self.add_slide("[Your HTML goes here]",\n '
177
+ ' code="[Your software code goes here]",\n '
178
+ ' content2="[Additional HTML goes here]",\n '
179
+ ' notes="[Attached speaker notes go here]"\n '
180
+ ' "[Note A! -- Note B! -- Note C! ]")' ),
181
+ notes = ' <h2><ul><li>Note A!<li>Note B!<li>Note C!<li>Note D!</h2>' ,
182
+ content2 = " <h4>(Notes can include HTML tags)</h4>" )
183
+ self .add_slide(
184
+ ' <h3>Multiple <b>themes</b> available:</h3>' ,
185
+ code = (
186
+ ' self.create_presentation(theme="serif")\n\n '
187
+ ' self.create_presentation(theme="sky")\n\n '
188
+ ' self.create_presentation(theme="simple")\n\n '
189
+ ' self.create_presentation(theme="white")\n\n '
190
+ ' self.create_presentation(theme="moon")\n\n '
191
+ ' self.create_presentation(theme="black")\n\n '
192
+ ' self.create_presentation(theme="night")\n\n '
193
+ ' self.create_presentation(theme="beige")\n\n '
194
+ ' self.create_presentation(theme="league")' ))
195
+ self .add_slide(
196
+ ' <h2><b>The End</b></h2>' ,
197
+ image = " https://seleniumbase.io/img/sb_logo_10.png" )
198
+ self .begin_presentation(filename = " presenter.html" , interval = 0 )
130
199
```
131
200
132
201
#### This example is from [ my_presentation.py] ( https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/my_presentation.py ) , which you can run from the `` examples/presenter `` folder with the following command:
@@ -140,7 +209,7 @@ pytest my_presentation.py
140
209
If you want to save the presentation you created as an HTML file, use:
141
210
142
211
``` python
143
- self .save_presentation(filename = " my_presentation.html" , name = None )
212
+ self .save_presentation(filename = " my_presentation.html" )
144
213
```
145
214
146
215
Presentations automatically get saved when calling:
0 commit comments