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
-
@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. -
@omz As for the bug, iPad on iOS 8.1.1 (and I had it on iOS 8.1 as well). Actually doesn't work on a single file either.
@blmacbeth Just think though, wouldn't
dialogs.color_picker_dialog(title='', multiple=False)
that returns a color be so much easier? -
ui.TableView.row_height is still always -1.
-
Not sure why line 10 gives me an error.
# coding: utf-8 import dialogs import reminders import ui v = ui.load_view('reminders') reminders_table = v['reminders'] def picked(sender): item = sender.items[sender.selected_row] # gives me error r = item['reminder'] r.completed = True r.save() del sender.items[sender.selected_row] def grabbed(): global todo_items, completed_items todo = reminders.get_reminders(completed=False) todo_items = [{'title': r.title, 'reminder': r} for r in todo] done = reminders.get_reminders(completed=True) completed_items = [{'title': r.title, 'reminder': r} for r in done] reminders_table.data_source = ui.ListDataSource(items=todo_items) reminders_table.data_source.action = picked reminders_table.reload() def button_action(sender): if segment.selected_index == 0: reminders_table.data_source = ui.ListDataSource(items=todo_items) reminders_table.data_source.action = picked reminders_table.reload() elif segment.selected_index == 1: reminders_table.data_source = ui.ListDataSource(items=completed_items) reminders_table.data_source.action = picked reminders_table.reload() @ui.in_background def but_action(sender): fields = [{'key' : 'name', 'type' : 'text', 'value' : 'Name your reminder'},] result=dialogs.form_dialog(title='Create a Reminder', fields=fields) r = reminders.Reminder() r.title = result['name'] r.save() segment.selected_index = 0 grabbed() segment = v['segmentedcontrol1'] segment.action = button_action reminders_table.data_source.action = picked create_button = ui.ButtonItem() create_button.image = ui.Image.named('ionicons-ios7-plus-empty-32') create_button.action = but_action grabbed() v.right_button_items = [create_button] v.present('sheet')
-
I've got a bad image loading related bug. If you do this:
import ui imageurl = 'http://s9.postimage.org/n92phj9tr/image1.jpg' v = ui.View() v.background_color = 'white' im = ui.ImageView() im.flex = 'LRTBWH' im.load_from_url(imageurl) v.add_subview(im) v.present()
Then run, cancel, and run again, Pythonista hangs and has to be closed from multitasking, then often the icon has to be pressed twice just to open it again.
-
I've found something that I think is a weird bug...I ran the exact same code on a Windows machine (albeit in Python 3.4) and it worked fine. However in Pythonista it does..well..nothing.
<li>maxchar = 128
<li>charset = range(maxchar)<li>for n in charset:
<li> print "{0:2s} => {1:2s}".format(str(n), chr(n))The problem seems to be in the
for
loop, every time I run the script nothing is printed. I check the value of n and it is equal to 0. I have no idea why.Apologies for the bullet points..it was the only way I could get newlines by insertings list element HTML tags. They wer'nt present in the code. Also the print statement was indented. (I'm terrible at markdown)
-
One thing that is sometimes strange is that certain errors don't show up in the console, but show up as a red dropdown in the filename in the editor. That's what happened when I ran your code. You will notice the filename changes to re, then when you click on it it shows the error. Not sure why some errors show up this way, some show as red arrows, and some show in the console.
As for the specific problem, apparently you cannot print null bytes ( try
print chr(0)
in the console to see the exception).maxchar = 128 charset = range(maxchar) for n in charset: try: print "{0:2s} => {1:2s}".format(str(n), chr(n)) except TypeError: print 'type error with n={}'.format(n)
To properly format code, you want three backticks, on a newline, with a newline before it, and likewise at the end. Note this doesn't show up in the preview. Backticks are annoying on ios, I have a shortcut. You can also just use four leading spaces, on each line following a blank line.
-
And if you put the word
python
directly after the first three backticks, you get language specific syntax highlighting as in:maxchar = 128 charset = range(maxchar) for n in charset: try: print "{0:2s} => {1:2s}".format(str(n), chr(n)) except TypeError: print 'type error with n={}'.format(n)
-
Python version 2.7.5 --> 2.7.9?
>>> sys.version '2.7.5 (default, Dec 3 2014, 19:04:52) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)]'
Python 2.7.9 is scheduled to be released this Wednesday with some nice networking security fixes backported from Python3. It will also bring
ensurepip
to Python2.I know it is a lot of work but is there any chance of an upgrade of the underlying Python interpreter in the next Pythonisa release?
EDIT: Python 2.7.9 is now officially released
-
-
-
Tech, perhaps create a new thread, since the problem is likely not related to 1.6.
Maybe include the traceback, so we know what error you got. Also, be sure to include enough info, like the troubleshooting steps you took. Like what did you see when you printed all of the expressions individually on that line. -
Not about technical things, but I believe omz should provide demo video of Pythonista both on the site and in the app store. The video should be able to present the ability of Pythonista much better than just static images, especially the advance features. Omz can take a look at Codea's demo video, it's quite good. And I believe a good demo video would also be able to attract new purchasers.
Thank you.
-
I'm also getting the disappearing script bug found on here a lot more in the beta.
-
I too lost a script mysteriously. The file is still there - it's just empty.
-
Did you guys see disappearing scripts with or without external keyboards?
-
Both with and without.
-
@techteej About your bug. You really didn't provide enough info. The error message itself should have been the minimum. plus anything you figured out while debugging. "I got some random error in this big piece of code" isn't enough to get most people involved. I couldn't even run your code since you didn't include the view file so I just moved on. I assume others did the same. Print out the values of the relevant variables. Simplify the code so it is easier to read from scratch. Save us a minute or two of analysis by commenting on what the line of failing code was trying to do and why you think it should have worked. If you have theories share them. Help us help you.
-
Ole, I saw your post about the new Workflow app, and I went and downloaded it. I see that it has support for Editorial and Pythonista.
I am supposing you are adding some type of extensions support in this version, I am just wondering if you are now considering adding something a little special for this new (and soon to be very popular) app.
-
@TutorialDoctor what is this workflow app you speak of?