Skip to content

Commit 4b23f16

Browse files
committed
update docs
1 parent 2990dde commit 4b23f16

7 files changed

Lines changed: 131 additions & 16 deletions

File tree

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Run locally
7878

7979
Commands to run locally::
8080

81-
pip install pythonhere
82-
jupyter notebook start
81+
pip install pythonhere jupyter
82+
jupyter notebook
8383

8484

8585
Build Android app

examples/android.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ cat /sdcard/test_python_here.txt
118118
rm /sdcard/test_python_here.txt
119119
```
120120

121+
### Application-specific directories
122+
Previous example will not work on Android >= 10,
123+
124+
because of privacy changes: https://developer.android.com/about/versions/10/privacy/changes#scoped-storage
125+
126+
In this case, it is possible to use directories that owned by the application:
127+
128+
```python
129+
%%there
130+
from jnius import autoclass, cast
131+
PythonActivity = autoclass('org.kivy.android.PythonActivity')
132+
Environment = autoclass('android.os.Environment')
133+
context = cast('android.content.Context', PythonActivity.mActivity)
134+
print(context.getExternalFilesDir(None).getAbsolutePath())
135+
print(context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath())
136+
print(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath())
137+
```
138+
121139
## Take picture with a camera
122140
Camera could be displayed and captured with the Kivy [Camera](https://kivy.org/doc/stable/api-kivy.uix.camera.html) widget.
123141

examples/ble.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jupyter:
1313
---
1414

1515
# Android Bluetooth Low Energy functions
16-
BLE functions could be used with the [able](https://github.com/b3b/able) library.
16+
BLE functions could be used with the [able](https://herethere.me/able) library.
1717

1818
```python
1919
%load_ext pythonhere

examples/commands.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Commands are provided by the *pythonhere* extension
2020
%load_ext pythonhere
2121
```
2222

23-
## connect-there
24-
**Connect to remote interpreter via SSH.**
23+
## %connect-there
24+
**Connect to remote interpreter via SSH**
2525

2626
Command takes single optional argument: location of connection config.<br>
2727
If argument is not provided, values are loaded from the **there.env** file.
@@ -62,15 +62,15 @@ THERE_PASSWORD=xxx
6262
Default action for *%there*, if command is not specified - execute python code.
6363

6464

65-
## there
65+
### there
6666
**Execute python code on the remote side.**<br>
6767

6868
```python
6969
%%there
7070
import this
7171
```
7272

73-
## kv
73+
### kv
7474

7575
```python
7676
%there kv --help
@@ -96,7 +96,7 @@ Image:
9696
PopMatrix
9797
```
9898

99-
## shell
99+
### shell
100100

101101
```python
102102
%there shell --help
@@ -124,7 +124,7 @@ Listen to Android system logs in the background and show last two lines of outpu
124124
logcat
125125
```
126126

127-
## upload
127+
### upload
128128

129129
```python
130130
%there upload --help
@@ -146,7 +146,18 @@ logcat
146146
find
147147
```
148148

149-
## log
149+
150+
### pin
151+
152+
```python
153+
%there pin --help
154+
```
155+
156+
```python
157+
%there pin script.py --label "My script"
158+
```
159+
160+
### log
150161

151162
```python
152163
%there log --help
@@ -157,16 +168,21 @@ Since the command blocks and never ends, it is useful to run with --backgroud (-
157168
```
158169

159170
```python
160-
%there -bl 1 log
171+
%there -b -l 1 log
172+
```
173+
174+
```python
175+
# wait, to make sure *log* cell connection is established before next cell is executed
176+
import asyncio ; await asyncio.sleep(3)
161177
```
162178

163179
```python
164180
%%there
165181
from kivy.logger import Logger
166-
Logger.info("Hello from the future cell")
182+
Logger.info(f"Hello from the main cell")
167183
```
168184

169-
## screeenshot
185+
### screeenshot
170186

171187
```python
172188
%there screenshot --help
@@ -178,5 +194,5 @@ Logger.info("Hello from the future cell")
178194
* and save image to a local file:
179195

180196
```python
181-
%there -d .5 screenshot -w 200 -o /tmp/screenshot_test.png
197+
%there -d 0.5 screenshot -w 200 -o /tmp/screenshot_test.png
182198
```

examples/midi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,5 @@ for code in list(midi_instruments.keys()):
284284
```
285285

286286
```python
287-
%there screenshot -w 200
287+
%there -d 1 screenshot -w 200
288288
```

examples/random_animation.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
text_representation:
5+
extension: .md
6+
format_name: markdown
7+
format_version: '1.2'
8+
jupytext_version: 1.7.1
9+
kernelspec:
10+
display_name: Python 3
11+
language: python
12+
name: python3
13+
---
14+
15+
# Some animation and effects with KV
16+
17+
```python
18+
%load_ext pythonhere
19+
%connect-there
20+
```
21+
22+
```python
23+
%%there kv
24+
#:import Animation kivy.animation.Animation
25+
#:import ew kivy.uix.effectwidget
26+
27+
<Dancer@Button>:
28+
moves: ("\(-_- )\\", "/( -_-)/")
29+
font_size: 100
30+
seq: 0
31+
text: self.moves[int(self.seq)]
32+
on_press: self.seq = int(not(self.seq))
33+
34+
<Rotor@Image>:
35+
angle: 360
36+
allow_stretch: True
37+
source: "../app/data/logo/logo-128.png"
38+
39+
canvas.before:
40+
PushMatrix
41+
Rotate:
42+
angle: self.angle
43+
origin: self.center
44+
canvas.after:
45+
PopMatrix
46+
47+
rotate: Animation(angle=0, duration=2) + Animation(angle=360, duration=0)
48+
grow:
49+
(
50+
Animation(size=(300, 300), duration=.1) +
51+
Animation(size=(100, 100), duration=.1) +
52+
Animation(size=(100, 100), duration=.3)
53+
)
54+
55+
on_parent:
56+
self.rotate.repeat=True
57+
self.grow.repeat=True
58+
self.rotate.start(self)
59+
self.grow.start(self)
60+
61+
62+
<RootLayout@FloatLayout>:
63+
GridLayout:
64+
cols: 2
65+
Dancer:
66+
Dancer:
67+
Dancer:
68+
Dancer:
69+
70+
EffectWidget:
71+
effects: ew.ScanlinesEffect(),
72+
AnchorLayout:
73+
Rotor:
74+
size_hint: None, None
75+
76+
RootLayout:
77+
```
78+
79+
```python
80+
%there -d 1 screenshot -w 200
81+
```

pythonhere/magic_here/shortcuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def screenshot(ctx, width, output):
8080
@click.option("-l", "--label", type=str, default="", help="Label for shortcut")
8181
@click.argument("script", nargs=1)
8282
def pin(code: str, script: str, label: str) -> str: # pylint: disable=unused-argument
83-
"""Create pinned shortcut to run a Python script."""
83+
"""Create pinned shortcut to run a Python script from Android home screen."""
8484
if not label:
8585
label = script.split("/")[-1]
8686
return PIN_COMMAND_TEMPLATE.format(script=script, label=label)

0 commit comments

Comments
 (0)