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.


    Need help about ui function

    Pythonista
    6
    15
    9432
    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.
    • Phuket2
      Phuket2 last edited by Phuket2

      Another post on the subject, but there are a lot more.

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

        @omz i've got an error : no objectiveC MPMediaPickerController blabla... Is this ios10 only?
        btw, would be nice to be able to copy the error messages.

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

          @jmv38 It works on iOS 9 too. For some reason, MediaPlayer.framework (where MPMediaPickerController is from) is loaded by default on iOS 10, but on iOS 9 you first need to load it manually:

          NSBundle.bundleWithPath_("/System/Library/Frameworks/MediaPlayer.framework").load()
          MPicker = ObjCClass("MPMediaPickerController")
          

          By the way, it is possible to copy error messages. When you open the traceback navigator (the red window that pops up when an exception happens) there is a "Print Traceback" option at the top of the traceback list. This prints a normal Python traceback to the console, which you can copy and paste like normal.

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

            thank you @dgelessus .
            I dont have the print option, it must be a pythonista3 feature.

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

              @omz doesn't iOS 10 require a NSAppleMusicUsageDescription entry in the Info.plist to access the MediaPlayer framework?

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

                @lukaskollmer Only if the app is linked against the iOS 10 SDK. The current App Store versions are linked against the iOS 9 SDK, and the betas do have that Info.plist key.

                1 Reply Last reply Reply Quote 0
                • wolf71
                  wolf71 @Phuket2 last edited by

                  @Phuket2 Thanks.

                  error:

                  Traceback (most recent call last):
                  File "/private/var/mobile/Containers/Shared/AppGroup/A393CF34-1371-47E1-B49E-D9AF34A644DC/Pythonista3/Documents/Test/test1.py", line 41, in <module>
                  mc = MYUIClass(ui_file, frame=f, bg_color='white')
                  File "/private/var/mobile/Containers/Shared/AppGroup/A393CF34-1371-47E1-B49E-D9AF34A644DC/Pythonista3/Documents/Test/test1.py", line 20, in init
                  super().init(*args, **kwargs)
                  TypeError: super() takes at least 1 argument (0 given)

                  Phuket2 2 Replies Last reply Reply Quote 0
                  • Phuket2
                    Phuket2 @wolf71 last edited by

                    @wolf71 , are you using Pythonista 2?

                    1 Reply Last reply Reply Quote 0
                    • Phuket2
                      Phuket2 @wolf71 last edited by

                      @wolf71 , well I guess you are. If you replace the super().xxx line as the below it will work.

                      class MYUIClass(ui.View):
                          def __init__(self, ui_file, *args, **kwargs):
                              ui.load_view(ui_file, pyui_bindings(self))
                              #super().__init__(*args, **kwargs)
                              ui.View.__init__(self, *args, **kwargs)
                      
                      wolf71 1 Reply Last reply Reply Quote 0
                      • wolf71
                        wolf71 @Phuket2 last edited by

                        @Phuket2 said:

                        ui.View.init(self, *args, **kwargs)

                        1. Python 2.7
                        2. ui.View.init(self, *args, **kwargs) work.
                        3. Thank you very much. :-)
                        Phuket2 1 Reply Last reply Reply Quote 0
                        • Phuket2
                          Phuket2 @wolf71 last edited by

                          @wolf71 , great. The call to super is a Python 3 construct. But it's nice, because it's generic. It just calls the base class without having to refer to it absolutely. In the Python 2 version, you can see calling ui.View.init() by name. It may seem like a small difference, but it really can make life a lot easier if you chop,and change your code object model. I am just thinking about small things here. But on a medium to large project I am sure it can have a profound impact. I can only speculate as I have never done a large project in Python.

                          My comments above are about when you are inheriting from just one base class. You have to think a little harder(aka, have more understanding) if your are inheriting from multiple base classes (multiple inheritance).

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