-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
120 lines (95 loc) · 3.91 KB
/
main.py
File metadata and controls
120 lines (95 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import glfw
import imgui
import webbrowser
from imgui.integrations.glfw import GlfwRenderer
from OpenGL.GL import glClear, GL_COLOR_BUFFER_BIT
def michas():
if not glfw.init():
return
window = glfw.create_window(1200, 800, "pyimgui-example", None, None)
glfw.make_context_current(window)
imgui.create_context()
io = imgui.get_io()
io.fonts.add_font_from_file_ttf("font/ProggyClean.ttf", 26)
renderer = GlfwRenderer(window)
show_second_window = False
show_third_window = False
checkbox_1 = False
checkbox_2 = True
slider_1 = 0.5
slider_2 = 0.8
text_input_1 = "visit my site!"
text_input_2 = "https://michas.lol/"
while not glfw.window_should_close(window):
glfw.poll_events()
renderer.process_inputs()
glClear(GL_COLOR_BUFFER_BIT)
imgui.new_frame()
imgui.set_next_window_size(800, 550, condition=imgui.FIRST_USE_EVER)
imgui.begin("first window")
imgui.text("cool pyimgui example with glfw")
imgui.spacing()
if imgui.begin_tab_bar("tabs"):
if imgui.begin_tab_item("tab 1")[0]:
if imgui.button("open second window"):
show_second_window = True
if imgui.button("open third window"):
show_third_window = True
if imgui.button("exit app"):
glfw.set_window_should_close(window, True)
imgui.spacing()
imgui.separator()
imgui.spacing()
_, checkbox_1 = imgui.checkbox("checkbox 1", checkbox_1)
_, checkbox_2 = imgui.checkbox("checkbox 2", checkbox_2)
imgui.spacing()
imgui.separator()
imgui.spacing()
_, text_input_1 = imgui.input_text("text input 1", text_input_1, 256)
_, text_input_2 = imgui.input_text("text input 2", text_input_2, 256)
imgui.end_tab_item()
if imgui.begin_tab_item("tab 2")[0]:
imgui.text("slider controls")
imgui.spacing()
imgui.separator()
imgui.spacing()
_, slider_1 = imgui.slider_float("slider 1", slider_1, 0.0, 1.0)
_, slider_2 = imgui.slider_float("slider 2", slider_2, 0.0, 1.0)
imgui.end_tab_item()
imgui.end_tab_bar()
imgui.spacing()
imgui.separator()
imgui.spacing()
if imgui.button("about me"):
webbrowser.open("https://me.michas.lol/")
imgui.text("docs will be posted here soon")
imgui.same_line()
if imgui.button("https://docs.michas.lol/"):
webbrowser.open("https://docs.michas.lol/")
imgui.end()
if show_second_window:
imgui.set_next_window_size(300, 200, condition=imgui.FIRST_USE_EVER)
imgui.begin("second window")
if imgui.button("close second window"):
show_second_window = False
imgui.spacing()
imgui.text("sussyyyy bakaaa")
imgui.end()
if show_third_window:
imgui.set_next_window_size(600, 250, condition=imgui.FIRST_USE_EVER)
imgui.begin("third window", flags=imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE)
imgui.text("third window with custom title bar")
imgui.same_line(imgui.get_window_width() - 30)
if imgui.button("X"):
show_third_window = False
imgui.separator()
imgui.spacing()
imgui.text("this is the third window yayyy")
imgui.end()
imgui.render()
renderer.render(imgui.get_draw_data())
glfw.swap_buffers(window)
renderer.shutdown()
glfw.terminate()
if __name__ == "__main__":
michas()