-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
79 lines (72 loc) · 3.33 KB
/
example.py
File metadata and controls
79 lines (72 loc) · 3.33 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
from pyray import *
import sgui as gui
import subprocess, os, platform
import math
def open_file(filepath):
if platform.system() == 'Darwin': # macOS
subprocess.call(('open', filepath))
elif platform.system() == 'Windows': # Windows
os.startfile(filepath)
else: # linux variants
subprocess.call(('xdg-open', filepath))
init_window(1280,720,"SGUI Example")
gui.init()
win = gui.Window(10,10,200,150,"test")
win2 = gui.Window(10,250,200,150,"test2",Color(255,0,0,255))
timesclicked = 0
while not window_should_close():
begin_drawing()
clear_background(BLACK)
draw_fps(10,10)
gui.NotifTick()
with win:
#with gui.frame(100,100+round(math.sin(get_time())*10)):
if 1:
# with gui.frame(50,50):
# gui.label("I'm A FramEEEE!!!!")
gui.label(str(gui.GUIState.SelectedWidget))
if gui.checkbox_button("hello","test",False).value:
gui.sameline()
if gui.checkbox_button("world","test2",False).value:
gui.sameline()
gui.label("Yipee!")
if gui.button(100,f"Click me").pressed:
timesclicked += 1
dur = gui.slider(100,"duration","duration").value
if gui.button(100,"click me for notification").pressed:
gui.notify("Notification","you clicked the button!",dur)
isize = round(gui.slider(100,"Icon Size","iconsize",default=10).value)
gui.button_icon(100,isize,"Logo Button!","logo.png")
gui.label("times clicked: " + str(timesclicked))
if gui.button(100,"Hold me").held:
gui.sameline()
gui.label("Yipee!")
gui.label("value of input: " + gui.textinput(100,"Type Something!","testinput").value)
if gui.button_img(50,50,"testimg.png").pressed:
print("test")
gui.sameline()
gui.image(50,50,"testimg.png")
gui.slider_vec2(50,50,"test","2D slider???").limit(-10,10)
g = gui.slider(100,"Limited Slider","test").limit(-10,10).value
gui.label("value of slider = " + str(g))
gui.slider(150,"Unlimited Slider","test2").value
if gui.collapsing_header(100,"Click me","test").show():
gui.label("I Collapse and Expand!")
if gui.collapsing_header(100,"test","test2").show():
for i in range(round(gui.slider(200,"Drag me for a surprise!","surprise",0.1).limit(0,None).value)):
gui.button(100,"Cool, right?")
gui.label("This is a label!")
gui.reset_collapsing_header("test2")
gui.reset_collapsing_header("test")
gui.button(150,"This is a useless button!")
with win2:
gui.label("another window...")
if gui.button(100,"Open Source Code").pressed:
open_file(__file__)
win2.movable = gui.checkbox_button("Enable window move","winmove",True).value
win2.resizable = gui.checkbox_button("Enable window resize","winres",True).value
if gui.checkbox_button("Window size slider","winresize",False).value:
s = gui.slider_vec2(50,50,"Window Size","winsize",1).limit(100,None)
win2.w,win2.h = round(s.x),round(s.y)
win2.titlecolor = gui.colorpicker("test",default=[0,255,255]).value
end_drawing()