Skip to content

Commit 374e549

Browse files
authored
Add example snippet for SPythonComboBox
1 parent 086454f commit 374e549

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/Slate_API.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,31 @@ Check this example: https://github.com/20tab/UnrealEnginePython/blob/master/exam
824824

825825
It shows even how to register new style sets.
826826

827+
## SPythonComboBox
828+
829+
```python
830+
from unreal_engine import SWindow, STextBlock, SPythonComboBox
831+
832+
def generate_combo_box_widget(item):
833+
return STextBlock(text=item)
834+
835+
def get_current_item():
836+
return combo_box.get_selected_item()
837+
838+
def on_selection_changed(item, index):
839+
print ('New selection: %s, %s' % (item, index))
840+
841+
items = ['spam', 'ham', 'eggs']
842+
combo_box = SPythonComboBox(options_source=items, on_generate_widget=generate_combo_box_widget, content=STextBlock(text=get_current_item), on_selection_changed=on_selection_changed)
843+
combo_box.set_selected_item(items[0])
844+
845+
SWindow(client_size=(300,30))(
846+
combo_box
847+
)
848+
```
849+
850+
![SDetailView](screenshots/slate_SPythonComboBox.png)
851+
827852
## SPythonListView
828853

829854
## SPythonTreeView

0 commit comments

Comments
 (0)