Hi guys,
Are there any news regarding MIDI access?
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.
Hi guys,
Are there any news regarding MIDI access?
Hi friends of electronic music :-),
I'm looking for a possibility to use Pythonista for communicating to MIDI devices. I have found one thread here (created about 2 years ago) discussing this a bit, but there is no solution mentioned. What's the current situation? Do I e.g. have a possibility to use objc_util to call the required functions? Did anyone already play around with this? Thanks!
Stefan
OK, things can be so easy ;-). I tried it with a PNG, and the example works only for JPEGs.
Hello,
I have recently upgraded to a new iPad Air and also installed the new Pythonista version. Now the extension does not find images anymore. You can test this with the example "Copy Photo Location". When I send an image to this extension I get the position information of the image if I use the iPhone. When I do this on the iPad I get the message "No input image found". Either it is related to iPhone / iPad or to iOS 10.0.2 / 10.2. The iPad runs iOS 10.2. I think this is the problem. My last iPad with iOS 10.0.2 worked fine. Can anyone reproduce this behavior?
Stefan
Thanks, I will try this. I was so focused on the word 'destructor' that I missed them.
Hello Pythonista friends,
Me again ;-) with a simple question which could not be answered by the documentation: Is there any kind of useable destructor for a Scene object? When terminating the program I would like to save some data which is created dynamically during the runtime and as I see for the moment the nicest solution would be a member function within my class (the class is derived from scene.Scene). Sometimes I have used __del__
in other classes but it does not seem to work in a stable way. Is there a function within Scene which is called when the scene is closed and all nodes are still available?
Stefan
Yes, see above: print 'hello'
;-) You don't really need code, one line printing some text (or sys.argv) is enough. Go to Settings / Share Extension Shortcuts -> create a new shortcut -> set Arguments to any value. After that run the extension by sharing any file. That's it.
Hi,
Does anyone have an sharing extension running successfully which receives arguments at the call? I don't even get the simplest program running which only contains print 'hello'
. When I leave the shortcut parameter "Arguments" blank the program runs. When I set the arguments to any string or number the program is not called.
Stefan
This seems to be the shortest solution for now:
import ui
from scene import *
class MyScene(Scene):
def setup(self):
pass
def get_viewpos_from_touch(self, touch):
xt, yt = touch.location
xw, yw = ui.get_window_size()
return xt, yw - yt
def touch_began(self, touch):
menu = ui.View(frame=(0, 0, 200, 200))
menu.present('popover', popover_location=self.get_viewpos_from_touch(touch))
run(MyScene())
I can live with that at least at the moment. I hope that "hiding" the popup as I already explained does not result in memory leaks. ;-)
However, I'm still interested in any information which explains the strange behavior mentioned above: Why does the popup not close completely?
Yes, seems to be better. I will check again which is the best solution for me. I'm still struggling with this popup. Maybe someone else has a hint, too. Maybe @omz can tell us why the popup does not disappear completely when I click beside it.
BTW: The position seems to be strange because the coordinate systems are different. The popup placed at position 0,0 appears in the top left corner, but the point 0,0 of the touch coordinates is in the bottom left corner. The Y axes are leading in different directions.
Thanks, good hint, at least this works! The problem which I see at the moment is when I "hide" the popup as described -> close() does not seem to have an effect anymore. I'm still wondering which state the hidden popup has. The class variables don't change, independent if it is not visible, presented or "hidden" by me:
obj.__dict__ = {}
obj.alpha = 1.0
obj.autoresizing =
obj.background_color = (0.0, 0.0, 0.0, 0.0)
obj.bg_color = (0.0, 0.0, 0.0, 0.0)
obj.border_color = (0.0, 0.0, 0.0, 1.0)
obj.border_width = 0.0
obj.bounds = (0.00, 0.00, 200.00, 200.00)
obj.center = (100.00, 100.00)
obj.content_mode = 0
obj.corner_radius = 0.0
obj.flex =
obj.frame = (0.00, 0.00, 200.00, 200.00)
obj.height = 200.0
obj.hidden = False
obj.left_button_items = None
obj.multitouch_enabled = False
obj.name = popup
obj.navigation_view = None
obj.on_screen = False
obj.right_button_items = None
obj.subviews = ()
obj.superview = None
obj.tint_color = (0.0, 0.47843137383461, 1.0, 1.0)
obj.touch_enabled = True
obj.width = 200.0
obj.x = 0.0
obj.y = 0.0
I'm not sure, both self.menu.hidden
and self.menu.on_screen
are always False. They never get True, even if the view is displayed. I have hoped that at least self.menu.on_screen
will be True as soon as I see the view.
Hi there,
Please have a look at this app:
import ui
from scene import *
class MyScene(Scene):
def setup(self):
self.menu = ui.View(frame=(0, 0, 200, 200))
def touch_began(self, touch):
self.menu.present('popover', popover_location=touch.location)
run(MyScene())
If I touch any point on the screen the view opens as popup window. When I then touch any point outside the view it closes. So far this should be the normal function. But when I touch the screen again I get an exception:
Value error: View is already being presented or animation in progress
What's wrong? It also happens after waiting some seconds, so the view seems to be really closed.
Stefan
OK, done. :-)
quick&dirty (hopefully not very dirty ;-), but if you find some things to optimize please tell me):
import ui
class MyWebView(ui.View):
def __init__(self, url):
self.width, self.height = ui.get_window_size()
self.wv = ui.WebView(frame=self.bounds)
self.wv.load_url(url)
self.add_subview(self.wv)
bi_back = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_back_32'))
bi_forward = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_forward_32'))
bi_back.action = self.go_back
bi_forward.action = self.go_forward
self.right_button_items = [bi_forward, bi_back]
self.present()
def go_back(self, bi):
self.wv.go_back()
def go_forward(self, bi):
self.wv.go_forward()
wv = MyWebView('https://forum.omz-software.com')
Hi,
I'm struggling a bit with the WebView. See this code:
import ui
wv = ui.WebView()
wv.load_url('https://forum.omz-software.com')
wv.present()
Works fine so far, it opens the page ;-). However, I don't see any navigation buttons to navigate forward or back. Do I have to create them by myself by making a view which contains WebView and the buttons (assigned to wv.go_forward()
and wv.go_back()
) or is there an option which I could set for WebView? I haven't found one in the documentation, but maybe I was looking for the wrong keywords...
Stefan
Got it! It works only when using Python 3, either by setting the default to 3.5 or using the shebang #!python3 to override the default interpreter which is set to 2.7 in my case.
Is this a bug or a feature? ;-)
I had Pythonista 2 installed before I changed to 3, but now I have installed only 3. I have created some test files. This one is the extension:
try:
import test23
except:
print('test23 not found')
try:
import test2
except:
print('test2 not found')
try:
import test3
except:
print('test3 not found')
These are test files located in site-packages and so on...
print('test23 found in site-packages')
print('test2 found in site-packages-2')
print('test3 found in site-packages-3')
When I start the extension from Pythonista I get this result when using Python 2.7:
test23 found in site-packages
test2 found in site-packages-2
test3 not found
and this one for Python 3.5:
test23 found in site-packages
test2 not found
test3 found in site-packages-3
Called as extension I get:
test23 not found
test2 not found
test3 not found
Hi,
I have created a Python file "ftpx.py" containing only one class which I want to use in several programs. I have stored the file in site-packages. A standard program which imports this file using "from ftpx import FTPx" works fine. An extension program quits with "ImportError: No module named ftpx" as soon as I call it using the appex functionality. What could be the reason? How can I import my own functions also in appex programs?
Stefan
Thanks a lot. Especially "CMMotionManager" mentioned in the document was a very good keyword for further searches. :-)
Hi,
I'm playing with the motion functions right now because I want to create some kind of compass and spirit level app. Does anyone have any good links to documents which explain the values I get from magnetometer etc.? Thanks a lot!
Stefan