Adds a date picker component to the app.
dtp = ui.addDatePicker(
date,
options )
→
Object: DatePicker Component
Properties
These are the setter and getter properties for the addDatePicker Component.
Example - Default
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "Top,VCenter", 1, 1 )
this.main.setMargins( 0.01, 0.01, 0.01, 0.01 )
this.btn = ui.addButton( this.main, "Show Date Picker", "Secondary" )
this.btn.setOnTouch( this.showDatePicker )
this.dtp = ui.addDatePicker()
}
showDatePicker()
{
this.dtp.show()
}
}
from hybrid import ui
def OnStart():
global dtp
main = ui.addLayout("main", "Linear", "Top,Vcenter", 1, 1)
main.setMargins(0.01, 0.01, 0.01, 0.01)
btn = ui.addButton(main, "Show Date Picker", "Secondary")
btn.setOnTouch(showDatePicker)
dtp = ui.addDatePicker()
def showDatePicker(event):
dtp.show()
Example - With initial value & portrait
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "Top,VCenter", 1, 1 )
this.main.setMargins( 0.01, 0.01, 0.01, 0.01 )
this.btn = ui.addButton( this.main, "Show Date Picker", "Secondary" )
this.btn.setOnTouch( this.showDatePicker )
this.dtp = ui.addDatePicker( "2022-12-25", "Portrait" )
}
showDatePicker()
{
this.dtp.show()
}
}
from hybrid import ui
def OnStart():
global dtp
main = ui.addLayout("main", "Linear", "Top,Vcenter", 1, 1)
main.setMargins(0.01, 0.01, 0.01, 0.01)
btn = ui.addButton(main, "Show Date Picker", "Secondary")
btn.setOnTouch(showDatePicker)
dtp = ui.addDatePicker("2022-12-25", "Portrait")
def showDatePicker(event):
dtp.show()
Example - With limits & callback
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "Top,VCenter", 1, 1 )
this.main.setMargins( 0.01, 0.01, 0.01, 0.01 )
this.btn = ui.addButton( this.main, "Show Date Picker", "Secondary" )
this.btn.setOnTouch( this.showDatePicker )
this.dtp = ui.addDatePicker( "2022-12-25", "Portrait" )
this.dtp.setOnSelect( this.onSelect )
}
showDatePicker()
{
this.dtp.show()
}
onSelect( value )
{
console.log( value )
}
}
from hybrid import ui
from native import app
def OnStart():
global dtp
main = ui.addLayout("main", "Linear", "Top,Vcenter", 1, 1)
main.setMargins(0.01, 0.01, 0.01, 0.01)
btn = ui.addButton(main, "Show Date Picker", "Secondary")
btn.setOnTouch(showDatePicker)
dtp = ui.addDatePicker("2022-12-25", "Portrait")
dtp.setOnSelect(onSelect)
def showDatePicker(event):
dtp.show()
def onSelect(value):
app.ShowPopup(value)
Methods
The following methods are available on the DatePicker object: