def __init__(self): super(SplitPanelBasicExample, self).__init__() # First a vertical SplitPanel vert = VerticalSplitPanel() vert.setHeight('450px') vert.setWidth('100%') vert.setSplitPosition(150, ISizeable.UNITS_PIXELS) self.addComponent(vert) # add a label to the upper area vert.addComponent(Label(self.brownFox)) # Add a horizontal SplitPanel to the lower area horiz = HorizontalSplitPanel() horiz.setSplitPosition(50) # percent vert.addComponent(horiz) # left component: horiz.addComponent(Label(self.brownFox)) # right component: horiz.addComponent(Label(self.brownFox)) # Lock toggle button toggleLocked = CheckBox('Splits locked', LockListener(vert, horiz)) toggleLocked.setImmediate(True) self.addComponent(toggleLocked)
def __init__(self): super(TabSheetIconsExample, self).__init__() # Tab 1 content l1 = VerticalLayout() l1.setMargin(True) l1.addComponent(Label('There are no previously saved actions.')) # Tab 2 content l2 = VerticalLayout() l2.setMargin(True) l2.addComponent(Label('There are no saved notes.')) # Tab 3 content l3 = VerticalLayout() l3.setMargin(True) l3.addComponent(Label('There are currently no issues.')) self._t = TabSheet() self._t.setHeight('200px') self._t.setWidth('400px') self._t.addTab(l1, 'Saved actions', self._icon1) self._t.addTab(l2, 'Notes', self._icon2) self._t.addTab(l3, 'Issues', self._icon3) self._t.addListener(self, ISelectedTabChangeListener) self.addComponent(self._t)
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 init(self): main = Window('CSS Tools Add-on Test') self.setMainWindow(main) testWindow = Window('Normal Window') testWindow.addComponent( Label("<p>This window is used as the component to measure.</p>", Label.CONTENT_XHTML)) main.addWindow(testWindow) testWindow.center() title = Label('CSS Properties to Retrieve') title.addStyleName(Reindeer.LABEL_H2) main.addComponent(title) target = NativeSelect('Target Component') main.addComponent(target) get = Button('Refresh Properties', GetClickListener(self, target)) main.addComponent(get) main.addComponent(self.buildLabels()) target.addItem(main.getContent()) target.setItemCaption(main.getContent(), 'Root layout') target.addItem(testWindow) target.setItemCaption(testWindow, 'Sub window') target.addItem(get) target.setItemCaption(get, 'The \'' + get.getCaption() + '\' Button') target.setNullSelectionAllowed(False) target.select(testWindow)
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)
def attach(self): if self._populated: return # Only populate the layout once # Find the context we are running in and get the browser information # from that. context = self.getApplication().getContext() webBrowser = context.getBrowser() # Create a text to show based on the browser. browserText = self.getBrowserAndVersion(webBrowser) browserText = browserText + ' in ' + self.getOperatingSystem( webBrowser) # Create labels for the information and add them to the application ipAddresslabel = Label( "Hello user from <b>" + webBrowser.getAddress() + "</b>.", Label.CONTENT_XHTML) browser = Label("You are running <b>" + browserText + "</b>.", Label.CONTENT_XHTML) screenSize = Label( "Your screen resolution is <b>" + str(webBrowser.getScreenWidth()) + "x" + str(webBrowser.getScreenHeight()) + "</b>.", Label.CONTENT_XHTML) locale = Label( "Your browser is set to primarily use the <b>" + str(webBrowser.getLocale()) + "</b> locale.", Label.CONTENT_XHTML) # FIXME: timezones # timeZones = NativeSelect() # # Client timezone offset w/o possible DST: # rtzOffset = webBrowser.getRawTimezoneOffset() # # DST: # dst = webBrowser.getDSTSavings() # # use raw offset to get possible TZ: # tzs = TimeZone.getAvailableIDs(rtzOffset) # for idd in tzs: # tz = TimeZone.getTimeZone(idd) # if dst == tz.getDSTSavings(): # # only include zones w/ DST if we know we have DST # caption = idd + ' (' + tz.getDisplayName() + ')' # timeZones.addItem(caption) # if timeZones.getValue() is None: # # select first # timeZones.setValue(caption) # # timeZones.setImmediate(True) # timeZones.setNullSelectionAllowed(False) # timeZones.setCaption(self.getTimeZoneInfoString(webBrowser)) self.addComponent(ipAddresslabel) self.addComponent(browser) self.addComponent(screenSize) self.addComponent(locale) # self.addComponent(timeZones) self._populated = True
def init(self): # super(GoogleMapWidgetApp, self).__init__() self.setMainWindow(Window('Google Map add-on demo')) # Create a new map instance centered on the IT Mill offices self._googleMap = GoogleMap(self, (22.3, 60.4522), 8) self._googleMap.setWidth('640px') self._googleMap.setHeight('480px') # Create a marker at the IT Mill offices self._mark1 = BasicMarker(1L, (22.3, 60.4522), 'Test marker 1') self._mark2 = BasicMarker(2L, (22.4, 60.4522), 'Test marker 2') self._mark3 = BasicMarker(4L, (22.6, 60.4522), 'Test marker 3') self._mark4 = BasicMarker(5L, (22.7, 60.4522), 'Test marker 4') l = MarkerClickListener(self) self._googleMap.addListener(l, IMarkerClickListener) # Marker with information window pupup self._mark5 = BasicMarker(6L, (22.8, 60.4522), 'Marker 5') self._mark5.setInfoWindowContent(self._googleMap, Label('Hello Marker 5!')) content = Label('Hello Marker 2!') content.setWidth('60px') self._mark2.setInfoWindowContent(self._googleMap, content) self._googleMap.addMarker(self._mark1) self._googleMap.addMarker(self._mark2) self._googleMap.addMarker(self._mark3) self._googleMap.addMarker(self._mark4) self._googleMap.addMarker(self._mark5) self.getMainWindow().getContent().addComponent(self._googleMap) # Add a Marker click listener to catch marker click events. # Note, works only if marker has information window content l = MarkerClickListener2(self) self._googleMap.addListener(l, IMarkerClickListener) # Add a MarkerMovedListener to catch events when a marker is dragged to # a new location l = MarkerMovedListener(self) self._googleMap.addListener(l, IMarkerMovedListener) l = MapMoveListener(self) self._googleMap.addListener(l, IMapMoveListener) self._googleMap.addControl(MapControl.MapTypeControl) self.addTestButtons() # Add buttons that trigger tests map features
def __init__(self): super(TabSheetClosingExample, self).__init__() # Tab 1 content l1 = VerticalLayout() l1.setMargin(True) l1.addComponent(Label('There are no previously saved actions.')) # Tab 2 content l2 = VerticalLayout() l2.setMargin(True) l2.addComponent(Label('There are no saved notes.')) # Tab 3 content l3 = VerticalLayout() l3.setMargin(True) l3.addComponent(Label('There are currently no issues.')) # Tab 4 content l4 = VerticalLayout() l4.setMargin(True) l4.addComponent(Label('There are no comments.')) # Tab 5 content l5 = VerticalLayout() l5.setMargin(True) l5.addComponent(Label('There is no new feedback.')) self._t = TabSheet() self._t.setHeight('200px') self._t.setWidth('400px') saved = self._t.addTab(l1, 'Saved actions', None) saved.setClosable(True) notes = self._t.addTab(l2, 'Notes', None) notes.setClosable(True) issues = self._t.addTab(l3, 'Issues', None) issues.setClosable(True) comments = self._t.addTab(l4, 'Comments', None) comments.setClosable(True) feedback = self._t.addTab(l5, 'Feedback', None) feedback.setClosable(True) self._t.addListener(self, tab_sheet.ISelectedTabChangeListener) self._t.setCloseHandler(self) self.addComponent(self._t)
def __init__(self): super(SubwindowExample, self).__init__() # Create the window self._subwindow = Window('A subwindow') # Configure the windows layout; by default a VerticalLayout layout = self._subwindow.getContent() layout.setMargin(True) layout.setSpacing(True) # Add some content; a label and a close-button message = Label('This is a subwindow') self._subwindow.addComponent(message) close = Button('Close', CloseListener(self)) # The components added to the window are actually added to the window's # layout; you can use either. Alignments are set using the layout layout.addComponent(close) layout.setComponentAlignment(close, Alignment.TOP_RIGHT) # Add a button for opening the subwindow opn = Button('Open subwindow', OpenListener(self)) self.addComponent(opn)
def __init__(self): super(DragDropHtml5FromDesktopExample, self).__init__() self.addComponent( Label('Drag text from desktop application or ' 'image files from the ' + 'file system to the drop box ' 'below (dragging files requires HTML5 capable browser ' 'like FF 3.6, Safari or Chrome)')) dropPane = CssLayout() dropPane.setWidth('200px') dropPane.setHeight('200px') dropPane.addStyleName('image-drop-pane') dropBox = ImageDropBox(dropPane, self) dropBox.setSizeUndefined() panel = Panel(dropBox) panel.setSizeUndefined() panel.addStyleName('no-vertical-drag-hints') panel.addStyleName('no-horizontal-drag-hints') self.addComponent(panel) self._progress = ProgressIndicator() self._progress.setIndeterminate(True) self._progress.setVisible(False) self.addComponent(self._progress)
def __init__(self): super(PopupViewContentsExample, self).__init__() self.setSpacing(True) # ------ # Static content for the minimized view # ------ # Create the content for the popup content = Label('This is a simple Label component inside the popup. ' 'You can place any Muntjac components here.') # The PopupView popup will be as large as needed by the content content.setWidth('300px') # Construct the PopupView with simple HTML text representing the # minimized view popup = PopupView('Static HTML content', content) self.addComponent(popup) # ------ # Dynamic content for the minimized view # ------ # In this sample we update the minimized view value with the content of # the TextField inside the popup. popup = PopupView(PopupTextField()) popup.setDescription('Click to edit') popup.setHideOnMouseOut(False) self.addComponent(popup)
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)
def create(self, parent): """ Creates the underlying widget to display HTML. """ self.widget = Label() self.widget.setContentMode(Label.CONTENT_XHTML) parent.addComponent(self.widget)
def __init__(self): super(WebLayoutWindow, self).__init__() # Our main layout is a horizontal layout main = HorizontalLayout() main.setMargin(True) main.setSpacing(True) self.setContent(main) # Tree to the left tree = Tree() tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) for idd in tree.rootItemIds(): tree.expandItemsRecursively(idd) self.addComponent(tree) # vertically divide the right area left = VerticalLayout() left.setSpacing(True) self.addComponent(left) # table on top tbl = Table() tbl.setWidth('500px') tbl.setContainerDataSource(ExampleUtil.getISO3166Container()) tbl.setSortDisabled(True) tbl.setPageLength(7) left.addComponent(tbl) # Label on bottom text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML) text.setWidth('500px') # some limit is good for text left.addComponent(text)
def __init__(self): super(OptionGroupsExample, self).__init__() self.setSpacing(True) # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select a city', self._cities) # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect) self.addComponent( Label('<h3>Multi-selection</h3>', Label.CONTENT_XHTML)) # Create the multiselect option group # 'Shorthand' constructor - also supports data binding using Containers citySelect = OptionGroup('Please select cities', self._cities) citySelect.setMultiSelect(True) # FIXME: multi-select # user can not 'unselect' citySelect.setNullSelectionAllowed(False) # select this by default citySelect.select('Berlin') # send the change to the server at once citySelect.setImmediate(True) # react when the user selects something citySelect.addListener(self, IValueChangeListener) self.addComponent(citySelect)
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
def valueChange(self, event): tf = event.getProperty() tf.validate() if tf.getValue() is not None: self._component._usernames.add(str(tf.getValue())) self.addComponent(Label('Added ' + tf.getValue() + ' to usernames'))
def __init__(self): super(SubwindowCloseExample, self).__init__() self._closableWindow = CheckBox('Allow user to close the window', True) self._closableWindow.setImmediate(True) self._closableWindow.addListener(ClosableChangeListener(self), IValueChangeListener) # Create the window self._subwindow = Window('A subwindow w/ close-listener') self._subwindow.addListener(CloseListener(self), ICloseListener) # Configure the windws layout; by default a VerticalLayout layout = self._subwindow.getContent() layout.setMargin(True) layout.setSpacing(True) # Add some content; a label and a close-button message = Label('This is a subwindow with a close-listener.') self._subwindow.addComponent(message) # Add a button for opening the subwindow self._openCloseButton = Button("Open window", ClickListener(self)) self.setSpacing(True) self.addComponent(self._closableWindow) self.addComponent(self._openCloseButton)
def handleURI(self, context, relativeUri): f = FeatureSet.FEATURES.getFeature(relativeUri) if f is not None: self._window.addComponent(CodeLabel(f.getSource())) else: lbl = Label('Sorry, no source found for ' + relativeUri) self._window.addComponent(lbl) return None
def __init__(self): super(AccordionIconsExample, self).__init__() self.setSpacing(True) l1 = Label('There are no previously saved actions.') l2 = Label('There are no saved notes.') l3 = Label('There are currently no issues.') self._a = Accordion() self._a.setHeight('300px') self._a.setWidth('400px') self._a.addTab(l1, 'Saved actions', self._icon1) self._a.addTab(l2, 'Notes', self._icon2) self._a.addTab(l3, 'Issues', self._icon3) self._a.addListener(self, ISelectedTabChangeListener) self.addComponent(self._a)
def __init__(self): super(LayoutMarginExample, self).__init__(3, 3) self.setWidth('100%') self.setSpacing(True) self.addComponent( Label('Toggle layout margins with the checkboxes. ' 'The right side margin has a theme-specified value, while ' 'the other margins are the defaults.'), 0, 0, 2, 0) self.space() self._topMargin = CheckBox('Top', self) self._topMargin.setValue(True) self._topMargin.setImmediate(True) self.addComponent(self._topMargin) self.setComponentAlignment(self._topMargin, Alignment.TOP_CENTER) self.space() self._leftMargin = CheckBox('Left', self) self._leftMargin.setValue(True) self._leftMargin.setImmediate(True) self.addComponent(self._leftMargin) self.setComponentAlignment(self._leftMargin, Alignment.MIDDLE_LEFT) self._marginLayout = VerticalLayout() self._marginLayout.setStyleName('marginexample') self._marginLayout.setSizeUndefined() self._marginLayout.setMargin(True) self.addComponent(self._marginLayout) self._marginLayout.addComponent(Label('Margins all around?')) self._rightMargin = CheckBox('Right (100px)', self) self._rightMargin.setValue(True) self._rightMargin.setImmediate(True) self.addComponent(self._rightMargin) self.setComponentAlignment(self._rightMargin, Alignment.MIDDLE_LEFT) self.space() self._bottomMargin = CheckBox('Bottom', self) self._bottomMargin.setValue(True) self._bottomMargin.setImmediate(True) self.addComponent(self._bottomMargin) self.setComponentAlignment(self._bottomMargin, Alignment.TOP_CENTER)
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 __init__(self): super(Calc, self).__init__() # All variables are automatically stored in the session. self._current = 0.0 self._stored = 0.0 self._lastOperationRequested = 'C' # User interface components self._display = Label('0.0')
def init(self): """Init is invoked on application load (when a user accesses the application for the first time). """ # Main window is the primary browser window main = Window('Hello window') self.setMainWindow(main) # "Hello world" text is added to window as a Label component main.addComponent(Label('Hello World!'))
def __init__(self): super(FeatureView, self).__init__() self._right = None self._left = None self._controls = None self._title = Label("", Label.CONTENT_XHTML) self._showSrc = None self._exampleCache = dict() self._currentFeature = None self._srcWindow = None self.setWidth('100%') self.setMargin(True) self.setSpacing(True) self.setStyleName('sample-view') self._left = VerticalLayout() self._left.setWidth('100%') self._left.setSpacing(True) self._left.setMargin(False) self.addComponent(self._left) self.setExpandRatio(self._left, 1) rightLayout = VerticalLayout() self._right = Panel(rightLayout) rightLayout.setMargin(True, False, False, False) self._right.setStyleName(Reindeer.PANEL_LIGHT) self._right.addStyleName('feature-info') self._right.setWidth('319px') self.addComponent(self._right) self._controls = HorizontalLayout() self._controls.setWidth('100%') self._controls.setStyleName('feature-controls') self._title.setStyleName('title') self._controls.addComponent(self._title) self._controls.setExpandRatio(self._title, 1) resetExample = NativeButton('Reset', ResetListener(self)) resetExample.setStyleName(BaseTheme.BUTTON_LINK) resetExample.addStyleName('reset') resetExample.setDescription('Reset Sample') self._controls.addComponent(resetExample) self._showSrc = ActiveLink() self._showSrc.setDescription( 'Right / middle / ctrl / shift -click for browser window/tab') self._showSrc.addListener(ShowSrcListener(self), ILinkActivatedListener) self._showSrc.setCaption(self._MSG_SHOW_SRC) self._showSrc.addStyleName('showcode') self._showSrc.setTargetBorder(Link.TARGET_BORDER_NONE) self._controls.addComponent(self._showSrc)
def __init__(self): super(JSApiExample, self).__init__() self._toBeUpdatedFromThread = None self._startThread = None self._running = Label('') self.setSpacing(True) javascript = Label("<h3>Run Native JavaScript</h3>", Label.CONTENT_XHTML) self.addComponent(javascript) script = TextArea() script.setWidth('100%') script.setRows(3) script.setValue('alert(\"Hello Muntjac\");') self.addComponent(script) self.addComponent(Button('Run script', RunListener(self, script)))
def buildLabels(self): grid = GridLayout() grid.setSpacing(True) grid.setWidth('100%') grid.setColumns(6) for prop in CssProperty.values(): l = Label('-') l.setSizeUndefined() l.setCaption(str(prop)) self._props[prop] = l grid.addComponent(l) return grid
def init(self): mainWindow = Window("Color Picker Demo Application") label = Label("Hello Muntjac user") mainWindow.addComponent(label) self.setMainWindow(mainWindow) # Create the color picker cp = ColorPicker("Our ColorPicker", Color.RED) mainWindow.addComponent(cp) # Set the button caption cp.setButtonCaption("Our color")
def __init__(self): super(UploadBasicExample, self).__init__() self._result = Label() self._counter = LineBreakCounter() self._upload = Upload('Upload a file', self._counter) self.addComponent(self._upload) self.addComponent(self._result) self._upload.addListener(FinishedListener(self), IFinishedListener)
def handleAction(self, a, sender, target): if ACTION_MARK == a: self._c._markedRows.add(target) self._c._table.requestRepaint() elif ACTION_UNMARK == a: self._c._markedRows.remove(target) self._c._table.requestRepaint() elif ACTION_LOG == a: item = self._c._table.getItem(target) self._c.addComponent( Label('Saved: ' + target + ', ' + item.getItemProperty( ExampleUtil.iso3166_PROPERTY_NAME).getValue()))