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.


    Dark keyboard for ui.textfield/TextView

    Pythonista
    2
    5
    2230
    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.
    • Webmaster4o
      Webmaster4o last edited by

      Sorry if I'm missing something, but is this possible? If not, it should be.

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

        If not, it should be.

        Agreed. For now:

        import ui
        from objc_util import ObjCInstance, on_main_thread
        
        @on_main_thread
        def set_kb_apperance(view, appearance='dark'):
            a = 1 if appearance == 'dark' else 0
            if isinstance(view, ui.TextView):
                ObjCInstance(tv).setKeyboardAppearance_(a)
            elif isinstance(view, ui.TextField):
                ObjCInstance(view).subviews()[0].setKeyboardAppearance_(a)
            else:
                raise TypeError('Expected ui.TextView or ui.TextField')
        1 Reply Last reply Reply Quote 2
        • Webmaster4o
          Webmaster4o last edited by

          @omz As a follow up, I can't find a way to set the color of the background of a TextField either. The background_color attribute seems to affect the tiny areas behind the rounded corners, but leaves the text entry a glaring white. If you're wondering why I'm asking these questions, I'm trying to bulild a dark-looking UI and having problems.

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

            @Webmaster4o You can set the bordered attribute to False to make the background_color have an effect. You can then use border_width, border_color and corner_radius to emulate the default (rounded rect) style.

            Alternatively, you could put a view behind the text field for the background – you might want to do this to customize the padding.

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

              Thanks a lot, works like a charm ;)

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