Skip to content

Commit c60f036

Browse files
committed
Update BeeWare app
1 parent 13bd2a4 commit c60f036

File tree

1 file changed

+40
-4
lines changed
  • apps/beeware_pythonnative/src/beeware_pythonnative

1 file changed

+40
-4
lines changed

apps/beeware_pythonnative/src/beeware_pythonnative/app.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"""
44
import toga
55
from toga.style import Pack
6-
from toga.style.pack import COLUMN, ROW
6+
from toga.style.pack import CENTER, COLUMN, ROW
77

88

99
class HelloWorld(toga.App):
10-
1110
def startup(self):
1211
"""
1312
Construct and show the Toga application.
@@ -16,12 +15,49 @@ def startup(self):
1615
We then create a main window (with a name matching the app), and
1716
show the main window.
1817
"""
19-
main_box = toga.Box()
18+
self.main_window = toga.MainWindow(title=self.name)
19+
20+
self.webview = toga.WebView(
21+
on_webview_load=self.on_webview_loaded, style=Pack(flex=1)
22+
)
23+
self.url_input = toga.TextInput(
24+
value="https://beeware.org/", style=Pack(flex=1)
25+
)
26+
27+
main_box = toga.Box(
28+
children=[
29+
toga.Box(
30+
children=[
31+
self.url_input,
32+
toga.Button(
33+
"Go",
34+
on_press=self.load_page,
35+
style=Pack(width=50, padding_left=5),
36+
),
37+
],
38+
style=Pack(
39+
direction=ROW,
40+
alignment=CENTER,
41+
padding=5,
42+
),
43+
),
44+
self.webview,
45+
],
46+
style=Pack(direction=COLUMN),
47+
)
2048

21-
self.main_window = toga.MainWindow(title=self.formal_name)
2249
self.main_window.content = main_box
50+
self.webview.url = self.url_input.value
51+
52+
# Show the main window
2353
self.main_window.show()
2454

55+
def load_page(self, widget):
56+
self.webview.url = self.url_input.value
57+
58+
def on_webview_loaded(self, widget):
59+
self.url_input.value = self.webview.url
60+
2561

2662
def main():
2763
return HelloWorld()

0 commit comments

Comments
 (0)