Examples

hello world

1from pyegui import *
2
3def update_func(ctx):
4  heading("Hello, World!")
5
6if __name__ == "__main__":
7  run_native("Hello World App", update_func)
8  
hello world screenshot

pages

 1from pyegui import *
 2import logging
 3
 4PAGE_1 = 1
 5PAGE_2 = 2
 6PAGE_3 = 3
 7
 8page = Int(PAGE_1)
 9
10def update_func(ctx):
11  label("You can emulate pages in your app by using some variable and a few conditions")
12  label(f"For example, this app has 3 pages. Current page is {page.value}")
13
14  separator()
15
16  with Layout(LayoutType.Horizontal):
17    selectable_value(page, PAGE_1, "Go to page 1")
18    selectable_value(page, PAGE_2, "Go to page 2")
19    selectable_value(page, PAGE_3, "Go to page 3")
20
21  separator()
22
23  if page.value == PAGE_1:
24    heading("Page 1")
25    label("Distinctio ut assumenda officia necessitatibus consequatur. Quia laborum illo aliquid delectus. Molestiae maiores unde aut quas saepe laboriosam et voluptatum. Provident beatae suscipit id. Quam odio corrupti quia voluptate fugiat.")
26  if page.value == PAGE_2:
27    heading("Page 2")
28    label("Lorem ipsum is a dummy or placeholder text commonly used in graphic design, publishing, testing, and web development.")
29  if page.value == PAGE_3:
30    heading("Page 3")
31    label("Its purpose is to permit a page layout to be designed, independently of the copy that will subsequently populate it, or to demonstrate various fonts of a typeface without meaningful text that could be distracting. Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin.")
32
33if __name__ == "__main__":
34  run_native("pages", update_func)
pages screenshot

python IDE

 1from pyegui import *
 2import time
 3
 4buf = Str("")
 5output = Str("")
 6
 7def update_func(ctx):
 8  code_editor(buf)  
 9  separator()
10  label(output.value)
11  if button_clicked("Run"):
12    output.value = ""
13    try:
14      t1 = time.time_ns()
15      exec(buf.value)
16      t2 = time.time_ns()
17      output.value = f"Run {t2-t1}ns"
18    except Exception as e:
19      output.value = str(e)
20
21if __name__ == "__main__":
22  run_native("Python IDE", update_func)
python ide screenshot

all widgets

 1import datetime
 2from pyegui import *
 3
 4RED = 0                       
 5GREEN = 1
 6BLUE = 2
 7
 8text_singline = Str("")
 9text_multiline = Str("")
10checkbox_value = Bool(False)
11color = Int(RED)
12color_rgb = RGB(69, 69, 69)
13date = Date(datetime.datetime.now())
14is_visible = Bool(True)
15is_interactive = Bool(True)
16opacity_value = Float(1)
17
18def update_func(ctx):
19  label("Welcome to the widget gallery!")
20
21  hyperlink_to("pyegui on GitHub", "https://github.com/GachiLord/pyegui")
22
23  text_edit_singleline(text_singline, hint_text="hint text")
24  text_edit_multiline(text_multiline, hint_text="hint text")
25  code("print(69)")
26  code_editor(text_multiline)
27
28  if button_clicked("clear text"):
29    text_singline.value = ""
30
31  if link_clicked("I'm a fake link"):
32    text_singline.value = "new text"
33
34  checkbox(checkbox_value, "check me")
35
36  with Layout(LayoutType.Horizontal):
37    radio_value(color, RED, "red")
38    radio_value(color, GREEN, "green")
39    radio_value(color, BLUE, "blue")
40
41  with Layout(LayoutType.Horizontal):
42    selectable_value(color, RED, "red")
43    selectable_value(color, GREEN, "green")
44    selectable_value(color, BLUE, "blue")
45
46  combo_box(color, [RED, GREEN, BLUE], ["red", "green", "blue"], "Choose your fate") 
47
48  slider_int(color, 0, 2, "slide me")
49
50  drag_int(color, 0, 2, 1)
51
52  progress(1 / (color.value + 1))
53
54  color_edit_button_rgb(color_rgb)
55
56  image("https://github.githubassets.com/favicons/favicon.svg", max_width=240, max_height=320)
57
58  if image_and_text_clicked("https://github.githubassets.com/favicons/favicon.svg", "button with image"):
59    print("clicked on image with text")
60
61  date_picker_button(date) 
62
63  collapsing("collapsed", lambda: heading("I'm so collapsed now"))
64
65  separator()
66
67  heading("Configure block in the frame")
68
69  with Group():
70    set_opacity(opacity_value.value)
71    if not is_visible.value:
72      set_invisible()
73    if not is_interactive.value:
74      disable()
75      
76    heading("This block may be hidden")
77    button_clicked("Try to click me")
78
79  with Layout(LayoutType.Horizontal):
80    checkbox(is_visible, "Visible")
81    checkbox(is_interactive, "Interactive")
82    slider_float(opacity_value, 0.0, 1.0, "Opacity")
83
84
85if __name__ == "__main__":
86  run_native("Widget Gallery", update_func, inner_height=900, inner_width=500)
87
widget_gallery screenshot