• technoway

    @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 read more
  • technoway

    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.
            # 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 read more
  • technoway

    @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 read more
  • technoway

    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.

    posted in Pythonista read more
  • technoway

    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.


    and in another place in the code:


    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 read more
  • technoway

    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.
        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.
        def touch_ended(self, touch):
            """ This function is called when the user
                stops touching the screen.
    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)
            while True:
                x, y, z = motion.get_gravity()
                count += 1
                if count > 2:
                    if abs(x) < abs(y):
                        console.hud_alert(msg, duration=2)
    if __name__ == "__main__":
        # Prevent the iPhone from going to sleep while this program runs.
        # Is the phone positioned correctly?
        # Create and display the full-screen Morse code input button.
        v = TESTButtonView()

    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 read more
  • technoway

    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:


    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 read more
  • technoway

    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 read more
  • technoway

    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 read more
  • technoway

    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 read more

Internal error.

Oops! Looks like something went wrong!