Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
UI images
-
Hello! I'm pretty much new to Python and I want to know a small example of the Images UI thing
FromThank you!
-
file=cStringIO.StringIO(urllib.urlopen(inputUrl).read())
img = Image.open(file)
print imgThe above will take a picture from a url stored at inputUrl and print it to the console.
-
Ok thanks!
-
To use UI module: create an empty script. Name it imageviewtest for the code snippet below to work. Press the UI editor button top left. Press the plus symbol. Add an image view. It will be named imageview1 by default but you can change this if you want and change the corresponding name in the code.
Warning: there is a bug in Pythonista where if you try to run this twice in a row it will hang the second time. After running it once be sure to exit to your home screen before running it again.
import ui v= ui.load_view("imageviewtest.pyui") imageView1=v["imageview1"] url="http://images.sodahead.com/polls/0/0/2/5/0/5/9/1/5/hotty-71254875414.jpeg" imageView1.load_from_url(url) v.present()
-
To format the Python code in your post above...
- Tap the word
edit
at the upper right of your post to edit the text - Enter a blank line with no text
- Enter a line containing only: ```python
- Enter your Python code
- Enter a line containing only: ```
The ` character is a backtick or accent grave character which you can get by doing a tap-and-hold on the ' keyboard key.
Make sure there are
no space characters before or after the backticks
.A nice additional suggestion from @JonB on creating a keyboard shortcut can be found at: http://omz-forums.appspot.com/pythonista/post/6368952812830720
- Tap the word
-
Sorry about that, posted from my phone. Thanks for the tip.