omz:forum

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

    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 3
    • Followers 0
    • Topics 4
    • Posts 54
    • Best 6
    • Controversial 0
    • Groups 0

    technoway

    @technoway

    8
    Reputation
    1973
    Profile views
    54
    Posts
    0
    Followers
    3
    Following
    Joined Last Online

    technoway Unfollow Follow

    Best posts made by technoway

    • RE: New Beta for Pythonista 3.3

      @omz - Thank you for the workaround.

      You do not have to apologize for anything.

      Pythonista would have to have many, many, more bugs before it would stop being my favorite App. Thanks for making Python programming available on IOS.

      posted in Pythonista
      technoway
      technoway
    • RE: Syntax error def__init__(self, rare=False)

      dgelessus - Good catch. I missed the missing space at first when I read the first post.

      That is def__init__-ly the problem.

      Sorry, I couldn't resist the bad pun.

      In my defense, I would have tried to help too, but I just got here.

      posted in Pythonista
      technoway
      technoway
    • RE: PythonistaKit dialogs.alert() buttons can't be pressed on real iPhone X (but it works in simulator?)

      I looked up the documentation for dialog.alert, and was directed to look at console.alert.

      I found this topic from 3 years ago about a similar hang with console.alert.

      console.alert with SceneView
      https://forum.omz-software.com/topic/1699/console-alert-with-sceneview

      posted in Pythonista
      technoway
      technoway
    • RE: Script that can’t be stopped

      Each time the "dont_stop_me_now" function is called, the return address is saved on the call stack; so that if the function ever did return, it would return to the caller. So, if you were to try to stop the program enough times, eventually it would run out of stack memory. This would take a very, very, long time though.

      I'm not sure what Pythonista will do if it runs out of internal stack memory. I expect it would abort the program, but that's just a guess. Actually, all of that is a guess - but Python has to have a call stack, or it couldn't support recursion.

      posted in Pythonista
      technoway
      technoway
    • RE: Pythonista is now featured on Python.org

      Thank you omz for making such a great product, and congratulations ccc, on getting Pythonista on the Python website.
      Pythonista is, by far, my favorite App on my iPhone.

      posted in Pythonista
      technoway
      technoway
    • How do I make a full-screen button and handle button-down and button-up events?

      I want to be able to enter data in a Morse-code-like language while my phone is in my pocket by pushing anywhere on the screen.

      I've examined the UI examples, but I am confused as how to separate button-down events and button-up events in separate handlers. Also, since this will be a full-screen button, I might not need to use a "button" at all.

      How could this be done?

      posted in Pythonista
      technoway
      technoway

    Latest posts made by technoway

    • RE: New Beta for Pythonista 3.3

      @omz - Thank you for the workaround.

      You do not have to apologize for anything.

      Pythonista would have to have many, many, more bugs before it would stop being my favorite App. Thanks for making Python programming available on IOS.

      posted in Pythonista
      technoway
      technoway
    • RE: New Beta for Pythonista 3.3

      With the latest Pythonista Beta v. 3.3 (330025), installed today, i.e. 20 Feb., 2020, I get the same crash in my App I got with the last Beta.

      I tracked it down to the very first line of code that executes in my App! I commented out that line, and my App runs successfully.

      That line is:

      A great many lines of code are omitted both before and after the code snippet shown.

              # Prevent iPhone from going to sleep while this program runs.
              console.set_idle_timer_disabled(True)
      
              # Create an instance of a class that derives from ui.View.
              # <code-omitted>
      

      If I comment out that one line of code, the program does not crash.

      I am running that on an iPhone 6s running IOS 13.3.1

      posted in Pythonista
      technoway
      technoway
    • RE: Can Pythonista handle volume switch up-down events a for an earphone button that is plugged into an iPhone 6s?

      @mikael - Thank you for the reply. I could make that work, but I'd have to change the signalling method. I need both up and down events now.

      I'll continue to use the screen, and I'll look for other solutions. Perhaps there's a way to signal the screen with a device attached to the phone. I'll keep looking for a solution.

      posted in Pythonista
      technoway
      technoway
    • Can Pythonista handle volume switch up-down events a for an earphone button that is plugged into an iPhone 6s?

      Is it possible to use Pythonista APIs to get notifications for the the volume-up and volume-down switches that are on an earphone set plugged into the earphone jack of an iPhone 6s? I want to access just one button, and get up and down notifications, similar to the touch_began and touch_ended notifications for a screen button.

      I am currently using tapping on the screen to control something. I have an electrical engineering background, so I can wire a button up and plug that in, while satifying the impedances for the other connections on the plug. I'd like to be able to push that button to control something, rather than having to push on the screen of the phone.

      I have no idea how to do this. Note, I do not care if this also affects the audio volume. I can have the audio muted. I just want to access the up-event and down-event when the button is depressed and let go.

      I found this page, but it does not appear to have the information for the volume control switches that are plugged in with earphones.
      https://developer.apple.com/documentation/audiotoolbox/system_sound_services

      posted in Pythonista
      technoway
      technoway
    • RE: touch_began no longer called for ui.View derived class using Pythonista beta

      brumm - Thank you. With the first change you proposed, the touch_began method is now called when I touch the screen. The image is now too large, but I'll figure that out.

      JonB, than you for identifying the source of the problem. I didn't think of that.

      mikael - Thank you for the response. Whatever changed, it was a while ago.

      I only recently had time to work on this again. It occurs to me this also might have broken because of an IOS upgrade. I think both an IOS upgrade and a Pythonista beta update happened before I noticed it was broken.

      Note, one of the things I can control is what is on the screen. In the main program, the following can be called.

          self.change_title_bar_color('000000')
          self.remove_subview(self.iv)
      

      and in another place in the code:

          self.change_title_bar_color('334444')
          self.add_subview(self.iv)
      

      That's why I chose an ImageView.

      I have a background in digital signal processing, so I know something about images, but I have a weak understanding of Pythonista's image classes. I got things to work mostly by copying examples.

      The image is now scaled way too big. I think I might need a frame? I tried setting the size a couple of ways, but that had no effect.

      In any event, thanks. I will fix the image size issue - the touch_began problem had me stumped. I was looking in all the wrong places. The word "View" in "ImageView" should have given me a clue as to what was wrong.

      posted in Pythonista
      technoway
      technoway
    • touch_began no longer called for ui.View derived class using Pythonista beta

      I am running the Pythonista 3 beta.

      I have a class that creates a full screen button, which I can use to covertly control something else. This is a sanitized version of the program. It's a very large program, but this smaller version demonstrates the issue I am encountering.

      For the first beta, the touch_began method was called when I touched the screen, but after one of the subsequent updates, that method is no longer being called.

      I am not asking for anyone to debug my program. All I want to know is should a ui.View derived class work in this case, i.e. did something break in the beta, or do I need to change to something else, perhaps a Scene?

      Or, it's possible that I deleted something by mistake that made this work before?

      """ testview.py
          Author: Bill Hallahan
      """
      import os
      import time
      import speech
      import ui
      import motion
      from ui import Image
      from ui import ImageView
      import types
      import console
      from objc_util import *
      
      class TESTButtonView(ui.View):
          """ This user interface class forms a full-screen
              button that ... .
          """
      
          def __init__(self, *args, **kwargs):
              """ Initialize the user interface """
              super().__init__(*args, **kwargs)
              self.update_interval = 1.0
              # Set up an image view.
              self.width, self.height = ui.get_window_size()
              self.iv = ImageView()
              self.iv.background_color = '#000000'
              self.iv.width = self.width
              self.iv.height = self.height
              self.iv.image = Image('lock_screen.png')
      
          def update(self):
              """ This update function is called once a second
                   to ...
              """
              # code omitted. This method is being called.
              pass
      
          def change_title_bar_color(self, hex_color):
              """ Change the title bar color to the passed color.
              """
              vv = ObjCInstance(self)
              bar_bckgnd = vv.superview().superview().superview().subviews()[1].subviews()[0]
              bar_bckgnd.backgroundColor = UIColor.colorWithHexString_(hex_color)
      
          def touch_began(self, touch):
              """ This function is called when the user
                  touches the screen.
              """
              speech.say('up')
      
          def touch_ended(self, touch):
              """ This function is called when the user
                  stops touching the screen.
              """
              speech.say('down')
      
      def wait_for_portrait_mode():
          """ Do not return until the device is held in portrait mode. """
          msg = 'Hold your phone in portrait mode.'
          console.hud_alert(msg, duration=3)
          motion.start_updates()
          try:
              count=0
              while True:
                  x, y, z = motion.get_gravity()
                  count += 1
                  if count > 2:
                      if abs(x) < abs(y):
                          break
                      else:
                          console.hud_alert(msg, duration=2)
                  time.sleep(0.5)
          finally:
              motion.stop_updates()
          time.sleep(1)
      
      if __name__ == "__main__":
          # Prevent the iPhone from going to sleep while this program runs.
          console.set_idle_timer_disabled(True)
          # Is the phone positioned correctly?
          wait_for_portrait_mode()
          # Create and display the full-screen Morse code input button.
          v = TESTButtonView()
          v.present('sheet',
                    title_bar_color='#000000',
                    hide_close_button=True,
                    orientations=['portrait'])
      

      Note, just to be sure there was no issue with the speech.say method being called there, I replaced that with os._exit(0). If I put that in the update method, the program exited. If I put it in the touch_began method, ran the program, and touched the screen, nothing happened.

      posted in Pythonista
      technoway
      technoway
    • RE: Transition to Python 3

      I would be distressed. I use a file transfer program that runs only under Python 2, and so I have this line at the top of the file:

      #!/usr/bin/python2

      at the top of the file.

      Sure, I could take some time and rewrite the file transfer program for Python 3, although given that I often want to transfer ASCII, that would take time away from the actual programming I want to do - and I barely have enough time for that. I want to work on my primary application, not on tools.

      I also wrote python 2 programs for many years, and I like being able to transfer them and just run them. That's one reason I purchased Pythonista 2 separately before I purchased Pythonista 3. (Or whatever the official product names are - you get the idea).

      I don't care if Python 2 is never improved, but I do hope it never goes away.

      posted in Pythonista
      technoway
      technoway
    • RE: Polling from a ui.View (built in timers in ui.Views)

      Thank you mikael and JonB for the help.

      @JonB said:

      You sure you have update_interval set?

      Yes. I have:

      self.update_interval = 1.0
      

      in my derived class's __init__ method.

      It likely I did something to break code that was working, but I don't see anything wrong. I'll debug my application - if this works for others, then I'm sure I introduced a bug somewhere. It's odd though, because I only made two very small changes and then updated the OS.

      Next time, before I upgrade the OS, I'll test before to make sure it's the OS that breaks code, and not my code changes.

      posted in Pythonista
      technoway
      technoway
    • RE: Polling from a ui.View (built in timers in ui.Views)

      I just updated my iPhone 6s to IOS 12.0.1, and the 'update' method is not longer called in my ui.View derived class.

      I wonder if anyone else has encountered this?

      posted in Pythonista
      technoway
      technoway
    • RE: Syntax error def__init__(self, rare=False)

      dgelessus - Good catch. I missed the missing space at first when I read the first post.

      That is def__init__-ly the problem.

      Sorry, I couldn't resist the bad pun.

      In my defense, I would have tried to help too, but I just got here.

      posted in Pythonista
      technoway
      technoway