• Change the language to Swift on Apple’s docu pages and you will see the values (in this case anyway).

  • @b0hr see @JonB real original code

    which is the first line of the script linked by your "original code"

  • @cvp yep...just realized that must be the reason, since CGFloat can be 32 or 64 bits, so isn't always compatible with a float.
    I just changed things to this:

    CGFloat_p = ctypes.POINTER(objc_util.CGFloat) CGGradientCreateWithColors = objc_util.c.CGGradientCreateWithColors CGGradientCreateWithColors.restype = c_void_p CGGradientCreateWithColors.argtypes = [c_void_p, c_void_p, CGFloat_p] locations = (objc_util.CGFloat * 2)(0.0,1.0) gradient = CGGradientCreateWithColors(colorSpace, objc_util.ns(colors), ctypes.cast(locations, CGFloat_p))

    and of course it works fine now. Should have realized that right away. I'll update the original thread as well.

  • @JonB regardless of the troubles I was having...that objc decorator idea is brilliant, and ought to be rolled into objc_util.

    re: my problems with pyObject being crashy. After going over the way my code was executing, I rearranged things to be absolutely certain that all attempts to access internals via pyObject() and cast() were within a @on_main_thread...and that seemed to finally make it stable. So, though I'm not entirely clear where it was going wrong, somewhere at least one of those calls was being made outside the main thread, and was therefore making the whole thing unstable at any future call.

  • Hey thank you everyone.

    I must have had a typo when I initially posted this - but it seems to work now.

    Notes: I used ui.parse_color('blue').CGColor()

    This works with RGBA, Hex and Named Colors.

    Ill post the code when done, I am using this to create custom button styles, along with some custom styles for "checkbox" functionality (circles, squares, stars, etc)

    Thanks again for your help!

  • @shinyformica, thanks. I will include the weakref version.

    I was also wondering if you had some globals-clearing code somewhere. Remembering some previous threads where the goal was to make Pythonista act like a fresh interpreter starting every time you run a script.

  • Thank you all, this thread has been so very useful.

  • Hi @reticulated, I'm quite sure omz is still working on Pythonista because I think it's tremendous (and not very smart) that such an application is abandoned. We should know that he knows this fact (I know he knows this fact).

    I'm happy when people help people with ideas, codes, examples, informations.
    You are talking about things too advanced for me, but I'm sure you are talking in order to give Pythonista more power.

    The nice and curious thing is to understand how to give more power to Pythonista without pretending that is omz to give it (that is without need to compile entire Pythonista for new releases).

    The best thing in my opinion is to give omz maximum freedom to decide when to give us new releases of his great app, and in the meantime people could continue to give more power to Pythonista, maybe with plug-ins development.

    Some ideas:

    to extend functions of code editor with find/replace, reformat, code folding... with one click to extend functions of file browser with find/replace for files and folders and content (with regex), zip compression, full properties on files and folders (size, last edited data, if file is editable or not, so I'd like to block some files or folder by editing them, ... ) to extend functions to link Pythonista to any computer for comfortable development of Pythonista/Python scripts using big pc keyboard (my iphone is little and to use WebIDE) we need a wifi shared, not always available, but maybe with bluetooth could be possible using only pure python libraries or scripts, to extend a possible free remote connection service/interface if you want to make calculations that require not-pure python libraries not present in Pythonista (scipy, pandas, etc..) and with a full and complete integration with the app environment (example: my script, to run, needs some scipy functions, ok, I write it in Pythonista and I execute the entire script with Pythonista interpreter, and only the code that requires scipy is executed by the server with full working input-output capabilities), to extend internal site-packages folder in order to be able to delete not used pure-python libraries, since we can reinstall them with pip (using StaSH for example).

    Thank you

  • @cbanta, what is the exception? Install the fault handler to find out.

  • @dgelessus said:

    Ah, that's an auto-generated header from a class dump or something like that. I was looking at the "real" headers from the iOS SDK, which use vector types. (The iOS SDK headers aren't available online, the closest thing you can see is Apple's online documentation for GKAgent2D.position.) I'm guessing that during compilation some "magic" happens to properties/methods that use vector types, and the result is what you see in the class dump header. You could try using the methods position_ and setPosition__ (note the extra underscores), which according to the class dump header use structs instead of vector types.

    Thank you very much, using the methods with underscore solved the problem!

  • As far as I know, apps can only load libraries that are a part of iOS or that came with the app. This is based on the code signature, and not on the framework location. (For example, you can copy one of Pythonista's internal frameworks and load the copy without any issues using ctypes.) It's not possible to load frameworks that were signed for a different app. (For example you cannot copy a Pythonista framework to Editorial, even though both apps are from the same developer.) Frameworks that you compiled yourself using Xcode cannot be loaded either, even if you sign them with a development certificate. (The exception to that is @omz himself when using a dev build on Pythonista, because that is also signed with the dev cert. I remember there was a conversation about that on Twitter a while back, where omz could load a dev-cert-signed framework, but others couldn't.)

  • Thanks for those suggestions, learning about threading was very helpful.

    Apparently, the while loop was working the whole time! I feel very silly now. It didn't appear to be working because it always updated the decibel level to be -120 (which is unusual because -160 is typically silence). It is my hypothesis that Apple restricts widgets in certain ways like recording (which is odd because I've used taptic feedback in a widget before). (Ex: the Shazam app has a widget, but it has to open the app to work.) Anyway, my new problem will be figuring out if it's possible to collect and analyze the recording elsewhere and pass that information to the widget through some sort of callback url.

  • Thanks :)

  • Thank you! Yes it does work!
    On the 7 Plus I'm able to access all 4 cameras this way. This is what I get and it works perfect:

    "<AVCaptureFigVideoDevice: 0x12db72c40 [Back Camera][com.apple.avfoundation.avcapturedevice.built-in_video:0]>",
    "<AVCaptureFigVideoDevice: 0x12dbeb240 [Front Camera][com.apple.avfoundation.avcapturedevice.built-in_video:1]>",
    "<AVCaptureFigVideoDevice: 0x12dbe1b20 [Back Telephoto Camera][com.apple.avfoundation.avcapturedevice.built-in_video:2]>",
    "<AVCaptureFigVideoDevice: 0x12dbe6bf0 [Back iSight Duo Camera][com.apple.avfoundation.avcapturedevice.built-in_video:3]>"

  • https://github.com/jsbain/objc_hacks with a "c" on the objc

  • @cvp , thanks for replying. I also had a wick go with launcher. Also no luck. It's ok. Not a big deal. Just a nice to have 🙄😬

  • @lukaskollmer I would be very surprised if this API isn't shut down for third-party apps in one of the next iOS updates. While it is a private API, and you wouldn't get through app review calling it directly, there are obviously lots of ways you could get around those checks...

Internal error.

Oops! Looks like something went wrong!