FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UnrealEnginePython/examples/dynamic_combo_box.py at master · flashpoint493/UnrealEnginePython · GitHub
flashpoint493
UnrealEnginePython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
UnrealEnginePython
/
examples
/
dynamic_combo_box.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (59 loc) · 2.47 KB
Breadcrumbs
UnrealEnginePython
/
examples
/
dynamic_combo_box.py
Copy path
File metadata and controls
70 lines (59 loc) · 2.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
unreal_engine
import
SWindow
,
SBox
,
SPythonComboBox
,
STextBlock
,
SBorder
,
SVerticalBox
,
SEditableTextBox
,
SHorizontalBox
,
SButton
from
unreal_engine
.
enums
import
EHorizontalAlignment
,
EVerticalAlignment
from
unreal_engine
import
FLinearColor
from
unreal_engine
.
structs
import
SlateColor
,
Margin
class
DynamicComboBox
:
def
__init__
(
self
,
items
):
self
.
box
=
SBox
(
height_override
=
100
,
min_desired_width
=
400
)
self
.
items
=
items
self
.
build_combo_box
()
self
.
combo_box
.
set_selected_item
(
self
.
items
[
0
])
def
get_widget
(
self
):
return
self
.
box
def
generate_combo_box_widget
(
self
,
item
):
return
STextBlock
(
text
=
item
)
def
append
(
self
,
item
,
committed
):
if
item
and
item
not
in
self
.
items
:
self
.
items
.
append
(
item
)
self
.
build_combo_box
()
self
.
combo_box
.
set_selected_item
(
item
)
def
get_current_item
(
self
):
return
self
.
combo_box
.
get_selected_item
()
def
build_combo_box
(
self
):
self
.
combo_box
=
SPythonComboBox
(
options_source
=
self
.
items
,
on_generate_widget
=
self
.
generate_combo_box_widget
,
content
=
STextBlock
(
text
=
self
.
get_current_item
))
self
.
box
.
set_content
(
self
.
combo_box
)
dynamic_combo_box
=
DynamicComboBox
([
'one'
,
'two'
,
'three'
])
# the final backslash is required for the 'pretty syntax'
SWindow
(
client_size
=
(
1024
,
576
),
title
=
'DynamicComboBox'
)\
(
SBorder
(
color_and_opacity
=
FLinearColor
(
0
,
1
,
0
,
1
),
border_background_color
=
SlateColor
(
SpecifiedColor
=
FLinearColor
(
1
,
0
,
0
,
1
)))
(
SBox
(
h_align
=
EHorizontalAlignment
.
HAlign_Center
,
v_align
=
EVerticalAlignment
.
VAlign_Center
)
(
SBorder
(
color_and_opacity
=
FLinearColor
(
0
,
1
,
0
,
1
),
border_background_color
=
SlateColor
(
SpecifiedColor
=
FLinearColor
(
0
,
1
,
0
,
1
)))
(
SVerticalBox
()
(
STextBlock
(
text
=
'Hello 1'
,
tool_tip_text
=
'Test Tool Tip'
)
)
(
STextBlock
(
text
=
'Hello 2'
)
)
(
dynamic_combo_box
.
get_widget
()
)
(
SHorizontalBox
()
(
SEditableTextBox
(
text
=
lambda
:
''
,
on_text_committed
=
dynamic_combo_box
.
append
),
fill_width
=
0.8
)
(
SButton
(
text
=
'Ok'
),
fill_width
=
0.2
)
)
)
)
)
)
Back
|
FazBrowse Home
|
New Git URL