Skip to content

Commit bb8e2f1

Browse files
author
Roberto De Ioris
authored
Update Slate_API.md
1 parent cf93163 commit bb8e2f1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/Slate_API.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,5 +621,41 @@ Basically the .assign(global_name) method, will map the SWidget to the global it
621621
Very useful for managing boolean values:
622622

623623
```python
624+
from unreal_engine import SWindow, SEditableTextBox, SHorizontalBox, SButton, SCheckBox, STextBlock
625+
from unreal_engine.classes import Object
626+
from unreal_engine.enums import EVerticalAlignment
627+
import unreal_engine as ue
624628

629+
asset_name=None
630+
checkbox_bool=False
631+
632+
def open_or_validate(path, only_validate):
633+
try:
634+
asset = ue.load_object(Object, path)
635+
except:
636+
ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'invalid path')
637+
return
638+
639+
if only_validate:
640+
ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'path is valid')
641+
else:
642+
ue.open_editor_for_asset(asset)
643+
644+
window = SWindow(client_size=(512, 32), title='Open Asset', sizing_rule=0)(
645+
SHorizontalBox()
646+
(
647+
SEditableTextBox().assign('asset_name')
648+
)
649+
(
650+
STextBlock(text='only validate path'), auto_width=True, v_align=EVerticalAlignment.VAlign_Center
651+
)
652+
(
653+
SCheckBox().assign('checkbox_bool'), auto_width=True
654+
)
655+
(
656+
SButton(text='Ok', on_clicked=lambda: open_or_validate(asset_name.get_text(), checkbox_bool.is_checked())), auto_width=True
657+
)
658+
)
625659
```
660+
661+
![SCheckBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SCheckBox.png)

0 commit comments

Comments
 (0)