Esempio n. 1
0
def mainLoop():
    """
    This runs a loop while the UI is shown to keep the program running. You should always call this function after showing an interactive UI.
    """

    while __PyContentViewController__.shared.isViewVisible:
        sleep(1)

    def unsetViewController() -> None:
        __PyContentViewController__.shared.setRootViewController(None)

    mainthread.runSync(unsetViewController)
Esempio n. 2
0
def openURL(url):
    """
    Opens the given URL.
    
    Args:
        url: URL to open. Can be a String or an Objective-C `NSURL`.
    """
    
    def __openURL__() -> None:
        __UIApplication__.sharedApplication.openURL(__url__)
    
    if (type(url) is str):
        __url__ = __NSURL__.URLWithString(url)
        mainthread.runSync(__openURL__)
    elif (__PySharingHelper__.isURL(url)):
        __url__ = url
        mainthread.runSync(__openURL__)
    else:
        raise ValueError('url musts be a String or an Objective-C `NSURL`.')
Esempio n. 3
0
    class ExampleViewController(UIViewController):
        @objc_method
        def sayHello_(self, sender) -> None:
            sayHello(self)

        @objc_method
        def viewDidLoad(self) -> None:
            viewDidLoad(self)

        @objc_method
        def viewDidLayoutSubviews(self):
            setViewsFrame(self.view.size)


# MARK: - Showing the UI


def main() -> None:

    viewController = ExampleViewController.new()

    navigationController = UINavigationController.new()
    navigationController.setViewControllers([viewController])
    navigationController.navigationBar.barStyle = 1
    ui.showViewController(navigationController)


mainthread.runSync(main)

ui.mainLoop()
Esempio n. 4
0
"""
Changes the tint color of the app to red.
"""

from UIKit import UIColor, UIApplication
import mainthread

# Code here

def changeTintColor() -> None:
  UIApplication.sharedApplication.keyWindow.tintColor = UIColor.redColor
  
mainthread.runSync(changeTintColor)
Esempio n. 5
0
def clear():
    """
    Clears the console.
    """
    mainthread.runSync(__clear__)