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.


    Making a Transparent Webview

    Pythonista
    webview charts graphs
    2
    5
    2874
    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.
    • zmous
      zmous last edited by zmous

      so kinda wanted to create animated charts in pythonista except that matplotlib creates static ones and non interactive charts. I was thinking if there's a way to sorta wrap Chartjs (a JavaScript library for cretaing charts) in a webview and set it's background to be clear. i tried doing this but i ran into a problem:
      • setting a clear background webview doesn't seem all that easy, although it seems that it could be done using obj_util (something i am unfamiliar with)

      Any help would be very much appreciated thanks alot

      Update: All right so i have been looking around and found this: https://stackoverflow.com/questions/3646930/how-to-make-a-transparent-uiwebview

      Which i tried implementing as follows ( But for some reason pythonista crashes instead):

      #[webView setBackgroundColor:[UIColor clearColor]];
      
      from objc_util import *
      import ui
      
      UIColor=ObjCClass('UIColor')
      
      class WebViewContainer (ui.View):
          def __init__(self, web_view):
              ui.View.__init__(self)
              self.web_view = web_view
              self.add_subview(web_view)
              _web_view = ObjCInstance(web_view)
              _web_view.setBackgroundColor_(UIColor.clearColor().CGColor())
              _web_view.setOpaque_('NO')
      
      w,h=ui.get_screen_size()
      wv=ui.WebView()
      wv.frame=(0,0,w,h)
      wvo=WebViewContainer(wv)
      view=ui.View()
      view.add_subview(wvo)
      view.present()
      
      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @zmous last edited by

        @zmous Please, Try this code

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

          @zmous only one change needed:

                  _web_view.setBackgroundColor_(UIColor.clearColor())#.CGColor())
          
          1 Reply Last reply Reply Quote 0
          • zmous
            zmous last edited by zmous

            @cvp unfortunately crashes, however the code provided by @zrzka does work just fine. Anyway thanks alot!

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

              @zmous Strange, your code with only the little modification above commented the .CGColor() does not crash for me

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