omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. indoxan

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    indoxan

    @indoxan

    Japanese high school student. My English depends on machine translation.

    0
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Location Japan

    indoxan Unfollow Follow

    Latest posts made by indoxan

    • Cannot call UIButton.setMenu_() in Pythonista 3.4

      Using UIButton.setMenu_() crashes.
      I noticed this problem when I'm using @mikael ui3 menu.py.

      It looks like:

      objc_button = self.button.objc_instance.button()
      objc_button.setMenu_(objc_menu)
      

      I also tried something like this:

      button = ObjCClass("UIButton").alloc().init()
      menu = ObjCClass("UIMenu").alloc().init()
      ...
      button.setMenu_(menu)
      

      But crashed as well.

      I remember there was no problem in Pythonista3.3, is there any solution?

      posted in Pythonista
      indoxan
      indoxan
    • RE: KVO on WKWebView

      @vivek101 @cvp @JonB

      I was able to solve this problem by using ObjCDelegate of @mikael pythonista-achors for the time being. I will try other methods as well.

      Thank you for your kind reply!

      posted in Pythonista
      indoxan
      indoxan
    • RE: KVO on WKWebView

      I also tried programs like:

      class WebView(ui.View):
      
          def __init__(self):
              self.create_webview()
      
          @objc_util.on_main_thread
          def create_webview(self):
              self.webview = objc_util.ObjCClass("WKWebView").alloc().initWithFrame_(...)
              self.objc_instance.addSubview_(self.webview)
      
      class View(ui.View):
      
          def __init__(self):
      
              self.webview = WebView()
              self.add_subview(self.webview)
      
              observer_cls = objc_util.create_objc_class("observer_cls", methods=[self.observeValueForKeyPath_ofObject_change_context_])
              observer = objc_util.ObjCClass("observer_cls").alloc()
      
              self.webview.webview.addObserver_forKeyPath_options_context_(observer, "canGoBack", 0, None)
              self.webview.webview.addObserver_forKeyPath_options_context_(observer, "canGoForward", 0, None)
              ...
      
          def observeValueForKeyPath_ofObject_change_context_(_self, _cmd, _path, _obj, _change, _context):
                  ...
      

      observer is used as an instance of observer_cls.
      But in this case an error occurs. _objc_exception.py looks like this:

      Exception ignored on calling ctypes callback function: <bound method View.observeValueForKeyPath_ofObject_change_context_ of <__main__.View object at 0x116bbc180>>
      TypeError: View.observeValueForKeyPath_ofObject_change_context_() takes 6 positional arguments but 7 were given
      
      posted in Pythonista
      indoxan
      indoxan
    • RE: KVO on WKWebView

      @vivek101 Thank you for your welcome and for answering my question.

      I tried the solution you showed, but it still seems that observeValueForKeyPath_ofObject_change_context_ is not called.
      Also, when I specified a non-existent name in keyPath of addObserver, nothing happened as well.

      I'm not familiar with Objective-C and there are many things I don't understand, but I have the following questions:

      • I understand that in create_objc_class the superclass defaults to NSObject.
      • When using observeValueForKeyPath_ofObject_change_context_ as a class method, shouldn't I use the classmethod argument of create_objc_class?
      posted in Pythonista
      indoxan
      indoxan
    • KVO on WKWebView

      I'm trying out Key-Value-Observing with WKWebView in objc_util.

      class WebView(ui.View):
      
          def __init__(self):
              self.create_webview()
      
          @objc_util.on_main_thread
          def create_webview(self):
              self.webview = objc_util.ObjCClass("WKWebView").alloc().initWithFrame_(...)
              self.objc_instance.addSubview_(self.webview)
      
      class View(ui.View):
      
          def __init__(self):
      
              self.webview = WebView()
              self.add_subview(self.webview)
      
              observer = objc_util.create_objc_class("observer", methods=[self.observeValueForKeyPath_ofObject_change_context_])
      
              self.webview.webview.addObserver_forKeyPath_options_context_(observer, "canGoBack", 0, None)
              self.webview.webview.addObserver_forKeyPath_options_context_(observer, "canGoForward", 0, None)
              ...
      
          def observeValueForKeyPath_ofObject_change_context_(_self, _cmd, _path, _obj, _change, _context):
              ...
      

      I'm using something like this, but observeValueForKeyPath_ofObject_change_context_ doesn't seem to get called. Is there something wrong?

      posted in Pythonista
      indoxan
      indoxan