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.
Pythonista 1.6 Beta #160020
-
Hackingroelz, you probably need the MIDIPlayer to be a global, or at least an instance variable -- otherwise i think it goes out of scope and stops when the function ends. you just need to hang onto a reference. i dont remember if SoundPlayer had that problem.
-
Few more comments on latest beta.
-
NSDictionary get/set using python dictionary language doesnt seem to work. at least for dicts found in the wild, the isKindClass seems to not be returning true. i wonder if it would be better to look for whether the object responds to
setValue_forKey_
, orvalueForKey_
etc, rather than checking class? similarly for iterables. -
with the tabbed editor, the
editor
class needs updates to access tabs, or should have areload
command which reloads all tabs. when changing a file on disk, it was a good idea to check if it was thr current file in the editor, and reload, but this cant happen in current version, since reopening a file programatically causes a new tab to open, and theget_path
only returns current tab. -
the editor should probably disallow opening two copies of the same file, unless one is set to read only. this can cause confusion, where one copy is edited, then switching to the other copy effectively undoes the changes! maybe just bring existing file tab to the front if opening an already open file? alternatively, editor should detect if file on disk changed, and reload (or prompt for reload) as is done in many text editors. ... there are use cases for having two tabs open on the same file, say for editing very large files, but keeping edits in sync is necessary.
-
-
- NSDictionary get/set using python dictionary language doesnt seem to work. at least for dicts found in the wild
It's likely that dictionaries you find "in the wild" are
NSDictionary
instances, notNSMutableDictionary
, so they're immutable (this is different from Python where all dictionaries are mutable).- with the tabbed editor, the editor class needs updates to access tabs
Yes, that needs some work.
- the editor should probably disallow opening two copies of the same file, unless one is set to read only. this can cause confusion, where one copy is edited, then switching to the other copy effectively undoes the changes!
The way it's supposed to work is that editing a file in one tab, then switching to a different tab with the same file open would reload the file in the second tab... I just did a quick test, and this mechanism seems to work fine here.
-
the problem comes when two copies of a file are opened, and then you write to the file programatically, then use
editor.open_file
. the new file is now open in one tab, but the old file is in the old tab. i think the problem is because each copy thinks it is "clean", since the changes were made outside of the editor. if you then edit one copy in the editor, then i think it gets reloaded in the other, but in some cases that is exactly the wrong thing, for instance i just want to close the "old" copy, but then it ends up overwriting the new version. -
@JonB Thanks for the clarification. Yes, the way external changes to files are handled could definitely be improved...
-
mostly this is an issue with tabs ... in 1.5 we knew to reload the file in the editor if modifying externally. having ability to programatically check what is in each tab, and reload specific tabs programatically would fix my particular use case.
-
in latest beta 160021
if issubclass(restype, Structure) and not LP64:
should probably be
if restype and issubclass(restype, Structure) and not LP64:
when restype is None, this throws an exception.
-
re dictionaries, as an example:
ns({'test':'ing'})['test']
throws an exception.
ns
of a dict returns a__NSDictionaryM
. maybe this is another 32bit quirk? -
Bug:
did_load
isn't called with CustomView in newui
-
Is the documentation for the beta (modules etc.) available online, or only in app? (I only have an iPhone - easier to read docs on larger screen...)
-
re dictionaries, as an example:
ns({'test':'ing'})['test']
Strange, that works just fine here. I'll have to test it on a 32-bit device...
in latest beta 160021
if issubclass(restype, Structure) and not LP64:
should probably be
if restype and issubclass(restype, Structure) and not LP64:
Yes, I noticed that as well.
@hyshai
Bug: did_load isn't called with CustomView in new ui
Thanks, should be fixed in the next build.
Is the documentation for the beta (modules etc.) available online, or only in app?
The beta documentation is currently only available in the app, sorry.
-
Okay, I know what's going on with the dictionary in 32-bit mode now. Apparently, the 32-bit runtime encodes boolean return types as
char
, and I usedc_char
to translate that... which results in a one-character string in Python that is evaluated asTrue
in a boolean context. I think mapping'c'
toc_byte
(in thetype_encodings
dict) should fix the problem (in case you want to experiment in your own version of the module before I get to upload a new build).What does this have to do with
NSDictionary
? Well,__getitem__
etc. useisKindOfClass_
to determine whether anObjCInstance
wraps anNS(Mutable)Dictionary
, and sinceisKindOfClass_
always returns"True"
, this check doesn't work properly. -
ahh, i dont envy your job trying to support both 32 and 64 bit (but please do!). i did think it was strange that i had to use '\x01` etc for some bools.
went with the duck typing approach for getitem, setittem, delitem, etc, in my hacked module and that is working fine.one other question: some objc objects get created with an alloc(), if we create the instance in python. do we need to explicitly dealloc those when we are done withe the object, or does the objc garbage collection take care of that assuming we delete the python reference?
-
hyashi,
os.path.join(os.path.split(os.__file__)[0],'../Documentation')
contains the docs(html) so you could use your favorite archiver script to copy these off of the device, for leisurely consumption -
In a nutshell: You have to balance every
alloc
-init
with arelease()
orautorelease()
. Objects that are returned from other methods are typically autoreleased already, so releasing them again would result in a crash.ObjCInstance
keeps its own strong reference to the wrapped object internally, so that the object isn't deallocated as long as the wrapper exists (whose memory is managed by Python's reference counting mechanism, aka Garbage Collection).If you're unsure about the correct memory management, it's usually better to leak a little bit of memory than to over-release because the latter leads to crashes.
-
Is it possible to use the new ui editor to add a button to a NavView using the custom attributes field?
I tried using this in the custom attributes box but it doesn't seem to work.
{ 'left_button_items': [ui.ButtonItem(image=ui.Image.named('ionicons-close-24')) ]}
-
Referring to the latest beta:
I set the border of a slider to width=1,radius=15 via UI Editor
When i present the view it only takes the width parameter but the border is 0 -
Thanks, definitely looks like a bug. As a workaround for now, you could put this into the "Custom Attributes" field:
{'corner_radius': 15}
-
@hyshai
Is it possible to use the new ui editor to add a button to a NavView using the custom attributes field?
Unfortunately, this isn't possible right now. The problem is that the button items that a
NavigationView
shows depend on the view that is currently shown in the navigation view, not the navigation view itself.ui.load_view
creates the root view of the navigation stack automatically, but there's currently no way to access it programmatically. -
Ui.convert_point(touch.location, fmview, toview) no longer works. Touch.location is not a tuple and also does not have an as_tuple function as the documentation states.
I had to manually convert to a tuple grabbing the x and y. Touch.location now seems to be a subclass of vector2.