Created
May 21, 2021 22:50
-
-
Save telent/549414a56269f4939ae22e48a2b24541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
My first application | |
""" | |
import toga | |
from toga.style import Pack | |
from toga.style.pack import COLUMN, ROW | |
from rubicon.java import JavaClass | |
class Gadgetbee(toga.App): | |
def startup(self): | |
""" | |
Construct and show the Toga application. | |
Usually, you would add your application to a main content box. | |
We then create a main window (with a name matching the app), and | |
show the main window. | |
""" | |
main_box = toga.Box(style=Pack(direction=COLUMN)) | |
name_label = toga.Label( | |
'Your name: ', | |
style=Pack(padding=(0, 5)) | |
) | |
self.name_input = toga.TextInput(style=Pack(flex=1)) | |
name_box = toga.Box(style=Pack(direction=ROW, padding=5)) | |
name_box.add(name_label) | |
name_box.add(self.name_input) | |
button = toga.Button( | |
'Say Hello!', | |
on_press=self.say_hello, | |
style=Pack(padding=5) | |
) | |
main_box.add(name_box) | |
main_box.add(button) | |
self.main_window = toga.MainWindow(title=self.formal_name) | |
self.main_window.content = main_box | |
self.main_window.show() | |
def say_hello(self, widget): | |
Intent = JavaClass('android/content/Intent') | |
Uri = JavaClass('android/net/Uri') | |
MainActivity = JavaClass('org/beeware/android/MainActivity') | |
i = Intent( "android.intent.action.VIEW", | |
Uri.parse("https://ww.telent.net")) | |
print(MainActivity.singletonThis) | |
print(MainActivity.singletonThis.startActivity(i)) | |
self.main_window.info_dialog( | |
'Hi there!', | |
"Hello {}".format(i) | |
) | |
def main(): | |
return Gadgetbee() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment