omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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?

    Pythonista
    7
    39
    13327
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikael
      mikael last edited by

      Anyone with the latest beta, can you use the new symbol set that comes with iOS 13, e.g.:

      i = ui.Image('lessthan.circle')
      
      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @mikael last edited by

        @mikael

        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'

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @mikael last edited by cvp

          @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() 
          

          mikael 1 Reply Last reply Reply Quote 1
          • mikael
            mikael @cvp last edited by

            @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.

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @mikael last edited by

              @mikael ๐Ÿ‘

              mikael 1 Reply Last reply Reply Quote 0
              • mikael
                mikael @cvp last edited by

                @cvp, I am just a little bit frustrated that we cannot go the easy route with ui.Image.from_data because we cannot(?) call the UIImagePNGRepresentation ObjC function.

                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @mikael last edited by

                  @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()  
                  
                  1 Reply Last reply Reply Quote 1
                  • JonB
                    JonB last edited by

                    @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.

                    mikael cvp 2 Replies Last reply Reply Quote 1
                    • ccc
                      ccc last edited by

                      Is there a way to programmatically obtain the 1,500 strings that correspond to the 1,500 images?

                      cvp mikael 2 Replies Last reply Reply Quote 0
                      • cvp
                        cvp @ccc last edited by

                        @ccc https://sfsymbols.com/

                        1 Reply Last reply Reply Quote 0
                        • mikael
                          mikael @ccc last edited by

                          @ccc, see a list as a simple text file here. It still has the โ€Usage restricted...โ€ lines included. I am considering creating a simple browser for Pythonista.

                          1 Reply Last reply Reply Quote 0
                          • mikael
                            mikael @JonB last edited by

                            @JonB, looks to me like imageAsset is readonly.

                            1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @JonB last edited by ccc

                              @JonB

                              i.objc_instance.setImageAsset_(o.imageAsset()) 
                              

                              gives

                              TypeError: expected 5 arguments, got 1 
                              
                              JonB 1 Reply Last reply Reply Quote 0
                              • mikael
                                mikael last edited by mikael

                                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.

                                Demo

                                cvp 1 Reply Last reply Reply Quote 1
                                • cvp
                                  cvp @mikael last edited by cvp

                                  @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

                                  1 Reply Last reply Reply Quote 0
                                  • JonB
                                    JonB @cvp last edited by

                                    @cvp strange, works on my ios9 ipad. ill have to play around with my ios13.

                                    mikael 1 Reply Last reply Reply Quote 0
                                    • mikael
                                      mikael @JonB last edited by

                                      @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.โ€

                                      1 Reply Last reply Reply Quote 0
                                      • mikael
                                        mikael last edited by mikael

                                        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 size
                                        • weight - Font weight, one of sfsymbol.ULTRALIGHT, THIN, LIGHT, REGULAR, MEDIUM, SEMIBOLD, BOLD, HEAVY, BLACK
                                        • scale - Size relative to font size, one of SMALL, MEDIUM, LARGE
                                        cvp 1 Reply Last reply Reply Quote 1
                                        • cvp
                                          cvp @mikael last edited by

                                          @mikael if you call your code dirty again, I promise to stop writing programs ๐Ÿ˜‚

                                          1 Reply Last reply Reply Quote 0
                                          • pulbrich
                                            pulbrich last edited by

                                            @mikael thanks for this, excellent. (If only it had a fuzzy search function... Just if you feel bored...)

                                            mikael 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors