PyxelMenu
Pyxel class for generating, displaying and controlling a menu
Source code in pyxel_menu.py
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
__init__(x, y, options=None, limit=5)
Class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
int
|
Position of the menu with respect to the left margin in pixels |
required |
y |
int
|
Position of the menu with respect to the up margin in pixels |
required |
options |
list
|
A list with the options to add. Defaults to None |
None
|
limit |
int
|
The limit of options to display. Defaults to 5. |
5
|
Source code in pyxel_menu.py
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 | |
draw()
Draw the menu
Source code in pyxel_menu.py
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 | |
get_current_pos()
Return selected option index
Source code in pyxel_menu.py
92 93 94 | |
get_current_text()
Return selected option text
Source code in pyxel_menu.py
96 97 98 | |
move_down()
Move the cursor down one position
Source code in pyxel_menu.py
105 106 107 108 | |
move_up()
Move the cursor up one position
Source code in pyxel_menu.py
100 101 102 103 | |
set_cursor(cursor_type='circle', color=7)
Defines the type and/or color of the cursor to be used
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor_type |
str
|
The type of the cursor (circle, square, triangle). Defaults to 'circle'. |
'circle'
|
color |
int
|
The color index of the Pyxel palette to use for the options (0-15). Defaults to 7. |
7
|
Source code in pyxel_menu.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
set_cursor_img(img, u, v, colkey=None)
Set an image from the image bank as the cursor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img |
int
|
The image bank (0-2) to use |
required |
u |
int
|
Horizontal image position |
required |
v |
int
|
Vertical image position |
required |
colkey |
int
|
If a color is indicated, it will be considered as transparent. Defaults to None. |
None
|
Source code in pyxel_menu.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
set_cursor_pos(pos)
Set the current position of the cursor
Source code in pyxel_menu.py
145 146 147 | |
set_highlight_color(color)
Sets the highlight color for the indicated option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color |
int
|
The color index of the Pyxel palette to use for the options (0-15) |
required |
Source code in pyxel_menu.py
149 150 151 152 153 154 155 156 157 | |
set_options(options)
Set the options for the menu
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options |
list
|
The options list |
required |
Source code in pyxel_menu.py
159 160 161 162 163 164 165 | |
set_text_color(color)
Defines the color of the options
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color |
int
|
The color index of the Pyxel palette to use for the options (0-15) |
required |
Source code in pyxel_menu.py
167 168 169 170 171 172 173 174 175 176 | |