Need help about ui function
Phuket2 last edited by Phuket2
Another post on the subject, but there are a lot more.
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.
dgelessus last edited by
@jmv38 It works on iOS 9 too. For some reason,
MPMediaPickerControlleris 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.
jmv38 last edited by
thank you @dgelessus .
I dont have the print option, it must be a pythonista3 feature.
lukaskollmer last edited by
@omz doesn't iOS 10 require a
NSAppleMusicUsageDescriptionentry in the
Info.plistto access the
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.
wolf71 last edited by
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
TypeError: super() takes at least 1 argument (0 given)
@wolf71 , are you using Pythonista 2?
@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 last edited by
ui.View.init(self, *args, **kwargs)
- Python 2.7
- ui.View.init(self, *args, **kwargs) work.
- Thank you very much. :-)
@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).