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?
-
Anyone with the latest beta, can you use the new symbol set that comes with iOS 13, e.g.:
i = ui.Image('lessthan.circle')
-
i = ui.Image('lessthan.circle')
=> OSError: Could not load image
i = ui.Image.named('lessthan.circle') i.show()
=> AttributeError: 'NoneType' object has no attribute 'show'
-
@mikael this works
o = ObjCClass('UIImage').systemImageNamed_('lessthan.circle') with ui.ImageContext(32,32) as ctx: o.drawAtPoint_(CGPoint(0,0)) ui_image = ctx.get_image() ui_image.show()
-
@cvp, sweet! This also works in the app store version.
1500 symbols available, built in and matching the rest of the OS in look and feel.
-
@mikael ๐
-
@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...)