class TestDict: def onModuleLoad(self): self.r = WrapperDict() self.kbox = TextBox() self.addbutton = Button("Click to look up key value (hello or goodbye)") self.addbutton.addClickListener(self) self.kbox.setText("hello") # default to make life easier RootPanel().add(HTML("Key:")) RootPanel().add(self.kbox) RootPanel().add(self.addbutton) def display_value(self): key = self.kbox.getText() RootPanel().add(HTML("Value using python:" )) RootPanel().add(HTML(self.r.python_get_value(key))) RootPanel().add(HTML("Value using javascript:" )) RootPanel().add(HTML(self.r.javascript_get_value(key))) def onClick(self, sender): self.display_value()
def make_panel(self): message = Label( 'The configuration has been changed.\n' 'You must apply the changes in order for them to take effect.') DOM.setStyleAttribute(message.getElement(), "whiteSpace", 'pre') msgbox = Grid(1, 2, StyleName='changes') msgbox.setWidget(0, 0, Image('icons/exclam.png')) msgbox.setWidget(0, 1, message) msgbox.getCellFormatter().setStyleName(0, 0, 'changes-image') msgbox.getCellFormatter().setStyleName(0, 1, 'changes-text') button = Button('apply changes') button.addClickListener(self.apply_clicked) self.changes = VerticalPanel() self.changes.setHorizontalAlignment('right') self.changes.setVisible(False) self.changes.add(msgbox) self.changes.add(button) panel = VerticalPanel() panel.setSpacing(10) panel.add(self.table) panel.add(self.status) panel.add(self.changes) return panel
class PopupPanelDemo(SimplePanel): def __init__(self): SimplePanel.__init__(self) vPanel = VerticalPanel() vPanel.setSpacing(4) self._btn = Button("Click Me", getattr(self, "showPopup")) vPanel.add(HTML("Click on the button below to display the popup.")) vPanel.add(self._btn) self.add(vPanel) def showPopup(self, event): contents = HTML("Hello, World!") contents.addClickListener(getattr(self, "onClick")) self._popup = PopupPanel(autoHide=True) self._popup.add(contents) self._popup.setStyleName("showcase-popup") left = self._btn.getAbsoluteLeft() + 10 top = self._btn.getAbsoluteTop() + 10 self._popup.setPopupPosition(left, top) self._popup.show() def onClick(self, sender=None): self._popup.hide()
class PopupPanelDemo(SimplePanel): def __init__(self): SimplePanel.__init__(self) vPanel = VerticalPanel(Spacing=4) self._btn = Button("Click Me", getattr(self, "showPopup")) vPanel.add(HTML("Click on the button below to display the popup.")) vPanel.add(self._btn) self.add(vPanel) def showPopup(self, event): contents = HTML("Hello, World!") contents.addClickListener(getattr(self, "onClick")) self._popup = PopupPanel(autoHide=True) self._popup.add(contents) self._popup.setStyleName("showcase-popup") left = self._btn.getAbsoluteLeft() + 10 top = self._btn.getAbsoluteTop() + 10 self._popup.setPopupPosition(left, top) self._popup.show() def onClick(self, sender=None): self._popup.hide()
def htmlElements(self, addList = None): if not self._htmlElements: h = HTML("<h1>Run data</h1>", StyleName='font-s07em') p = HTML('<p>Enter <em>weighed</em> data to get information, through the neural network...</p>') b=Button('addField', self, StyleName='link') b.setID(ADD_FIELD_BUTTON) f = FormPanel() _f = self.fieldPanel([self.getWidgetObj(),0,0]) f.add(_f) """ t = TextArea(StyleName='page-textarea') s=Button('submit', self, StyleName='link') s.setID('submitButton') """ self._htmlElements = [['h', h], ['p', p], ['b', b], ['f', f]] for i in range(len(self._htmlElements)): RootPanel().add(self._htmlElements[i][1]) if addList: self._htmlElements+=addList for i in range(len(self._htmlElements)): RootPanel().add(addList[i][1]) return self._htmlElements
class YChanger(HorizontalPanel): def __init__(self, chart): self.chart = chart HorizontalPanel.__init__(self) # y-changing, x,y coordinate displaying, widget self.incrementY = Button("Increment Y") self.coordinates = HTML("") # x,y of selected point self.decrementY = Button("Decrement Y") self.incrementY.addClickListener(self) self.decrementY.addClickListener(self) self.add(self.incrementY) self.add(self.coordinates) self.add(self.decrementY) def onClick(self, sender): if sender == self.incrementY: self.chart.getTouchedPoint().setY( self.chart.getTouchedPoint().getY() + 1) else: self.chart.getTouchedPoint().setY( self.chart.getTouchedPoint().getY() - 1) self.chart.update() # The 2 HoverUpdateable interface methods: def hoverCleanup(self, hoveredAwayFrom): pass def hoverUpdate(self, hoveredOver): # update (x,y) display when they click point self.coordinates.setHTML(hoveredOver.getHovertext())
def __init__(self): AbsolutePanel.__init__(self) StyleSheetCssText(margins) # initialize css... header = """<div><H2 align="center">Welcome to Unbeatable Tic-Tac-Toe!</H2><br>My <a href="https://github.com/chetweger/min-max-games/blob/master/ttt/ttt.py">implementation</a> uses the min-max search algorithm with alpha beta pruning and a transposition table!</div>""" header = HTML(header, StyleName='margins_both') self.add(header) self.ai_first = Button("AI first.", self, StyleName='margins_left') self.add(self.ai_first) self.new_game = Button("New game", self, StyleName='margins_left') self.add(self.new_game) self.g=Grid(StyleName='margins_left') self.g.resize(3, 3) self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.init() self.add(self.g) self.state = State() self.game_resolution=Label("", StyleName='margins_left') self.add(self.game_resolution)
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 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 TestDict: def onModuleLoad(self): self.r = WrapperDict() self.kbox = TextBox() self.addbutton = Button( "Click to look up key value (hello or goodbye)") self.addbutton.addClickListener(self) self.kbox.setText("hello") # default to make life easier RootPanel().add(HTML("Key:")) RootPanel().add(self.kbox) RootPanel().add(self.addbutton) def display_value(self): key = self.kbox.getText() RootPanel().add(HTML("Value using python:")) RootPanel().add(HTML(self.r.python_get_value(key))) RootPanel().add(HTML("Value using javascript:")) RootPanel().add(HTML(self.r.javascript_get_value(key))) def onClick(self, sender): self.display_value()
def __init__(self): # We need to use old form of inheritance because of pyjamas SimplePanel.__init__(self) self.hpanel = HorizontalPanel(Width='475px') self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) self.name = TextBox() self.name.setStyleName('form-control') self.status = ListBox() self.status.addItem('Active') self.status.addItem('Inactive') self.status.setVisibleItemCount(0) self.status.setStyleName('form-control input-lg') self.status.setSize('100px', '34px') lbl = Label('', Width='10px') self.add_btn = Button('Add') self.add_btn.setStyleName('btn btn-primary') self.del_btn = Button('Delete') self.del_btn.setStyleName('btn btn-danger') self.hpanel.add(self.name) self.hpanel.add(lbl) self.hpanel.add(self.status) self.hpanel.add(self.add_btn) self.hpanel.add(self.del_btn)
class GettextExample(object): def __init__(self): self.b = Button(_("Click me"), self.greet, StyleName='teststyle') self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle') self.l = Label(_("Hello World (label)"), StyleName='teststyle') self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(), StyleName='teststyle') RootPanel().add(self.b) RootPanel().add(self.h) RootPanel().add(self.l) RootPanel().add(self.base) def change_texts(self, text): self.b.setText(_("Click me")) self.h.setHTML(_("<b>Hello World</b> (html)")) self.l.setText(_("Hello World (label)")) text = [_("Hello from %s") % pygwt.getModuleBaseURL()] for i in range(4): text.append(ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i)) text = '<br />'.join(text) self.base.setHTML(text) def greet(self, fred): fred.setText(_("No, really click me!")) Window.alert(_("Hello, there!")) i18n.load(lang=lang[0], onCompletion=self.change_texts) lang.append(lang.pop(0))
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): Algorithm.__init__(self) self.MLAlgorithmService = MLAlgorithmService(self) self.image=Image(self.baseURL() + "services/kMeansPictures/lenna.png",Width="320px", Height="360px") self.resultImage=Image("",Width="320px", Height="360px") self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif") self.calculateButton = Button("RUN", self.onButtonClick) self.log = Button("SHOW LOG", self.openLogFile) self.log.setEnabled(False) self.image.addLoadListener(self) topPanel = DockPanel() topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) topPanel.add(self.calculateButton, DockPanel.WEST) topPanel.add(self.loadingImage, DockPanel.CENTER) topPanel.add(self.log, DockPanel.EAST) panel = DockPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) #panel.add(HTML("<h2>Image compression</h2>", True)) panel.add(topPanel, DockPanel.NORTH) panel.add(self.image, DockPanel.WEST) panel.add(self.resultImage, DockPanel.EAST) panel.setWidth("100%") self.initWidget(panel) self.image.setStyleName("ks-images-Image") self.calculateButton.setStyleName("ks-images-Button") self.loadImage("picturem.png")
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_constants_adj_grid(self): '''Initializes the grid that allows the TD_CONSTS to be adjusted. ''' self.decr_buttons = {} self.adj_learning_labels = {} self.adj_static_labels = {} self.incr_buttons = {} td_keys = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6'] learning_ai_header = Label("Constant for the learning AI.") self.adj_grid.setWidget(0, 0, learning_ai_header) static_ai_header = Label("Constants for the static AI.") self.adj_grid.setWidget(0, 2, static_ai_header) for i, key in enumerate(td_keys): j = i + 1 # off by one because of header... self.adj_learning_labels[key] = Label( "Constant %d: %f" % (key[1], self.TD_CONSTS[key])) self.adj_grid.setWidget(j, 0, self.adj_learning_labels[key]) self.decr_buttons[key] = Button('<', self) self.adj_grid.setWidget(j, 1, self.decr_buttons[key]) self.adj_static_labels[key] = Label("Constant %d: %f" % (key[1], self.CONSTS[key])) self.adj_grid.setWidget(j, 2, self.adj_static_labels[key]) self.incr_buttons[key] = Button('>', self) self.adj_grid.setWidget(j, 3, self.incr_buttons[key])
def __init__(self, key, title, content): AbsolutePanel.__init__(self) self.edit_header = Label("Edit a Post", StyleName="header_label") self.edit_title_label = Label("Title:") self.edit_title = TextBox() self.edit_title.setMaxLength(255) self.edit_content = TextArea() self.edit_content.setVisibleLines(2) self.edit_button = Button("Save") self.edit_cancel_button = Button("Cancel") self.edit_hidden_key = Hidden() self.error_message_label = Label("", StyleName="error_message_label") edit_contents = VerticalPanel(StyleName="Contents", Spacing=4) edit_contents.add(self.edit_header) edit_contents.add(self.edit_title_label) edit_contents.add(self.edit_title) edit_contents.add(self.edit_content) edit_contents.add(self.edit_button) edit_contents.add(self.edit_cancel_button) edit_contents.add(self.error_message_label) edit_contents.add(self.edit_hidden_key) self.edit_dialog = DialogBox(glass=True) self.edit_dialog.setHTML('<b>Blog Post Form</b>') self.edit_dialog.setWidget(edit_contents) left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft() top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop() self.edit_dialog.setPopupPosition(left, top) self.edit_dialog.hide()
class TestRect: def onModuleLoad(self): self.r = Rect(0.0, 0.0) self.xbox = TextBox() self.ybox = TextBox() self.addbutton = Button("Click to add x and y to Rectangle") self.addbutton.addClickListener(self) self.xbox.setText("2") self.ybox.setText("5") RootPanel().add(HTML("X Value:")) RootPanel().add(self.xbox) RootPanel().add(HTML("Y Value:")) RootPanel().add(self.ybox) RootPanel().add(self.addbutton) RootPanel().add(HTML("Current value: %d %d" % ( self.r.get_x(), self.r.get_y()))) def onClick(self, sender): x = int(self.xbox.getText()) y = int(self.ybox.getText()) r = Rect(x, y) self.r.add(r) RootPanel().add(HTML("New value: %d" % ( self.r.get_x()))) RootPanel().add(HTML("New value: %d" % ( self.r.get_y()))) RootPanel().add(HTML("New value: %d %d" % ( self.r.get_x(), self.r.get_y()))) RootPanel().add(HTML("New Area: %d" % self.r.area()))
def __init__(self, parent): AbsolutePanel.__init__(self) self.roleList = ListBox() self.roleList.setWidth('300px') self.roleList.setVisibleItemCount(6) self.roleList.addChangeListener(self.onListChange) #self.roleList.addKeyboardListener(self) self.roleCombo = ListBox() self.roleCombo.addKeyboardListener(self) self.roleCombo.addChangeListener(self.onComboChange) self.addBtn = Button("Add") self.addBtn.setEnabled(False) self.removeBtn = Button("Remove") self.removeBtn.setEnabled(False) vpanel = VerticalPanel() vpanel.add(self.roleList) hpanel = HorizontalPanel() hpanel.add(self.roleCombo) hpanel.add(self.addBtn) hpanel.add(self.removeBtn) vpanel.add(hpanel) self.add(vpanel) self.clearForm() return
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 __init__(self): SimplePanel.__init__(self) self._table = FlexTable(BorderWidth=1, Width="100%") cellFormatter = self._table.getFlexCellFormatter() rowFormatter = self._table.getRowFormatter() self._table.setHTML(0, 0, "<b>Mammals</b>") self._table.setText(1, 0, "Cow") self._table.setText(1, 1, "Rat") self._table.setText(1, 2, "Dog") cellFormatter.setColSpan(0, 0, 3) cellFormatter.setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER) self._table.setWidget(2, 0, Button("Hide", getattr(self, "hideRows"))) self._table.setText(2, 1, "1,1") self._table.setText(2, 2, "2,1") self._table.setText(3, 0, "1,2") self._table.setText(3, 1, "2,2") cellFormatter.setRowSpan(2, 0, 2) cellFormatter.setVerticalAlignment(2, 0, HasAlignment.ALIGN_MIDDLE) self._table.setWidget(4, 0, Button("Show", getattr(self, "showRows"))) cellFormatter.setColSpan(4, 0, 3) rowFormatter.setVisible(4, False) self.add(self._table)
def __init__(self, parent): AbsolutePanel.__init__(self) self.userGrid = Grid() self.userGrid.createGrid(6, 6) self.userGrid.addTableListener(self) self.userGrid.setBorderWidth(2) self.userGrid.setCellPadding(4) self.userGrid.setCellSpacing(1) self.userGrid.setColLabelValue(0, "Username") self.userGrid.setColLabelValue(1, "First Name") self.userGrid.setColLabelValue(2, "Last Name") self.userGrid.setColLabelValue(3, "Email") self.userGrid.setColLabelValue(4, "Department") self.userGrid.setColLabelValue(5, "Password") self.newBtn = Button("New") self.deleteBtn = Button("Delete") self.deleteBtn.setEnabled(False) self.add(self.userGrid) self.add(self.newBtn) self.add(self.deleteBtn) return
def themesPanel(self, themes=None): Window.alert('line:111') themes = None if not themes: themes=['0','1', 'cms', 'pypress'] vPanel = VerticalPanel() for i in range(len(themes)): """ a_n = location.getPathName().split('/')[1] lambda1 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/'+x+'/')+'?theme='+x lambda2 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/a/')+'?theme='+x href = { 'cms' : lambda1, 'pypress' : lambda1, 'o' : lambda2, '1' : lambda2 }.get(themes[i], lambda2)(themes[i]) """ a=Button('theme '+themes[i], lambda x: location.setSearchDict({'theme': x.getID()}), StyleName='link') a.setID(themes[i]) vPanel.add(a) return vPanel
def redraw(self): self.data.sort(self.sortfn) rows = len(self.data) cols = 0 if rows > 0: cols = len(self.data[0]) self.grid.resize(rows, cols) self.header.resize(1, cols) cf = self.grid.getCellFormatter() for (nrow, row) in enumerate(self.data): for (ncol, item) in enumerate(row): self.grid.setHTML(nrow, ncol, str(item)) cf.setWidth(nrow, ncol, "200px") cf = self.header.getCellFormatter() self.sortbuttons = [] for ncol in range(cols): sb = Button("sort col %d" % ncol) sb.addClickListener(self) self.header.setWidget(0, ncol, sb) cf.setWidth(0, ncol, "200px") self.sortbuttons.append(sb)
def onModuleLoad(self): ## Grid setup self.grid = Grid() # Note: The resize method args are Rows,Cols (Curses style) self.grid.resize(1,4) self.grid.setBorderWidth(1) self.grid.setHTML(0,0,'#') self.grid.setHTML(0,1,'ID') self.grid.setHTML(0,2,'Revision') self.grid.setHTML(0,3,'Delete') self.grid.addTableListener(self) self.parent_panel.add(self.grid) ## Buttons self.button_panel = HorizontalPanel() # Prev self.first_button = Button("<-", self.firstPage) self.first_button.setEnabled(False) self.button_panel.add(self.first_button) self.prev_button = Button("Previous", self.prevPage) self.prev_button.setEnabled(False) self.button_panel.add(self.prev_button) self.next_button = Button("Next", self.nextPage) self.next_button.setEnabled(False) self.button_panel.add(self.next_button) self.parent_panel.add(self.button_panel)
class GettextExample(object): def __init__(self): self.b = Button(_("Click me"), self.greet, StyleName='teststyle') self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle') self.l = Label(_("Hello World (label)"), StyleName='teststyle') self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(), StyleName='teststyle') RootPanel().add(self.b) RootPanel().add(self.h) RootPanel().add(self.l) RootPanel().add(self.base) def change_texts(self, text): self.b.setText(_("Click me")) self.h.setHTML(_("<b>Hello World</b> (html)")) self.l.setText(_("Hello World (label)")) text = [_("Hello from %s") % pygwt.getModuleBaseURL()] for i in range(4): text.append( ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i)) text = '<br />'.join(text) self.base.setHTML(text) def greet(self, fred): fred.setText(_("No, really click me!")) Window.alert(_("Hello, there!")) i18n.load(lang=lang[0], onCompletion=self.change_texts) lang.append(lang.pop(0))
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)
class YChanger (HorizontalPanel): def __init__(self, chart): self.chart = chart HorizontalPanel.__init__(self) # y-changing, x,y coordinate displaying, widget self.incrementY = Button("Increment Y") self.coordinates = HTML(""); # x,y of selected point self.decrementY = Button("Decrement Y") self.incrementY.addClickListener(self) self.decrementY.addClickListener(self) self.add(self.incrementY) self.add(self.coordinates) self.add(self.decrementY) def onClick(self, sender): if sender == self.incrementY: self.chart.getTouchedPoint().setY( self.chart.getTouchedPoint().getY() + 1) else: self.chart.getTouchedPoint().setY( self.chart.getTouchedPoint().getY() - 1) self.chart.update() # The 2 HoverUpdateable interface methods: def hoverCleanup(self, hoveredAwayFrom): pass def hoverUpdate(self, hoveredOver): # update (x,y) display when they click point self.coordinates.setHTML(hoveredOver.getHovertext())
def __init__(self,parent): AbsolutePanel.__init__(self) self.roleList = ListBox() self.roleList.setWidth('300px') self.roleList.setVisibleItemCount(6) self.roleList.addChangeListener(self.onListChange) #self.roleList.addKeyboardListener(self) self.roleCombo = ListBox() self.roleCombo.addKeyboardListener(self) self.roleCombo.addChangeListener(self.onComboChange) self.addBtn = Button("Add") self.addBtn.setEnabled(False) self.removeBtn = Button("Remove") self.removeBtn.setEnabled(False) vpanel = VerticalPanel() vpanel.add(self.roleList) hpanel = HorizontalPanel() hpanel.add(self.roleCombo) hpanel.add(self.addBtn) hpanel.add(self.removeBtn) vpanel.add(hpanel) self.add(vpanel) self.clearForm() return
def __init__(self, operations,after,type='rel'): DialogWindow.__init__(self, modal=True, close=True) self.formula = Formula([]) self.after=after left = 100 top = 100 self.ops_with_buttons = [{"op": op, "button": Button(op.name, self)} for op in operations if op.available] dock = DockPanel() dock.setSpacing(3) for owb in self.ops_with_buttons: dock.add(owb['button'], DockPanel.NORTH) dock.setWidth("300") self.image = Image(latex_to_url(self.formula.fill_with_placeholders().to_latex())) dock.add(self.image, DockPanel.EAST) dock.setCellHorizontalAlignment(self.image, HasAlignment.ALIGN_TOP) self.doneButton=Button("Done",self) self.doneButton.setEnabled(False) dock.add(self.doneButton,DockPanel.SOUTH) dock.add(HTML(""),DockPanel.CENTER) self.setText("opkop") self.setPopupPosition(left, top) self.setStyleAttribute("background-color", "#ffffff") self.setStyleAttribute("color", "blue") self.setStyleAttribute("border-width", "5px") self.setStyleAttribute("border-style", "solid") self.setWidget(dock)
def __init__(self): Algorithm.__init__(self) self.MLAlgorithmService = MLAlgorithmService(self) self.image = Image(self.baseURL() + "services/kMeansPictures/lenna.png", Width="320px", Height="360px") self.resultImage = Image("", Width="320px", Height="360px") self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif") self.calculateButton = Button("RUN", self.onButtonClick) self.log = Button("SHOW LOG", self.openLogFile) self.log.setEnabled(False) self.image.addLoadListener(self) topPanel = DockPanel() topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) topPanel.add(self.calculateButton, DockPanel.WEST) topPanel.add(self.loadingImage, DockPanel.CENTER) topPanel.add(self.log, DockPanel.EAST) panel = DockPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) #panel.add(HTML("<h2>Image compression</h2>", True)) panel.add(topPanel, DockPanel.NORTH) panel.add(self.image, DockPanel.WEST) panel.add(self.resultImage, DockPanel.EAST) panel.setWidth("100%") self.initWidget(panel) self.image.setStyleName("ks-images-Image") self.calculateButton.setStyleName("ks-images-Button") self.loadImage("picturem.png")
def createDefaultControl(self, control_type): if control_type == 'minimize': return Button("_") elif control_type == 'maximize': return Button("^") elif control_type == 'close': return Button("X") raise ValueError("Invalid control '%s'" % control_type)
def __init__(self): HorizontalPanel.__init__(self) History.newItem("test") show = Button("Show deep link", self.showDL) setDL = Button("Set deep link to 'pyjamas'", self.setDL) self.add(setDL) self.add(show)
def backspaceButton_add(self): def backspaceButton_click(): self.formula = Formula(self.formula.body[:-1]) self.refresh() self.backspaceButton = Button("Backspace", backspaceButton_click) self.backspaceButton.setEnabled(False) self.dock.add(self.backspaceButton, DockPanel.SOUTH)
def doneButton_add(self): def doneButton_click(): self.hide() self.after(self.formula) self.doneButton = Button("Done", doneButton_click) self.doneButton.setEnabled(False) self.dock.add(self.doneButton, DockPanel.SOUTH)
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
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 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)
def __init__(self): self.b = Button(_("Click me"), self.greet, StyleName='teststyle') self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle') self.l = Label(_("Hello World (label)"), StyleName='teststyle') self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(), StyleName='teststyle') RootPanel().add(self.b) RootPanel().add(self.h) RootPanel().add(self.l) RootPanel().add(self.base)
def __init__(self, parent): AbsolutePanel.__init__(self) self.home_header = Label("Blogjamas", StyleName="header_label") self.write_button = Button("Write a Post") self.edit_hidden_button = Button("", StyleName="hidden_button") self.delete_hidden_button = Button("", StyleName="hidden_button") self.add(self.home_header) self.add(self.write_button) self.add(self.edit_hidden_button) self.add(self.delete_hidden_button)
def __init__(self, chart, **kwargs): self.chart = chart HorizontalPanel.__init__(self, **kwargs) self.bzoomIn = Button("<big>+</big>", self) self.bzoomOut = Button("<big>-</big>", self) self.bzoomIn.setTitle( "Zoom in (expands selected region so it fills plot area)") self.bzoomOut.setTitle( "Zoom out (shrinks plot area so it fits in selected region)") self.add(self.bzoomIn) self.add(self.bzoomOut)
def __init__(self): GChart.__init__(self) self.updateButton = Button( "<b><big>Generate New Simulated Revenues</big></b>") self.setChartSize(WIDTH, HEIGHT) self.setChartTitle("<b><big><big>" + "Simulated Quarterly Revenues" + "</big></big><br> </b>") self.updateButton.addClickListener(self) self.setChartFootnotes(self.updateButton) for iCurve in range(len(barLabels)): self.addCurve() # one curve per quarter self.getCurve().getSymbol().setSymbolType( SymbolType.VBAR_SOUTHWEST) self.getCurve().getSymbol().setBackgroundColor(barColors[iCurve]) self.getCurve().setLegendLabel(barLabels[iCurve]) self.getCurve().getSymbol().setHovertextTemplate( formatAsHovertext(barLabels[iCurve] + " revenue=${y}")) self.getCurve().getSymbol().setModelWidth(1.0) self.getCurve().getSymbol().setBorderColor("black") self.getCurve().getSymbol().setBorderWidth(1) for jGroup in range(len(groupLabels)): # the '+1' creates a bar-sized gap between groups y = rnd() * MAX_REVENUE print "x, y", 1 + iCurve + jGroup * (len(barLabels) + 1), y self.getCurve().addPoint( 1 + iCurve + jGroup * (len(barLabels) + 1), y) self.getCurve().getPoint().setAnnotationText(barLabels[iCurve]) self.getCurve().getPoint().setAnnotationLocation( AnnotationLocation.NORTH) for i in range(len(groupLabels)): # formula centers tick-label horizontally on each group self.getXAxis().addTick( len(barLabels) / 2. + i * (len(barLabels) + 1), groupLabels[i]) self.getXAxis().setTickLabelFontSize(20.0) self.getXAxis().setTickLabelThickness(40.0) self.getXAxis().setTickLength(6.0) # small tick-like gap... self.getXAxis().setTickThickness(0) # but with invisible ticks self.getXAxis().setAxisMin(0) # keeps first bar on chart self.getYAxis().setAxisMin(0) # Based on sim revenue range self.getYAxis().setAxisMax(MAX_REVENUE) # of 0 to MAX_REVENUE. self.getYAxis().setTickCount(11) self.getYAxis().setHasGridlines(True) self.getYAxis().setTickLabelFormat("$#,###")
class FormulaBuilder(DialogWindow): def __init__(self, operations,after,type='rel'): DialogWindow.__init__(self, modal=True, close=True) self.formula = Formula([]) self.after=after left = 100 top = 100 self.ops_with_buttons = [{"op": op, "button": Button(op.name, self)} for op in operations if op.available] dock = DockPanel() dock.setSpacing(3) for owb in self.ops_with_buttons: dock.add(owb['button'], DockPanel.NORTH) dock.setWidth("300") self.image = Image(latex_to_url(self.formula.fill_with_placeholders().to_latex())) dock.add(self.image, DockPanel.EAST) dock.setCellHorizontalAlignment(self.image, HasAlignment.ALIGN_TOP) self.doneButton=Button("Done",self) self.doneButton.setEnabled(False) dock.add(self.doneButton,DockPanel.SOUTH) dock.add(HTML(""),DockPanel.CENTER) self.setText("opkop") self.setPopupPosition(left, top) self.setStyleAttribute("background-color", "#ffffff") self.setStyleAttribute("color", "blue") self.setStyleAttribute("border-width", "5px") self.setStyleAttribute("border-style", "solid") self.setWidget(dock) def onClick(self, sender): if sender==self.doneButton: self.hide() self.after(self.formula) op=None for owb in self.ops_with_buttons: if owb['button'] == sender: self.setText(sender.getText()) op=owb['op'] if not self.formula.is_closed(): self.formula.add_one_op(op,type) self.image.setUrl(latex_to_url(self.formula.fill_with_placeholders().to_latex())) if self.formula.is_closed(): self.doneButton.setEnabled(True)
def __init__(self, chart): self.chart = chart HorizontalPanel.__init__(self) # y-changing, x,y coordinate displaying, widget self.incrementY = Button("Increment Y") self.coordinates = HTML(""); # x,y of selected point self.decrementY = Button("Decrement Y") self.incrementY.addClickListener(self) self.decrementY.addClickListener(self) self.add(self.incrementY) self.add(self.coordinates) self.add(self.decrementY)
def themesPanel(self, themes=None): themes = None if not themes: themes=['0','1', 'cms', 'pypress'] vPanel = VerticalPanel() vPanel.setID('themes') for i in range(len(themes)): a=Button('theme %s' % themes[i], Index.toTheme, StyleName='link') a.setID(themes[i]) vPanel.add(a) return vPanel
def __init__(self): HorizontalPanel.__init__(self, Spacing=4) self.add(Label('Dispatch:', StyleName='section')) self.pause = Button('Pause', self) self.add(self.pause) self.resume = Button('Resume', self) self.add(self.resume) self.refresh = Button('Refresh', self, StyleName='refresh') self.add(self.refresh) self.err = Label() self.add(self.err) self._refresh()
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 themesPanel(self, themes=None): themes = None if not themes: themes=['0','1', 'cms', 'pypress'] vPanel = VerticalPanel() for i in range(len(themes)): a=Button('theme '+themes[i], lambda x: location.setSearchDict({'theme': x.getID()}), StyleName='link') a.setID(themes[i]) vPanel.add(a) return vPanel
def __init__(self, countdown): # It's a Timer, no it's a Button, WAIT! It's BOTH!! Timer.__init__(self) Button.__init__(self) # save the countdown value self.countdown_save = countdown # this instance handles the clicks self.addClickListener(self) # the box the popups go into self.box = SimplePanel(StyleName='popupbox') # kickstart self.reset()
class CalibrateChannelTrimsView(object) : """ Class that takes care of the purely UI parts of the trim calibration """ def __init__( self ) : numberOfLoopsPanel=HorizontalPanel() numberOfLoopsPanel.add( HTML("Maximum number of loops") ) self.maximumNumberOfLoops=TextBox() self.maximumNumberOfLoops.setText(10) numberOfLoopsPanel.add( self.maximumNumberOfLoops ) numberOfLoopsPanel.setCellHorizontalAlignment( self.maximumNumberOfLoops, HasHorizontalAlignment.ALIGN_RIGHT ) numberOfLoopsPanel.setWidth("100%") aimPointPanel=HorizontalPanel() aimPointPanel.add( HTML("Aim point") ) self.aimPoint=TextBox() self.aimPoint.setText(127) aimPointPanel.add( self.aimPoint ) aimPointPanel.setCellHorizontalAlignment( self.aimPoint, HasHorizontalAlignment.ALIGN_RIGHT ) aimPointPanel.setWidth("100%") self.start=Button("Start") self.echo=HTML("Initiating...") self.mainPanel = VerticalPanel() self.mainPanel.add( numberOfLoopsPanel ) self.mainPanel.add( aimPointPanel ) self.mainPanel.add( self.start ) self.mainPanel.add( self.echo ) def getMaxNumberOfLoops( self ) : return int(self.maximumNumberOfLoops.getText()) def getAimPoint( self ) : return int(self.aimPoint.getText()) def getStartButton( self ) : return self.start def setEchoText( self, text ) : self.echo.setText( text ) def enable( self ) : self.start.setEnabled(True) def disable( self ) : self.start.setEnabled(False) def getPanel( self ) : return self.mainPanel
def __init__(self, *args, **kwargs): super(LayersPanel, self).__init__(*args, **kwargs) navbar = NavigationBar() navbar.add(HTML('<div class="brand">Layers</div>')) b = Button("Edit", StyleName="btn") b.addStyleName("btn-inverse") b.addStyleName("pull-right") navbar.add(b) self.add(navbar) self._tree = Tree() self.add(self._tree)
def __init__(self): # We need to use old form of inheritance because of pyjamas SimplePanel.__init__(self) self.hpanel = HorizontalPanel(Width='755px') self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP) self.name = TextBox() self.name.setStyleName('form-control') self.start = Report_Date_Field(cal_ID='start') self.start.getTextBox().setStyleName('form-control') self.start.setRegex(DATE_MATCHER) self.start.appendValidListener(self._display_ok) self.start.appendInvalidListener(self._display_error) self.start.validate(None) self.end = Report_Date_Field(cal_ID='end') self.end.getTextBox().setStyleName('form-control') self.end.setRegex(DATE_MATCHER) self.end.appendValidListener(self._display_ok) self.end.appendInvalidListener(self._display_error) self.end.validate(None) self.status = ListBox() self.status.addItem('Active') self.status.addItem('Inactive') self.status.setVisibleItemCount(0) self.status.setStyleName('form-control input-lg') self.status.setSize('100px', '34px') spacer1 = Label(Width='10px') spacer2 = Label(Width='10px') spacer3 = Label(Width='10px') self.add_btn = Button('Add') self.add_btn.setStyleName('btn btn-primary') self.del_btn = Button('Delete') self.del_btn.setStyleName('btn btn-danger') self.hpanel.add(self.name) self.hpanel.add(spacer1) self.hpanel.add(self.status) self.hpanel.add(spacer2) self.hpanel.add(self.start) #self.hpanel.add(spacer3) self.hpanel.add(self.end) self.hpanel.add(self.add_btn) self.hpanel.add(Label(Width='10px')) self.hpanel.add(self.del_btn)
class GridWidget(AbsolutePanel): def __init__(self): AbsolutePanel.__init__(self) self.page=0 self.min_page=1 self.max_page=10 self.addb=Button("Next >", self) self.subb=Button("< Prev", self) self.clearb=Button("Clear", self) self.g=Grid() self.g.resize(5, 5) self.g.setWidget(0, 0, HTML("<b>Grid Test</b>")) self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.updatePageDisplay() self.add(self.subb) self.add(self.addb) self.add(self.clearb) self.add(self.g) def onClick(self, sender): if sender == self.clearb: print "clear" self.g.clear() return elif sender==self.addb: self.page+=1 elif sender==self.subb: self.page-=1 self.updatePageDisplay() def updatePageDisplay(self): if self.page<self.min_page: self.page=self.min_page elif self.page>self.max_page: self.page=self.max_page total_pages=(self.max_page-self.min_page) + 1 self.g.setHTML(0, 4, "<b>page %d of %d</b>" % (self.page, total_pages)) if self.page>=self.max_page: self.addb.setEnabled(False) else: self.addb.setEnabled(True) if self.page<=self.min_page: self.subb.setEnabled(False) else: self.subb.setEnabled(True) for y in range(1, 5): for x in range(5): self.g.setText(y, x, "%d (%d,%d)" % (self.page, x, y))
def __init__(self, contentitem, onPublish, onLike, onDislike): """Create a ContentItemToolbar. Event handlers should be methods that take: sender """ HorizontalPanel.__init__(self) self.contentitem = contentitem self.publishBtn = Button('Publish', listener=onPublish, StyleName=Styles.TOOLBAR_BUTTON) self.add(self.publishBtn) self.likeBtn = Button('FOO', listener=onLike, StyleName=Styles.TOOLBAR_BUTTON) self.add(self.likeBtn) self.dislikeBtn = Button('Dislike', listener=onDislike, StyleName=Styles.TOOLBAR_BUTTON) self.add(self.dislikeBtn) self.updateStatusFromItem() return