def createComponents(self): components = list() label = Label('This is a long text block that will wrap.') label.setWidth('120px') components.append(label) image = Embedded('', ThemeResource('../runo/icons/64/document.png')) components.append(image) documentLayout = CssLayout() documentLayout.setWidth('19px') for _ in range(5): e = Embedded(None, ThemeResource('../runo/icons/16/document.png')) e.setHeight('16px') e.setWidth('16px') documentLayout.addComponent(e) components.append(documentLayout) buttonLayout = VerticalLayout() button = Button('Button') button.addListener(ButtonClickListener(self), IClickListener) buttonLayout.addComponent(button) buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER) components.append(buttonLayout) return components
class LabelRichExample(VerticalLayout, IClickListener): def __init__(self): super(LabelRichExample, self).__init__() self.setSpacing(True) self._editor = RichTextArea() self._richText = Label( '<h1>Rich text example</h1>' '<p>The <b>quick</b> brown fox jumps <sup>over</sup> ' 'the <b>lazy</b> dog.</p>' '<p>This text can be edited with the <i>Edit</i> -button</p>') self._richText.setContentMode(Label.CONTENT_XHTML) self.addComponent(self._richText) self._b = Button('Edit') self._b.addListener(self, IClickListener) self.addComponent(self._b) self._editor.setWidth('100%') def buttonClick(self, event): if self.getComponentIterator().next() == self._richText: self._editor.setValue(self._richText.getValue()) self.replaceComponent(self._richText, self._editor) self._b.setCaption('Apply') else: self._richText.setValue(self._editor.getValue()) self.replaceComponent(self._editor, self._richText) self._b.setCaption('Edit')
class AccordionDisabledExample(VerticalLayout, tab_sheet.ISelectedTabChangeListener, button.IClickListener): _icon1 = ThemeResource('../sampler/icons/action_save.gif') _icon2 = ThemeResource('../sampler/icons/comment_yellow.gif') _icon3 = ThemeResource('../sampler/icons/icon_info.gif') def __init__(self): super(AccordionDisabledExample, self).__init__() self.setSpacing(True) self._l1 = Label('There are no previously saved actions.') self._l2 = Label('There are no saved notes.') self._l3 = Label('There are currently no issues.') self._a = Accordion() self._a.setHeight('300px') self._a.setWidth('400px') self._t1 = self._a.addTab(self._l1, 'Saved actions', self._icon1) self._t2 = self._a.addTab(self._l2, 'Notes', self._icon2) self._t3 = self._a.addTab(self._l3, 'Issues', self._icon3) self._a.addListener(self, tab_sheet.ISelectedTabChangeListener) self._b1 = Button('Disable \'Notes\' tab') self._b2 = Button('Hide \'Issues\' tab') self._b1.addListener(self, button.IClickListener) self._b2.addListener(self, button.IClickListener) hl = HorizontalLayout() hl.setSpacing(True) hl.addComponent(self._b1) hl.addComponent(self._b2) self.addComponent(self._a) self.addComponent(hl) def selectedTabChange(self, event): c = self._a.getTab(event.getTabSheet().getSelectedTab()).getCaption() self.getWindow().showNotification('Selected tab: ' + c) def buttonClick(self, event): if self._b1 == event.getButton(): # b1 clicked if self._t2.isEnabled(): self._t2.setEnabled(False) self._b1.setCaption('Enable \'Notes\' tab') else: self._t2.setEnabled(True) self._b1.setCaption('Disable \'Notes\' tab') else: # b2 clicked if self._t3.isVisible(): self._t3.setVisible(False) self._b2.setCaption('Show \'Issues\' tab') else: self._t3.setVisible(True) self._b2.setCaption('Hide \'Issues\' tab') self._a.requestRepaint()
def init(self): # Application.init is called once for each application. Here it # creates the UI and connects it to the business logic. # Create the main layout for our application (4 columns, 5 rows) layout = GridLayout(4, 5) # Create the main window for the application using the main layout. # The main window is shown when the application is starts. self.setMainWindow(Window('Calculator Application', layout)) # Create a result label that over all 4 columns in the first row layout.addComponent(self._display, 0, 0, 3, 0) # The operations for the calculator in the order they appear on the # screen (left to right, top to bottom) operations = ['7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '=', 'C', '+'] for caption in operations: # Create a button and use this application for event handling button = Button(caption) button.addListener(self) # Add the button to our main layout layout.addComponent(button)
class LabelRichExample(VerticalLayout, IClickListener): def __init__(self): super(LabelRichExample, self).__init__() self.setSpacing(True) self._editor = RichTextArea() self._richText = Label('<h1>Rich text example</h1>' '<p>The <b>quick</b> brown fox jumps <sup>over</sup> ' 'the <b>lazy</b> dog.</p>' '<p>This text can be edited with the <i>Edit</i> -button</p>') self._richText.setContentMode(Label.CONTENT_XHTML) self.addComponent(self._richText) self._b = Button('Edit') self._b.addListener(self, IClickListener) self.addComponent(self._b) self._editor.setWidth('100%') def buttonClick(self, event): if self.getComponentIterator().next() == self._richText: self._editor.setValue(self._richText.getValue()) self.replaceComponent(self._richText, self._editor) self._b.setCaption('Apply') else: self._richText.setValue(self._editor.getValue()) self.replaceComponent(self._editor, self._richText) self._b.setCaption('Edit')
def __init__(self): super(PanelLightExample, self).__init__() self.setSpacing(True) self.setSpacing(True) # Panel 1 - with caption self._panel = Panel('This is a light Panel') self._panel.setStyleName(Reindeer.PANEL_LIGHT) self._panel.setHeight('200px') # we want scrollbars # let's adjust the panels default layout (a VerticalLayout) layout = self._panel.getContent() layout.setMargin(True) # we want a margin layout.setSpacing(True) # and spacing between components self.addComponent(self._panel) # Let's add a few rows to provoke scrollbars: for _ in range(20): l = Label('The quick brown fox jumps over the lazy dog.') self._panel.addComponent(l) # Caption toggle: b = Button('Toggle caption') b.addListener(self, IClickListener) self.addComponent(b)
class AccordionDisabledExample(VerticalLayout, tab_sheet.ISelectedTabChangeListener, button.IClickListener): _icon1 = ThemeResource('../sampler/icons/action_save.gif') _icon2 = ThemeResource('../sampler/icons/comment_yellow.gif') _icon3 = ThemeResource('../sampler/icons/icon_info.gif') def __init__(self): super(AccordionDisabledExample, self).__init__() self.setSpacing(True) self._l1 = Label('There are no previously saved actions.') self._l2 = Label('There are no saved notes.') self._l3 = Label('There are currently no issues.') self._a = Accordion() self._a.setHeight('300px') self._a.setWidth('400px') self._t1 = self._a.addTab(self._l1, 'Saved actions', self._icon1) self._t2 = self._a.addTab(self._l2, 'Notes', self._icon2) self._t3 = self._a.addTab(self._l3, 'Issues', self._icon3) self._a.addListener(self, tab_sheet.ISelectedTabChangeListener) self._b1 = Button('Disable \'Notes\' tab') self._b2 = Button('Hide \'Issues\' tab') self._b1.addListener(self, button.IClickListener) self._b2.addListener(self, button.IClickListener) hl = HorizontalLayout() hl.setSpacing(True) hl.addComponent(self._b1) hl.addComponent(self._b2) self.addComponent(self._a) self.addComponent(hl) def selectedTabChange(self, event): c = self._a.getTab(event.getTabSheet().getSelectedTab()).getCaption() self.getWindow().showNotification('Selected tab: ' + c) def buttonClick(self, event): if self._b1 == event.getButton(): # b1 clicked if self._t2.isEnabled(): self._t2.setEnabled(False) self._b1.setCaption('Enable \'Notes\' tab') else: self._t2.setEnabled(True) self._b1.setCaption('Disable \'Notes\' tab') else: # b2 clicked if self._t3.isVisible(): self._t3.setVisible(False) self._b2.setCaption('Show \'Issues\' tab') else: self._t3.setVisible(True) self._b2.setCaption('Hide \'Issues\' tab') self._a.requestRepaint()
def __init__(self): super(TableStylingExample, self).__init__() self.setSpacing(True) self._table = Table() self._markedRows = dict() self._markedCells = dict() self.addComponent(self._table) # set a style name, so we can style rows and cells self._table.setStyleName('contacts') # size self._table.setWidth('100%') self._table.setPageLength(7) # connect data source self._table.setContainerDataSource(ExampleUtil.getPersonContainer()) # Generate the email-link from firstname & lastname self._table.addGeneratedColumn('Email', TableColumnGenerator(self)) # turn on column reordering and collapsing self._table.setColumnReorderingAllowed(True) self._table.setColumnCollapsingAllowed(True) # Actions (a.k.a context menu) self._table.addActionHandler( TableActionHandler(self) ) # style generator self._table.setCellStyleGenerator( TableStyleGenerator(self) ) # toggle cell 'marked' styling when double-clicked self._table.addListener(TableClickListener(self), IItemClickListener) # Editing # we don't want to update container before pressing 'save': self._table.setWriteThrough(False) # edit button editButton = Button('Edit') self.addComponent(editButton) editButton.addListener(EditListener(self, editButton), button.IClickListener) self.setComponentAlignment(editButton, Alignment.TOP_RIGHT)
def __init__(self): super(TableStylingExample, self).__init__() self.setSpacing(True) self._table = Table() self._markedRows = dict() self._markedCells = dict() self.addComponent(self._table) # set a style name, so we can style rows and cells self._table.setStyleName('contacts') # size self._table.setWidth('100%') self._table.setPageLength(7) # connect data source self._table.setContainerDataSource(ExampleUtil.getPersonContainer()) # Generate the email-link from firstname & lastname self._table.addGeneratedColumn('Email', TableColumnGenerator(self)) # turn on column reordering and collapsing self._table.setColumnReorderingAllowed(True) self._table.setColumnCollapsingAllowed(True) # Actions (a.k.a context menu) self._table.addActionHandler( TableActionHandler(self) ) # style generator self._table.setCellStyleGenerator( TableStyleGenerator(self) ) # toggle cell 'marked' styling when double-clicked self._table.addListener(TableClickListener(self), IItemClickListener) # Editing # we don't want to update container before pressing 'save': self._table.setWriteThrough(False) # edit button editButton = Button('Edit') self.addComponent(editButton) editButton.addListener(EditListener(self, editButton), button.IClickListener) self.setComponentAlignment(editButton, Alignment.TOP_RIGHT)
def __init__(self): super(ImmediateUploadExample, self).__init__() self.setSpacing(True) self._status = Label('Please select a file to upload') self._pi = ProgressIndicator() self._receiver = MyReceiver() self._progressLayout = HorizontalLayout() self._upload = Upload(None, self._receiver) # Slow down the upload self._receiver.setSlow(True) self.addComponent(self._status) self.addComponent(self._upload) self.addComponent(self._progressLayout) # Make uploading start immediately when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Select file') self._progressLayout.setSpacing(True) self._progressLayout.setVisible(False) self._progressLayout.addComponent(self._pi) self._progressLayout.setComponentAlignment(self._pi, Alignment.MIDDLE_LEFT) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setStyleName('small') self._progressLayout.addComponent(cancelProcessing) # =========== Add needed listener for the upload component: start, # progress, finish, success, fail =========== 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(ImmediateUploadExample, self).__init__() self.setSpacing(True) self._status = Label('Please select a file to upload') self._pi = ProgressIndicator() self._receiver = MyReceiver() self._progressLayout = HorizontalLayout() self._upload = Upload(None, self._receiver) # Slow down the upload self._receiver.setSlow(True) self.addComponent(self._status) self.addComponent(self._upload) self.addComponent(self._progressLayout) # Make uploading start immediately when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Select file') self._progressLayout.setSpacing(True) self._progressLayout.setVisible(False) self._progressLayout.addComponent(self._pi) self._progressLayout.setComponentAlignment(self._pi, Alignment.MIDDLE_LEFT) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setStyleName('small') self._progressLayout.addComponent(cancelProcessing) # =========== Add needed listener for the upload component: start, # progress, finish, success, fail =========== 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): layout = GridLayout(4, 5) self.setMainWindow(Window('Calculator Application', layout)) layout.addComponent(self._display, 0, 0, 3, 0) operations = ['7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '=', 'C', '+'] for caption in operations: # Create a button and use this application for event handling button = Button(caption) button.addListener(self) # Add the button to our main layout layout.addComponent(button)
def __init__(self): super(ButtonLinkExample, self).__init__() self.setSpacing(True) # Button w/ text and tooltip b = Button(self._CAPTION) b.setStyleName(BaseTheme.BUTTON_LINK) b.setDescription(self._TOOLTIP) b.addListener(self, button.IClickListener) # react to clicks self.addComponent(b) # Button w/ text, icon and tooltip b = Button(self._CAPTION) b.setStyleName(BaseTheme.BUTTON_LINK) b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, button.IClickListener) # react to clicks self.addComponent(b) # Button w/ icon and tooltip b = Button() b.setStyleName(BaseTheme.BUTTON_LINK) b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, button.IClickListener) # react to clicks self.addComponent(b)
class ApplicationLayoutExample(VerticalLayout): def __init__(self): super(ApplicationLayoutExample, self).__init__() self.setMargin(True) self._win = ApplicationLayoutWindow() self._open = Button('Open sample in subwindow') # We'll open this example in a separate window, configure it self._win.setWidth('70%') self._win.setHeight('70%') self._win.center() self._win.addListener(WindowCloseListener(self), ICloseListener) # 'open sample' button self.addComponent(self._open) self._open.addListener(ClickListener(self), IClickListener) self.addComponent(Label('Don\'t worry: the content of the window ' 'is not supposed to make sense...'))
class ApplicationLayoutExample(VerticalLayout): def __init__(self): super(ApplicationLayoutExample, self).__init__() self.setMargin(True) self._win = ApplicationLayoutWindow() self._open = Button('Open sample in subwindow') # We'll open this example in a separate window, configure it self._win.setWidth('70%') self._win.setHeight('70%') self._win.center() self._win.addListener(WindowCloseListener(self), ICloseListener) # 'open sample' button self.addComponent(self._open) self._open.addListener(ClickListener(self), IClickListener) self.addComponent( Label('Don\'t worry: the content of the window ' 'is not supposed to make sense...'))
class WebLayoutExample(VerticalLayout): def __init__(self): super(VerticalLayout, self).__init__() self._win = WebLayoutWindow() self._open = Button('Open sample in subwindow') self.setMargin(True) # We'll open this example in a separate window, configure it self._win.setWidth('70%') self._win.setHeight('70%') self._win.center() # Allow opening window again when closed self._win.addListener(WindowListener(self), window.ICloseListener) # 'open sample' button self.addComponent(self._open) self._open.addListener(OpenListener(self), button.IClickListener) self.addComponent( Label('Don\'t worry: the content of the window ' 'is not supposed to make sense...'))
class WebLayoutExample(VerticalLayout): def __init__(self): super(VerticalLayout, self).__init__() self._win = WebLayoutWindow() self._open = Button('Open sample in subwindow') self.setMargin(True) # We'll open this example in a separate window, configure it self._win.setWidth('70%') self._win.setHeight('70%') self._win.center() # Allow opening window again when closed self._win.addListener(WindowListener(self), window.ICloseListener) # 'open sample' button self.addComponent(self._open) self._open.addListener(OpenListener(self), button.IClickListener) self.addComponent(Label('Don\'t worry: the content of the window ' 'is not supposed to make sense...'))
class TabSheetDisabledExample(VerticalLayout, tab_sheet.ISelectedTabChangeListener, button.IClickListener): _icon1 = ThemeResource('../sampler/icons/action_save.gif') _icon2 = ThemeResource('../sampler/icons/comment_yellow.gif') _icon3 = ThemeResource('../sampler/icons/icon_info.gif') def __init__(self): super(TabSheetDisabledExample, self).__init__() self.setSpacing(True) # Tab 1 content self._l1 = VerticalLayout() self._l1.setMargin(True) self._l1.addComponent(Label('There are no previously saved actions.')) # Tab 2 content self._l2 = VerticalLayout() self._l2.setMargin(True) self._l2.addComponent(Label('There are no saved notes.')) # Tab 3 content self._l3 = VerticalLayout() self._l3.setMargin(True) self._l3.addComponent(Label('There are currently no issues.')) self._t = TabSheet() self._t.setHeight('200px') self._t.setWidth('400px') self._t1 = self._t.addTab(self._l1, 'Saved actions', self._icon1) self._t2 = self._t.addTab(self._l2, 'Notes', self._icon2) self._t3 = self._t.addTab(self._l3, 'Issues', self._icon3) self._t.addListener(self, tab_sheet.ISelectedTabChangeListener) self._toggleEnabled = Button('Disable \'Notes\' tab') self._toggleEnabled.addListener(self, button.IClickListener) self._toggleVisible = Button('Hide \'Issues\' tab') self._toggleVisible.addListener(self, button.IClickListener) hl = HorizontalLayout() hl.setSpacing(True) hl.addComponent(self._toggleEnabled) hl.addComponent(self._toggleVisible) self.addComponent(self._t) self.addComponent(hl) def selectedTabChange(self, event): selected = event.getTabSheet().getSelectedTab() c = self._t.getTab(selected).getCaption() self.getWindow().showNotification('Selected tab: ' + c) def buttonClick(self, event): if self._toggleEnabled == event.getButton(): # toggleEnabled clicked self._t2.setEnabled(not self._t2.isEnabled()) if self._t2.isEnabled(): self._toggleEnabled.setCaption('Disable \'Notes\' tab') else: self._toggleEnabled.setCaption('Enable \'Notes\' tab') else: # toggleVisible clicked self._t3.setVisible(not self._t3.isVisible()) if self._t3.isVisible(): self._toggleVisible.setCaption('Hide \'Issues\' tab') else: self._toggleVisible.setCaption('Show \'Issues\' tab') self._t.requestRepaint()
class TabSheetDisabledExample(VerticalLayout, tab_sheet.ISelectedTabChangeListener, button.IClickListener): _icon1 = ThemeResource('../sampler/icons/action_save.gif') _icon2 = ThemeResource('../sampler/icons/comment_yellow.gif') _icon3 = ThemeResource('../sampler/icons/icon_info.gif') def __init__(self): super(TabSheetDisabledExample, self).__init__() self.setSpacing(True) # Tab 1 content self._l1 = VerticalLayout() self._l1.setMargin(True) self._l1.addComponent(Label('There are no previously saved actions.')) # Tab 2 content self._l2 = VerticalLayout() self._l2.setMargin(True) self._l2.addComponent(Label('There are no saved notes.')) # Tab 3 content self._l3 = VerticalLayout() self._l3.setMargin(True) self._l3.addComponent(Label('There are currently no issues.')) self._t = TabSheet() self._t.setHeight('200px') self._t.setWidth('400px') self._t1 = self._t.addTab(self._l1, 'Saved actions', self._icon1) self._t2 = self._t.addTab(self._l2, 'Notes', self._icon2) self._t3 = self._t.addTab(self._l3, 'Issues', self._icon3) self._t.addListener(self, tab_sheet.ISelectedTabChangeListener) self._toggleEnabled = Button('Disable \'Notes\' tab') self._toggleEnabled.addListener(self, button.IClickListener) self._toggleVisible = Button('Hide \'Issues\' tab') self._toggleVisible.addListener(self, button.IClickListener) hl = HorizontalLayout() hl.setSpacing(True) hl.addComponent(self._toggleEnabled) hl.addComponent(self._toggleVisible) self.addComponent(self._t) self.addComponent(hl) def selectedTabChange(self, event): selected = event.getTabSheet().getSelectedTab() c = self._t.getTab(selected).getCaption() self.getWindow().showNotification('Selected tab: ' + c) def buttonClick(self, event): if self._toggleEnabled == event.getButton(): # toggleEnabled clicked self._t2.setEnabled(not self._t2.isEnabled()) if self._t2.isEnabled(): self._toggleEnabled.setCaption('Disable \'Notes\' tab') else: self._toggleEnabled.setCaption('Enable \'Notes\' tab') else: # toggleVisible clicked self._t3.setVisible(not self._t3.isVisible()) if self._t3.isVisible(): self._toggleVisible.setCaption('Hide \'Issues\' tab') else: self._toggleVisible.setCaption('Show \'Issues\' tab') self._t.requestRepaint()
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)
def __init__(self): super(ButtonPushExample, self).__init__() # Normal buttons (more themable) buttons = VerticalLayout() buttons.setSpacing(True) buttons.setMargin(False, True, False, False) self.addComponent(buttons) buttons.addComponent(Label("<h3>Normal buttons</h3>", Label.CONTENT_XHTML)) # Button w/ text and tooltip b = Button(self._CAPTION) b.setDescription(self._TOOLTIP) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b) # Button w/ text, icon and tooltip b = Button(self._CAPTION) b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b) # Button w/ icon and tooltip b = Button() b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b) # NativeButtons buttons = VerticalLayout() buttons.setSpacing(True) buttons.setMargin(False, False, False, True) self.addComponent(buttons) buttons.addComponent(Label("<h3>Native buttons</h3>", Label.CONTENT_XHTML)); # NativeButton w/ text and tooltip b = NativeButton(self._CAPTION) b.setDescription(self._TOOLTIP) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b) # NativeButton w/ text, icon and tooltip b = NativeButton(self._CAPTION) b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b) # NativeButton w/ icon and tooltip b = NativeButton() b.setDescription(self._TOOLTIP) b.setIcon(self._ICON) b.addListener(self, IClickListener) # react to clicks buttons.addComponent(b)
class SimpleEditor ( Editor, IClickListener ): """ Simple style editor for a button. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # The button label label = Unicode # The list of items in a drop-down menu, if any #menu_items = List # The selected item in the drop-down menu. selected_item = Str #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ label = self.factory.label or self.item.get_label(self.ui) self.control = Button( str(self.string_value(label)) ) self.sync_value(self.factory.label_value, 'label', 'from') self.control.addListener(self, IClickListener) self.set_tooltip() #--------------------------------------------------------------------------- # Handles the 'label' trait being changed: #--------------------------------------------------------------------------- def _label_changed(self, label): self.control.setCaption( str(self.string_value(label)) ) #--------------------------------------------------------------------------- # Handles the user clicking the button by setting the value on the object: #--------------------------------------------------------------------------- def buttonClick(self, event): self.update_object() def update_object(self): """ Handles the user clicking the button by setting the factory value on the object. """ if self.selected_item != "": self.value = self.selected_item else: self.value = self.factory.value # If there is an associated view, then display it: if (self.factory is not None) and (self.factory.view is not None): self.object.edit_traits( view = self.factory.view, parent = self.control ) #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor(self): """ Updates the editor when the object trait changes externally to the editor. """ pass