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.


    Access to Apple standard language dictionaries?

    Pythonista
    5
    15
    6778
    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.
    • cvp
      cvp last edited by

      The standard UI could perhaps is sufficient for me.
      How can I try it?

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

        If the default iOS dictionary lookup UI is acceptable for you, this script is probably what you're looking for.

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

          Thanks a lot, it's very good for what I want.

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

            On all my scripts, I start by "hiding" the Pythonista window with a full_screen ui.view.
            But with this code, the standard UI dictionary is not visible.
            How can I solve that?

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

              What to add in your sample to set the ViewController as a sub view of an ui.view?

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

                @cvp In theory you can, but it doesn't look nice at all and there are some big problems with navigation.

                view = ui.load_view()
                
                lookup_view = referenceViewController.view()
                ObjCInstance(view).addSubview_(lookup_view)
                
                view.present()
                

                I wouldn't use that approach

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

                  I think Workflow has a "define this" stage. Not sure how they do it. But maybe you could invoke it.

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

                    @MartinPacker They just show the UIReferenceLibraryViewController in a popover.

                    1 Reply Last reply Reply Quote 1
                    • cvp
                      cvp last edited by ccc

                      First, I know for Workflow, but I try to replace all my workflows by Pythonista scripts.

                      There is my shortest script using what you advice me.
                      If I comment all statements using "back" (my ui.view), all is ok.
                      If I uncomment them, except the "subview", the background is shown but not the dictionary window.
                      If I also uncomment the "subview" statement, Pythonista crashes and I fall on the home screen of the idevice...
                      Thus, obviously, my "ObjCInstance(back).addSubview_(referenceViewController)" is not correct.
                      I really need help and I'm sorry to ask you to spend your time for helping a starter like me.

                      X

                      Coding: utf-8
                      from objc_util import ObjCClass, UIApplication, CGSize, on_main_thread,ObjCInstance
                      import sys
                      import ui
                      
                      UIReferenceLibraryViewController = ObjCClass('UIReferenceLibraryViewController')
                      
                      
                      back= ui.View()
                      back.background_color='gray'
                      back.name = 'Dictionary'	
                      back.present('full_screen',hide_title_bar=False)
                      
                      input = 'word'
                      referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input)
                      		
                      ObjCInstance(back).addSubview_(referenceViewController)
                      		
                      rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
                      tabVC = rootVC.detailViewController()
                      
                      referenceViewController.setTitle_('Definition: {0}{1}{0}'.format('\'', input))
                      referenceViewController.setPreferredContentSize_(CGSize(540, 540))
                      referenceViewController.setModalPresentationStyle_(2)		
                      #tabVC.addTabWithViewController_(referenceViewController)
                      tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
                      
                      1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB last edited by

                        You were very close! addSubview takes a view, not a viewcontroller, which can be obtained thusly:

                        ObjCInstance(back).addSubview_(referenceViewController.view())
                        
                        1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp last edited by

                          One more time, thanks a lot to be so kind with me...
                          But I have the same problem of script causing Pythonista to crash without any message...

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

                            If I comment the "tabVC.addTabWithViewController_(referenceViewController)" statement, all is ok
                            Thanks and have a good end of week-end

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

                              My error! In your original script, this line was commented and during my tests, I've removed the comment, sorry.

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