python 3 pygi webkit2 api how to call a variable inside __init__(self):

135 Views Asked by At

I got the class below and i need to call self.webview variable from a function inside another class. how do i achieve that.

class Window(w):

      def __init__(self):

         self.webview = WebKit2.WebView()


class anotherclass:

      def send_js(js):

         w = self.webview <-- cant get this to match
         w.run_javascript(str(js))
1

There are 1 best solutions below

1
On
class anotherclass:

  js = "some js"


class Window(w):

  def __init__(self):

     self.webview = WebKit2.WebView()
     self.webview.run_javascript(str(anotherclass.js))

i was doing it with the wrong approach the above seems to work for me, i can also put js variable inside a function.