Search code examples
pythonuser-interfacedatepickerfiremonkey

How do I create a date picker in a Python FMX GUI App?


Is there any standard component for selecting a date in the DelphiFMX GUI library for Python?

I'm looking for some kind of Date Picker component. Currently what I'm doing is making a couple of SpinBox components and then using them to enter a Date, this is my UI:

Year, Month, Day Python GUI

But what I actually want is just one component for selecting a date instead of three SpinBox components.


Solution

  • There's a Calendar and DateEdit component that you can use:

    self.myCalendar = Calendar(self)
    self.myCalendar.Parent = self
    self.myCalendar.Align = "MostTop"
    self.myCalendar.Margins.Top = 20
    self.myCalendar.Margins.Right = 20
    self.myCalendar.Margins.Bottom = 20
    self.myCalendar.Margins.Left = 20
    
    self.myDateEdit = DateEdit(self)
    self.myDateEdit.Parent = self
    self.myDateEdit.Align = "Top"
    self.myDateEdit.Margins.Right = 20
    self.myDateEdit.Margins.Bottom = 20
    self.myDateEdit.Margins.Left = 20
    

    This will look like the following screenshot: Calendar and DateEdit components in Python FMX GUI App