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?
Your url needs to start with
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).
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.)
One other comment,
exportdoesn't seem to ever get called. If you are trying to have
exportas a button action, it must have exactly one free input variable.
def export(sender): ...
for a non-instance method, or
def export(self, sender): ...
if this is inside a class.
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!