Group Details Private


Member List

  • RE: Pythonista 3.4 is out!

    @LankyDonkey I have a suspicion that the crashes might have to do with UIKit APIs not being called on the main (UI) thread somewhere in your code (or possibly in Pythonista's own code, I'm not sure). Using UIKit on a secondary thread has always been discouraged by Apple, but it's enforced more strictly when building with the iOS 16 SDK, so this could be why the new version's behavior is different.

    This is just a guess, but you could try decorating your functions/methods that use ObjC APIs with @objc_util.on_main_thread, like this:

    def button_tapped(sender):
      # ...
    posted in Pythonista
  • RE: Help with dialog field

    @ProfessorFlaw Here's a possible solution. The kb_input_alert function below allows you to get a short text input, using the on-screen (PyKeys) keyboard. It doesn't support cursor placement or text selection, so it's only really suitable for short input, but I hope it's still helpful.

    import keyboard
    import ui
    import dialogs
    class KeyboardTypingView(ui.View):
      def __init__(self, *args, **kwargs):
        self.label = ui.Label(frame=self.bounds, flex='wh')
        self.label.font = ('<System>', 20)
        self.placeholder = ui.Label(frame=self.bounds.inset(0, 8, 0, 8), flex='wh')
        self.placeholder.font = ('<System>', 20)
        self.label.text = ''
        self.placeholder.alpha = 0.3
        self.cursor = ui.View(bg_color='#63aaff')
        self.entered_text = ''
        super().__init__(*args, **kwargs)
      def kb_should_insert(self, text):
        if text == '\n':
          # Return pressed
          self.entered_text = self.label.text
        self.label.text += text
        return ''
      def update_cursor(self):
        self.placeholder.hidden = len(self.label.text) > 0
        self.cursor.frame = (self.label.frame.max_x, 0, 3, self.bounds.h)
      def kb_should_delete(self):
        self.label.text = self.label.text[0:-1]
        return False
    def kb_input_alert(title='Enter text'):
      if not keyboard.is_keyboard():
        return dialogs.input_alert(title)
      v = KeyboardTypingView()
      v.placeholder.text = title
      return v.entered_text
    def main():
      name = kb_input_alert('Enter your name')
      dialogs.hud_alert(f'Hello, {name}!')
    if __name__ == '__main__':
    posted in Pythonista
  • RE: Help with dialog field

    @ProfessorFlaw input_alert and similar functions are not available in the custom keyboard because they would require showing the system keyboard, which isn't possible in custom keyboards. I realize that this is unfortunate, but right now, this simply isn't supported.

    posted in Pythonista
  • RE: 'No route to host' error in beta 340009 when using multicast

    @ttobias It looks like multicast networking requires an additional entitlement from Apple that I have to apply for, and explain why my app needs this... I think the previous version might still have worked because it was built with an older iOS SDK. I'll look into this, but it might take a little while.

    posted in Pythonista
  • RE: Black on Pythonista?

    @upwart Release notes are available in in the documentation, and there's a link from empty tabs.

    posted in Pythonista
  • RE: Bug: scene.load_pil_image raises SystemError

    @upwart Thank you, I'll look into it.

    posted in Pythonista
  • RE: 3.4: URL schemes not working in built-in browser

    I made a last-minute change to use WKWebView instead of UIWebView for the in-App browser, and it looks like I forgot about some details.

    Here's sort of a workaround, similar to the one @cvp suggested, but opening in a tab, like the built-in one.

    import ui
    import webbrowser
    from urllib.parse import urlparse
    class WebDelegate (object):
      def webview_should_start_load(self, webview, url, nav_type):
        if urlparse(url).scheme in  ['http', 'https', 'file']:
          return True

    def open_browser(url):
      v = ui.WebView() = 'Web Browser'
      v.delegate = WebDelegate()
    import os
    url = 'file://' + os.path.abspath('test.html')
    posted in Pythonista
  • RE: Pythonista 3.4 is out!

    @ForceBru Thanks for the crash log. Unfortunately, it has become pretty difficult to test on iOS 12, and apparently no one in the beta was still using it, so it slipped through. Sorry about this! I'll look into it.

    posted in Pythonista
  • Pythonista 3.4 is out!

    Title says it all, I've finally managed to get the new version through app review, so the new features (Python 3.10, Shortcuts, pandas...) are now available to everyone.

    Here are the release notes for 3.4.

    posted in Pythonista
  • RE: I have a dumb editor question.

    @Zoot You can skip the closing bracket by typing it.

    posted in Pythonista