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.


    Pythonista 3.3 and theme access

    Pythonista
    theme pythonista 3 objc
    2
    5
    2192
    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.
    • shinyformica
      shinyformica last edited by

      Hey all you Pythonisters, I just upgraded one of my devices to Pythonista 3.3 to test what has changed or broken from 3.2 in my project.

      There's a few things, mostly minor. The biggest one is actually that the theme-management code I was using, which was cobbled together from threads in this forum, is no longer working.

      I have this code:

      def currentThemeName(self):
          if self._NSUserDefaults is None:
              self._NSUserDefaults = objc_util.ObjCClass('NSUserDefaults')
          defaults = self._NSUserDefaults.standardUserDefaults()
          name = str(defaults.stringForKey_('ThemeName'))
          if not name: name = 'Default'
          return name
      

      that used to return the currently selected theme but is now, I believe, always returning the theme setting from Pythonista 3.2, which implies the user default key has changed?

      Anyone know (@omz if you have a spare moment)? Perhaps there's now a better way to access this info?

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

        Well look at me, being all fancy and figuring this one out myself!

        Ok, so first step was looking at all the NSUserDefaults key/value pairs to see what held the theme:

        import objc_util
        nsd = objc_util.ObjCClass("NSUserDefaults")
        standard = nsd.standardUserDefaults()
        defaults = standard.dictionaryRepresentation()
        print(defaults)
        

        Then, just scanning through the output, I see:

        ThemeName = ...
        ThemeNameDarkMode = ...
        ThemeNameLightMode = ...

        so, obviously in retrospect, we've got new keys for the theme settings for light and dark modes. Et, voila.

        Now then...anyone know how we find out which mode we are in from a script?

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

          I should probably do the research first before asking questions: to get which theme mode we are in, light or dark, there is a new ui module function:

          ui.get_ui_style()
          

          So there you go.

          Now...how do I find out the pythonista version to special case this situation since we'll be running some Pythonista 3.2 and some Pythonista 3.3, and some iOS 12 and some iOS 13, for a little while at least?

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

            https://forum.omz-software.com/topic/2444/determining-pythonista-s-version

            Also

            https://github.com/ywangd/stash/blob/master/bin/version.py

            Shows examples of getting pythonista build version, along with iOS platform/version in a mostly robust way.

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

              @JonB thanks so much, that's perfect.

              @omz can I request that some future minor update to pythonista put the ability to check the build version and the iOS version into some globally available module?

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