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.
How to ask a good question
-
@zrzka Very good explanation, thank you!
Writing to this forum, I ask two things:- with Markdown can we change image dimensions directly inside the command
![(http://some-link-to-an-image)
? I've noticed that the images I post here are too large. - Often I read Pythonista forum via Safari in my little iphone: sometimes I need to copy an entire code posted by users but I can't find easy to select the full text of the codes/scripts in the forum. Do you know some other ways to quickly select (with Safari or Pythonista web browser) only all text between
</>
in order to copy the full script in clipboard (then it is easy to paste in a new Pythonista script)?
Thank you
Regards - with Markdown can we change image dimensions directly inside the command
-
Re 1 - There're many extensions doing this, but I don't know if NodeBB supports it. Search for them and try. I doubt that it will work.
Re 2 - Little bit of scripting, but doable.
Let's say you have a topic with URL like https://forum.omz-software.com/topic/4622/notification-module-api. Every comment starts with a line like Phuket2 posted a day ago. When you tap on a day ago, URL changes to https://forum.omz-software.com/topic/4622/notification-module-api/6. And now:
- You can prepend
/api
to get JSON /6
is a post number starting from 1, so, the index is6-1=5
JSON response contains
posts
, which is an array of dictionaries and every dictionary has keycontent
. You have a content now. You can get<code>xxx</code>
via regexCODE_PATTERN = re.compile('\<code.*?\>(.*?)\<\/code\>', re.MULTILINE | re.DOTALL)
.Here's code with fixed URL inside:
UPDATE: <snip>...see gist in following post, removed code & sample just not to clutter this topic...</snip>
- You can prepend
-
@Matteo decided to make your life easier :) https://gist.github.com/zrzka/7fc25156da0714daa9aa79a17898da2f
-
@omz, not sure if you can have more than one post pinned in a forum or not. But it seems to me that a consolidation of this post pinned to this forum would benefit everyone. The shame is that in a week or so, this post will get swallowed up with all the other posts. If you dont want to pin it in this forum, maybe in the General Discussion. Even if new users dont see it, it can be easily found and new users can be directed to read it to help themselves when popsing questions here.
Just my 2 cents worth -
@zrzka, impressive, as always.
I would add, at the very top, that before even asking the question, you should always search for a solution with Google or other preferred external search engine, and including the word ”Pythonista” in your search.
As well as checking Pythonista-Tools first for some reference implementations.
+1 for sticking this thread.
-
Hi @zrzka , sorry for delay, thank you very much for your help! I surely will try your procedure next weekend to make easier to copy and paste in a new Pythonista script a full script posted by any user in this forum using browser. I find a lot of useful scripts or pieces of code here.
It would be useful for any Pythonista user to have an updated first post written by you with new info about using this forum (practical info). The new info that any user can add in this thread with his/her personal post based on personal experience could be examinated and maybe, if correct and useful, added to your first post, in order to have always an updated first post about state of art in pythoning with Pythonista.
I'm agree with you about having this thread always in the first/second position from top in the forum, for fast reading.Thank you,
Regards
Bye -
getting a copy of the code from a forum-post ( code from omz)
https://forum.omz-software.com/topic/2022/a-copy-code-button-here-in-the-forum/4 -
@dgelessus, went to imgur, and it seems that login is now needed?
-
@mikael At the top of https://imgur.com/ there is a "New post" button, when you tap it you get an upload dialog that doesn't require a login. If you're not on a regular computer, you probably get the mobile site by default, which is useless and just wants you to download the app. In that case reload the page in desktop mode (in Safari, you can long-tap on the reload button to get the desktop site option).
-
@dgelessus, thanks. Still, on the phone, I have so far not found out how to get the actual link to just the picture.
-
@mikael check this https://gist.github.com/zrzka/b61c74975c777a77232035a3e171337d
- Follow instructions above line 21 to get an client ID
- This script can be run from the Pythonista or you can add it to share extensions and run it from Photos for example
-
Hi @zrzka, I'm trying to follow the steps you have suggested me and I discovered a new feature of Pythonista never tried before (sorry for my ignorance): user can create a script that can executes some operations on a web page or other files through "Share Extension Shortcuts"!
I have a little problem with the code
forum-post-copy-code.py
Info:
- iOS=10.3.3
- Pythonista = 3.1 (301016)
- I'm following the steps in this link
- I obtain an error:
File "/private......../forum-post-copy-code.py", line 17 raise ValueError(f'{url} does not point to the Pythonista Forum) SyntaxError: invalid syntax
Can you kindly help me to solve this?
Thank you
Regards -
@Matteo update to 3.2 & use 3.6 as default interpreter (the error is about f strings).
-
@zrzka If I remember correctly, @Matteo said in another thread that he isn't able to update, because of the Python 2
matplotlib
crashes in 3.2.If the f-strings are the only issue, you can probably translate them to
format
calls by hand, which work on any Python version since 2.6 or so. For example,f"{url} does not point to the Pythonista forum"
would become"{} does not point to the Pythonista forum".format(url)
. -
@zrzka Hi, ok it is a problem related to version of Pythonista, but @dgelessus is right: for now I'm happy with 3.1 version so no need to upgrade.
I understand that there is a solution for my problem without upgrade. Can you (@zrzka , @dgelessus or someone else) kindly show me how can I modify the rest of the script in order to not obtain errors related to f-string? In other words can you provide a modified version of the script working with python 2.7.12?Thank you for help
Regards -
@Matteo An approach to enable fstrings in 3.1:
In stash:
pip install tokenize_rt
Then, Download future_fstrings.py, and install into site-packages-3.
Create usercustomize.py in site-packages-3, which includes
import future_fstrings future_fstrings.register()
(Iirc, pythonista_startup doesnt get executed by the extension, but usercustomize.py does)
Finally, add
# -*- coding: future_fstrings -*-
to the top of any file where you want fstrings enabled, such as zrzka's script.
-
Hi @JonB, thank you for suggestion! I will try your procedure.
@enceladus thank you for showing me an other way to do what I ask: when I will be able to use @zrzka script with python 2.7.12 by trying to copy the code here (as you suggest) in clipboard, I will try also the @omz script!
Regards
-
-
Guys, below in the snippet is a func 'pythonista_info'. I am pretty sure @JonB wrote this function a long time ago. It still seems to work ok. My wapper to copy it to the clipboard is not so nice(user friendly). But a refined version of what is below could be used as a wrench item to get details about the env when you are posting to the forum. I didn't attempt to make a nice version of it. I think others would do a better job than me.
This is quite old, so maybe it does need updating...
import clipboard, console import os, platform, plistlib, scene, sys def pythonista_info(): plist = plistlib.readPlist(os.path.abspath(os.path.join (sys.executable, '..', 'Info.plist'))) ios_ver, _, machine_model = platform.mac_ver() return dict(pythonista_ver_str=plist['CFBundleShortVersionString'], pythonista_ver_num=plist['CFBundleVersion'], ios_ver_str=ios_ver, screen_resoultion=scene.get_screen_size(), screen_scale=scene.get_screen_scale(), machine_architecture=platform.architecture()[0], machine_model=machine_model, ) if __name__ == '__main__': info = pythonista_info() str_info = "\n".join(str((k, v)) for k, v in info.items()) clipboard.set(str_info) print(str_info) console.hud_alert('Pythonista Env copied to clipboard')
-
@Phuket2 Immediately integrated in my apps/tools