Unfold the pink sheet and press "print traceback" then go into the console
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.
Posts made by uj_jonas
-
RE: How do you get full error messages?
-
RE: WebView not allowing me to scroll to the bottom right corner
@Cethric thanks. Didn't even think of that
-
RE: WebView not allowing me to scroll to the bottom right corner
@ccc said:
import ui
main = ui.ScrollView(frame=(0, 0, *ui.get_screen_size()))
main.content_size = (1920, 1080)
wv = ui.WebView(frame=(0, 0, *main.content_size))
wv.load_url('http://www.example.com')
main.add_subview(wv)
main.present()Can I do this and still have the
wv_container
? I kinda need my webview inside a separate view :/ -
WebView not allowing me to scroll to the bottom right corner
I have an iPad 4 with 720p resolution. When I run this code, the webview prevents me from scrolling to the right.
import ui main = ui.View(frame=(0, 0, ui.get_screen_size()[0], ui.get_screen_size()[1])) wv_container = ui.View(frame=(0, 0, 1920, 1080)) wv = ui.WebView(frame=wv_container.frame) wv.load_url('http://www.example.com') wv_container.add_subview(wv) main.add_subview(wv_container) main.present('fullscreen')
-
RE: Get web source code
So I know the question has been answered, but I just wanted to share this. It's just another approach.
import ui, appex class wvdelegate(object): def webview_did_finish_load(self, webview): html = webview.eval_js('document.documentElement.innerHTML') webview.load_html('<xmp>' + html + r'<\xmp>') webview.delegate = None wv = ui.WebView() wv.load_url(appex.get_url()) wv.delegate = wvdelegate() wv.present()
You could also do like this to copy the HTML
import ui, appex, clipboard class wvdelegate(object): def webview_did_finish_load(self, webview): self.html = webview.eval_js('document.documentElement.innerHTML') webview.load_html('<xmp>' + self.html + r'<\xmp>') webview.delegate.webview_did_finish_load = None wv.right_button_items = [ui.ButtonItem(image=ui.Image('iob:clipboard_32'), action=lambda x: clipboard.set(wv.delegate.html))] wv = ui.WebView() wv.load_url(appex.get_url()) wv.delegate = wvdelegate() wv.present()
-
pdfkit PermissionError
I wanted to convert HTML to PDF and looked it on Google. I found the pdfkit docs, but when I tried using it
import pdfkit pdfkit.from_url('https://google.com', sys.argv[0][:-7] + 'out.pdf')
I got a PermissionError
My guess is it's just iOS restricting me, but I'd like to know if I'm doing something wrong.
-
RE: [Share]CSS Color Selector/Picker Wrench utility
Awesome :D definitely going to be using this. I just made a few changes to it, so that it writes it in the editor directly instead of copying it to the clipboard.
Also, I just have to know, what keyboard are you using?
-
RE: Gives an error at the line that I marked.
@happy_variable
I don't know why you get that error, but tryappex.get_attachments()[0]
instead ofappex.get_image()
That did it for me :/Oh, and remove the
str()
aroundimg
on the line you get the error -
RE: How do we use raw_input()?
@NickAtNight Yes. In Python 3 print is a function.
If you want to run your script to run in Python 2 you could add
#! python2
at the top of your script like this:#! python2 var = raw_input('using raw_input()') print 'python 2 print'
You can also test your script in Python 2 by holding down the play button and choosing "Run with Python 2.7"
-
RE: [Share] Running code from clipboard
@Phuket2 I could have left that part out, but didn't since you're such a big part of the forum.
There's not much code to run, if it can't run yours ;)
-
RE: [Share] Running code from clipboard
@omz yeah it probably would. I looked up ways to make scripts run other scripts, but none of them worked in pythonista. I just didn't come across runpy.
-
[Share] Running code from clipboard
First of all please, excuse my bad English and code :)
So I was browsing the forums, looking at all sorts of topics. I got tired of copy-pasting the scripts into a new file, every time I wanted to test a script someone wrote. So I (of course) thought it'd be nice if I could just run the script from the app extension, without leaving Safari.
So I wrote this, which kinda works most of the time. (I tried to comment it as best as I could.)
import clipboard import runpy # Every line of the copied script cliplines = clipboard.get().split('\n') # Some scripts contain the 'if __name__ == "__main__":' statement # We can't have that since we need the script to run when it's imported try: cliplines[cliplines.index("if __name__ == '__main__':")] = "if __name__ != '__main__':" except ValueError: pass # @Phuket2 keeps importing editor without using it # Since editor is not supported in the app extension... # We try to remove it and see if it still works for i in range(len(cliplines)): cliplines[i] = (cliplines[i].replace('import editor', '').replace(', editor', '') + '\n').encode() # Writing the new script to the .py file with open('TheScript.py', 'wb') as f: f.writelines(cliplines) # Run the script runpy.run_path('TheScript.py')
It works by writing the text in your clipboard to a .py file and then running it.
I would appreciate I someone helped improve it
(Here's some random code to test it on)
from math import pi from ui import View, TextView # Just a pointless function def changeText(sender, text): sender.text = text v = View() v.bg_color = 'white' v.frame = (0, 0, 400, 100) l = TextView() l.alignment = 1 l.editable = False l.frame = (0, 0, len(str(pi)) * 20, 96) l.font = ('CourierNewPSMT', 32) changeText(l, 'Pi\n' + str(pi)) if __name__ == '__main__': v.present('sheet') l.x = v.width/2 - l.width/2 l.y = v.height/2 - l.height/2 v.add_subview(l)
Edit: What @omz said
-
RE: [Solved]ImportError when importing Images, Twitter and more
@lukaskollmer I got it all working again, except imgurpython.
I removed it from site-packages and tried to reinstall it with pip, but it wouldn't let me. -
RE: [Solved]ImportError when importing Images, Twitter and more
@JonB is everything in site-packages what stash has installed?
If so, wouldn't trashing it all fix the problem? -
RE: [Solved]ImportError when importing Images, Twitter and more
@JonB future is now gone.
All I'm doing is
import twitter
It doesn't work in 3.5
It works in 2.7From the console(2.7):
>>> import twitter >>> twitter.__file__ '/var/containers/Bundle/Application/05B93F09-B103-44A6-9622-55237A53AC5E/Pythonista3.app/Frameworks/PythonistaKit.framework/pylib/site-packages/twitter.py'
-
RE: [Solved]ImportError when importing Images, Twitter and more
@JonB didn't quite work.
I did remove the twitter folder, but now it's just back to the first error.
And I'm still wondering why this affects other modules. The ImportError says I'm either running Python-future from the src folder or it's corrupted, it think it's corrupted -
RE: [Solved]ImportError when importing Images, Twitter and more
@ccc and now it raised a new error
module "copyreq" has no attribute "pickle"Damn I wish there was a undo button in stash
-
RE: [Solved]ImportError when importing Images, Twitter and more
But why does this affect other modules?
-
RE: [Solved]ImportError when importing Images, Twitter and more
Yes, I thought it was something like that :/