Example #1
0
    def onModuleLoad(self):

        self.label = Label("Not set yet")

        self.button = Button("Probe button", self)
        self.image_up = Image("./images/logo.png")
        self.image_up3 = Image("./images/logo.png")
        self.image_down = Image("./images/logo.png")
        self.image_down3 = Image("./images/logo.png")
        self.toggle = ToggleButton(self.image_up, self.image_down, self)
        self.toggle2 = ToggleButton("up", "down", getattr(self, "onToggleUD"))
        self.push = PushButton(self.image_up3, self.image_down3)

        self.vpanel = VerticalPanel()
        self.togglePanel = HorizontalPanel()
        self.togglePanel.setSpacing(10)

        self.togglePanel.add(self.toggle)
        self.togglePanel.add(self.toggle2)
        self.togglePanel.add(self.push)

        self.vpanel.add(self.label)
        self.vpanel.add(self.button)
        self.vpanel.add(self.togglePanel)

        RootPanel().add(self.vpanel)
        self.i = False
Example #2
0
 def __init__(self, text=None, forid=None, wordWrap=True, **kwargs):
     if not kwargs.has_key('Element'):
         element = DOM.createLabel()
         if forid: 
             element.setAttribute("for", forid)
         kwargs['Element'] = element
     Label.__init__(self, text, wordWrap, **kwargs)
Example #3
0
    def __init__(self):
        """ Constructs a new EditPanel.
        """
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"

        #        self.remote_py = RegionNamesServicePython()

        self.panel = VerticalPanel()

        top_panel = HorizontalPanel()
        top_panel.setSpacing(8)
        self.panel.add(top_panel)

        refresh = Button("Refresh", self)
        top_panel.add(refresh)

        self.status = Label()
        top_panel.add(self.status)

        edit_panel = HorizontalPanel()
        self.panel.add(edit_panel)

        self.tree = Tree()
        self.tree.addTreeListener(self)
        edit_panel.add(self.tree)

        upload_item = TreeItem("Upload")
        self.tree.add(upload_item)
        map_item = TreeItem("Map")
        self.tree.add(map_item)
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
Example #5
0
File: Gettext.py Project: Afey/pyjs
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))
Example #6
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))
Example #7
0
  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)
Example #8
0
        def validateEmployee(self, index, name, address, salary):
                valid = True

                if name == "":
                        self.errors.add(Label("- Enter a valid name, please."))
                        valid = False

                if address == "":
                        self.errors.add(Label("- Enter a valid address, please."))
                        valid = False

                if salary == "":
                        self.errors.add(Label("- Enter a valid salary, please."))
                        valid = False

                try:
                        float(salary)
                except ValueError:
                        self.errors.add(Label("- The salary must be a number. Enter a valid salary, please."))
                        valid = False
                        
                
                for item in self.app.employees:
                        if item.id != index and name == item.name and item.address == address:
                                self.errors.add(Label("- There is already an employee with the same name and address combination. Enter a valid name and address, please."))
                                valid = False
                return valid
Example #9
0
    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
Example #10
0
 def __init__(self, start_date, can_delete=True):
     # We need to use old form of inheritance because of pyjamas
     SimplePanel.__init__(self)
     self.vpanel = VerticalPanel()
     desc_panel = VerticalPanel()
     self.desc_box = TextBox()
     self.desc_box.setVisibleLength(44)
     self.desc_box.setStyleName('form-control')
     desc_lbl = Label('impediment description')
     desc_lbl.setStyleName('text-muted')
     desc_panel.add(self.desc_box)
     desc_panel.add(desc_lbl)
     # Set to False if loaded from database
     self.can_delete = can_delete
     
     status_panel = VerticalPanel()
     self.status_lst = ListBox(Height='34px')
     self.status_lst.setStyleName('form-control input-lg')
     self.status_lst.addItem('Open')
     self.status_lst.addItem('Closed')
     # we put date here
     
     self.status_lbl = Label('')
     self.set_start_date(start_date)
     self.status_lbl.setStyleName('text-muted')
     status_panel = VerticalPanel()
     status_panel.add(self.status_lst)
     status_panel.add(self.status_lbl)
     self.comment = Text_Area_Row('', 'why it exists or is being closed')
     hpanel = HorizontalPanel()
     hpanel.add(desc_panel)
     hpanel.add(Label(Width='10px'))
     hpanel.add(status_panel)
     self.vpanel.add(hpanel)
     self.vpanel.add(self.comment.panel())
Example #11
0
    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
Example #12
0
class Form_Row(SimplePanel):
    '''
    Create row that will be put in the Form
    '''
    def __init__(self, name, widget, help=''):
        SimplePanel.__init__(self)
        # Container
        self.mainpanel = VerticalPanel()

        self.lbl = Label(name)
        self.hlp = Label(help)
        self.lbl.setStyleName('h3')
        self.hlp.setStyleName('text-muted')
        
        self.wdg = widget
        self.mainpanel.add(self.lbl)
        self.mainpanel.add(self.wdg)
        self.mainpanel.add(self.hlp)
        
    def panel(self):
        return self.mainpanel

    def widget(self):
        return self.wdg

    def help(self):
        return self.hlp
Example #13
0
 def __init__(self, **kwargs):
     DialogWindow.__init__(self, modal=True, close=True)
     v = VerticalPanel()
     v.setWidth(300)
     # v.setHeight(500)
     self.setText("definition")
     self.setPopupPosition(100, 100)
     self.setStyleAttribute("background-color", "#ffffff")
     self.setStyleAttribute("color", "#9847a2")
     self.setStyleAttribute("border-width", "5px")
     self.setStyleAttribute("border-style", "solid")
     h = HorizontalPanel()
     self.textbox_name = TextBox()
     h.add(Label("name"))
     h.add(self.textbox_name)
     v.add(h)
     h = HorizontalPanel()
     self.textbox_scheme = TextBox()
     h.add(Label("print scheme"))
     h.add(self.textbox_scheme)
     v.add(h)
     self.add(v)
     self.theorems = list()
     self.radios = list()
     for t in Theorem.theorems:
         if t.formula.is_in_unique_form():
             self.theorems.append(t)
             self.radios.append(RadioButton("group1", ""))
             h = HorizontalPanel()
             h.add(self.radios[-1])
             im = Image()
             im.setUrl(latex_to_url(t.formula.to_latex()))
             h.add(im)
             v.add(h)
     v.add(Button("Done", self.done_click))
Example #14
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel()
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)
        self.url = "http://localhost/pyjamas_upload_demo"
        self.form.setAction(self.url)
        self.form.setTarget("results")

        vPanel = VerticalPanel()

        hPanel = HorizontalPanel()
        hPanel.setSpacing(5)
        hPanel.add(Label("Upload file:"))

        self.field = FileUpload()
        self.field.setName("file")
        hPanel.add(self.field)

        hPanel.add(Button("Submit", getattr(self, "onBtnClick")))
        vPanel.add(hPanel)

        self.simple = CheckBox("Simple mode?  ")
        #self.simple.setChecked(True)
        vPanel.add(self.simple)
        self.progress = Label('0%')

        results = NamedFrame("results")
        vPanel.add(results)
        vPanel.add(self.progress)

        self.form.add(vPanel)
        self.add(self.form)
Example #15
0
class EditPanel(AbsolutePanel):

    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()

    def clear_edit_panel(self):
        self.edit_title.setText("")
        self.edit_content.setText("")
        self.error_message_label.setText("")
Example #16
0
 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()
Example #17
0
    def __init__(self):

        # create the label and slider
        self.__label = Label('OFF')
        self.slider = slider = HorizontalSlider(0,
                                                5,
                                                step=1,
                                                StyleName="slider")
        slider.setDragable(True)
        slider.addControlValueListener(self)

        # put them in a hpanel
        self.hpanel = hpanel = HorizontalPanel(Spacing=10)
        hpanel.add(slider)
        hpanel.add(self.__label)

        # create the color panel and give it color
        self.colorpanel = CaptionPanel('Color:',
                                       SimplePanel(StyleName='colorpanel'))
        self.randomcolor()

        # we're initially off
        self.value = 0
        # create our timer
        self.timer = Timer(notify=self)
Example #18
0
 def __init__(self, n, limit):
     Label.__init__(self,
         "Sorry, your query had too many (%s) results! The current "
         "supported limit is %s." % (
                        utils.splitthousands(n),
                        utils.splitthousands(limit)),
         StyleName='userlist-error-title')
Example #19
0
    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 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()
Example #21
0
 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()
Example #22
0
 def addline(line):
     global curgroup, curgroupwidgets, curgrouphead, fp
     line = line.strip()
     line = line.replace("->", RARROW)
     if line.startswith("Installing "):
         # New group: 1
         if curgroup != 1: finishgroup()
         curgroup = 1
         curgroupwidgets.append(Label(line))
     elif line.startswith(RARROW):
         # New group: 2.
         if curgroup == 0:
             # The last line is still stored in curgroupwidgets. We use
             # it as the DisclosurePanel head.
             assert curgrouphead == None
             if curgroupwidgets == []:
                 curgrouphead = "unknown reduction"
             else:
                 assert len(curgroupwidgets) == 1
                 curgrouphead = curgroupwidgets[0].getText()
                 curgroupwidgets = []
         elif curgroup != 2:
             finishgroup()
         curgroup = 2
         curgroupwidgets.append(Label(line))
         # Window.alert(curgroupwidgets)
     else:
         # New group: 0
         finishgroup()
         curgroup = 0
         curgroupwidgets = [Label(line)]
Example #23
0
    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()
Example #24
0
class ParticleDemoControls (Composite):
    def __init__(self):
        self.average = 1
        self.iterations = 1
        self.startTime = -1

        self.refreshRateLabel = Label("")
        self.averageLabel = Label("")

        layout = VerticalPanel()
        layout.add(self.refreshRateLabel)
        layout.add(self.averageLabel)

        Composite.__init__(self, layout)

    def doBenchmark(self, now):
        if self.startTime < 0:
            self.startTime = now
        else:
            self.refreshRate = now - self.startTime
            self.startTime = now
            self.average = ((self.average * self.iterations) + self.refreshRate) / (self.iterations + 1)
            self.iterations += 1

            self.refreshRateLabel.setText("Refresh Interval: " + str(refreshRate))
            self.averageLabel.setText("Average Interval: " + str(average))



    def resetBenchmark(self):
        self.average = 1
        self.iterations = 1
        self.startTime = -1
Example #25
0
    def __init__(self):
        SimplePanel.__init__(self)

        panel = VerticalPanel(BorderWidth=1,
                              HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                              VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
                              Width="50%",
                              Height="300px")

        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.setCellHeight(part1, "10%")
        panel.setCellHeight(part2, "70%")
        panel.setCellHeight(part3, "10%")
        panel.setCellHeight(part4, "10%")

        panel.setCellHorizontalAlignment(part3, HasAlignment.ALIGN_RIGHT)

        self.add(panel)
Example #26
0
	def initCompanyGUI(self):
		self.current = self.app.company
	
		self.grid.clear()
		self.grid.resize(4, 3)
		
		# row 1
		self.grid.setWidget(0, 0, Label("Name:"))
		self.grid.setWidget(1, 0, Label("Department:"))
		self.grid.setWidget(2, 0, Label("Total:"))
		
		# row 2
		self.grid.setWidget(0, 1, self.name)
		self.grid.setWidget(1, 1, self.departments)
		self.grid.setWidget(2, 1, self.total)

		# row 3
		self.grid.setWidget(0, 2, self.save)
		self.grid.setWidget(1, 2, self.selectDepartment)
		self.grid.setWidget(2, 2, self.cut)
		
		self.name.setText(self.current.name)
		self.departments.clear()
		for item in self.current.departments:
			self.departments.addItem(item.name, item.id)
		if self.departments.getItemCount() > 0:
			self.departments.setSelectedIndex(0)
		self.total.setText(self.current.total())
Example #27
0
    def __init__(self):
        SimplePanel.__init__(self)

        panel = VerticalPanel()
        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.setCellHeight(part1, "10%")
        panel.setCellHeight(part2, "70%")
        panel.setCellHeight(part3, "10%")
        panel.setCellHeight(part4, "10%")

        panel.setCellHorizontalAlignment(part3, HasAlignment.ALIGN_RIGHT)

        panel.setWidth("50%")
        panel.setHeight("300px")

        self.add(panel)
Example #28
0
    def __init__(self, milestone_names, milestone_dates):
        # We need to use old form of inheritance because of pyjamas
        SimplePanel.__init__(self)
        self.milestone_dates = milestone_dates
       
        self.hpanel = HorizontalPanel()
        self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
        self.name = ListBox(Height='34px', Width='208px')
        self.name.setStyleName('form-control input-lg')
        self.name.addChangeListener(getattr(self, 'on_milestone_changed'))
       
        for m in milestone_names:
            self.name.addItem(m) 
        if len(self.milestone_dates) > 0:
            self.planned_completion = Label(self.milestone_dates[0])
        else:
            self.planned_completion = Label('Undefined')
            
        self.planned_completion.setStyleName('form-control text-normal')

        self.expected_completion = Report_Date_Field(cal_ID='end')
        self.expected_completion.getTextBox().setStyleName('form-control')
        self.expected_completion.setRegex(DATE_MATCHER)
        self.expected_completion.appendValidListener(self._display_ok)
        self.expected_completion.appendInvalidListener(self._display_error)
        self.expected_completion.validate(None)

        self.hpanel.add(self.name)
        self.hpanel.add(Label(Width='10px'))
        self.hpanel.add(self.planned_completion)
        self.hpanel.add(Label(Width='10px'))
        self.hpanel.add(self.expected_completion)
Example #29
0
class ParticleDemoControls(Composite):
    def __init__(self):
        self.average = 1
        self.iterations = 1
        self.startTime = -1

        self.refreshRateLabel = Label("")
        self.averageLabel = Label("")

        layout = VerticalPanel()
        layout.add(self.refreshRateLabel)
        layout.add(self.averageLabel)

        Composite.__init__(self, layout)

    def doBenchmark(self, now):
        if self.startTime < 0:
            self.startTime = now
        else:
            self.refreshRate = now - self.startTime
            self.startTime = now
            self.average = ((self.average * self.iterations) + self.refreshRate) / (self.iterations + 1)
            self.iterations += 1

            self.refreshRateLabel.setText("Refresh Interval: " + str(refreshRate))
            self.averageLabel.setText("Average Interval: " + str(average))

    def resetBenchmark(self):
        self.average = 1
        self.iterations = 1
        self.startTime = -1
Example #30
0
class QueueSize(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Queue size:', StyleName='section'))
        self.underway = Label()
        self.add(self.underway)
        self.queued = Label()
        self.add(self.queued)
        self.button = Button('Refresh', self, StyleName='refresh')
        self.add(self.button)
        self.err = Label()
        self.add(self.err)
        self.update()

    def update(self):
        remote = server.AdminService()
        id = remote.queueSize(self)
        if id < 0:
            self.err.setText('oops: could not call getQueueSize')

    def onRemoteResponse(self, result, request_info):
        self.button.setEnabled(True)
        underway, queued = result
        self.underway.setText('Underway: %d' % underway)
        self.queued.setText('Queued: %d' % queued)

    def onRemoteError(self, code, message, request_info):
        self.button.setEnabled(True)
        self.err.setText('Could not getQueueWidth: ' + message)

    def onClick(self, sender):
        self.err.setText('')
        self.button.setEnabled(False)
        self.update()
Example #31
0
 def __init__(self, ctype, data):
     Label.__init__(self)
     AddablePanel.__init__(self)
     self.setStyleName('content_text')
     self.setText("'%s' content:" % ctype)
     self.content = HTML(data, StyleName='content')
     self.append(self.content)
Example #32
0
 def __init__(self, ctype, data):
     Label.__init__(self)
     AddablePanel.__init__(self)
     self.setStyleName('content_text')
     self.setText("'%s' content:" % ctype)
     self.content = HTML(data, StyleName='content')
     self.append(self.content)
Example #33
0
    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])
Example #34
0
class WritePanel(AbsolutePanel):

    def __init__(self, parent):
        AbsolutePanel.__init__(self)
        self.post_header = Label("Write a Post", StyleName="header_label")
        self.post_write_title_label = Label("Title:")
        self.post_title = TextBox()
        self.post_content = TextArea()
        self.post_button = Button("Post")
        self.cancel_button = Button("Cancel")
        self.error_message_label = Label("", StyleName="error_message_label")
        contents = VerticalPanel(StyleName="Contents", Spacing=4)
        contents.add(self.post_header)
        contents.add(self.post_write_title_label)
        contents.add(self.post_title)
        contents.add(self.post_content)
        contents.add(self.post_button)
        contents.add(self.cancel_button)
        contents.add(self.error_message_label)
        self.dialog = DialogBox(glass=True)
        self.dialog.setHTML('<b>Blog Post Form</b>')
        self.dialog.setWidget(contents)
        left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
        self.dialog.setPopupPosition(left, top)
        self.dialog.hide()

    def clear_write_panel(self):
        self.post_title.setText("")
        self.post_content.setText("")
        self.error_message_label.setText("")
Example #35
0
class BrowserDetect:
    def onModuleLoad(self):
        self.l = Label()
        RootPanel().add(self.l)
        self.display()

    def display(self):
        self.l.setText("Browser not detected/supported")
Example #36
0
 def addRow(self, values):
     self.rows += 1
     col = -1
     for name, maxLength, visibleLength in self.columns:
         col += 1
         label = Label()
         label.setText(values[col])
         self.setWidget(self.rows, col, label)
Example #37
0
 def __init__(self, countdown=1000):
     Timer.__init__(self)
     Label.__init__(self)
     self.countdown = countdown
     self.task_id = None
     self.wait_cnt = 0
     self.remote_py = \
         EchoServicePython(server="flask", flask_view_type="celery")
Example #38
0
 def __init__(self, countdown=1000):
     Timer.__init__(self)
     Label.__init__(self)
     self.countdown = countdown
     self.task_id = None
     self.wait_cnt = 0
     self.remote_py = \
         EchoServicePython(server="flask", flask_view_type="celery")
Example #39
0
 def addRow(self, values):
     self.rows += 1
     col = -1
     for name, maxLength, visibleLength in self.columns:
         col += 1
         label = Label()
         label.setText(values[col])
         self.setWidget(self.rows, col, label)
Example #40
0
 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)
Example #41
0
 def __init__(self, name, age):
     #Label.__init__(self, Element=DOM.createElement('div'))
     #self.dragHandler = DragHandler()
     #self.dragHandler.addDragListener(self)
     Label.__init__(self, Element=DOM.createElement('li'))
     self.student_name = name
     self.age = int(age)
     self.setText("%s (%s)" % (self.student_name, self.age))
     self.setStyleName('dragme')
Example #42
0
 def __init__(self, name, age):
     #Label.__init__(self, Element=DOM.createElement('div'))
     #self.dragHandler = DragHandler()
     #self.dragHandler.addDragListener(self)
     Label.__init__(self, Element=DOM.createElement('li'))
     self.student_name = name
     self.age = int(age)
     self.setText("%s (%s)" % (self.student_name, self.age))
     self.setStyleName('dragme')
Example #43
0
 def onRemoteResponse(self, response, request_info):
     if (isinstance(response, (dict, ))):
         if ("echo" in response):
             msg = "Celery echo: %s\nElapsed Time: %d"
             self.setText(msg % (response["echo"], self.wait_cnt))
         else:
             msg = "Waiting for Celery (id, checkno): %s, %d"
             Label.setText(self, msg % (self.task_id, self.wait_cnt))
     else:
         self.setText("Could not get remote response as a dictionary")
Example #44
0
 def onRemoteResponse(self, response, request_info):
     if(isinstance(response, (dict,))):
         if("echo" in response):
             msg = "Celery echo: %s\nElapsed Time: %d"
             self.setText(msg % (response["echo"], self.wait_cnt))
         else:
             msg = "Waiting for Celery (id, checkno): %s, %d"
             Label.setText(self, msg % (self.task_id, self.wait_cnt))
     else:
         self.setText("Could not get remote response as a dictionary")
Example #45
0
 def addGroup(self, sender):
     self.listPanel.setVisible(True)
     op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-group-op', Visible=False)
     op.addClickListener(getattr(self, 'invertOperator'))
     if len(self.children) > 0 or len(self.parameters) > 0: op.setVisible(True)
     self.childPanel.add(op)
     self.childPanel.setCellHorizontalAlignment(op, 'right')
     g = ParamGroup(self.childPanel, self.kind, self, self.level+1)
     g.op = op
     self.children.append(g)
Example #46
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)
Example #47
0
class AuthPanel(VerticalPanel):
    def __init__(self, beginVerifyAuth, onClose, baseStyleName='gwt-authdlgbox'):
        """Initialize a new instance.

        beginVerifyAuth: callable that takes (string username, string password).Should call 'endVerifyAuth' when
        finished.
        onClose: callable that takes (AuthDlgBox sender, bool wasAuthorized, string username, string password).  Called
        when Cancel is pressed, or OK is pressed and verification is successful.
        baseStyleName: base css name for type.  baseStyleName + -label, -textbox, and -warninglabel should also be
        defined.
        """
        VerticalPanel.__init__(self, StyleName=baseStyleName)
        self.onClose = onClose
        self.wasAuthorized = False
        self._beginVerifyAuth = beginVerifyAuth
        self.baseStyleName = baseStyleName
        self._createContent()
    def _createContent(self):
        self.add(self._createUsernamePanel())
        self.add(self._createPasswordPanel())
        self.add(self._createButtonPanel())
        self.warningLabel = Label('', StyleName='-warninglabel')
        self.add(self.warningLabel)
    def _createUsernamePanel(self):
        hp = HorizontalPanel()
        hp.add(Label('Username: '******'-label'))
        self.usernameTB = TextBox(StyleName=self.baseStyleName + '-textbox')
        hp.add(self.usernameTB)
        return hp
    def _createPasswordPanel(self):
        hp = HorizontalPanel()
        hp.add(Label('Password: '******'-label'))
        self.passTB = PasswordTextBox(StyleName=self.baseStyleName + '-textbox')
        hp.add(self.passTB)
        return hp
    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 getUserAndPass(self):
        return self.usernameTB.getText(), self.passTB.getText()
    def onOk(self, sender):
        self._beginVerifyAuth(*self.getUserAndPass())
        return
    def onCancel(self, sender):
        self.onClose(self, False, None, None)
        return
    def endVerifyAuth(self, result, username, password, msg='Username/password invalid.'):
        if result:
            self.onClose(self, True, username, password)
        else:
            self.warningLabel.setText(msg)
Example #48
0
    def __init__(self, text=None, listener=None, **kwargs):
        if not kwargs.has_key("Element"):
            element = DOM.createElement("a")
            element.setAttribute("href", "javascript:void(0)")
            kwargs["Element"] = element
        if not kwargs.has_key("StyleName"):
            kwargs["StyleName"] = "pseudolink"

        Label.__init__(self, text, True, **kwargs)
        if listener:
            self.addClickListener(listener)
Example #49
0
class PauseResume(HorizontalPanel):
    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()

    def _refresh(self):
        self.refresh.setEnabled(False)
        self.pause.setEnabled(False)
        self.resume.setEnabled(False)
        remote = server.AdminService()
        id = remote.queuePaused(self)
        if id < 0:
            self.err.setText('oops: could not call getQueueSize')

    def onClick(self, sender):
        self.err.setText('')
        if sender is self.refresh:
            self._refresh()
        elif sender is self.pause:
            self._pause()
        else:
            self._resume()

    def _pause(self):
        remote = server.AdminService()
        id = remote.pause(Paused(self))
        if id < 0:
            self.err.setText('oops: could not call pause.')

    def _resume(self):
        remote = server.AdminService()
        id = remote.resume(Resumed(self))
        if id < 0:
            self.err.setText('oops: could not call resume.')
            
    def onRemoteResponse(self, paused, request_info):
        self.refresh.setEnabled(True)
        if paused:
            self.resume.setEnabled(True)
        else:
            self.pause.setEnabled(True)

    def onRemoteError(self, code, message, request_info):
        self.refresh.setEnabled(True)
        self.err.setText('Error from queuePaused: ' + message)
Example #50
0
    def onRemoteError(self, code, message, request_info):
        """ Called when a returned response is invalid or Server Error
        """
        code = str(code)
        message = str(message)

        if len(code) > 200: code = code[0:200] + "..."
        if len(message) > 200: message = message[0:200] + "..."

        err_msg = Label("Server Error or invalid response: ERROR " + str(code) + " - " + str(message))
        err_msg.addStyleName("status")
        Window.alert(err_msg.getText())
Example #51
0
 def __init__(self):
     HorizontalPanel.__init__(self, Spacing=4)
     self.add(Label('Queue size:', StyleName='section'))
     self.underway = Label()
     self.add(self.underway)
     self.queued = Label()
     self.add(self.queued)
     self.button = Button('Refresh', self, StyleName='refresh')
     self.add(self.button)
     self.err = Label()
     self.add(self.err)
     self.update()
Example #52
0
    def __init__(self):
        self.remote_case = CaseService()

        self.base_panel = VerticalPanel()
        self.tab_panel = TabPanel()
        self.base_panel.add(self.tab_panel)
        self.tab_panel.add(self.get_case_panel(), "Case")
        self.tab_panel.add(self.get_buses_panel(), "Buses")
        self.tab_panel.selectTab(0)
        self.status = Label()
        self.base_panel.add(self.status)
        RootPanel().add(self.base_panel)
Example #53
0
    def __init__(self):

        # the button
        self.button = Button(listener=self)
        # set an attr on the button to keep track of its state
        self.button.stop = False
        # date label
        self.datelabel = Label(StyleName='clock')
        # the timer
        self.timer = Timer(notify=self.updateclock)
        # kick start
        self.onClick(self.button)
Example #54
0
 def addParam(self, sender):
     self.listPanel.setVisible(True)
     op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-param-op', Visible=False)
     op.addClickListener(getattr(self, 'invertOperator'))
     if len(self.parameters) > 0: op.setVisible(True)
     self.paramPanel.add(op)
     self.paramPanel.setCellHorizontalAlignment(op, 'right')
     k = self.kind[self.paramChooser.getSelectedValues()[0]]
     p = Param(self.paramPanel, k, self)
     p.op = op
     self.parameters.append(p)
     if len(self.children) > 0:
         self.children[0].op.setVisible(True)
Example #55
0
    def __init__(self):
        self.average = 1
        self.iterations = 1
        self.startTime = -1

        self.refreshRateLabel = Label("")
        self.averageLabel = Label("")

        layout = VerticalPanel()
        layout.add(self.refreshRateLabel)
        layout.add(self.averageLabel)

        Composite.__init__(self, layout)
Example #56
0
    def __init__(self, name, widget, help=''):
        SimplePanel.__init__(self)
        # Container
        self.mainpanel = VerticalPanel()

        self.lbl = Label(name)
        self.hlp = Label(help)
        self.lbl.setStyleName('h3')
        self.hlp.setStyleName('text-muted')
        
        self.wdg = widget
        self.mainpanel.add(self.lbl)
        self.mainpanel.add(self.wdg)
        self.mainpanel.add(self.hlp)
Example #57
0
class CookieExample:
    COOKIE_NAME = "myCookie"

    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 onClick(self, sender):
        """
        Run when any button is clicked
        """
        if sender.getText() == "Set Cookie":
            # clicked the set cookie button
            text = self.text_area.getText()
            # print goes to console.log
            print "setting cookie to:", text
            # Note: this sets the cookie on the top level
            setCookie(COOKIE_NAME, text, 10000, path="/")
        else:
            cookie_text = getCookie(COOKIE_NAME)
            if cookie_text is None:
                print "No Cookie"
            else:
                print "myCookie", cookie_text
                self.status.setText(cookie_text)
Example #58
0
class Clock:

    # pyjamas doesn't generate __doc__
    __doc__ = '''This demonstrates using Timer instantiated with the
    notify keyword, as in:<pre> timer = Timer(notify=func) </pre>When
    the timer fires it will call func() with no arguments (or
    <code>self</code> if it is a bound method as in this example).
    This timer is scheduled with the <code>scheduleRepeating()</code>
    method, so after func() is called, it is automatically rescheduled
    to fire again after the specified period.  The timer can be
    cancelled by calling the <code>cancel()</code> method; this
    happens when you click on the button.
    '''

    
    start_txt = 'Click to start the clock'
    stop_txt = 'Click to stop the clock'
    
    def __init__(self):

        # the button
        self.button = Button(listener=self)
        # set an attr on the button to keep track of its state
        self.button.stop = False
        # date label
        self.datelabel = Label(StyleName='clock')
        # the timer
        self.timer = Timer(notify=self.updateclock)
        # kick start
        self.onClick(self.button)

    def onClick(self, button):
        if self.button.stop:
            # we're stopping the clock
            self.button.stop = False
            self.timer.cancel()
            self.button.setText(self.start_txt)
        else:
            # we're starting the clock
            self.button.stop = True
            self.timer.scheduleRepeating(1000)
            self.button.setText(self.stop_txt)

    def updateclock(self, timer):

        # the callable attached to the timer with notify
        dt = datetime.now().replace(microsecond=0)
        self.datelabel.setText(dt.isoformat(' '))