def onModuleLoad(self): self.curInfo = '' self.curAlgorithm = None self.description = HTML() self.Algorithm_list = AlgorithmList() self.panel = DockPanel() self.loadAlgorithms() self.AlgorithmContainer = DockPanel() self.AlgorithmContainer.setStyleName("ks-Algorithm") vp = VerticalPanel() vp.setWidth("100%") vp.add(self.description) vp.add(self.AlgorithmContainer) self.description.setStyleName("ks-Info") self.panel.add(self.Algorithm_list, DockPanel.WEST) self.panel.add(vp, DockPanel.CENTER) self.panel.setCellVerticalAlignment(self.Algorithm_list, HasAlignment.ALIGN_TOP) self.panel.setCellWidth(vp, "100%") History.addHistoryListener(self) RootPanel().add(self.panel) RootPanel().add(Logger()) #Show the initial screen. initToken = History.getToken() if len(initToken): self.onHistoryChanged(initToken) else: self.showInfo()
def __init__(self, autoHide=None, modal=True, centered=False, **kwargs): # Init section self.dragging = False self.dragStartX = 0 self.dragStartY = 0 self.child = None self.panel = FlexTable( Height="100%", BorderWidth="0", CellPadding="0", CellSpacing="0", ) cf = self.panel.getCellFormatter() cf.setHeight(1, 0, "100%") cf.setWidth(1, 0, "100%") cf.setAlignment( 1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE, ) # Arguments section self.modal = modal self.caption = HTML() self.panel.setWidget(0, 0, self.caption) self.caption.setStyleName("Caption") self.caption.addMouseListener(self) # Finalize kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox") PopupPanel.__init__(self, autoHide, modal, **kwargs) PopupPanel.setWidget(self, self.panel) self.centered = centered
def onModuleLoad(self): self.curInfo = '' self.curSink = None self.description = HTML() self.sink_list = SinkList() self.panel = DockPanel() self.loadSinks() self.sinkContainer = DockPanel() self.sinkContainer.setStyleName("ks-Sink") vp = VerticalPanel() vp.setWidth("100%") vp.add(self.description) vp.add(self.sinkContainer) self.description.setStyleName("ks-Info") self.panel.add(self.sink_list, DockPanel.WEST) self.panel.add(vp, DockPanel.CENTER) self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP) self.panel.setCellWidth(vp, "100%") History.addHistoryListener(self) RootPanel().add(self.panel) initToken = History.getToken() if len(initToken): self.onHistoryChanged(initToken) else: self.showIntro()
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, grid_size): Grid.__init__(self) # populate the grid with some stuff # self.resize(grid_size, grid_size) self.setBorderWidth(2) self.setCellPadding(4) self.setCellSpacing(1) self.setStyleName("gameboard") # just doesn't work # Set up game board # # Note that must iterate over indices, rather than Cell # instances, until the table positions are set up here # index = 0 # debug for i in range(grid_size): for j in range(grid_size): cell = HTML(SPACE) # cell.setVisible(False) # causes to ignore click events cell.position = (i, j) # might be handy at some point index+=1; cell.index = index # debug # cell.setStyleName("cell_O") cell.addClickListener(getattr(self, "onCellClicked")) self.setWidget(i, j, cell)
def addContact(self, contact): link = HTML("<a href='javascript:;'>" + contact.name + "</a>") self.panel.add(link) # Add a click listener that displays a ContactPopup when it is clicked. listener = ContactListener(contact, link) link.addClickListener(listener)
def __init__(self, userListPanel, tabPanel, topPanel): VerticalPanel.__init__(self, StyleName='large-avatar-panel') self.userListPanel = userListPanel self.tabPanel = tabPanel self.topPanel = topPanel upperPanel = HorizontalPanel(StyleName='large-avatar-upper-panel', Spacing=8) self.image = Image(StyleName='large-avatar') self.upperText = HTML(StyleName='large-avatar-upper-text') upperPanel.add(self.image) upperPanel.add(self.upperText) self.add(upperPanel) self.lowerText = HTML(StyleName='large-avatar-lower-text') self.add(self.lowerText) self.followButton = None self.user = None insertPanel = HorizontalPanel(Spacing=3) insertPanel.add(Label('Use name: ')) if tabPanel.tabName == 'simple': b1 = Button('upper', SimpleInserter(self, 'upper')) b2 = Button('lower', SimpleInserter(self, 'lower')) insertPanel.add(b1) insertPanel.add(b2) else: b1 = Button('or', QueryInserter(self, 'or')) b2 = Button('and', QueryInserter(self, 'and')) b3 = Button('except', QueryInserter(self, 'except')) insertPanel.add(b1) insertPanel.add(b2) insertPanel.add(b3) self.add(insertPanel)
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))
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): Composite.__init__(self) self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>") self.aboutLink = HTML("<a href='javascript:;'>About</a>") outer = HorizontalPanel() inner = VerticalPanel() outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) links = HorizontalPanel() links.setSpacing(4) links.add(self.signOutLink) links.add(self.aboutLink) outer.add(inner) inner.add(HTML("<b>Welcome back, [email protected]</b>")) inner.add(links) self.signOutLink.addClickListener(self) self.aboutLink.addClickListener(self) self.initWidget(outer) inner.setStyleName("mail-TopPanel") links.setStyleName("mail-TopPanelLinks")
def onModuleLoad(self): dock = DockPanel(Width="100%") self.header = HTML(Width="100%", Height="220px") self.footer = HTML(Width="100%") self.sidebar = HTML(Width="200px", Height="100%", StyleName="sidebar") self.fTabs = DecoratedTabPanel(Size=("100%", "100%"), StyleName="tabs") #dp = DecoratorTitledPanel("Tabs", "bluetitle", "bluetitleicon", # ["bluetop", "bluetop2", "bluemiddle", "bluebottom"]) #dp.add(self.fTabs) dock.add(self.header, DockPanel.NORTH) dock.add(self.footer, DockPanel.SOUTH) dock.add(self.sidebar, DockPanel.EAST) dock.add(self.fTabs, DockPanel.CENTER) dock.setCellVerticalAlignment(self.fTabs, HasAlignment.ALIGN_TOP) #dock.setCellHorizontalAlignment(self.fTabs, HasAlignment.ALIGN_CENTER) dock.setCellWidth(self.header, "100%") dock.setCellHeight(self.header, "220px") dock.setCellWidth(self.footer, "100%") dock.setCellWidth(self.sidebar, "200px") RootPanel().add(dock) self.dock = dock self.loadPageList() Window.addWindowResizeListener(self) DeferredCommand.add(self)
def __init__(self): SimplePanel.__init__(self) vert = VerticalPanel() vert.setSpacing("10px") self.add(vert) panel = ScrollPanel(Size=("300px", "100px")) contents = HTML("<b>Tao Te Ching, Chapter One</b><p>" + "The Way that can be told of is not an unvarying " + "way;<p>The names that can be named are not " + "unvarying names.<p>It was from the Nameless that " + "Heaven and Earth sprang;<p>The named is but the " + "mother that rears the ten thousand creatures, " + "each after its kind.") panel.add(contents) vert.add(panel) container = SimplePanel(Width="400px", Height="200px") contents2 = HTML( 50 * "Dont forget to grab the css for SuperScrollPanel in Showcase.css! " ) panel2 = SuperScrollPanel(contents2) container.add(panel2) vert.add(container)
def onModuleLoad(self): #red = PrettyTab("1638", "images/user_red.png") #red.setStyleName('gwt-TabBarItem') #green = PrettyTab("1640", "images/user_green.png") #red.setStyleName('gwt-TabBarItem') red = "1638" green = "1640" self.fTabs = DecoratedTabPanel(Size=("600px", "100%")) self.fTabs.add(self.createImage("rembrandt/JohannesElison.jpg"), red, True) self.fTabs.add(self.createImage("rembrandt/SelfPortrait1640.jpg"), green, True) self.fTabs.add(self.createImage("rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add( self.createImage("rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.add(HTML("shouldn't be here!"), None) self.fTabs.add(HTML("This is a Test.<br />Tab should be on right"), "Test") self.fTabs.selectTab(0) dp = DecoratorTitledPanel( "Tabs", "bluetitle", "bluetitleicon", ["bluetop", "bluetop2", "bluemiddle", "bluebottom"]) dp.add(self.fTabs) RootPanel().add(dp)
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)
class DisplayPanel(Composite): def __init__(self, owner): Composite.__init__(self) self.owner = owner self.bar = DockPanel() self.timer_msg = HTML(" timer: ") self.timer = TimeDisplay() self.timer_panel = HorizontalPanel() self.timer_panel.add(self.timer_msg) self.timer_panel.add(self.timer) self.counter_msg = HTML(" total moves: ") self.counter = HTML("0") self.counter_panel = HorizontalPanel() self.counter_panel.add(self.counter_msg) self.counter_panel.add(self.counter) self.initWidget(self.bar) self.bar.add(self.timer_panel, DockPanel.WEST) self.bar.add(self.counter_panel, DockPanel.EAST) self.setStyleName("Puzzle-DisplayPanel") def incrCount(self): count = self.counter.getText() count = int(count) + 1 self.counter.setText(count) def reset(self): self.timer.setDisplay(0, 0, 0) self.counter.setText("0")
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 draw(self): Popup.draw(self) namePanel = HorizontalPanel() #namePanel.add(Label('Crie um arquivo')) if self.title == 'Abrir': self.enableOkButton(False) namePanel.add(HTML("""<div class=""gwt-Label"" style=""white-space: normal;""> Abra o arquivo salvo, copie<br>e cole aqui o conteudo:</div>""")) self.field = FileUpload() self.field.setName('file') self.field.setID('files') self.center.add(self.field) element = self.field.getElement() JS("""function handleFileSelect(evt) {@{{self}}.enableOkButton(evt.target.files[0]!=null);} @{{element}}.addEventListener('change', handleFileSelect, false);""") #http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml else: namePanel.add(HTML("""<div class=""gwt-Label"" style=""white-space: normal;""> Crie um arquivo txt e copie<br>e cole o conteudo a seguir:</div>""")) self.textBox = TextBox() self.textBox.setStyleAttribute('marginLeft', 10) namePanel.add(self.textBox) self.center.add(namePanel) self.textBox.addInputListener(self) self.onInput()
def __init__(self, **kwargs): """ setMatchPattern - defaults to '' to match everything match pattern examples: '^[0-9]*$' is for digits only '^[0-9,A-Z]*$' is for digits and uppercase setMaxLength setText OB """ kwargs['MatchPattern'] = kwargs.pop('MatchPattern', '') cs = kwargs.pop('CursorStyle', "inputbox-cursor") gs = kwargs.pop('StyleName', 'gwt-inputbox') ap = AbsolutePanel(StyleName="inputbox") self.tp = Grid(StyleName=gs, Width="100%", Height="100%", CellPadding=0, CellSpacing=0) self.cursor = HTML(StyleName=cs) ap.add(self.tp) ap.add(self.cursor, 0, 0) self.cf = self.tp.getCellFormatter() FocusPanel.__init__(self, Widget=ap, **kwargs) self.addTableListener(self) self.addKeyboardListener(self) self.addFocusListener(self) self.word_selected_pos = 0 self.ctimer = Timer(notify=self.cursorFlash) self.focusset = False self.cstate = False self._keypressListeners = []
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 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 __init__(self, hrs=0, mins=0, secs=0): self.isActive = False self.hrs = hrs self.mins = mins self.secs = secs HTML.__init__(self) self.setDisplay(self.hrs, self.mins, self.secs) self.onTimer()
def __init__(self, txt, **kwargs): txt = HTML(txt) txt.addClickListener(self) PopupPanel.__init__(self, autoHide=True, StyleName="showcase-popup", **kwargs) self.add(txt) self.show()
def __init__(self): PopupPanel.__init__(self, True) contents = HTML("Click anywhere outside this popup to make it disappear.") contents.setWidth("128px") self.setWidget(contents) self.setStyleName("ks-popups-Popup")
def OnGameLoad(self): self.NameScore.setText(0, 0, "Player ID") self.NameScore.setText(0, 1, "Score") self.NameScore.setCellSpacing(10) self.NameScore.setCellPadding(10) self.NameScore.setBorderWidth(2) self.NameScore.setVisible(False) self.TempBoard.setText(0, 0, "Player's Turn") self.TempBoard.setText(0, 1, "Temporary Score") self.TempBoard.setText(1, 0, "X") self.TempBoard.setText(1, 1, "0") self.TempBoard.setCellSpacing(10) self.TempBoard.setCellPadding(10) self.TempBoard.setBorderWidth(2) self.TempBoard.setVisible(False) #Adding StartButton to Dock panel self.DPanel.add(self.StartButton, DockPanel.EAST) self.DPanel.setCellHeight(self.StartButton, "200px") self.DPanel.setCellWidth(self.StartButton, "20px") Txt = HTML("<center><b>Enter Number of Players (between 2 & 6)</b><center>")#Adding playernumber and winscore textbox to Horizontal Panel Txt1 = HTML("<left><b>Enter Target Score (between 10 & 100)</b><left>") self.HPanel1.add(Txt) self.HPanel1.add(self.PlayerNum) self.HPanel1.add(Txt1) self.HPanel1.add(self.WinScore) self.HPanel1.add(self.StartButton) self.HPanel1.setSpacing(20) #Adding Horizontal panel containing playernumber and winscore textbox to Dock Panel self.DPanel.add(self.HPanel1, DockPanel.NORTH) self.DPanel.setCellHeight(self.HPanel1, "30px") self.DPanel.setCellWidth(self.HPanel1, "2000px") self.TxtInstructions = HTML("<b><u><center>Instructions</center></u><ul><li>Pig is game for 2 to 6 Players.</li><li>Players take turns rolling a dice as many times as they like. </li><li>If a roll is 2, 3, 4, 5 or 6, the player adds that many points to their score for the turn. </li><li>A player may choose to end their turn at any time and 'bank' their points.</li><li>If a player rolls a 1, they lose all their unbanked points and their turn is over.</li><li>The first player to score the target or more wins.</li></ul></b>") self.TxtInstructions.setStyleName("TxtInstructions") self.DPanel.add(self.TxtInstructions, DockPanel.CENTER) self.DPanel.add(self.NameScore, DockPanel.WEST) #Adding main scoreboard to Dock Panel self.DPanel.setCellHeight(self.NameScore, "300px") self.DPanel.setCellWidth(self.NameScore, "100px") self.DPanel.setSpacing(10) self.DPanel.setPadding(2) #Adding Tempboard and BankButton to Horizontal Panel self.HPanel.add(self.TempBoard) #Adding BankButton and RollButton to vertical panel self.VPanel.add(self.RollButton) self.RollButton.setVisible(False) self.VPanel.add(self.BankButton) self.BankButton.setVisible(False) self.VPanel.setSpacing(10) #Adding Vertical panel containing BankButton and RollButton to Horizontal Panel self.HPanel.add(self.VPanel) self.HPanel.setSpacing(40) #Adding Horizontal panel containing Tempboard and vertical panel containing BankButton and RollButton to Dock Panel self.DPanel.add(self.HPanel, DockPanel.SOUTH) self.DPanel.setCellHeight(self.HPanel, "20px") self.DPanel.setCellWidth(self.HPanel, "2000px") RootPanel().add(self.DPanel)
def __init__(self): # layed out in a grid with odd rows a different color for # visual separation grid = Grid(4, 3, CellPadding=50, CellSpacing=0) rf = grid.getRowFormatter() rf.setStyleName(1, 'oddrow') rf.setStyleName(3, 'oddrow') # the clock clock = Clock() grid.setWidget( 0, 0, CaptionPanel('Using notify()', clock.button, StyleName='left')) grid.setWidget(0, 1, clock.datelabel) grid.setWidget(0, 2, HTML(Clock.__doc__, StyleName='desc')) # popup timer buttons ptb = PopupTimerButton(5) grid.setWidget( 1, 0, CaptionPanel('Subclassing Timer()', ptb, StyleName='left')) grid.setWidget(1, 1, ptb.box) grid.setWidget(1, 2, HTML(PopupTimerButton.__doc__, StyleName='desc')) # the second instance ptb = PopupTimerButton(15) grid.setWidget( 2, 0, CaptionPanel('Subclassing Timer() (<em>again</em>)', ptb, StyleName='left')) grid.setWidget(2, 1, ptb.box) grid.setWidget( 2, 2, HTML('''This is the same as the previous example and is here to demonstrate creating multiple timers (each with their own state) which is difficult to do without sublcassing''', StyleName='desc')) # random color randomcolor = RandomColor() grid.setWidget( 3, 0, CaptionPanel('Using onTimer()', randomcolor.hpanel, StyleName='left')) grid.setWidget(3, 1, randomcolor.colorpanel) grid.setWidget(3, 2, HTML(RandomColor.__doc__, StyleName='desc')) # add it all to the root panel RootPanel().add(grid) # kickstart the slider handle (see above concerning a # potential bug) randomcolor.initialize()
def __init__(self): PopupPanel.__init__(self, True) contents = HTML( "Click anywhere outside this popup to make it disappear.") contents.setWidth("128px") self.setWidget(contents) self.setStyleName("ks-popups-Popup")
def onCompletion(self, response): '''This method is called when asyncGet returns. If we know parameters of the repsponse we may process differently for various cases. For example we may setup data in the form if we call it from Populate Form button. ''' self.view.root.remove(self.view.panel) html = HTML() html.setHTML(response) self.view.root.add(html)
def __init__(self): self.calsPanel = VerticalPanel(Size=("50%", "")) self.info = HTML("", Width="100%") self.calsPanel.add(self.info) self.localcalreport = HTML("", True, ) self.globalcalreport = HTML("", True, ) self.calsPanel.add(self.localcalreport) self.calsPanel.add(self.globalcalreport) self.panel = self.calsPanel
def __init__(self, tags = None, width = 300, selected = None, myid = 'select2example'): #log.info("tags='%s' width='%s' selected='%s'", tags, width, selected) self.myid = myid self.tags = tags # This markup is used by select2 to configure the component html = '<p><input type="hidden" id="%s" style="width:%dpx"/></p>' % (myid, width) html += '<div id="%s-show"></div>' % (myid) self.selected = selected log.info("html = '%s'", html) HTML.__init__(self, html)
def start(sender): Window.alert("Hello, GAMERS!") hw = HTML("<img src='http://github.com/jrabbit/Defenditt/raw/master/public/media/instructions%20screen.png' alt='instructions'/>") hw.setID('instructions') RootPanel().add(hw) JS(""" parent.top.document.getElementById("splash").style.display = "none"; parent.top.document.getElementById("startbutton").style.display = "none"; parent.top.document.getElementById("startbutton").style.height = 0; """)
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 get_home_panel(self): panel = VerticalPanel() title = HTML("""OpenPowerSystem""") panel.add(title) subtitle = HTML("""The Open Power System data repository.""") panel.add(subtitle) return panel
class RightPanel(DockPanel): def __init__(self): DockPanel.__init__(self) self.grids = {} self.g = Grid() self.g.setCellSpacing("0px") self.g.setCellPadding("8px") self.title = HTML(" ") self.title.setStyleName("rightpanel-title") self.add(self.title, DockPanel.NORTH) self.setCellWidth(self.title, "100%") self.setCellHorizontalAlignment(self.title, HasHorizontalAlignment.ALIGN_LEFT) self.add(self.g, DockPanel.CENTER) def setTitle(self, title): self.title.setHTML(title) def clear_items(self): for i in range(len(self.grids)): g = self.grids[i] if hasattr(g, "clear_items"): g.clear_items() self.grids = {} self.g.resize(0, 0) def setup_panels(self, datasets): self.grids = {} self.data = {} self.names = {} self.loaded = {} size = len(datasets) self.g.resize(size, 1) #for i in range(size): # item = datasets[i] # fname = item[0] # self.grids[i] = RightGrid(fname) # self.g.setWidget(i, 0, self.grids[i]) def add_html(self, html, name, index): self.data[index] = html self.names[index] = name self.grids[index] = HTML(html) self.g.setWidget(index, 0, self.grids[index]) def add_items(self, items, name, index): self.data[index] = items self.names[index] = name self.grids[index] = RightGrid("") self.grids[index].set_items(items) self.g.setWidget(index, 0, self.grids[index])
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)
def __init__(self): SimplePanel.__init__(self) tabs = TabPanel(Width="100%", Height="250px") tabs.add(HTML("The quick brown fox jumps over the lazy dog."), "Tab 1") tabs.add(HTML("The early bird catches the worm."), "Tab 2") tabs.add(HTML("The smart money is on the black horse."), "Tab 3") tabs.selectTab(0) self.add(tabs)
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 parseAlbums(self, items): album_list = json.loads(items) self.albums = [] for al in album_list: analbum = {} analbum['title'] = HTML(al[u"title"][u"$t"]) analbum['thumb'] = HTML( '<img src="' + al[u"media$group"][u"media$thumbnail"][0][u"url"] + '"/>') url = al[u"id"][u"$t"] analbum['id'] = url.split(u'albumid/')[1].split(u'?alt')[0] self.albums.append(analbum)
def __init__(self): DockPanel.__init__(self) self.grids = {} self.g = Grid() self.g.setCellSpacing("0px") self.g.setCellPadding("8px") self.title = HTML(" ") self.title.setStyleName("rightpanel-title") self.add(self.title, DockPanel.NORTH) self.setCellWidth(self.title, "100%") self.setCellHorizontalAlignment(self.title, HasHorizontalAlignment.ALIGN_LEFT) self.add(self.g, DockPanel.CENTER)
def parseAlbums(self, items): album_list = json.loads(items) self.albums = [] for i in range(len(album_list)): index = "%s" % i analbum = {} analbum['title'] = HTML(album_list[index]["title"]["$t"]) analbum['thumb'] = HTML('<img src="' + album_list[index]["media$group"] ["media$thumbnail"]["0"]["url"] + '"/>') url = album_list[index]["id"]["$t"] analbum['id'] = url.split('albumid/')[1].split('?alt')[0] self.albums.append(analbum)
def set_grid_value(self, v, y, x): if v: w = "" else: w = "0px" v = v or EMPTY s = HTML(v, StyleName="inputbox-square") self.tp.setWidget(y, x, s) self.cf.setAlignment(y, x, HasAlignment.ALIGN_LEFT, HasAlignment.ALIGN_MIDDLE) self.cf.setWidth(y, x, w) s.setWidth(w)
class Slideshow: def onModuleLoad(self): self.slide = HTML() RootPanel().add(self.slide) HTTPRequest().asyncPost("test_slide.txt", "", SlideLoader(self)) def setSlide(self, content): self.slide.setHTML("<pre>%s</pre>" % content) def onError(self, text, code): self.slide.setHTML(text + "<br />" + code)
def __init__(self): SimplePanel.__init__(self) stack = StackPanel(Width="100%", Height="300px") stack.add(HTML('The quick<br>brown fox<br>jumps over the<br>lazy dog.'), "Stack 1") stack.add(HTML('The<br>early<br>bird<br>catches<br>the<br>worm.'), "Stack 2") stack.add(HTML('The smart money<br>is on the<br>black horse.'), "Stack 3") self.add(stack)
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
class BulkDirectAdd(HorizontalPanel): def __init__(self): HorizontalPanel.__init__(self, Spacing=4) self.add(Label('Directly add in bulk:', StyleName='section')) self.names = TextArea(VisibleLines=5) self.add(self.names) self.update = Button('Add', self) self.add(self.update) self.err = HTML() self.add(self.err) def onClick(self, sender): self.err.setHTML('') names = self.names.getText().strip() if names == '': return else: self.update.setEnabled(False) remote = server.AdminService() id = remote.bulkAddUsers(names, self) if id < 0: self.err.setText('oops: could not add') def onRemoteResponse(self, result, request_info): self.update.setEnabled(True) self.err.setText('OK, adding.') def onRemoteError(self, code, message, request_info): self.update.setEnabled(True) self.err.setHTML('Errors:<br/>' + '<br/>'.join(message['data']['message']))
def __init__(self,text,styles,prev,constraints,enforce_constraints,update_widgets): #Constraints are of the forms (x,y) where #both x and y are integers in the set of possible #states. x represents the state of this word #and y represents the state of the previous word HTML.__init__(self,text) self.text = text self.addClickListener(self) self.state = 0 self.styles = styles self.prev = prev self.constraints = constraints self.enforce_constraints = enforce_constraints self.update_widgets = update_widgets self.addStyleName("clickable")
class SimpleTweetPanel(HorizontalPanel): def __init__(self, screennames, nUsers, topPanel): HorizontalPanel.__init__(self) self.screennames = screennames self.nUsers = nUsers self.topPanel = topPanel self.add(HTML(_title, StyleName='result-detail')) self.withButton = Button(_withAtText, self, StyleName='with-at-button') self.add(self.withButton) self.withoutButton = Button(_withoutAtText, self, StyleName='without-at-button') self.add(self.withoutButton) self.link = HTML() self.add(self.link) def onClick(self, sender): self.link.setText('') if sender == self.withButton: self.withButton.setEnabled(False) useAts = True else: self.withoutButton.setEnabled(False) useAts = False remote = server.TickeryService() id = remote.simpleTweet( self.topPanel.loginPanel.oauthCookie, self.screennames, self.nUsers, userlist._sortKey, useAts, self) if id < 0: self.link.setText('Oops!') def onRemoteResponse(self, response, request_info): self.withButton.setEnabled(True) self.withoutButton.setEnabled(True) if response['result']: self.link.setHTML('<a href="%s">%s</a>' % (response['URL'], _doneText)) else: self.link.setText('Oops: %r' % response) def onRemoteError(self, code, message, request_info): self.withButton.setEnabled(True) self.withoutButton.setEnabled(True) self.link.setText('Server Err or Invalid Response: ERROR %d - %s' % (code, message))
class TopPanel(Composite): def __init__(self): Composite.__init__(self) self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>") self.aboutLink = HTML("<a href='javascript:;'>About</a>") outer = HorizontalPanel() inner = VerticalPanel() outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) links = HorizontalPanel() links.setSpacing(4) links.add(self.signOutLink) links.add(self.aboutLink) outer.add(inner) inner.add(HTML("<b>Welcome back, [email protected]</b>")) inner.add(links) self.signOutLink.addClickListener(self) self.aboutLink.addClickListener(self) self.initWidget(outer) inner.setStyleName("mail-TopPanel") links.setStyleName("mail-TopPanelLinks") def onClick(self, sender): if (sender == self.signOutLink): Window.alert("If this were implemented, you would be signed out now.") elif (sender == self.aboutLink): # When the 'About' item is selected, show the AboutDialog. # Note that showing a dialog box does not block -- execution continues # normally, and the dialog fires an event when it is closed. dlg = AboutDialog() # Position it roughly in the middle of the screen. left = (Window.getClientWidth() - 512) / 2 top = (Window.getClientHeight() - 256) / 2 Logger("TopPanel", "left: %d" % left) Logger("TopPanel", "top: %d" % top) dlg.setPopupPosition(left, top) dlg.show()
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, 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 onModuleLoad(self): self.curInfo='' self.curSink=None self.description=HTML() self.sink_list=SinkList() self.panel=DockPanel() self.loadSinks() self.sinkContainer = DockPanel() self.sinkContainer.setStyleName("ks-Sink") vp=VerticalPanel() vp.setWidth("100%") vp.add(self.description) vp.add(self.sinkContainer) self.description.setStyleName("ks-Info") self.panel.add(self.sink_list, DockPanel.WEST) self.panel.add(vp, DockPanel.CENTER) self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP) self.panel.setCellWidth(vp, "100%") History.addHistoryListener(self) RootPanel().add(self.panel) RootPanel().add(Logger()) #Show the initial screen. initToken = History.getToken() if len(initToken): self.onHistoryChanged(initToken) else: self.showInfo()
def __init__(self): Sink.__init__(self) self.fPasswordText = PasswordTextBox() self.fTextArea = TextArea() self.fTextBox = TextBox() panel = VerticalPanel() panel.setSpacing(8) panel.add(HTML("Normal text box:")) panel.add(self.createTextThing(self.fTextBox)) panel.add(HTML("Password text box:")) panel.add(self.createTextThing(self.fPasswordText)) panel.add(HTML("Text area:")) panel.add(self.createTextThing(self.fTextArea)) panel.add(HTML("""Textarea below demos oninput event. oninput allows to detect when the content of an element has changed. This is different from examples above, where changes are detected only if they are made with keyboard. oninput occurs when the content is changed through any user interface(keyboard, mouse, etc.). For example, at first type few chars, but then paste some text to the text areas above and below by selecting 'Paste' command from context menu or by dragging&dropping and see the difference. oninput is similar to onchange event, but onchange event fires only when a text-entry widget loses focus.""")) vp = VerticalPanel() self.echo = HTML() textArea = TextArea() vp.add(textArea) vp.add(self.echo) textArea.addInputListener(self) panel.add(vp) self.initWidget(panel)