def createChildComponentClickableLayout(self): # Create a grid layout with click events layout = GridLayout(5, 2) layout.addStyleName('border') layout.setSpacing(True) layout.setWidth('90%') layout.setMargin(True) # Add some components to the layout layout.addComponent(Label('<b>Clickable layout events include a ' 'reference to the child component beneath the click. ' 'Try clicking anywhere in this layout.</b>', Label.CONTENT_RAW), 0, 0, 4, 0) layout.addComponent(TextField(None, 'Click here')) layout.addComponent(Link('Click here', None)) select = Select(None, ['Click here']) select.select('Click here') layout.addComponent(select) # Listen for layout click event layout.addListener(GridListener(self), ILayoutClickListener) return layout
def createChildComponentClickableLayout(self): # Create a grid layout with click events layout = GridLayout(5, 2) layout.addStyleName('border') layout.setSpacing(True) layout.setWidth('90%') layout.setMargin(True) # Add some components to the layout layout.addComponent( Label( '<b>Clickable layout events include a ' 'reference to the child component beneath the click. ' 'Try clicking anywhere in this layout.</b>', Label.CONTENT_RAW), 0, 0, 4, 0) layout.addComponent(TextField(None, 'Click here')) layout.addComponent(Link('Click here', None)) select = Select(None, ['Click here']) select.select('Click here') layout.addComponent(select) # Listen for layout click event layout.addListener(GridListener(self), ILayoutClickListener) return layout
def init(self): mainWindow = Window('CodeMirror Sample Application') hl = GridLayout(2, 5) hl.setSpacing(True) mainWindow.addComponent(hl) # #1 code = CodeMirror('Your Code', CodeMode.TEXT) code.setValue(self._SAMPLE_CODE) code.setWidth('500px') code.setHeight('350px') hl.addComponent(code) # #2 code2 = CodeMirror('Your Code Too', CodeMode.PYTHON) code2.setValue(self._SAMPLE_CODE) # code2.setWidth('400px') # code2.setHeight('300px') hl.addComponent(code2) codeMode = Select('Select your mode') for cs in CodeMode.values(): codeMode.addItem(cs) codeMode.setNewItemsAllowed(False) codeMode.setNullSelectionAllowed(False) codeMode.setImmediate(True) hl.addComponent(codeMode) l = CodeModeChangeListener(code, codeMode) codeMode.addListener(l, IValueChangeListener) codeMode.setValue(CodeMode.TEXT) codeMode = Select('Select your mode too') for cs in CodeMode.values(): codeMode.addItem(cs) codeMode.setNewItemsAllowed(False) codeMode.setNullSelectionAllowed(False) codeMode.setImmediate(True) hl.addComponent(codeMode) l = CodeModeChangeListener(code2, codeMode) codeMode.addListener(l, IValueChangeListener) codeMode.setValue(CodeMode.PYTHON) codeTheme = Select('Select your theme') for ct in CodeTheme.values(): codeTheme.addItem(ct) codeTheme.setNewItemsAllowed(False) codeTheme.setImmediate(True) hl.addComponent(codeTheme) l = CodeThemeChangeListener(code, codeTheme) codeTheme.addListener(l, IValueChangeListener) codeTheme.setValue(CodeTheme.DEFAULT) codeTheme = Select('Select your theme too') for ct in CodeTheme.values(): codeTheme.addItem(ct) codeTheme.setNewItemsAllowed(False) codeTheme.setImmediate(True) hl.addComponent(codeTheme) l = CodeThemeChangeListener(code2, codeTheme) codeTheme.addListener(l, IValueChangeListener) codeTheme.setValue(CodeTheme.ECLIPSE) l = CopyClickListener(code, code2) hl.addComponent(Button('copy to -->', l)) l = CopyClickListener(code2, code) hl.addComponent(Button('<- copy to', l)) l = ShowLineNumbersListener(code) cb = CheckBox("Show line numbers", l) cb.setImmediate(True) hl.addComponent(cb) l = ShowLineNumbersListener(code2) cb = CheckBox("Show line numbers", l) cb.setImmediate(True) hl.addComponent(cb) self.setMainWindow(mainWindow)