Group Details Private

administrators

Member List

  • Forum is read-only for now

    Due to excessive spam, I've decided to make the forum read-only for now, so that I can clean everything up, and then I would suggest to move the discussion elsewhere (GitHub probably), where I don't have to deal with spam accounts as much. I would preserve the forum's archive for future reference, but new discussions should be started elsewhere.

    posted in Announcements
  • 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:

    @objc_util.on_main_thread
    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.add_subview(self.label)
        self.add_subview(self.placeholder)
        self.label.text = ''
        self.placeholder.alpha = 0.3
        self.cursor = ui.View(bg_color='#63aaff')
        self.add_subview(self.cursor)
        self.update_cursor()
        self.entered_text = ''
        super().__init__(*args, **kwargs)
    
      def kb_should_insert(self, text):
        if text == '\n':
          # Return pressed
          self.entered_text = self.label.text
          keyboard.set_view(None)
        self.label.text += text
        self.update_cursor()
        return ''
    
      def update_cursor(self):
        self.placeholder.hidden = len(self.label.text) > 0
        self.label.size_to_fit()
        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]
        self.update_cursor()
        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
      keyboard.set_view(v)
      v.wait_modal()
      return v.entered_text
    
    def main():
      name = kb_input_alert('Enter your name')
      dialogs.hud_alert(f'Hello, {name}!')
    
    
    if __name__ == '__main__':
      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
        else:
          webbrowser.open(url)
    
    def open_browser(url):
      v = ui.WebView()
      v.name = 'Web Browser'
      v.delegate = WebDelegate()
      v.load_url(url)
      v.present('panel')
    
    import os
    url = 'file://' + os.path.abspath('test.html')
    open_browser(url)
    
    
    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