コード例 #1
0
    def __init__(self):
        super(DateResolutionExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)
        self._datetime.setImmediate(True)

        # Create selection
        self._localeSelection = ComboBox('Select resolution:')
        self._localeSelection.setNullSelectionAllowed(False)
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)

        # Fill the selection with choices, set captions correctly
        self._localeSelection.setContainerDataSource(
            self.getResolutionContainer())
        self._localeSelection.setItemCaptionPropertyId(
            self.resolution_PROPERTY_NAME)
        self._localeSelection.setItemCaptionMode(
            ComboBox.ITEM_CAPTION_MODE_PROPERTY)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)
コード例 #2
0
    def __init__(self):
        super(DateLocaleExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_MIN)
        self._datetime.setImmediate(True)
        self._datetime.setShowISOWeekNumbers(True)

        # Create selection and fill it with locales
        self._localeSelection = ComboBox('Select date format:')
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)
        self._localeSelection.setContainerDataSource(
            ExampleUtil.getLocaleContainer())
        self._localeSelection.setNullSelectionAllowed(False)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)
コード例 #3
0
class DateInlineExample(VerticalLayout, IValueChangeListener):

    def __init__(self):
        super(DateInlineExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)

        # Add valuechangelistener
        self._datetime.addListener(self, IValueChangeListener)
        self._datetime.setImmediate(True)

        self.addComponent(self._datetime)


    def valueChange(self, event):
        app = self.getApplication()
        if app is not None:
            l = app.getLocale()

        # Get the new value and format it to the current locale
        dateOut = format_date(event.getProperty().getValue(),
                locale=l).encode('utf-8')

        # Show notification
        self.getWindow().showNotification('Starting date: ' + dateOut)
コード例 #4
0
class DateInlineExample(VerticalLayout, IValueChangeListener):
    def __init__(self):
        super(DateInlineExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)

        # Add valuechangelistener
        self._datetime.addListener(self, IValueChangeListener)
        self._datetime.setImmediate(True)

        self.addComponent(self._datetime)

    def valueChange(self, event):
        app = self.getApplication()
        if app is not None:
            l = app.getLocale()

        # Get the new value and format it to the current locale
        dateOut = format_date(event.getProperty().getValue(),
                              locale=l).encode('utf-8')

        # Show notification
        self.getWindow().showNotification('Starting date: ' + dateOut)
コード例 #5
0
class DateInlineExample(VerticalLayout, IValueChangeListener):

    def __init__(self):
        super(DateInlineExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)

        # Add valuechangelistener
        self._datetime.addListener(self, IValueChangeListener)
        self._datetime.setImmediate(True)

        self.addComponent(self._datetime)


    def valueChange(self, event):
        # Get the new value and format it to the current locale
        dateFormatter = locale.nl_langinfo(locale.D_FMT)
        dateOut = event.getProperty().getValue().strftime(dateFormatter)
        # Show notification
        self.getWindow().showNotification('Starting date: ' + dateOut)
コード例 #6
0
ファイル: DateResolutionExample.py プロジェクト: AvdN/muntjac
    def __init__(self):
        super(DateResolutionExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)
        self._datetime.setImmediate(True)

        # Create selection
        self._localeSelection = ComboBox('Select resolution:')
        self._localeSelection.setNullSelectionAllowed(False)
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)

        # Fill the selection with choices, set captions correctly
        self._localeSelection.setContainerDataSource(
                self.getResolutionContainer())
        self._localeSelection.setItemCaptionPropertyId(
                self.resolution_PROPERTY_NAME)
        self._localeSelection.setItemCaptionMode(
                ComboBox.ITEM_CAPTION_MODE_PROPERTY)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)
コード例 #7
0
    def __init__(self):
        super(DateInlineExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)

        # Add valuechangelistener
        self._datetime.addListener(self, IValueChangeListener)
        self._datetime.setImmediate(True)

        self.addComponent(self._datetime)
コード例 #8
0
    def __init__(self):
        super(DateInlineExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)

        # Add valuechangelistener
        self._datetime.addListener(self, IValueChangeListener)
        self._datetime.setImmediate(True)

        self.addComponent(self._datetime)
コード例 #9
0
class DateResolutionExample(VerticalLayout, IValueChangeListener):

    resolution_PROPERTY_NAME = 'name'

    # Resolution fields from DateField
    _resolutions = [
        InlineDateField.RESOLUTION_YEAR, InlineDateField.RESOLUTION_MONTH,
        InlineDateField.RESOLUTION_DAY, InlineDateField.RESOLUTION_HOUR,
        InlineDateField.RESOLUTION_MIN, InlineDateField.RESOLUTION_SEC,
        InlineDateField.RESOLUTION_MSEC
    ]

    _resolutionNames = [
        'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Millisecond'
    ]

    def __init__(self):
        super(DateResolutionExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)
        self._datetime.setImmediate(True)

        # Create selection
        self._localeSelection = ComboBox('Select resolution:')
        self._localeSelection.setNullSelectionAllowed(False)
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)

        # Fill the selection with choices, set captions correctly
        self._localeSelection.setContainerDataSource(
            self.getResolutionContainer())
        self._localeSelection.setItemCaptionPropertyId(
            self.resolution_PROPERTY_NAME)
        self._localeSelection.setItemCaptionMode(
            ComboBox.ITEM_CAPTION_MODE_PROPERTY)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)

    def valueChange(self, event):
        self._datetime.setResolution(event.getProperty().getValue())
        self._datetime.requestRepaint()

    def getResolutionContainer(self):
        resolutionContainer = IndexedContainer()
        resolutionContainer.addContainerProperty(self.resolution_PROPERTY_NAME,
                                                 str, None)

        for i, res in enumerate(self._resolutions):
            added = resolutionContainer.addItem(res)
            added.getItemProperty(self.resolution_PROPERTY_NAME).setValue(
                self._resolutionNames[i])

        return resolutionContainer
コード例 #10
0
ファイル: DateResolutionExample.py プロジェクト: AvdN/muntjac
class DateResolutionExample(VerticalLayout, IValueChangeListener):

    resolution_PROPERTY_NAME = 'name'

    # Resolution fields from DateField
    _resolutions = [
        InlineDateField.RESOLUTION_YEAR,
        InlineDateField.RESOLUTION_MONTH,
        InlineDateField.RESOLUTION_DAY,
        InlineDateField.RESOLUTION_HOUR,
        InlineDateField.RESOLUTION_MIN,
        InlineDateField.RESOLUTION_SEC,
        InlineDateField.RESOLUTION_MSEC
    ]

    _resolutionNames = [
        'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Millisecond'
    ]

    def __init__(self):
        super(DateResolutionExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_DAY)
        self._datetime.setImmediate(True)

        # Create selection
        self._localeSelection = ComboBox('Select resolution:')
        self._localeSelection.setNullSelectionAllowed(False)
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)

        # Fill the selection with choices, set captions correctly
        self._localeSelection.setContainerDataSource(
                self.getResolutionContainer())
        self._localeSelection.setItemCaptionPropertyId(
                self.resolution_PROPERTY_NAME)
        self._localeSelection.setItemCaptionMode(
                ComboBox.ITEM_CAPTION_MODE_PROPERTY)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)


    def valueChange(self, event):
        self._datetime.setResolution(event.getProperty().getValue())
        self._datetime.requestRepaint()


    def getResolutionContainer(self):
        resolutionContainer = IndexedContainer()
        resolutionContainer.addContainerProperty(
                self.resolution_PROPERTY_NAME, str, None)

        for i, res in enumerate(self._resolutions):
            added = resolutionContainer.addItem(res)
            added.getItemProperty(
                    self.resolution_PROPERTY_NAME).setValue(
                            self._resolutionNames[i])

        return resolutionContainer
コード例 #11
0
class DateLocaleExample(VerticalLayout, IValueChangeListener):
    def __init__(self):
        super(DateLocaleExample, self).__init__()

        self.setSpacing(True)

        self._datetime = InlineDateField('Please select the starting time:')

        # Set the value of the PopupDateField to current date
        self._datetime.setValue(datetime.today())

        # Set the correct resolution
        self._datetime.setResolution(InlineDateField.RESOLUTION_MIN)
        self._datetime.setImmediate(True)
        self._datetime.setShowISOWeekNumbers(True)

        # Create selection and fill it with locales
        self._localeSelection = ComboBox('Select date format:')
        self._localeSelection.addListener(self, IValueChangeListener)
        self._localeSelection.setImmediate(True)
        self._localeSelection.setContainerDataSource(
            ExampleUtil.getLocaleContainer())
        self._localeSelection.setNullSelectionAllowed(False)

        self.addComponent(self._datetime)
        self.addComponent(self._localeSelection)

    def valueChange(self, event):
        selected = self._localeSelection.getItem(
            event.getProperty().getValue())
        self._datetime.setLocale(
            selected.getItemProperty(
                ExampleUtil.locale_PROPERTY_LOCALE).getValue())
        self._datetime.requestRepaint()