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?
-
@cvp, I am just a little bit frustrated that we cannot go the easy route with
ui.Image.from_data
because we cannot(?) call theUIImagePNGRepresentation
ObjC function. -
@mikael is that what you want?
import ui from objc_util import * o = ObjCClass('UIImage').systemImageNamed_('lessthan.circle') UIImagePNGRepresentation = c.UIImagePNGRepresentation UIImagePNGRepresentation.restype = c_void_p UIImagePNGRepresentation.argtypes = [c_void_p] UIImage_data = nsdata_to_bytes(ObjCInstance(UIImagePNGRepresentation(o))) ui_image = ui.Image.from_data(UIImage_data) ui_image.show()
-
@mikael said:
UIImagePNGRepresentation
why not?
Actually, try this -- works for regular ui.Image's:
i=ui.Image.named('iow:alert_32') o = ObjCClass('UIImage').systemImageNamed_('lessthan.circle') i.objc_instance.setImageAsset_(o.imageAsset())
now i should be pointing to the same image asset as o, just in a convienent ui.Image wrapper.
-
Is there a way to programmatically obtain the 1,500 strings that correspond to the 1,500 images?
-
-
-
@JonB, looks to me like imageAsset is readonly.
-
-
Ok, a quick and dirty symbol browser here. Expects to have the list of symbol names linked above in the same directory.
Tap on row to copy symbol name to clipboard. Tap on βThinβ to cycle through different weights. Symbols restricted by Apple for a specific app are shown in orange.
-
@mikael said:
quick and dirty
are reserved (by me) words, you'll have to pay royalties π
And, your code is never dirty... while mine, yes
-
@cvp strange, works on my ios9 ipad. ill have to play around with my ios13.
-
@JonB, must have changed since iOS 9? As said,
imageAsset
is now marked as readonly in the docs, and there is this statement in the first paragraph of UIImage:βImage objects are immutable, so you always create them from existing image data, such as an image file on disk or programmatically created image data.β
-
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!