omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    55
    301
    474126
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wradcliffe
      wradcliffe last edited by

      I have been working with the dialogs form_dialog and this test code:

      import dialogs
      import datetime
      
      dt = datetime.datetime.now()
      fields = [
        {'key' : 'the_key0', 'type' : 'switch', 'value' : 'the_value'},
        {'key' : 'the_key1', 'type' : 'text', 'value' : 'the_value'},
        {'key' : 'the_key2', 'type' : 'url', 'value' : 'the_value'},
        {'key' : 'the_key3', 'type' : 'email', 'value' : 'the_value'},
        {'key' : 'the_key4', 'type' : 'password', 'value' : 'the_value'},
        {'key' : 'the_key5', 'type' : 'number', 'value' : '100' },
        {'key' : 'the_key6', 'type' : 'check', 'value' : 'the_value'},
        {'key' : 'the_key7', 'type' : 'datetime', 'value' : dt},
        {'key' : 'the_key8', 'type' : 'date', 'value' : dt},
        {'key' : 'the_key9', 'type' : 'time', 'value' : dt}
      ]
      result=dialogs.form_dialog(title='look at all this stuff', fields=fields)
      print 'text:', result
      
      

      When I look at this, I can't help thinking that all the field data should be aligned right and that there should be labels on each one. Should there be a 'label' key added? How is the user suppose to know what each field represents?

      I suppose you could use sections to implement labels, but that seems wrong. Section as a way of breaking up and labeling combinations of like fields is good.

      sections = [
        ('switch section', [{'key' : 'the_key0', 'type' : 'switch', 'value' : 'the_value'}]),
        ('text section', [{'key' : 'the_key1', 'type' : 'text', 'value' : 'the_value'}])
      ]
      result=dialogs.form_dialog(title='look at all this stuff', sections=sections)
      print 'text:', result
      

      Also - datetime requires/returns a datetime and date and time do as well. Should date and time require and return date and time objects?

      Also, Also - email, url, number don't seem to do anything different then text. Shouldn't they be enforcing formatting or something?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        How is the user suppose to know what each field represents?

        There's a 'title' key you can use, the documentation is a little incomplete right now with regards to the supported keys.

        Also - datetime requires/returns a datetime and date and time do as well. Should date and time require and return date and time objects?

        Maybe, it was a bit easier to implement this way, and you can easily convert it to a date or time object by calling datetime.date() or datetime.time().

        Also, Also - email, url, number don't seem to do anything different then text. Shouldn't they be enforcing formatting or something?

        The keyboard for URL and email fields is different (e.g. the email keyboard has an additional '@' key), and they have autocorrection disabled by default.

        1 Reply Last reply Reply Quote 0
        • techteej
          techteej last edited by

          text = dialogs.text_dialog(title='Name Your Reminder', autocapitalization=ui.AUTOCAPITALIZE_SENTENCES, spellchecking=None)
          r = reminders.Reminder()
          r.title = text
          r.save()

          Gives me a excepted string error.

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            @techteej Did you use the Done button in the text dialog? If you cancel the dialog (via 'x'), it'll return None.

            1 Reply Last reply Reply Quote 0
            • techteej
              techteej last edited by

              It shows up while the dialog is up

              1 Reply Last reply Reply Quote 0
              • omz
                omz last edited by

                @techteej Is that really your entire code?

                1 Reply Last reply Reply Quote 0
                • wradcliffe
                  wradcliffe last edited by

                  There's a 'title' key you can use ...

                  The title key works perfectly. I noticed that the text color defaults to black except for the checkbox case where it is blue (or same as check color).

                  Looking forward to more keys assuming now that you are going to have color, font, etc. to really allow full control.

                  What about field validation? Popping up a special keyboard is nice, but a delegate function called on each keystroke would nail it. I used to work on named entity extraction in text and you can do a lot with simple regex matching, but you need to run code to do credit card numbers (for the checksum). I think mapping field types to entities would be super cool.

                  1 Reply Last reply Reply Quote 0
                  • techteej
                    techteej last edited by

                    @omz Here is my entire code.

                    # coding: utf-8
                    import dialogs
                    import reminders
                    import ui
                    
                    class Data (ui.ListDataSource):
                    	def __init__(self, items=None):
                    		ui.ListDataSource.__init__(self, items)
                    
                    	def tableview_cell_for_row(self, tableview, section, row):
                    		cell = ui.TableViewCell()
                    		cell.text_label.text = str(self.items[row])
                    		return cell
                    
                    v = ui.load_view('reminders')
                    
                    def button_action(sender):
                    	if segment.selected_index == 0:
                    		todo = reminders.get_reminders(completed=False)
                    		for r in todo:
                    			full = r.title
                    			reminders_table.data_source = Data(items=[full])
                    			reminders_table.reload()
                    	elif segment.selected_index == 1:
                    		done = reminders.get_reminders(completed=True)
                    		for r in done:
                    			full = r.title
                    			reminders_table.data_source = Data(items=[full])
                    			reminders_table.reload()
                    
                    def but_action(sender):
                    	text = dialogs.text_dialog(title='Name Your Reminder', autocapitalization=ui.AUTOCAPITALIZE_SENTENCES, spellchecking=None)
                    	r = reminders.Reminder()
                    	r.title = text
                    	r.save()
                    
                    segment = v['segmentedcontrol1']
                    segment.action = button_action
                    reminders_table = v['reminders']
                    
                    create_button = ui.ButtonItem()
                    create_button.image = ui.Image.named('ionicons-ios7-plus-empty-32')
                    create_button.action = but_action
                    
                    v.right_button_items = [create_button]
                    v.present('sheet')
                    
                    1 Reply Last reply Reply Quote 0
                    • omz
                      omz last edited by

                      @techteej Similar to console alerts, dialogs don't work from the main UI thread (allowing this would essentially lead to a deadlock). Try decorating your but_action function with @ui.in_background.

                      1 Reply Last reply Reply Quote 0
                      • techteej
                        techteej last edited by

                        Found a bug. In the UI Editor when delete enabled is off, you can still delete rows in a table.

                        1 Reply Last reply Reply Quote 0
                        • TutorialDoctor
                          TutorialDoctor last edited by

                          Will dialogs allow me to create tables with cells (rows and columns)?

                          This would be most useful, otherwise I don't see an advantage to dialogs over UI.

                          Pinch to zoom in the UI editor would be nice too, as well as saving UI control presets.

                          1 Reply Last reply Reply Quote 0
                          • andymitchhank2
                            andymitchhank2 last edited by

                            The beta doesn't seem to ask for permission to use Location Services when using the location module for the first time.

                            I thought it might be for all required permissions, but the Reminders seems to work fine.

                            Anyone have any ideas on this?

                            1 Reply Last reply Reply Quote 0
                            • omz
                              omz last edited by

                              Found a bug. In the UI Editor when delete enabled is off, you can still delete rows in a table.

                              I can't reproduce this. Note however that the "delete enabled" attribute only applies to the default ListDataSource that gets created as a convenience when loading a TableView from a pyui file. If you set a different data source after loading the view, it doesn't have an effect.

                              Will dialogs allow me to create tables with cells (rows and columns)?
                              This would be most useful, otherwise I don't see an advantage to dialogs over UI.

                              No. For the most part, dialogs doesn't really let you do things you couldn't do with the ui module, but things like form_dialog would require a lot more code when done with ui directly. There are also some things that you couldn't do otherwise, like dialogs.import_file() or dialogs.share().

                              The beta doesn't seem to ask for permission to use Location Services when using the location module for the first time.

                              Are you sure that you didn't give permission with the previous version? The beta would inherit those permissions (it's the same app after all).

                              1 Reply Last reply Reply Quote 0
                              • andymitchhank2
                                andymitchhank2 last edited by

                                I uninstalled the beta, installed the current App Store version and ran a simple get location script. It prompted for Location permissions and retrieved my location.

                                I then uninstalled the App Store version, installed the beta again and ran the script.

                                The script prints out the value of location.get_location(). It is currently printing out None in the beta with no prompt to allow access to Location Services.

                                1 Reply Last reply Reply Quote 0
                                • zencuke
                                  zencuke last edited by

                                  Bluetooth LE? Bless you! I'd love to beta test that. Sending email as soon as I track down your email address ;-)

                                  -steve (aka zencuke)

                                  1 Reply Last reply Reply Quote 0
                                  • omz
                                    omz last edited by

                                    @andymitchhank Hmm, that does sound like a bug indeed. Which version of iOS are you using?

                                    1 Reply Last reply Reply Quote 0
                                    • andymitchhank2
                                      andymitchhank2 last edited by

                                      8.1 on an iPad 3 and iPhone 6 Plus. Both are having the same issue.

                                      1 Reply Last reply Reply Quote 0
                                      • omz
                                        omz last edited by

                                        @andymitchhank Thanks, I've been able to reproduce the issue. Apparently this has to do with some new requirements for location permissions in iOS 8, looking into it.

                                        1 Reply Last reply Reply Quote 0
                                        • wradcliffe
                                          wradcliffe last edited by

                                          I am still working on reproducing an issue that occurs in one of the callbacks in the cb module. What happens is some kind of heap corruption when I call functions in other modules. I was writing some code that used str.append() and getting all kinds of wierd behavior. It looks like either heap corruption or blown stack.

                                          Trouble started when I modified the code trying to print out returned values in a characteristic. I used (print c.value.encode('hex')) in two callbacks and it did not "work". The program just printed nothing but also just returned from the callback and stopped working.

                                          I could use a few hints on how to get a good repro case. I could post my code, but the effect is random and the code needs to access a specific device. Any ideas on how to stress the heap or stack in this callback environment would be appreciated.

                                          1 Reply Last reply Reply Quote 0
                                          • polymerchm
                                            polymerchm last edited by

                                            And how does one find OMZ's e-mail address? happy to help.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors