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.


    Help

    Editorial
    2
    3
    2408
    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.
    • Jozh
      Jozh last edited by

      What do I add to this script so it output each element (date,text, width and, length ) on a separate lines of the open file? '\n' ? Thanks.

      import dialogs
      
      
      Dialog_List =[{'type':'date','title':'Date','key':'date'},{'type':'text','title':'description','key':'text'},{'type':'number','title':'Width','key':'wid'},{'type':'number','title':'Length','key':'len'},]
      
      Form_Dialogs = dialogs.form_dialog('Form Dialog',Dialog_List)
      
      date = Form_Dialogs['date']
      text = Form_Dialogs['text']
      width = Form_Dialogs['wid']
      length = Form_Dialogs['len']
      
      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        You're almost there. You can use the editor module to insert text in the current document:

        import dialogs
        import editor
        
        Dialog_List =[{'type':'date','title':'Date','key':'date'},{'type':'text','title':'description','key':'text'},{'type':'number','title':'Width','key':'wid'},{'type':'number','title':'Length','key':'len'},]
        
        Form_Dialogs = dialogs.form_dialog('Form Dialog',Dialog_List)
        
        if Form_Dialogs:
        	date = Form_Dialogs['date']
        	text = Form_Dialogs['text']
        	width = Form_Dialogs['wid']
        	length = Form_Dialogs['len']
        	date_str = date.strftime('%Y-%m-%d')
        
        	to_insert = '\n'.join([date_str, text, width, length])
        	editor.insert_text(to_insert)
        

        Note that I also converted the date to a string. You could customize the format by passing something else to strftime().

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

          Thank you

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