omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. boegh

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 6
    • Best 0
    • Controversial 0
    • Groups 0

    boegh

    @boegh

    0
    Reputation
    381
    Profile views
    6
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    boegh Unfollow Follow

    Latest posts made by boegh

    • RE: Maximize console view

      @cvp said:

      sorry for the delay but I needed some time to solve it

      Please don't be sorry. I assume you are a volunteer contributor, and even if not, the response times are quite a bit lower, than what I have experienced from paid professionals :)

      As for your question on wether or not you have understood the question, I can't answer that with exact certainty, but the solution you have provided does exactly what I was looking for, so I'd say that you most likely figured out what I meant. Sorry if I was not clear - English is not a first language for me, and the Python terminology is also a bit new for me.

      posted in Pythonista
      boegh
      boegh
    • Maximize console view

      Encouraged by the good and solid responses for my previous question I will dare another one here :)

      Is there a way to maximize the console scriptually?

      I have a script which I call through Siri Shortcuts, and prints the output to the console, but the state of the console/editor view is as Pythonista was left, so my thinking was to maximize the console view through the script.

      posted in Pythonista
      boegh
      boegh
    • RE: 'Enter'-keypress/softpress to call action in custom form input

      @cvp said:

      Normally, it is the purpose of deleting the imported dialogs module, did you remove this part of code?

      No I kept it exactly as you wrote it (copy/paste). I can offer no explanation, but I did narrow in on the problem:

      Removing the try/except-block around the del sys.modules['dialogs']-line, gave me the following error:

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/60EBD24F-667F-4F6E-B595-9100C20FC784/Pythonista3/Documents/dialogs_2.py", line 4, in <module>
          del sys.modules['dialogs']
      NameError: name 'sys' is not defined
      

      So I tried to add import sys in the beginning of the file, and it worked well. I am a bit perplexed by this behaviour, as I understood it so, that the sys-module would always be loaded?

      Keeping the import-statement in place, I reinserted the try/except-block and it works flawlessly.

      I am using Python 3.6 Interpreter in Pythoniste v.3.2 (320000).

      posted in Pythonista
      boegh
      boegh
    • RE: 'Enter'-keypress/softpress to call action in custom form input

      Again thank you for the teaching points @cvp :)

      I tried your code, and as you suggested, the rerun did give an error:

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/60EBD24F-667F-4F6E-B595-9100C20FC784/Pythonista3/Documents/dialogs_2.py", line 16, in     <module>
          f = dialogs.form_dialog(title='dialog title', done_button_title='ok',fields=fields, sections=None)
        File "/var/containers/Bundle/Application/CD376C3C-8193-4F37-B990-A9B960D30F2D/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/dialogs.py", line 456, in form_dialog
          c = _FormDialogController(title, sections, done_button_title=done_button_title)
        File "/private/var/mobile/Containers/Shared/AppGroup/60EBD24F-667F-4F6E-B595-9100C20FC784/Pythonista3/Documents/dialogs_2.py", line 10, in my__init__
          original__init__(self, *args, **kwargs)
        File "/private/var/mobile/Containers/Shared/AppGroup/60EBD24F-667F-4F6E-B595-9100C20FC784/Pythonista3/Documents/dialogs_2.py", line 10, in my__init__
          original__init__(self, *args, **kwargs)
        File "/private/var/mobile/Containers/Shared/AppGroup/60EBD24F-667F-4F6E-B595-9100C20FC784/Pythonista3/Documents/dialogs_2.py", line 10, in my__init__
          original__init__(self, *args, **kwargs)
        [Previous line repeated 494 more times]
      RecursionError: maximum recursion depth exceeded while calling a Python object
      

      Am I missing something here or isn't it the purpose of the del sys.modules['dialogs']-statement to avoid this issue?

      posted in Pythonista
      boegh
      boegh
    • RE: 'Enter'-keypress/softpress to call action in custom form input

      @cvp, thank you for your quick response.

      I see the magic lies in utilising c.textfield_did_end_editing and assigning that to a done_action(or like) function.

      Again thank you - can I buy you a cup of coffee?

      posted in Pythonista
      boegh
      boegh
    • 'Enter'-keypress/softpress to call action in custom form input

      I just started on Pythonista a few days ago (and so far I love it), in order to learn a bit more of Python (I have no professional programming experience).

      So after having stolen and modified the code by @cvp here and modified it a bit I ended up with the following little snippet, to convert a temperature from Fahrenheit to Celcius (just to have it do something more than print hello world):

      from dialogs import _FormDialogController
      from console import set_color
      
      c = _FormDialogController('Input Box', [('', [{'title':'Fahrenheit:','type':'text','value':''}])], done_button_title='Done')
      c.container_view.frame = (0, 0, 400,130)
       c.container_view.present('sheet')
       c.container_view.wait_modal()
       c.container_view = None
       if c.was_canceled:
          set_color(1,0,0)
          print('! ', end='')
          set_color()
          print('Cancelled')
       else:
          try:
             float(c.values['Fahrenheit:'])
             set_color(1,1,1)
             print(round((int(c.values['Fahrenheit:'])-32)*5/9,2), end='')
             set_color()
             print('˚C')
          except:
             set_color(1,0,0)
             print('! ', end='')
             set_color()
      

      I went the way with the custom box, in order to generate a simple single-line input form, which the dialogs in the dialogs-module does not seem to have, so this seemed like the appropriate way.
      I am missing a way to to press enter after having entered the Fahrenheit value, rather than having pto press Done. Is this doable?

      On a side-note: The documentation for console.set_color doesn't actually mention this, unlike for console.set_font, but set_color() (without parameters) does actually set the color back to default color.

      posted in Pythonista
      boegh
      boegh