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
-
I have some questions about the cb implementation. I have noticed that there is no support for Descriptors or Advertisement info.
Descriptors of characteristics would be nice if they are actually implemented by the BLE device manufactures. It would make it possible to write a nice generic BLE browser app.
Advertisement data is probably more important since this seems to be the way you get access to the signal strength of the remote device. It can also be the main way that all of the data a device produces is transmitted. This is the way that beacons are suppose to work. There is no connection ever made since all the data comes across as part of the advertisement.
Also, looking at the apple sdk, I notice that they have both a central manager and peripheral manager while your implementation rolls them into one. This keeps things simple, but it also makes managing multiple peripherals difficult.
The issue of persistence is an additional concern. I have read that the design of BLE encourages the persistence of service and characteristic uuids after they are discovered so that you don't need to rescan for them every time your app runs. The apple sdk seems to have support for this with calls you can make to do scans for connected peripherals or for specific services.
Is Apple still messing around with all this and changing their APIs a lot? In reading through the online docs, I keep seeing lots of crossed out functions and new ones so it looks kinda rough. I can't even find a mention of how MIDI is suppose to be implemented despite the fact it suppose to already be part of ios8.
-
I think I may have found a few bugs in the
dialogs
andconsole
modules:dialogs
I've only really played with the import_file() function, and I've noticed several things. However, I can't seem to find a way to reliably produce one exact problem but whatever the cause it either: crashes the app (jump to homescreen) OR unexpectdly closes the dialog.
So far this has happened when I:
<li> 1. switch from tile view to list view
<li> - this one's a bit longer
<li> 1. Switch to list view
<li> 2. Open external source menu
<li> 3. Set google drive toon
</li>console
I've only noticed one thing with this module and I'm not really sure how to reproduce it, I get varying results every time.
It has to do with the set_color() function, I use it in a script I run at least 3 times a day (its a calculator using sympy, <b>GREAT</b> for math class). I call `set_color(0.36458m 0.0, 1.0) and print the following:
<li>Imported:
<li> console, canvas, random,
<li> fmath as fm, numpy as np, decimal as d,
<li> * from sympy, * from database.prefixes, Dynamic from containers, ctype from type.ctype, <li>division+generators from future
<li>Assigned:
<li> a, b, c as norm
<li> k, i, n as int
<li> f, g, h as func
<li>Reassigned:
<li> fm.m -> m, fm.fr -> frac, fm.cm -> cm<li>Loading constants...</blockquote>
(I apolgogize for the bullet points; couldnt get the string to work any other way)And then the script continues.
For some reason, the "fm.fr" two lines from the end of the string appears as a lighter blue. I have no clue why. I can provide the rest of the script if you would like but it won't work as I import a bunch of custom modules.
-
Regarding
dialogs.import_file
: Yes, I've noticed a few issues as well (mostly the dialog closing unexpectedly), but I don't think there's much I can do about this. Basically everything that happens inside the document picker happens in an entirely different process, so Pythonista isn't actually doing anything while you navigate there... I might be wrong, but it seems to me that those are either iOS 8 or Google Drive bugs.As for the
set_color
thing, I think this has to do with a new feature in the console that tries to highlight URLs automatically.frm.fr
looks like a URL, so it gets a blue color (and you could tap it to open the browser). Obviously, this is not what you want in this case – I'll definitely consider making this feature optional. -
I have a question about the cb callbacks that I could use some insight on. I have been writing various test scripts and noticing that did_update_value seems to drop values if they are coming in too fast. I can use MIDI devices to generate a LOT of events and noticed that many of them are never logged by my script. It is obvious now that having any print statements or anything else that is slow in there is an issue and can cause data loss and other problems.
So how do I deal with this during script development and determine what is actually going on if I can't log using print statements?
How do I determine what is actually going on in the callback? Is the callback run in just one thread and events serialized and buffered by the os or is there no buffering and events that come in while my script is handling the callback simply dropped?
I am thinking that I need to implement a special logger that sends the info to a queue like in QueueHandler in 3.0. This might be fast enough to support development and debug.
Any ideas, thought, and suggestions are welcome.
-
Look at my chordcalc repository. The class debugStream allows you to acculumate depug output without calling print to slow things down. You can create multiple streams and dump each separtely when done.
-
Thanks polymerchm for the suggestion. I remember seeing this now as part of your app.
class debugStream(): """ create buffered output to speed up console printing""" def __init__(self): self.out = '' def push(self,string,*args): self.out += string.format(*args) + '\n' def send(self): print self.out self.out = ''
In my case I am in a callback handling a constant stream of MIDI data in the form of "time tick" events. This makes it difficult to know when to push and when to send. I guess I could just add some simple auto flushing logic to this based on the string length.
Thanks for the simple and practical suggestion.
-
A minor suggestion: the gui doesn't have presets for iPhone 6 or 6+. I haven't been able to run too much, though my standard scripts seem to work fine.
-
Potential bug
in betaView.present(style='full_screen', orientation=('landscape'))
Does not prevent rotation. With or without parens around 'landscape'
IPad Air 2
-
Potential bug in beta
View.present(style='full_screen', orientation=('landscape'))First off, it should be
orientations
(plural), notorientation
, but I assume that's just a typo (you'd get an error otherwise). More importantly, you should pass a sequence of valid orientations, not a single orientation. It looks like you're trying to pass a tuple, but tuples that only contain a single item must contain a trailing comma, like this:('landscape',)
. The method accepts your single string because it expects a sequence, and strings are actually sequences (of characters), but you won't get the proper behavior this way. -
Thanks. Didn't know about the trailing comma formalism in a in a tuple of text strings. Works just fine now. Sorry for false alarm.
-
Any chance of getting lxml in Pythonista 1.6 (and the next version of Editorial too, while I'm at it)? I would really, really like to use openpyxl (or python-xlsx) and python-docx to read/edit Excel and Word docs in my Dropbox but they have lxml as a dependency and, as a C-based library, it's not user-installable.
-
I've been having a lot of fun with the cb module. So far, I've been talking with a ti sensor tag. I have also been using a piconsole to communicate with a Raspberry pi via btle.
I'm having one issue and I'm not sure why. I have issue detecting my iphone. It seems to only detect it on rare occasions. Has anyone else been able to see with iphone while it's in discover mode?
-
Ole, remember to reinsert the xcode export!
-
@filippocld: I have found that using OMZ's online xCode snapshot is not quite as convenient but it works, in case the export functionality is an issue.
-
What is this xCode snapshot? Is this the template project currently needed build your own app? Is there a version we should look at that is for 1.6?
-
You will find a link to the snapshot mentioned in the 1.5 release notes. As far as I know that is still a snapshot of the 1.5 base but I haven't looked lately.
-
I would really appreciate a setting to make folders sort alphabetically within the list of files (Mac style) instead of at the top (Windows style). I find the latter incredibly rage-inducing.
-
@omz Just a few thoughts:
- [Bug] When archiving a folder to send as an email in the export menu, the email share sheet is never presented.
- [Feature Request] Would it be possible to get a color picker dialog?
- [Feature Request] Would it be possible to get a console.hud_alert with a loading icon? Sort of like when creating an archive?
-
[Bug] When archiving a folder to send as an email in the export menu, the email share sheet is never presented.
I can't reproduce this. iPhone or iPad? Which iOS version? Does it work with a single file?
[Feature Request] Would it be possible to get a console.hud_alert with a loading icon? Sort of like when creating an archive?
You can do this with
console.show_activity()
andconsole.hide_activity()
, e.g.:import console import time console.show_activity('Please wait') time.sleep(1) # do some work here... console.hide_activity()
-
@techteej I have a thing for you. It can (AND SHOULD) be cleaned up and or modified to look better.
import ui from random import random def color_chooser_dialog(): ''' Shows a color chooser dialog and returns the color as a hex value. I may have it return a tuple, but most Python modules will accept ANY color representation ''' def slider_action(sender): # Get the root view: v = sender.superview # Get the sliders: r = v['slider1'].value g = v['slider2'].value b = v['slider3'].value # Create the new color from the slider values: v['view1'].background_color = (r, g, b) v['label1'].text = '#%.02X%.02X%.02X' % (r*255, g*255, b*255) def shuffle_action(sender): v = sender.superview s1 = v['slider1'] s2 = v['slider2'] s3 = v['slider3'] s1.value = random() s2.value = random() s3.value = random() slider_action(s1) class ColorMixer (ui.View): def __init__(self): self.val = None self.background_color = 'white' self.frame = (0,0,320,244) view1 = ui.View(name='view1') view1.frame = (6,6,154,59) view1.flex = 'R' label1 = ui.Label(name='label1') label1.frame = (168,6,148,59) label1.flex = 'L' label1.font = ('<system>', 32) label1.number_of_lines = 0 label1.alignment = ui.ALIGN_CENTER label1.text = 'FFFFFF' slider1 = ui.Slider(name='slider1') slider1.frame = (6,73,308,34) slider1.flex = 'W' slider1.tint_color = '#ff0000' slider1.value = .5 slider1.continuous = True slider1.action = slider_action slider2 = ui.Slider(name='slider2') slider2.frame = (6,115,308,34) slider2.flex = 'W' slider2.tint_color = '#00ff00' slider2.value = .5 slider2.continuous = True slider2.action = slider_action slider3 = ui.Slider(name='slider3') slider3.frame = (6,157,308,34) slider3.flex = 'W' slider3.tint_color = '#0000ff' slider3.value = .5 slider3.continuous = True slider3.action = slider_action button1 = ui.Button(name='button1') button1.frame = (168,199,146,38) button1.flex = 'L' button1.title = 'Done' button1.font = ('<system>', 15) button1.action = self.done_action button2 = ui.Button(name='button2') button2.frame = (6,199,145.5,38) button2.flex = 'R' button2.title = 'Shuffle' button2.font = ('<system>', 15) button2.action = shuffle_action self.add_subview(view1) self.add_subview(label1) self.add_subview(slider1) self.add_subview(slider2) self.add_subview(slider3) self.add_subview(button1) self.add_subview(button2) shuffle_action(button2) def done_action(self, sender): self.val = self['label1'].text self.close() w = ColorMixer() w.present('popover') w.wait_modal() return w.val if __name__ == '__main__': print color_chooser_dialog()
Just remember to put
@ui.in_background
if you call it. I made that mistake too many times.