class Site: def __init__(self): # Record the image url for easy access self.IMAGES_URL = "http://www.cse.nd.edu/~cmc/teaching/cse30332_sp15/images" # The title label is intially empty but will be filled with the top # recommended movie by the time the page is viewed self.title_l = Label("", StyleName="teststyle") self.up_b = Button("UP", post_vote) self.down_b = Button("DOWN", post_vote) self.rating_l = Label("", StyleName="teststyle") self.img = Image("") # Construct three vertical panels to make he display slightly columnar self.leftVertPanel = VerticalPanel() self.midlVertPanel = VerticalPanel() self.riteVertPanel = VerticalPanel() self.horizontalizer = HorizontalPanel() # Add the buttons to the correct vertical panels!!! self.midlVertPanel.add(self.title_l) self.midlVertPanel.add(self.img) self.midlVertPanel.add(self.rating_l) self.riteVertPanel.add(self.down_b) self.leftVertPanel.add(self.up_b) # Add all the panels to the horizontal panel self.horizontalizer.add(self.leftVertPanel) self.horizontalizer.add(self.midlVertPanel) self.horizontalizer.add(self.riteVertPanel) # Add the horizontal panel to the vertical one RootPanel().add(self.horizontalizer) # Get the first recommendation get_recommendation()
def __init__(self): SimplePanel.__init__(self) panel = HorizontalPanel(BorderWidth=1, HorizontalAlignment=HasAlignment.ALIGN_CENTER, VerticalAlignment=HasAlignment.ALIGN_MIDDLE, Width="100%", Height="200px") part1 = Label("Part 1") part2 = Label("Part 2") part3 = Label("Part 3") part4 = Label("Part 4") panel.add(part1) panel.add(part2) panel.add(part3) panel.add(part4) panel.setCellWidth(part1, "10%") panel.setCellWidth(part2, "70%") panel.setCellWidth(part3, "10%") panel.setCellWidth(part4, "10%") panel.setCellVerticalAlignment(part3, HasAlignment.ALIGN_BOTTOM) self.add(panel)
def onModuleLoad(self): self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.remote = JSONProxy("../api", ["hello"]) self.status = Label() self.text_box = TextBox() self.button_send = Button("Send", self) buttons = HorizontalPanel() buttons.add(self.button_send) buttons.setSpacing(8) info = """<h2>JSON-RPC Example</h2> <p>This example demonstrates the calling of server services with <a href="http://json-rpc.org/">JSON-RPC</a>. </p> <p>Enter your name below.</p>""" panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_box) #panel.add(method_panel) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def __init__(self, tabBar=None, *kwargs): TabPanel.__init__(self, tabBar, *kwargs) self.parent_buoy = None self.tabs = [{'hovertype' : ListBox(), 'name' : 'Cost'}, {'hovertype' : ListBox(), 'name' : 'Speed'}] self.cost = self.tabs[0]['hovertype'] items = ['cheap','next to cheap','average','above average','expensive','if you have to ask'] self.cost.setVisibleItemCount(len(items)) for item in items: self.cost.addItem(item) self.cost.addChangeListener(self) self.speed = self.tabs[1]['hovertype'] items = ['very slow','slow','average','above average','fast','quick','hyper','turbo','lightening','light'] self.speed.setVisibleItemCount(len(items)) for item in items: self.speed.addItem(item) self.speed.addChangeListener(self) for tab in self.tabs: h = HorizontalPanel() h.add(tab['hovertype']) self.add(h, tab['name'])
def __init__(self): DockPanel.__init__(self) self.setSize('100%', '100%') self.geocoder = Geocoder() # widgets topPanel = HorizontalPanel() self.add(topPanel, DockPanel.NORTH) self.address = TextBox() self.address.setText("Sydney, NSW") self.address.addChangeListener(self.codeAddress) topPanel.add(self.address) button = Button("Geocode") button.addClickListener(self.codeAddress) topPanel.add(button) # now, the map mapPanel = SimplePanel() mapPanel.setSize('600', '400') self.add(mapPanel, DockPanel.CENTER) options = MapOptions(zoom=8, center=LatLng(-34.397, 150.644), mapTypeId=MapTypeId.ROADMAP) self.map = Map(mapPanel.getElement(), options)
def _createButtonPanel(self): hp = HorizontalPanel() self.okBtn = Button('OK', self.onOk, StyleName=self.baseStyleName + '-button') self.cancelBtn = Button('Cancel', self.onCancel, StyleName=self.baseStyleName + '-button') hp.add(self.okBtn) hp.add(self.cancelBtn) return hp
def _add_statusbar ( self ): """ Adds a statusbar to the dialog. """ if self.ui.view.statusbar is not None: control = HorizontalPanel() # control.setSizeGripEnabled(self.ui.view.resizable) listeners = [] for item in self.ui.view.statusbar: # Create the status widget with initial text name = item.name item_control = Label() item_control.setText(self.ui.get_extended_value(name)) # Add the widget to the control with correct size # width = abs(item.width) # stretch = 0 # if width <= 1.0: # stretch = int(100 * width) # else: # item_control.setMinimumWidth(width) control.add(item_control) # Set up event listener for updating the status text col = name.find('.') obj = 'object' if col >= 0: obj = name[:col] name = name[col+1:] obj = self.ui.context[obj] set_text = self._set_status_text(item_control) obj.on_trait_change(set_text, name, dispatch='ui') listeners.append((obj, set_text, name)) self.master.add(control) self.ui._statusbar = listeners
def __init__(self, row, column=0): super(Game, self).__init__(StyleName='game') self.sinkEvents(Event.ONCONTEXTMENU) # to disable right click self.row = row self.column = column or row self.level = 1 self.toppers = [[], [], []] # storage for top scorers for 3 levels. self.remote = DataService() self.remote_handler = RemoteHandler(self) self.remote.get_scores(self.remote_handler) # contents of Game menubar = MineMenuBar(self) score_board = HorizontalPanel(StyleName='score-board') self.grid_panel = SimplePanel(StyleName='grid-panel') self.add(menubar) self.add(score_board) self.add(self.grid_panel) # contents of score_board self.counter = Label('000', StyleName='digit counter') self.face = Smiley(self) self.timer = Label('000', StyleName='digit timer') for one in (self.counter, self.face, self.timer): score_board.add(one) score_board.setCellWidth(self.face, '100%') self.create_grid() self.start()
def onCellClicked(self, sender, row, col): if self.drill == 0: self.drill += 1 self.vp.clear() self.grid.clear() self.vp.add(self.up) self.vp.add(self.grid) gridcols = self.grid.getColumnCount() album = self.albums[row + col + (row * (gridcols - 1))] url = "http://picasaweb.google.com/data/feed/base/user/" + self.userid + "/albumid/" + album[ "id"] + "?alt=json-in-script&kind=photo&hl=en_US&callback=restCb" self.doRESTQuery(url, self.timer) elif self.drill == 1: self.drill += 1 gridcols = self.grid.getColumnCount() self.pos = row + col + (row * (gridcols - 1)) photo = self.photos[self.pos] self.vp.clear() self.fullsize = HTML('<img src="' + photo["full"] + '"/>') hp = HorizontalPanel() hp.add(self.up) hp.add(self.prev) hp.add(self.next) hp.setSpacing(8) self.vp.add(hp) self.vp.add(self.fullsize)
def __init__(self, chart): self.chart = chart self.canvas = chart.canvas self.b2 = Button("Compositing", self) self.b3 = Button("Paths & shapes", self) self.b4 = Button("Arcs & circles", self) self.b1 = Button("Bezier curves", self) self.b6 = Button("Colors", self) self.b7 = Button("Translating", self) self.b8 = Button("Scaling", self) self.b5 = Button("Rotating", self) self.b10 = Button("Transparency", self) self.b11 = Button("Lines", self) self.b9 = Button("Animations", self) hp = HorizontalPanel() vp = VerticalPanel() vp.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) vp.add(Label("MENU")) vp.setSpacing(6) vp.add(self.b2) vp.add(self.b3) vp.add(self.b4) vp.add(self.b1) vp.add(self.b6) vp.add(self.b7) vp.add(self.b8) vp.add(self.b5) vp.add(self.b10) vp.add(self.b11) vp.add(self.b9) hp.add(vp) Composite.__init__(self, hp)
def __init__(self, app): DialogBox.__init__(self) self.app = app self.table=FlexTable() self.table.setText(0, 0, "Please enter username and password") self.table.getFlexCellFormatter().setColSpan(0, 0, 2) self.table.setText(1, 0, "Username") self.handle = TextBox() h = getCookie('handle') self.handle.setText(h) self.table.setWidget(1, 1, self.handle) self.table.setText(2, 0, "Password") self.pwd = PasswordTextBox() self.table.setWidget(2, 1, self.pwd) self.table.setHTML(3,0,"") self.table.getFlexCellFormatter().setColSpan(3, 0, 2) h = HorizontalPanel() self.table.setWidget(4,0, h) self.table.getFlexCellFormatter().setColSpan(4, 0, 2) h.add(Button("Ok", getattr(self, "onOk"))) h.add(Button("Cancel", getattr(self, "onClose"))) h.setSpacing(4) self.setHTML("<b>Login</b>") self.setWidget(self.table) left = (Window.getClientWidth() - 200) / 2 top = (Window.getClientHeight() - 100) / 2 self.setPopupPosition(left,top)
def onModuleLoad(self): try: setCookie(COOKIE_NAME, "setme", 100000) except: pass self.status = Label() self.text_area = TextArea() self.text_area.setText(r"Me eat cookie!") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.button_py_set = Button("Set Cookie", self) self.button_py_read = Button("Read Cookie ", self) buttons = HorizontalPanel() buttons.add(self.button_py_set) buttons.add(self.button_py_read) buttons.setSpacing(8) info = r'This demonstrates setting and reading information using cookies.' panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def onModuleLoad(self): try: setCookie(COOKIE_NAME, "setme", 100000) except: pass self.status = Label() self.text_area = TextArea() self.text_area.setText(r"Me eat cookie!") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.button_py_set = Button("Set Cookie", self) self.button_py_read = Button("Read Cookie ", self) buttons = HorizontalPanel() buttons.add(self.button_py_set) buttons.add(self.button_py_read) buttons.setSpacing(8) info = r"This demonstrates setting and reading information using cookies." panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
class HorizontalToolbar(SimplePanel): def __init__(self, onRequestMore=None, onCollapseAll=None, onExpandAll=None, onSort=None): super(HorizontalToolbar, self).__init__(StyleName=Styles.TOOLBAR_HORIZONTAL) self.content = HorizontalPanel() self.requestMoreButton = Button('More', onRequestMore, StyleName=Styles.TOOLBAR_BUTTON) self.content.add(self.requestMoreButton) self.itemsShowingLabel = Label(StyleName=Styles.TOOLBAR_TEXT) self.content.add(self.itemsShowingLabel) self.setNumberOfItemsShowingText(0, 0) self.collapseAllButton = Button('Collapse All', onCollapseAll, StyleName=Styles.TOOLBAR_BUTTON) self.content.add(self.collapseAllButton) self.expandAllButton = Button('Expand All', onExpandAll, StyleName=Styles.TOOLBAR_BUTTON) self.content.add(self.expandAllButton) if onSort: self.content.add(SortPanel(onSort)) self.setWidget(self.content) return def setNumberOfItemsShowingText(self, number, total): self.itemsShowingLabel.setText('Showing %s of %s total items.' % (number, total)) return
class ControlPanel(Composite): def __init__(self): Composite.__init__(self) self.buttons = HorizontalPanel() self.buttons.setSpacing("10px") self.refresh_button = ControlButton("images/refresh.png", "images/refresh_down.png", "reload", "reload" ) self.refresh_button.addMouseListener(ReloadButtonListner()) self.refresh_button.base = self self.start_button = ControlButton("images/start.png" , "images/pause.png" , " start" , " pause" ) self.start_button.addMouseListener(StartButtonListner()) self.start_button.base = self self.buttons.add(self.refresh_button) self.buttons.add(self.start_button) self.initWidget(self.buttons)
def __init__(self, owner): Composite.__init__(self) self.owner = owner self.bar = DockPanel() self.gotoFirst = Button("<<", self) self.gotoNext = Button(">", self) self.gotoPrev = Button("<", self) self.status = HTML() self.initWidget(self.bar) self.bar.setStyleName("navbar") self.status.setStyleName("status") buttons = HorizontalPanel() buttons.add(self.gotoFirst) buttons.add(self.gotoPrev) buttons.add(self.gotoNext) self.bar.add(buttons, DockPanel.EAST) self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT) self.bar.add(self.status, DockPanel.CENTER) self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT) self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE) self.bar.setCellWidth(self.status, "100%") self.gotoPrev.setEnabled(False) self.gotoFirst.setEnabled(False)
def __init__(self): Sink.__init__(self) colour_grid = ColourGridCanvas() rotated = RotatedCanvas() spheres = SpheresCanvas() pattern = PatternCanvas() spiro = SpiroCanvas() self.solar = SolarCanvas() row0 = HorizontalPanel() row0.setSpacing(8) row0.add(colour_grid) row0.add(rotated) row0.add(spheres) row0.add(pattern) row1 = HorizontalPanel() row1.setSpacing(8) row1.add(self.solar) row1.add(spiro) panel = VerticalPanel() panel.add(row0) panel.add(row1) self.setWidget(panel)
def onCellClicked(self, sender, row, col): if self.drill==0: self.drill += 1 self.vp.clear() self.grid.clear() self.vp.add(self.up) self.vp.add(self.grid) gridcols = self.grid.getColumnCount() album = self.albums[row+col+(row*(gridcols-1))] url = "http://picasaweb.google.com/data/feed/base/user/" + self.userid + "/albumid/" + album["id"] + "?alt=json-in-script&kind=photo&hl=en_US&callback=restCb" self.doRESTQuery(url, self.timer) elif self.drill==1: self.drill += 1 gridcols = self.grid.getColumnCount() self.pos =row+col+(row*(gridcols-1)) photo = self.photos[self.pos] self.vp.clear() self.fullsize = HTML('<img src="' + photo["full"] + '"/>') hp = HorizontalPanel() hp.add(self.up) hp.add(self.prev) hp.add(self.next) hp.setSpacing(8) self.vp.add(hp) self.vp.add(self.fullsize)
def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.initWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER)
def __init__(self, left = 50, top = 50): DialogBox.__init__(self, modal = False) self.setPopupPosition(left, top) self.setText("Preferences") ftable = FlexTable() ftableFormatter = ftable.getFlexCellFormatter() row = 0 try: self.fileLocation = getCookie("fileLocation") except: self.fileLocation = None row += 1 ftable.setWidget(row, 0, Label("Sheet loaded on startup", wordWrap=False)) self.fileLocationInput = TextBox() self.fileLocationInput.addChangeListener(self.checkValid) self.fileLocationInput.addKeyboardListener(self) self.fileLocationInput.setVisibleLength(30) self.fileLocationInput.setText(self.fileLocation) ftable.setWidget(row, 1, self.fileLocationInput) row += 1 hpanel = HorizontalPanel() self.saveBtn = Button("Save", self.onSave) self.saveBtn.setEnabled(False) hpanel.add(self.saveBtn) self.cancelBtn = Button("Cancel", self.onCancel) hpanel.add(self.cancelBtn) ftable.setWidget(row, 0, hpanel) ftableFormatter.setColSpan(row, 0, 2) self.setWidget(ftable)
def InitialiseScreen(self): hpanel = HorizontalPanel() self.add(hpanel) vpanelMenu = VerticalPanel() hpanel.add(vpanelMenu) self.addbutton = Button("Add Triangle") vpanelMenu.add(self.addbutton) self.addbutton.addClickListener(getattr(self, "addtriangle")) self.canvas = GWTCanvas(self.CANVAS_WIDTH, self.CANVAS_HEIGHT) vpanelCanvas = VerticalPanel() self.canvas.setWidth(self.CANVAS_WIDTH) self.canvas.setHeight(self.CANVAS_HEIGHT) hpanel.add(vpanelCanvas) vpanelCanvas.add(self.canvas) self.canvas.addMouseListener(self) self.selecteditem = None self.selectedhandle = None self.mouseisdown = False dc = DocumentCollection.documentcollection DocumentCollection.documentcollection.edgelistener = self.EdgeListener if len(dc.documentsbyclass[model.Drawing.__name__]) == 0: drawing = model.Drawing(None) dc.AddDocumentObject(drawing) EdgePoster([a.asDict() for a in drawing.history.GetAllEdges()]) else: for k,v in dc.documentsbyclass[model.Drawing.__name__].iteritems(): drawing = v self.drawingid = drawing.id self.Draw()
def __init__(self, topPanel): TickeryTab.__init__(self, topPanel) # Get query names (if they exist) from the request. We don't check # that we're the wanted tab: if 2 names are given, just use them. args = Window.getLocation().getSearchDict() name1 = args.get("name1") name2 = args.get("name2") if name1 and name2: self.autoActivate = True if name1: name1 = urllib.unquote_plus(name1) else: name1 = _defaultName1 if name2: name2 = urllib.unquote_plus(name2) else: name2 = _defaultName2 v1 = VerticalPanel() self.name1 = text.TextBoxFocusHighlight( Text=name1, MaxLength=self.textBoxLength, VisibleLength=self.textBoxLength, StyleName="simple-query-box" ) v1.add(self.name1) self.followResult1 = HorizontalPanel(Spacing=4) v1.add(self.followResult1) v2 = VerticalPanel() self.name2 = text.TextBoxFocusHighlight( Text=name2, MaxLength=self.textBoxLength, VisibleLength=self.textBoxLength, StyleName="simple-query-box" ) v2.add(self.name2) self.followResult2 = HorizontalPanel(Spacing=4) v2.add(self.followResult2) self.goButton = go.GoButton(self) v = VerticalPanel(Spacing=2, StyleName="help-panel") v.add(HTML("Enter two Twitter usernames", StyleName="simple-instructions")) v.add(v1) h = HorizontalPanel() h.add(v2) h.add(self.goButton) v.add(h) self.topGrid.setWidget(0, 1, v) formatter = self.topGrid.getCellFormatter() formatter.setHorizontalAlignment(0, 1, "left") self.checkResult = HorizontalPanel() self.add(self.checkResult) self.results = userlist.UserListPanel(self, topPanel) self.add(self.results) # allow keypress ENTER reaction self.name1.addKeyboardListener(self) self.name2.addKeyboardListener(self)
def __init__(self): SimplePanel.__init__(self) panel = HorizontalPanel() panel.setBorderWidth(1) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) part1 = Label("Part 1") part2 = Label("Part 2") part3 = Label("Part 3") part4 = Label("Part 4") panel.add(part1) panel.add(part2) panel.add(part3) panel.add(part4) panel.setCellWidth(part1, "10%") panel.setCellWidth(part2, "70%") panel.setCellWidth(part3, "10%") panel.setCellWidth(part4, "10%") panel.setCellVerticalAlignment(part3, HasAlignment.ALIGN_BOTTOM) panel.setWidth("100%") panel.setHeight("200px") self.add(panel)
def __init__(self, left=50, top=50): DialogBox.__init__(self, modal=False) self.setPopupPosition(left, top) self.setText("Preferences") ftable = FlexTable() ftableFormatter = ftable.getFlexCellFormatter() row = 0 try: self.fileLocation = getCookie("fileLocation") except: self.fileLocation = None row += 1 ftable.setWidget(row, 0, Label("Sheet loaded on startup", wordWrap=False)) self.fileLocationInput = TextBox() self.fileLocationInput.addChangeListener(self.checkValid) self.fileLocationInput.addKeyboardListener(self) self.fileLocationInput.setVisibleLength(30) self.fileLocationInput.setText(self.fileLocation) ftable.setWidget(row, 1, self.fileLocationInput) row += 1 hpanel = HorizontalPanel() self.saveBtn = Button("Save", self.onSave) self.saveBtn.setEnabled(False) hpanel.add(self.saveBtn) self.cancelBtn = Button("Cancel", self.onCancel) hpanel.add(self.cancelBtn) ftable.setWidget(row, 0, hpanel) ftableFormatter.setColSpan(row, 0, 2) self.setWidget(ftable)
def InitialiseScreen(self): hpanel = HorizontalPanel() self.add(hpanel) vpanelMenu = VerticalPanel() hpanel.add(vpanelMenu) self.addbutton = Button("Add Triangle") vpanelMenu.add(self.addbutton) self.addbutton.addClickListener(getattr(self, "addtriangle")) self.canvas = GWTCanvas(self.CANVAS_WIDTH, self.CANVAS_HEIGHT) vpanelCanvas = VerticalPanel() self.canvas.setWidth(self.CANVAS_WIDTH) self.canvas.setHeight(self.CANVAS_HEIGHT) hpanel.add(vpanelCanvas) vpanelCanvas.add(self.canvas) self.canvas.addMouseListener(self) self.selecteditem = None self.selectedhandle = None self.mouseisdown = False dc = DocumentCollection.documentcollection DocumentCollection.documentcollection.edgelistener = self.EdgeListener if len(dc.documentsbyclass[model.Drawing.__name__]) == 0: drawing = model.Drawing(None) dc.AddDocumentObject(drawing) EdgePoster([a.asDict() for a in drawing.history.GetAllEdges()]) else: for k, v in dc.documentsbyclass[ model.Drawing.__name__].iteritems(): drawing = v self.drawingid = drawing.id self.Draw()
def __init__(self, app): self.app = app DialogWindow.__init__( self, modal=False, minimize=True, maximize=True, close=True, ) self.closeButton = Button("Close", self) self.saveButton = Button("Save", self) self.setText("Sample DialogWindow with embedded image") self.msg = HTML("", True) global _editor_id _editor_id += 1 editor_id = "editor%d" % _editor_id #self.ht = HTML("", ID=editor_id) self.txt = TextArea(Text="", VisibleLines=30, CharacterWidth=80, ID=editor_id) dock = DockPanel() dock.setSpacing(4) hp = HorizontalPanel(Spacing="5") hp.add(self.saveButton) hp.add(self.closeButton) dock.add(hp, DockPanel.SOUTH) dock.add(self.msg, DockPanel.NORTH) dock.add(self.txt, DockPanel.CENTER) dock.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_RIGHT) dock.setCellWidth(self.txt, "100%") dock.setWidth("100%") self.setWidget(dock) self.editor_id = editor_id self.editor_created = False
def set_variables(self, no_of_vars, x=True): def name(n): return "var" + str(n) def print_scheme(n): return ["\\alpha", "\\beta", "\\gamma", "\\delta", "\\epsilon"][n] def button_click(n): def sopa(): if not self.is_clicked[n]: v = Operation(name(n), 0, self.textbox[n].getText(), name(n), Operation.VARIABLE) self.var[n] = v self.textbox[n].setEnabled(False) self.is_clicked[n] = True self.add_op(self.var[n]) return sopa for i in range(no_of_vars): h = HorizontalPanel() b = Button("variable", button_click(i)) h.add(b) self.is_clicked.append(False) self.var.append(None) t = TextBox() self.textbox.append(t) t.setText(print_scheme(i)) h.add(t) self.add_button(h)
def draw(self): Popup.draw(self) namePanel = HorizontalPanel() namePanel.add(Label(_('Name') + ':')) self.textBox = TextBox() self.textBox.setMaxLength(15) self.textBox.setStyleAttribute('marginLeft', 10) namePanel.add(self.textBox) self.center.add(namePanel) self.choose = ChooseTypeVarPanel() self.center.add(self.choose) self.textBox.addInputListener(self) self.message = Element(Element=DOM.createDiv()) self.message.add(Widget(Element=DOM.createDiv(), StyleName='not_image')) self.message.add( Label(text=_('Name already used'), wordWrap=False, StyleName='not_message')) self.onInput()
def __init__(self,parent): AbsolutePanel.__init__(self) ftable = FlexTable() ftable.setWidget(0, 0, Label("First Name", wordWrap=False)) ftableFormatter = ftable.getFlexCellFormatter() self.firstInput = TextBox() self.firstInput.addChangeListener(self.checkValid) self.firstInput.addKeyboardListener(self) ftable.setWidget(0, 1, self.firstInput) ftable.setWidget(1, 0, Label("Last Name", wordWrap=False)) self.lastInput = TextBox() self.lastInput.addChangeListener(self.checkValid) self.lastInput.addKeyboardListener(self) ftable.setWidget(1, 1, self.lastInput) ftable.setWidget(2, 0, Label("Email", wordWrap=False)) self.emailInput = TextBox() self.emailInput.addChangeListener(self.checkValid) self.emailInput.addKeyboardListener(self) ftable.setWidget(2, 1, self.emailInput) ftable.setWidget(3, 0, Label("Username", wordWrap=False)) self.usernameInput = TextBox() self.usernameInput.addChangeListener(self.checkValid) self.usernameInput.addKeyboardListener(self) ftable.setWidget(3, 1, self.usernameInput) ftable.setWidget(4, 0, Label("Password", wordWrap=False)) self.passwordInput = PasswordTextBox() self.passwordInput.addChangeListener(self.checkValid) self.passwordInput.addKeyboardListener(self) ftable.setWidget(4, 1, self.passwordInput) ftable.setWidget(5, 0, Label("Confirm", wordWrap=False)) self.confirmInput = PasswordTextBox() self.confirmInput.addChangeListener(self.checkValid) self.confirmInput.addKeyboardListener(self) ftable.setWidget(5, 1, self.confirmInput) ftable.setWidget(6, 0, Label("Department", wordWrap=False)) self.departmentCombo = ListBox() self.departmentCombo.addChangeListener(self.checkValid) self.departmentCombo.addKeyboardListener(self) ftable.setWidget(6, 1, self.departmentCombo) hpanel = HorizontalPanel() self.addBtn = Button("Add User") self.addBtn.setEnabled(False) hpanel.add(self.addBtn) self.cancelBtn = Button("Cancel") hpanel.add(self.cancelBtn) ftable.setWidget(7, 0, hpanel) ftableFormatter.setColSpan(7, 0, 2) self.add(ftable) return
def __init__(self,parent): AbsolutePanel.__init__(self) ftable = FlexTable() ftable.setWidget(0, 0, Label("First Name", wordWrap=False)) ftableFormatter = ftable.getFlexCellFormatter() self.firstInput = TextBox() self.firstInput.addChangeListener(self.checkValid) self.firstInput.addKeyboardListener(self) ftable.setWidget(0, 1, self.firstInput) ftable.setWidget(1, 0, Label("Last Name", wordWrap=False)) self.lastInput = TextBox() self.lastInput.addChangeListener(self.checkValid) self.lastInput.addKeyboardListener(self) ftable.setWidget(1, 1, self.lastInput) ftable.setWidget(2, 0, Label("Email", wordWrap=False)) self.emailInput = TextBox() self.emailInput.addChangeListener(self.checkValid) self.emailInput.addKeyboardListener(self) ftable.setWidget(2, 1, self.emailInput) ftable.setWidget(3, 0, Label("Username", wordWrap=False)) self.usernameInput = TextBox() self.usernameInput.addChangeListener(self.checkValid) self.usernameInput.addKeyboardListener(self) ftable.setWidget(3, 1, self.usernameInput) ftable.setWidget(4, 0, Label("Password", wordWrap=False)) self.passwordInput = PasswordTextBox() self.passwordInput.addChangeListener(self.checkValid) self.passwordInput.addKeyboardListener(self) ftable.setWidget(4, 1, self.passwordInput) ftable.setWidget(5, 0, Label("Confirm", wordWrap=False)) self.confirmInput = PasswordTextBox() self.confirmInput.addChangeListener(self.checkValid) self.confirmInput.addKeyboardListener(self) ftable.setWidget(5, 1, self.confirmInput) ftable.setWidget(6, 0, Label("Department", wordWrap=False)) self.departmentCombo = ListBox() self.departmentCombo.addChangeListener(self.checkValid) self.departmentCombo.addKeyboardListener(self) ftable.setWidget(6, 1, self.departmentCombo) hpanel = HorizontalPanel() self.addBtn = Button("Add User", self.onAdd) self.addBtn.setEnabled(False) hpanel.add(self.addBtn) self.cancelBtn = Button("Cancel", self.onCancel) hpanel.add(self.cancelBtn) ftable.setWidget(7, 0, hpanel) ftableFormatter.setColSpan(7, 0, 2) self.add(ftable) return
def onModuleLoad(self): self.remote_py = MyBlogService() # Create a FormPanel and point it at a service. self.form = FormPanel() # Create a panel to hold all of the form widgets. vp=VerticalPanel(BorderWidth=0,HorizontalAlignment=HasAlignment.ALIGN_CENTER,VerticalAlignment=HasAlignment.ALIGN_MIDDLE,Width="100%",Height="150px") self.form.setWidget(vp) header=HTML("<h2>LOGIN TO YOUR ACCOUNT</h2>") part1=header # Create a TextBox, giving it a name so that it will be submitted. self.userName = TextBox() self.userName.setName("userNameFormElement") self.userName.setPlaceholder("User Name") part2=self.userName self.password = PasswordTextBox() self.password.setName("passwordFormElement") self.password.setPlaceholder("Password") part3=self.password self.errorInfoLabel = Label() self.errorInfoLabel.setStyleName('error-info') part4=self.errorInfoLabel part4.setStyleName("errorlabel") # Add a 'submit' button. hpanel = HorizontalPanel(BorderWidth=0,HorizontalAlignment=HasAlignment.ALIGN_CENTER,VerticalAlignment=HasAlignment.ALIGN_MIDDLE,Width="100%",Height="50px") partb=Button("Login", self) partb.setStyleName('btn') image=Label("Don''t have account? Sign up") anchor = Anchor(Widget=image, Href='/signup.html') parta=anchor hpanel.add(partb) hpanel.add(parta) part5=hpanel part5.setStyleName("hpanel") vp.add(part1) vp.add(part2) vp.add(part3) vp.add(part4) vp.add(part5) vp.setStyleName("signup") # Add an event handler to the form. self.form.addFormHandler(self) RootPanel().add(self.form)
class pjBallot: def __init__(self): self.mainPanel = VerticalPanel() self.contest = HorizontalPanel() self.contest.setStyleName('words') self.selection = HorizontalPanel() self.selection.setStyleName('words') self.button = Button('test', self.test) self.x = 1 def test(self): self.button.setText("No, really click me!") # Window.alert("Hello, AJAAAX!") self.contest.add(HTML('yay')) def nextContest(self): self.x += 1 self.contest.clear() self.contest.add(HTML('<b /> Contest: %d' % self.x)) def nextSelection(self): self.x += 1 self.selection.clear() self.selection.add(HTML('<b /> Selection: %d' % self.x)) def onKeyDown(self, sender, keycode, modifiers): pass def onKeyUp(self, sender, keycode, modifiers): pass def onKeyPress(self, sender, keycode, modifiers): DOM.eventPreventDefault(DOM.eventGetCurrentEvent()) #not needed if keycode == KeyboardListener.KEY_UP: self.nextContest() if keycode == KeyboardListener.KEY_DOWN: self.nextContest() if keycode == KeyboardListener.KEY_LEFT: self.nextSelection() if keycode == KeyboardListener.KEY_RIGHT: self.nextSelection() def onModuleLoad(self): h = HTML("<b />Contest: ") self.contest.add(h) l = HTML("<b />Selection: ") self.selection.add(l) # self.mainPanel.add(self.button) self.mainPanel.add(self.contest) self.mainPanel.add(self.selection) panel = FocusPanel(Widget=self.mainPanel) gp = RootPanelListener(panel) manageRootPanel(gp) RootPanel().add(panel) panel.setFocus(True)
def __init__( self ) : self.mainPanel = VerticalPanel() self.echo = HTML('Initiating') self.launchButton=Button("Update") controlPanel=HorizontalPanel() controlPanel.add(self.launchButton) controlPanel.add(self.echo) self.mainPanel.add(controlPanel) self.resultGrids={} self.resultLabels={}
def __init__(self): DockPanel.__init__(self) self.setSize('100%', '100%') # widgets topPanel = HorizontalPanel() self.add(topPanel, DockPanel.NORTH) places = { "chicago, il": "Chicago", "st louis, mo": "St Louis", "joplin, mo": "Joplin, MO", "oklahoma city, ok": "Oklahoma City", "amarillo, tx": "Amarillo", "gallup, nm": "Gallup, NM", "flagstaff, az": "Flagstaff, AZ", "winona, az": "Winona", "kingman, az": "Kingman", "barstow, ca": "Barstow", "san bernardino, ca": "San Bernardino", "los angeles, ca": "Los Angeles"} self.start = ListBox() self.end = ListBox() for value in places: self.start.addItem(places[value], value) self.end.addItem(places[value], value) self.start.addChangeListener(self.calcRoute) self.end.addChangeListener(self.calcRoute) topPanel.add(self.start) topPanel.add(self.end) # now, the map mapPanel = SimplePanel() mapPanel.setSize('800', '500') self.add(mapPanel, DockPanel.CENTER) chigado = LatLng(41.850033, -87.6500523) options = MapOptions(zoom=7, center=chigado, mapTypeId=MapTypeId.ROADMAP) self.map = Map(mapPanel.getElement(), options) # initialize the renderer self.directionsDisplay = DirectionsRenderer() self.directionsDisplay.setMap(self.map) self.directionsService = DirectionsService()
def __init__(self): DockPanel.__init__(self) self.setSize('100%', '100%') # widgets topPanel = HorizontalPanel() self.add(topPanel, DockPanel.NORTH) places = { "chicago, il": "Chicago", "st louis, mo": "St Louis", "joplin, mo": "Joplin, MO", "oklahoma city, ok": "Oklahoma City", "amarillo, tx": "Amarillo", "gallup, nm": "Gallup, NM", "flagstaff, az": "Flagstaff, AZ", "winona, az": "Winona", "kingman, az": "Kingman", "barstow, ca": "Barstow", "san bernardino, ca": "San Bernardino", "los angeles, ca": "Los Angeles" } self.start = ListBox() self.end = ListBox() for value in places: self.start.addItem(places[value], value) self.end.addItem(places[value], value) self.start.addChangeListener(self.calcRoute) self.end.addChangeListener(self.calcRoute) topPanel.add(self.start) topPanel.add(self.end) # now, the map mapPanel = SimplePanel() mapPanel.setSize('800', '500') self.add(mapPanel, DockPanel.CENTER) chigado = LatLng(41.850033, -87.6500523) options = MapOptions(zoom=7, center=chigado, mapTypeId=MapTypeId.ROADMAP) self.map = Map(mapPanel.getElement(), options) # initialize the renderer self.directionsDisplay = DirectionsRenderer() self.directionsDisplay.setMap(self.map) self.directionsService = DirectionsService()
def add_formula(self, f): h = HorizontalPanel() im = Image() im.setUrl(latex_to_url(f.to_latex())) c = CheckBox() h.add(c) h.add(im) self.pok.add(h) self.checkbox_list.append(c) self.hpanel_list.append(h) self.image_list.append(im)
def __init__(self, text, imageUrl): DecoratorPanel.__init__(self, DecoratorPanel.DECORATE_ALL) p = HorizontalPanel() p.setSpacing(3) self.img = Image(imageUrl) self.txt = HTML(text) p.add(self.img) p.add(self.txt) self.add(p)
class Editor: def __init__(self, db_url, parent_panel): self.db_url = db_url self.doc_id = None self.parent_panel = parent_panel def loadDocument(self, doc_id): # Load document into editor HTTPRequest().asyncGet(None, None, url=self.db_url+doc_id, handler=DocLoader(self)) def reloadDocument(self): if self.doc_id is None: Window.Alert('Trying to reload blank doc') else: self.loadDocument(self.doc_id) def updateDoc(self, json): doc_obj = JSONParser().decode(json) self.doc_id = doc_obj['_id'] self.id_label.setText('ID : %s'%doc_obj['_id']) self.rev_label.setText('REV: %s'%doc_obj['_rev']) self.save_button.setEnabled(True) self.doc_area.setText(json) self.doc_area.setEnabled(True) self.doc_area.setFocus(True) def saveDocument(self): self.doc_area.setEnabled(False) self.save_button.setEnabled(False) HTTPRequest().asyncPut(None, None, url=self.db_url+self.doc_id, postData=self.doc_area.getText(), handler=DocSaver(self)) def onModuleLoad(self): # Editor self.editor_panel = VerticalPanel() self.id_label = Label('ID: ') self.editor_panel.add(self.id_label) self.rev_label = Label('REV: ') self.editor_panel.add(self.rev_label) self.doc_area = TextArea() self.doc_area.setCharacterWidth(80) self.doc_area.setVisibleLines(24) self.doc_area.setEnabled(False) self.editor_panel.add(self.doc_area) self.parent_panel.add(self.editor_panel) # Buttons self.button_panel = HorizontalPanel() self.save_button = Button("Save", self.saveDocument) self.save_button.setEnabled(False) self.button_panel.add(self.save_button) self.parent_panel.add(self.button_panel)
def __init__(self): colours = ['Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White'] Sink.__init__(self) self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def addBlock(self, block, classHelp='help_default', beforeIndex=None): panel = HorizontalPanel() panel.add(block) info = Label('i', StyleName='info_btn') info.block = block info.classHelp = classHelp info.addClickListener(self.showInfo) panel.add(info) if beforeIndex is not None: self.list.insert(panel, self.list.getBody(), 0)#deprecated else: self.list.add(panel) self.list.setStyleName(self.list.getWidgetTd(panel), 'block_info') self.blocks.append(block)
def __init__(self, format='%d-%m-%Y'): DateSelectedHandler.__init__(self) if self.img_base is None: self.img_base = pygwt.getImageBaseURL(True) if self.icon_img is None: self.icon_img = self.img_base + 'icon_calendar.gif' self.format = format self.tbox = TextBox() self.tbox.setVisibleLength(10) # assume valid sep is - / . or nothing if format.find('-') >= 0: self.sep = '-' elif format.find('/') >= 0: self.sep = '/' elif format.find('.') >= 0: self.sep = '.' else: self.sep = '' # self.sep = format[2] # is this too presumptious? self.calendar = Calendar() self.img = Image(self.icon_img) self.img.addStyleName(self.icon_style) self.calendarLink = HyperlinkImage(self.img) self.todayLink = Hyperlink(self.today_text) self.todayLink.addStyleName(self.today_style) # # lay it out # hp = HorizontalPanel() hp.setSpacing(2) vp = VerticalPanel() hp.add(self.tbox) vp.add(self.calendarLink) vp.add(self.todayLink) #vp.add(self.calendar) hp.add(vp) Composite.__init__(self) self.initWidget(hp) # # done with layout, so now set up some listeners # self.tbox.addFocusListener(self) # hook to onLostFocus self.calendar.addSelectedDateListener(getattr(self, "onDateSelected")) self.todayLink.addClickListener(getattr(self, "onTodayClicked")) self.calendarLink.addClickListener(getattr(self, "onShowCalendar")) self.tbox.addChangeListener(getattr(self, "onFieldChanged")) self.tbox.addInputListener(getattr(self, "onFieldChanged")) self._last_date = None
def setup_after_data(self): self.TheoremPanel = TheoremPanel(self.add_formula) h = HorizontalPanel(BorderWidth=1, HorizontalAlignment=HasAlignment.ALIGN_LEFT, VerticalAlignment=HasAlignment.ALIGN_TOP, Width="100%", Height="200px") h.setStyleAttribute("background", "yellow") h.add(self.FormulaListPanel) h.add(self.TheoremPanel) h.setCellWidth(self.FormulaListPanel, "50%") h.setCellWidth(self.TheoremPanel, "50%") RootPanel().add(h)
def __init__(self, theorem, **kwargs): DialogWindow.__init__(self, modal=True, close=True) self.theorem = theorem v = VerticalPanel() v.setWidth(300) # v.setHeight(500) self.setText("save") self.setPopupPosition(100, 100) self.setStyleAttribute("background-color", "#ffffff") self.setStyleAttribute("color", "red") self.setStyleAttribute("border-width", "5px") self.setStyleAttribute("border-style", "solid") self.im = Image() self.im.setUrl(latex_to_url(self.theorem.formula.to_latex())) v.add(self.im) h = HorizontalPanel() self.radio = RadioButton("group1", "Existing folder:") h.add(self.radio) self.list = ListBox() self.list.setVisibleItemCount(1) for f in Theorem.get_all_folders(): self.list.addItem(f) h.add(self.list) v.add(h) h = HorizontalPanel() h.add(RadioButton("group1", "New folder:")) self.radio.setChecked(True) self.textbox = TextBox() h.add(self.textbox) v.add(h) v.add(Button("Done", self.done_click)) self.add(v)
def _create_add_dialog(self): contents = VerticalPanel(StyleName="Contents", Spacing=4) wtype = ListBox(Width="14em") wtype.addChangeListener(self) for wclass in self.WEIGHT_TYPES: wtype.addItem(wclass.NAME, value=wclass) panel = HorizontalPanel(Spacing=8) panel.add(HTML("Weight type: ", **captionstyle)) panel.add(wtype) contents.add(panel) contents.add(Button("OK", getattr(self, '_close_add_dialog'))) dialog = DialogBox(glass=True) dialog.setHTML('<b>Add a new type of weights</b>') dialog.setWidget(contents) return dialog, wtype
def __init__(self): SimplePanel.__init__(self) History.addHistoryListener(self) vPanel = VerticalPanel() self.stateDisplay = Label() vPanel.add(self.stateDisplay) hPanel = HorizontalPanel(Spacing=5) hPanel.add(Hyperlink("State 1", False, "state number 1")) hPanel.add(Hyperlink("State 2", False, "state number 2")) vPanel.add(hPanel) self.add(vPanel)
def __init__(self): colours = [ 'Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White' ] Sink.__init__(self) self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def onModuleLoad(self): '''Create initial view of the panel. ''' # Container that keeps everything self.panel = VerticalPanel() self.panel.setSpacing(10) spacer1 = Label() spacer1.setHeight('10px') spacer2 = Label() spacer2.setHeight('10px') self.tbl_panel = VerticalPanel(Width='755px') # First is a row count self.grid = Reports_Grid() self.grid.create_grid(1, 4, ['Milestone Name', 'Milestone State', 'Start Date', 'End Date']) self.tbl_panel.add(self.grid) self.editor = Milestones_Editor() self.submit_btn = Button('Submit', getattr(self, 'send_data')) self.submit_btn.setStyleName('btn btn-primary btn-lg') hpanel = HorizontalPanel() hpanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) hpanel.add(self.submit_btn) self.msg_lbl = HTMLPanel('', Width='755px') self.root = RootPanel('projects_') self.root.add(spacer1) self.root.add(self.editor.hpanel) self.root.add(spacer2) self.root.add(self.tbl_panel) spacer3 = Label() spacer3.setHeight('20px') self.root.add(self.msg_lbl) self.root.add(spacer3) self.root.add(hpanel) self.root.add(Label(Height='20px')) # Add listeners and initialize components self._add_listeners() self._iniate_states()
def onModuleLoad(self): self.status = Label() self.button = Button( "Display list of all published memories and fields", self) self.buttonupdate = Button("Update data from AMS publisher", self) buttons = HorizontalPanel() buttons.add(self.button) buttons.add(self.buttonupdate) buttons.setSpacing(8) info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>""" self.panel = VerticalPanel() self.panel.add(HTML(info)) self.panel.add(buttons) self.panel.add(self.status) RootPanel().add(self.panel) self.commobj = AMS_Comm() self.tree = None if AMSJavascript.sent > AMSJavascript.recv: self.status.setText('Press button again: AMSJavascript.sent ' + str(AMSJavascript.sent) + ' AMSJavascript.recv ' + str(AMSJavascript.recv)) return if self.commobj.commname == 'No AMS publisher running': self.status.setText(self.commobj.commname) else: self.status.setText('Memories for AMS Comm: ' + str(AMSJavascript.sent) + str(AMSJavascript.recv) + self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() for j in fields: field = memory.get_field_info(j) subtree.addItem(j + ' = ' + str(field[4])) self.tree.addItem(subtree) self.panel.add(self.tree)
def onClick(self, sender): global statusbar, boxes statusbar.setText('Button pressed') pass if sender == self.buttonupdate: self.commobj = AMS.AMS_Comm() statusbar.setText( 'Updating data: Press Display list button to refesh') if sender == self.button: if AMS.sent > AMS.recv: statusbar.setText('Press button again: sent ' + str(AMS.sent) + ' recv ' + str(AMS.recv)) if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or self.commobj.comm == -1: if self.tree: self.panel.remove(self.tree) else: statusbar.setText('Memories for AMS Comm: ' + self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: if i == "Stack": continue subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() if not isinstance(fields, list): fields = [fields] block = false for j in fields: field = memory.get_field_info(j) if str(field[1]) == 'AMS_READ': if j == "Publish Block": if field[4] == "true": block = true else: subtree.addItem(j + ' = ' + str(field[4])) else: if j == "Block" and not block: continue PN = HorizontalPanel() PN.add(Label(Text=j + ' =')) tb = TextBox(Text=str(field[4])) boxes[tb] = [i, j, memory] tb.addChangeListener(self.textboxlistener) PN.add(tb) subtree.addItem(PN) self.tree.addItem(subtree) self.panel.add(self.tree)