• FrankenApps

    Wow, this is very impressive. Sorry for that most likely stupid question: Is there a way to use this with a scene? I am trying to make a scene zoom+panable, but I did not manage to do it.
    I wanted to use

    def on_pinch(self, data):
        self.scale = data.scale 
    

    and

    def on_pan(self, data):
        self.frame = (data.translation.x, data.translation.y, self.width, self.height)   
    

    inside my scene class, where I would have got self.width and self.height before from ui.get_screen_size...

    Maybe someone could provide me with a basic example for a zoom and panable scene?
    Would be great, thanks in advance.

    posted in Pythonista read more
  • FrankenApps

    @cvp Thanks, I‘ll Play around with this a bit. I have Not seen that other thread, so sorry for the duplicate..

    posted in Pythonista read more
  • FrankenApps

    Whenever I update the title of a ui.button an animation is shown (so it appears as if the button flickers).

    This seems to be normal on iOS, and this is how it can be prevented in native Apps: https://stackoverflow.com/questions/18946490/how-to-stop-unwanted-uibutton-animation-on-title-change

    Is there a way to prevent this animation in Pythonista (for example using obj_c )?

    I would really like to use a button and not a custom view...

    posted in Pythonista read more
  • FrankenApps

    Yes, but the Script is still running, even so the UI is closed

    posted in Pythonista read more
  • FrankenApps

    @cvp I do it with:

    v=ui.loadView()
    v.present(style=full_screen, orientations= ['portrait'])
    

    the title bar is shown by default, isn't it?
    I can post the whole code later if necessary...

    posted in Pythonista read more
  • FrankenApps

    I have built an app with bluetooth running in a seperate thread. Now when I close the app via the UI (with the close button in the top left corner), the app still runs and I need to send 'CTRL-C' via the [x] button in Pythonista.
    Is there a way to send 'CTRL-C' via the UI close button in the title bar?

    I want to call

    except KeyboardInterrupt:
      cb.reset()
    

    when the close button in the title bar is tapped.

    I have tried making the main View a customView and then using

    class MainView(ui.View):
     def will_close(self):
       print('Closing')
       cb.reset()
       sys.exit(0)
    

    but while the function gets called, I still have to hit the [x] button in order to stop the script execution.

    Only to be clear: I do not want to close Pythonista, I only want to stop the script from running, when I hit the close button in the UI and return to the console/editor.

    posted in Pythonista read more
  • FrankenApps

    @cvp
    Thank you very much!

    posted in Pythonista read more
  • FrankenApps

    import ui, sound
    
    #sound.set_honors_silent_switch(False) #maybe for production
    
    class ButtonWrapper(ui.View):
        
        def touch_began(self, touch):
            imageName = self.subviews[0].path
            imageName = imageName[12:][:-7]
            imageName = 'res/buttons/' + imageName +'on.png'
            self.subviews[0].image = ui.Image.named(imageName).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
            self.subviews[0].path = imageName
            sound.play_effect(self.subviews[0].name)
            
        def touch_ended(self, touch):
            imageName = self.subviews[0].path
            imageName = imageName[12:][:-6]
            imageName = 'res/buttons/' + imageName +'off.png'
            self.subviews[0].image = ui.Image.named(imageName).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
            self.subviews[0].path = imageName
            
    
    v = ui.load_view()
    
    v.present(style = 'full_screen', orientations = ['portrait'],title_bar_color='#222222', hide_title_bar=True) #In order to exit swipe down with two fingers
    

    So I have a Script, that is supposed to change a background picture of a button while it is pressed.
    I have stored the pictures in "res/buttons/" where one is for example called "orangeoff.png" and one is called "orangeon.png". With the above code I can achieve what I want.
    However when I add the Script to the homescreen to run it from there I get the following exception most of the time:

    Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/C1A7CE9F-6A30-4CA8-9380-76FD1CACD07F/Pythonista3/Documents/main.py", line 19, in touch_ended
        self.subviews[0].image = ui.Image.named(imageName).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
    AttributeError: 'NoneType' object has no attribute 'with_rendering_mode'
    

    When I hit the back button on the left top, and basically reload the view, everything works as expected again. Does anybody have an idea, why this might happen, and how to prevent it?

    For clarification, this is my .pyui file (the view above the button is only needed to prevent the touch effect):

    [
      {
        "nodes" : [
          {
            "nodes" : [
              {
                "nodes" : [
    
                ],
                "frame" : "{{0, 0}, {240, 247}}",
                "class" : "View",
                "attributes" : {
                  "frame" : "{{46, 2}, {100, 100}}",
                  "class" : "View",
                  "name" : "view1",
                  "uuid" : "02ECED66-9D85-4C76-94DC-0FBB760E6596"
                },
                "selected" : false
              },
              {
                "nodes" : [
    
                ],
                "frame" : "{{0, 0}, {240, 247}}",
                "class" : "Button",
                "attributes" : {
                  "action" : "",
                  "frame" : "{{10, 34}, {80, 32}}",
                  "title" : "",
                  "uuid" : "350C205C-A1B2-41CA-B6ED-EA120173BF4C",
                  "class" : "Button",
                  "custom_attributes" : "{'image':ui.Image.named('res\/buttons\/blueoff.png'). with_rendering_mode(ui.RENDERING_MODE_ORIGINAL), 'path': 'res\/buttons\/blueoff.png'}",
                  "font_size" : 15,
                  "name" : "res\/sounds\/intro.mp3"
                },
                "selected" : false
              }
            ],
            "frame" : "{{0, 0}, {240, 240}}",
            "class" : "View",
            "attributes" : {
              "uuid" : "C5101DD7-0CBA-448A-8BC8-34F0CF0347B3",
              "frame" : "{{110, 950}, {100, 100}}",
              "class" : "View",
              "name" : "view1",
              "custom_class" : "ButtonWrapper"
            },
            "selected" : false
          }
        ],
        "frame" : "{{0, 0}, {240, 240}}",
        "class" : "View",
        "attributes" : {
          "name" : "",
          "enabled" : true,
          "background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)",
          "tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)",
          "border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)",
          "flex" : ""
        },
        "selected" : false
      }
    ]
    

    posted in Pythonista read more
  • FrankenApps

    This is sadly not working anymore in recent versions of pythonista, am I right?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!