native-ui/example.py

44 lines
945 B
Python
Raw Normal View History

2022-07-30 21:03:15 +00:00
import native_ui
import sys
native_ui.set_runtime_platform("gnome", "org.surferlul.native-ui.ExampleApp")
from native_ui import native, abstract
def main():
window = native.Window()
window.set(
child=None
)
app = native.Application(
window=native.Window(
child=native.Container(
layout=abstract.Layout.VERTICAL,
)
)
)
cont = app.window.child
def on_pressed(button, container):
print("Hello world")
container.call("add_child",
native.Button(
label="Hello",
pressed=on_pressed,
pressed_args=[container]
))
cont.add_child(native.Button(
label="Hello",
pressed=on_pressed,
pressed_args=[cont],
))
app.build()
app.run(sys.argv)
if __name__ == "__main__":
main()