def __init__(self): super(ErrorsExample, self).__init__() self.setSpacing(True) self.addComponent( Label('<h3>Errors in caption</h3>', Label.CONTENT_XHTML)) self.addComponent( Label('Error indicators are usually placed on the ' 'right side of the component\'s caption.')) inpt = TextField('Field caption') inpt.setComponentError(UserError('This field is never satisfied')) self.addComponent(inpt) self.addComponent( Label('<h3>Errors without caption</h3>', Label.CONTENT_XHTML)) self.addComponent( Label('If the component has no caption, the error ' 'indicator is usually placed on the right side of the ' 'component.')) inpt = TextField() inpt.setInputPrompt('This field has an error') inpt.setComponentError(UserError('This field is never satisfied.')) self.addComponent(inpt) self.addComponent( Label('<h3>Error icon placement depends on the ' 'layout</h3>', Label.CONTENT_XHTML)) self.addComponent( Label('FormLayout for example places the error ' 'between the component caption and the actual field.')) fl = FormLayout() fl.setMargin(False) fl.setSpacing(False) self.addComponent(fl) inpt = TextField('Field caption') inpt.setInputPrompt('This field has an error') inpt.setComponentError(UserError('This field is never satisfied.')) fl.addComponent(inpt)
def __init__(self): super(ErrorsExample, self).__init__() self.setSpacing(True) self.addComponent(Label('<h3>Errors in caption</h3>', Label.CONTENT_XHTML)) self.addComponent(Label('Error indicators are usually placed on the ' 'right side of the component\'s caption.')) inpt = TextField('Field caption') inpt.setComponentError(UserError('This field is never satisfied')) self.addComponent(inpt) self.addComponent(Label('<h3>Errors without caption</h3>', Label.CONTENT_XHTML)) self.addComponent(Label('If the component has no caption, the error ' 'indicator is usually placed on the right side of the ' 'component.')) inpt = TextField() inpt.setInputPrompt('This field has an error') inpt.setComponentError(UserError('This field is never satisfied.')) self.addComponent(inpt) self.addComponent(Label('<h3>Error icon placement depends on the ' 'layout</h3>', Label.CONTENT_XHTML)) self.addComponent(Label('FormLayout for example places the error ' 'between the component caption and the actual field.')) fl = FormLayout() fl.setMargin(False) fl.setSpacing(False) self.addComponent(fl) inpt = TextField('Field caption') inpt.setInputPrompt('This field has an error') inpt.setComponentError(UserError('This field is never satisfied.')) fl.addComponent(inpt)
def __init__(self): super(UploadWithProgressMonitoringExample, self).__init__() self.setSpacing(True) self._state = Label() self._result = Label() self._fileName = Label() self._textualProgress = Label() self._pi = ProgressIndicator() self._counter = LineBreakCounter() self._upload = Upload(None, self._counter) self.addComponent(Label('Upload a file and we\'ll count the number ' 'of line break characters (\\n) found in it.')) # make analyzing start immediatedly when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Upload File') self.addComponent(self._upload) handBrake = CheckBox('Simulate slow server') handBrake.setValue(True) self._counter.setSlow(True) handBrake.setDescription('Sleep for 100ms after each kilobyte to ' 'simulate slower processing/bandwidth. This is to show ' 'progress indicator even with rather small files.') handBrake.addListener(HandBrakeListener(self), button.IClickListener) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setVisible(False) cancelProcessing.setStyleName('small') handBrake.setImmediate(True) self.addComponent(handBrake) p = Panel('Status') p.setSizeUndefined() l = FormLayout() l.setMargin(True) p.setContent(l) stateLayout = HorizontalLayout() stateLayout.setSpacing(True) stateLayout.addComponent(self._state) stateLayout.addComponent(cancelProcessing) stateLayout.setCaption('Current state') self._state.setValue('Idle') l.addComponent(stateLayout) self._fileName.setCaption('File name') l.addComponent(self._fileName) self._result.setCaption('Line breaks counted') l.addComponent(self._result) self._pi.setCaption('Progress') self._pi.setVisible(False) l.addComponent(self._pi) self._textualProgress.setVisible(False) l.addComponent(self._textualProgress) self.addComponent(p) self._upload.addListener(StartedListener(self), upload.IStartedListener) self._upload.addListener(ProgressListener(self), upload.IProgressListener) self._upload.addListener(SucceededListener(self), upload.ISucceededListener) self._upload.addListener(FailedListener(self), upload.IFailedListener) self._upload.addListener(FinishedListener(self), upload.IFinishedListener)
def __init__(self): super(UploadWithProgressMonitoringExample, self).__init__() self.setSpacing(True) self._state = Label() self._result = Label() self._fileName = Label() self._textualProgress = Label() self._pi = ProgressIndicator() self._counter = LineBreakCounter() self._upload = Upload(None, self._counter) self.addComponent( Label('Upload a file and we\'ll count the number ' 'of line break characters (\\n) found in it.')) # make analyzing start immediatedly when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Upload File') self.addComponent(self._upload) handBrake = CheckBox('Simulate slow server') handBrake.setValue(True) self._counter.setSlow(True) handBrake.setDescription( 'Sleep for 100ms after each kilobyte to ' 'simulate slower processing/bandwidth. This is to show ' 'progress indicator even with rather small files.') handBrake.addListener(HandBrakeListener(self), button.IClickListener) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setVisible(False) cancelProcessing.setStyleName('small') handBrake.setImmediate(True) self.addComponent(handBrake) p = Panel('Status') p.setSizeUndefined() l = FormLayout() l.setMargin(True) p.setContent(l) stateLayout = HorizontalLayout() stateLayout.setSpacing(True) stateLayout.addComponent(self._state) stateLayout.addComponent(cancelProcessing) stateLayout.setCaption('Current state') self._state.setValue('Idle') l.addComponent(stateLayout) self._fileName.setCaption('File name') l.addComponent(self._fileName) self._result.setCaption('Line breaks counted') l.addComponent(self._result) self._pi.setCaption('Progress') self._pi.setVisible(False) l.addComponent(self._pi) self._textualProgress.setVisible(False) l.addComponent(self._textualProgress) self.addComponent(p) self._upload.addListener(StartedListener(self), upload.IStartedListener) self._upload.addListener(ProgressListener(self), upload.IProgressListener) self._upload.addListener(SucceededListener(self), upload.ISucceededListener) self._upload.addListener(FailedListener(self), upload.IFailedListener) self._upload.addListener(FinishedListener(self), upload.IFinishedListener)