Создание графического интерфейса¶
Большинство объектов создаются одинаково.
Можно задать высоту и ширину объекта, либо указать -1, для игнорирования параметра.
В качестве доп опции задаются: Выравнивание компонентов
-
app.
CreateButton
(text, width, height, options)¶ Возвращает
Button()
, кнопкаoptions - Выравнивание компонентов
Alum -
Custom - настриваемая иконка
FillX - расстянуть по ширине родителя
FillY - расстянуть по высоте родителя
FillXY - расстянуть по родителю
Gray -
HTML - html кнопка
NoSound
button = app.CreateButton('A', 0.2, 0.2) button = app.CreateButton('A', -1, -1, 'FillX') button = app.CreateButton('A', -1, -1, 'FillX,Gray') button = app.CreateButton('A', -1, -1, 'FillX,Alum') button = app.CreateButton('<b>Text</b>', -1, -1, 'HTML')
-
app.
CreateCameraView
(width, height, options)¶ Возвращает
CameraView()
options
CIF
QVGA
SVGA
VGA
XGA
UXGA
cam = app.CreateCameraView() cam = app.CreateCameraView('Front') cam = app.CreateCameraView(0.5, 0.7, 'CIF') cam = app.CreateCameraView( 0.8, 0.4 ); lay.AddChild( cam ); setTimeout( "cam.StartPreview()", 1000 );
-
app.
CreateCheckBox
(text, width, height, options)¶ Возвращает
CheckBox()
check_box = app.CreateCheckBox('CheckBox');
-
app.
CreateGLView
(width, height, option)¶ Возвращает
GLView()
glview = app.CreateGLView( 1, 1, "Fast2d" );
-
app.
CreateList
(list, width, height, options)¶ Возвращает
List()
Элемент списка может содержать различные компоненты, и тогда он должен описываться в виде title:icon или title:body:extra:icon.
Иконка может быть как абсолютным путем, так и быть одним из зарезервированных слов folder, audiofolder, photofolder, videofolder, audio, photo, video and playlist
Также можно создать список из кнопок, укзав доп параметры: AlumButton, GreenButton, OrangeButton, WhiteGrad, FontAwesome
lst = app.CreateList('1,2,3', 0.8, 0.4) lst = app.CreateList('Folder:folder,Audio:audio,Photo:photo,Video:video', 0.8, 0.4) lst = app.CreateList( data, 0.8, 0.8, "OrangeButton" ); var list = "[fa-file-text-o] Text, " + "[fa-file-photo-o] Photo, " + "[fa-file-audio-o] Sound, " + "[fa-file-video-o] Video"; lst = app.CreateList( list, 0.8, 0.25, "FontAwesome" );
-
app.
CreateListView
(list, title, options)¶ Возвращает
ListView()
lvw = app.CreateListView( "Mon,Tues,Wed,Thurs,Fri,Sat,Sun", "Days" );
-
app.
CreateScroller
(width, height, options)¶ Возвращает
Scroller()
function OnStart() { lay = app.CreateLayout( "Linear", "FillXY" ); scroll = app.CreateScroller( 1.0, 1.0 ); lay.AddChild( scroll ); layScroll = app.CreateLayout( "Linear", "Left" ); scroll.AddChild( layScroll ); img = app.CreateImage( "/Sys/Img/Hello.png", 2.0, 2.0 ); layScroll.AddChild( img ); app.AddLayout( lay ); }
-
app.
CreateSeekBars
(width, height, options)¶ Возвращает
SeekBars()
sb = app.CreateSeekBars(0.8)
-
app.
CreateSpinner
(list, width, height, options)¶ Возвращает
Spinner()
spin = app.CreateSpinner( "Bilbo,Frodo,Gandalf", 0.4 );
-
app.
CreateTabs
(tabs, width, height, options)¶ Возвращает
Tabs()
, вкладкиtabs = app.CreateTabs('FRED,BILL,MARK', 0.8, 0.8, 'VCenter');
-
app.
CreateText
(text, width, height, options)¶ Возвращает
Text()
, текстовое поле для отображения.В тексте можно указать иконку icons - Иконки
options - Выравнивание компонентов
Multiline - многострочный
text = app.CreateText('Hello'); text = app.CreateText('Hello', 0.8, 0.2, 'Multiline'); txt = app.CreateText("[fa-cogs] Settings", 0.8, 0.1, "FontAwesome"); txt = app.CreateText("\uf04c Settings", 0.8, 0.1, "FontAwesome"); txt = app.CreateText("<font color=#008800>[fa-check-square-o]</font> Done", 0.8, 0.1, "FontAwesome,HTML");
-
app.
CreateTextEdit
(text, width, height, options)¶ Возвращает
TextEdit()
- options
AutoScale - reduces text size to fit if needed
Bold - Write bold Text
FontAwesome - Use this to display Icons
from - this inbuilt font
Html -
Left -
Multiline -
Right -
txtedit = app.CreateTextEdit('edit')
-
app.
CreateToggle
(text, width, height, options)¶ Возвращает
ButtonToggle()
btn = app.CreateToggle('toggle me')
-
app.
CreateVideoView
(widrh, heigth, options)¶ Возвращает
VideoView()
. Проигрыватель видеоvideo = app.CreateVideoView()
-
app.
CreateWebView
(width, height, options, zoom)¶ Возвращает
WebView()
- options
IngoreErrors
NoScrollBars
ScrollFade
web = app.CreateWebView()
-
app.
GetLastCheckBox
()¶
-
app.
GetLastToggle
()¶ Возвращает
ButtonToggle()
, последнюю нажатую toggle кнопкуtglbutton = app.GetLastToggle()
-
app.
SetMenu
(menuList, p2)¶ Устанавливает элементы в меню, обработчиком выбора при этом будет
OnMenu()
, в который будет передаваться выбраннный элемент.На некоторых устройствах кнопки меню нет, при необходимости можно нарисовать кнопку меню и при нажатии на него вызывать
ShowMenu()
function OnStart() { app.SetMenu( "Start,Stop,Pause" ); } function OnMenu( item ) { app.ShowPopup( item, "Short" ); }