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.


    help about return type

    Pythonista
    7
    21
    6864
    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.
    • ryubai
      ryubai @JonB last edited by

      @JonB

      thank you all

      when i overwrite a method requested a return type in a new class.
      number and string can be returned directly.
      cell object in tableview is returned in cell.ptr
      but how to return a CGSize structure?
      objc's CGSize does't work

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

        @ryubai did you read this , it is to complex for me 😢

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

          anyone can help? please

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

            @ryubai, I tried a few things:

            • confirming that defining another method of the same protocol that returns a float works fine
            • looking a the definition of CGSize in objc_util
            • fiddling with the retype of the function
            • using CGSizeMake function, but could not get it defined
            • checking if ctypes.Structure would have some additional capabilities

            No help nowhere.

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

              okay, the issue here is that ctypes does not allow complex return types, such as Unions or Structures for callbacks.

              see
              https://bugs.python.org/issue5710

              However, @dgelessus actually came up with a solution.
              https://github.com/beeware/rubicon-objc/pull/85/files

              you need to download ctypes_patch.py and place in site-packages (or, you can use this executable link

              Then, you just need to call

              import ctypes_patch
              
              ...
              
              ctypes_patch.make_callback_returnable(CGSize)
              
              DataSource = create_objc_class('DataSource', methods=methods, protocols=['UICollectionViewDelegateFlowLayout', 'UICollectionViewDataSource', 'UICollectionViewDelegate'])
              
              ryubai 1 Reply Last reply Reply Quote 3
              • cvp
                cvp last edited by cvp

                Sincerely, what could we do without @dgelessus and @JonB
                Thanks to be here.

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

                  i updated the exec link, to download and install the patch into site-packages. click the link, then click run.

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

                    @JonB @mikael @cvp and other dear friends

                    Sincerely,many thanks to you all!
                    i love to stay here.

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

                      @JonB

                      run more than once will raise such errs,then how to solve?

                      ctypes_patch.make_callback_returnable(CGSize)
                      File "/private/var/mobile/Containers/Shared/AppGroup/02422888-CC52-45FC-BB53-72013D3F4AFA/Pythonista3/Documents/site-packages/ctypes_patch.py", line 128, in make_callback_returnable
                      raise ValueError("The ctype {} already has a getfunc")
                      ValueError: The ctype {} already has a getfunc

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

                        Probably you can just use a try/except around that, or explicitly check for the existence of a getfunc.

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

                          Sorry for the late reply - I forgot to check the forum recently... The version of ctypes_patch that @JonB linked to is the original version from the pull request that added it. There have been some updates to it that fix a few problems, including the "The ctype {} already has a getfunc" error that @ryubai posted above. I would recommend using the current version of ctypes_patch from the repo and not the old one from the pull request.

                          1 Reply Last reply Reply Quote 1
                          • eliotradisa
                            eliotradisa last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • eliotradisa
                              eliotradisa last edited by eliotradisa

                              File "/private/var/mobile/Containers/Shared/AppGroup/02422888-CC52-45FC-BB53-72013D3F4AFA/Pythonista3/Documents/site-packages/ctypes_patch.py", line 128, in make_callback_returnable https://snaptube.cam/ https://wordtopdf.ltd/ https://vidmate.bid/

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