omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Exporting

    Pythonista
    4
    5
    3326
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • reefboy1
      reefboy1 last edited by

      I currently have a export function for my application, named export()

      import ui
      import webbrowser
      
      def export():
      	url = 'www.youtube.com'
      	webbrowser.open(url)
      	
      
      
      
      def screenshot_action(sender):
          v = sender.superview
          with ui.ImageContext(v.width, v.height) as c:
              v.draw_snapshot()
              c.get_image().show()
      
      v = ui.load_view()
      v.present('sheet')
      

      I have a button to use the export function I made with UI, but when I click it it does not do anything. What do I do?

      1 Reply Last reply Reply Quote 0
      • 0942v8653
        0942v8653 last edited by

        Your url needs to start with http:// or safari-http:// to get it to open.

        You may also want to close the view first if you're using http:// (the built-in web browser).

        1 Reply Last reply Reply Quote 0
        • reefboy1
          reefboy1 last edited by

          Ok thanks

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            If you want to take a screenshot of a webpage, check out ScreenshotWebView.py which loads a webpage and then allows you to save a screenshot of the rendered webpage to the clipboard (NOT to a local file like ScreenshotView.py does.)

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              One other comment, export doesn't seem to ever get called. If you are trying to have export as a button action, it must have exactly one free input variable.

              e.g

              def export(sender):
                 ...
              

              for a non-instance method, or

              def export(self, sender):
                 ...
              

              if this is inside a class.

              Using just def export(), the button's action will try to call export(sender), which will generate a TypeError, which the ui code will silently suppress. I've made this mistake more than once, and it is confusing because no warning message is printed!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors