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.
SFSymbols?
-
As a half-accidental result, you can use the file linked above as a package:
import sfsymbol img = sfsymbol.SymbolImage('arrow.right.to.line')
There are three optional parameters:
point_size
- Integer font sizeweight
- Font weight, one of sfsymbol.ULTRALIGHT, THIN, LIGHT, REGULAR, MEDIUM, SEMIBOLD, BOLD, HEAVY, BLACKscale
- Size relative to font size, one of SMALL, MEDIUM, LARGE
-
@mikael if you call your code dirty again, I promise to stop writing programs 😂
-
@mikael thanks for this, excellent. (If only it had a fuzzy search function... Just if you feel bored...)
-
@pulbrich, others, any suggestions for a fuzzy search?
fuzzywuzzy
is good, but I would like to avoid requiring an extra install.difflib.get_close_matches
results are highly unintuitive.Is there something easy to use provided by iOS?
-
@mikael you could try FuzzyFinder in 10 lines of Python
Cheers,
-
I would go with @TPO ‘s idea, perfectly enough for the purpose.
-
-
@mikael Many, many thanks! Perfect now!
-
@mikael said:
for some reason textfield.end_editing() does not hide the keyboard
Same on my iPad mini 4 (iOS 13 + Pythonista beta)
There is a kind of flicking, I think that the keyboard is dismissed and then comes back. -
FWIW:
from ui import * from objc_util import * uiimage=ObjCClass('UIImage') v=Image.named('test:Lenna') u=uiimage.systemImageNamed_('lessthan.circle') v.objc_instance._setImageAsset_(u.imageAsset())
Leading underscore did the trick, iPadOS 13.1.3.
Maybe not the most future proof, but does the job... -
@JonB As usual, you're the 🤴
-
@JonB, thanks. Intuitively this seems like it should be faster and more efficient than going via the PNG conversion.
But when I went to test the performance I ran into a couple of issues with the asset approach:
- Resulting image size is dependent on the size of the original ui.Image created.
- Both the original and ”asset-applied” images are retained in the ui.Image somehow, and for example ButtonItems do not really handle that well.
See below couple of example images. First one uses a too-large initializing picture (Lenna), the second too small one (triangle arrow icon), which you can see presented in the title area.
-
@mikael your module now crashes with
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/668A7D98-7216-47ED-917D-AA0B6173167E/Pythonista3/Documents/MesTests/sfsymbol.py", line 233, in <module> data_source = symbol_table.data_source = SymbolSource(root, symbol_table) File "/private/var/mobile/Containers/Shared/AppGroup/668A7D98-7216-47ED-917D-AA0B6173167E/Pythonista3/Documents/MesTests/sfsymbol.py", line 76, in __init__ image=SymbolImage('arrow.left', 8, weight=THIN), File "/private/var/mobile/Containers/Shared/AppGroup/668A7D98-7216-47ED-917D-AA0B6173167E/Pythonista3/Documents/MesTests/sfsymbol.py", line 27, in SymbolImage conf = UIImageSymbolConfiguration.configurationWithConfiguration_and_( File "/var/containers/Bundle/Application/34BAEE1A-BC33-4D6F-A0C1-B733E4991F31/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 445, in __getattr__ cached_method = ObjCClassMethod(self, attr) File "/var/containers/Bundle/Application/34BAEE1A-BC33-4D6F-A0C1-B733E4991F31/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 752, in __init__ raise AttributeError('No class method found for selector "%s"' % (self.sel_name)) AttributeError: No class method found for selector "configurationWithConfiguration:and:"
-
@cvp, yes, just noticed. iOS 14 must’ve changed it. Will take a look.
-
-
@cvp, here’s the relevant code if you want to do a manual quick fix. Will push an update to PyPI soon.
... if point_size is not None: conf = conf.configurationByApplyingConfiguration_( UIImageSymbolConfiguration.configurationWithPointSize_(point_size)) if weight is not None: conf = conf.configurationByApplyingConfiguration_( UIImageSymbolConfiguration.configurationWithWeight_(weight)) if scale is not None: conf = conf.configurationByApplyingConfiguration_( UIImageSymbolConfiguration.configurationWithScale_(scale)) objc_image = objc_image.imageByApplyingSymbolConfiguration_(conf) ...
-
@cvp, for the new symbols, I found a downloadable list of changes, but no list of new icons or an updated master list.
-
-
-
If someone interested in a list of string, here we go
import plistlib import io vFilePath = '/System/Library/CoreServices/CoreGlyphs.bundle/symbol_order.plist' with open(vFilePath, 'rb') as vFile: vFileObject = io.BytesIO(vFile.read()) vJsonSFSymbols = plistlib.load(vFileObject) for vIndex, vJsonSFSymbol in enumerate(vJsonSFSymbols): print(str(vIndex).zfill(4), vJsonSFSymbol)