当前位置: 首页>>代码示例>>Python>>正文


Python Label.getText方法代码示例

本文整理汇总了Python中pyjamas.ui.Label.Label.getText方法的典型用法代码示例。如果您正苦于以下问题:Python Label.getText方法的具体用法?Python Label.getText怎么用?Python Label.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.Label.Label的用法示例。


在下文中一共展示了Label.getText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onRemoteError

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
    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())
开发者ID:cy245,项目名称:TextbookConnect,代码行数:14,代码来源:page_verify.py

示例2: FileUploadPanel

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
class FileUploadPanel(SimplePanel):
    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)

    def onBtnClick(self, event):
        self.progress.setText('0%')
        if self.simple.isChecked():
            self.form.submit()
        else:
            if AsyncUpload.is_old_browser():
                Window.alert("Hmmm, your browser doesn't support this.")
            else:
                el = self.field.getElement()
                files = getattr(el, 'files')
                #TODO implement loop for multiple file uploads 
                file = JS("@{{files}}[0]") #otherwise pyjs thinks it's a string?
                AsyncUpload.asyncUpload(self.url, file, self)

    def onload(self, status):
        self.progress.setText('100%')

    def onerror(self, status):
        Window.alert("oh noes we got an " + str(status))

    def onprogress(self, loaded, total):
        if self.progress.getText() == '100%': return
        progress = (loaded / total)
        p = int(progress * 100)
        self.progress.setText(str(p) + '%')
开发者ID:brodybits,项目名称:pyjs,代码行数:63,代码来源:Upload.py

示例3: onModuleLoad

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
class SoftChordApp:
    def onModuleLoad(self):
        """
        Gets run when the page is first loaded.
        Creates the widgets.
        """

        self.remote = DataService()
        
        main_layout = VerticalPanel()

        h_layout = HorizontalPanel()
        h_layout.setPadding(10)
        
        songlist_layout = VerticalPanel()
        
        songlist_layout.add(Label("Add New Song:"))
 	

        self.newSongTextBox = TextBox()
	self.newSongTextBox.addKeyboardListener(self)
        songlist_layout.add(self.newSongTextBox)
        
       	self.addSongButton = Button("Add Song")
	self.addSongButton.addClickListener(self)
	songlist_layout.add(self.addSongButton)

        #songlist_layout.add(Label("Click to Remove:"))

        self.songListBox = ListBox()
        self.songListBox.setVisibleItemCount(7)
        self.songListBox.setWidth("300px")
        self.songListBox.setHeight("400px")
        self.songListBox.addClickListener(self)
        songlist_layout.add(self.songListBox)
        
        self.deleteSongButton = Button("Delete")
        self.deleteSongButton.addClickListener(self)
        songlist_layout.add(self.deleteSongButton)
         
        h_layout.add(songlist_layout)
        
        #self.textArea = TextArea()
        #self.textArea.setCharacterWidth(30)
        #self.textArea.setVisibleLines(50)
        #h_layout.add(self.textArea)
        
        #self.scrollPanel = ScrollPanel(Size=("400px", "500px"))
        self.songHtml = HTML("<b>Please select a song in the left table</b>")
        #self.scrollPanel.add(self.songHtml)
        #h_layout.add(self.scrollPanel)
        h_layout.add(self.songHtml)
        
        main_layout.add(h_layout)
        
        self.status = Label()
        main_layout.add(self.status)
        
        RootPanel().add(main_layout)
        
        # Populate the song table:
        self.remote.getAllSongs(self)
    

    def onKeyUp(self, sender, keyCode, modifiers):
        pass

    def onKeyDown(self, sender, keyCode, modifiers):
        pass

    def onKeyPress(self, sender, keyCode, modifiers):
        """
        This functon handles the onKeyPress event
        """
        if keyCode == KeyboardListener.KEY_ENTER and sender == self.newSongTextBox:
            id = self.remote.addSong(self.newSongTextBox.getText(), self)
            self.newSongTextBox.setText("")

            if id<0:
                self.status.setText("Server Error or Invalid Response")

    def onClick(self, sender):
        """
        Gets called when a user clicked in the <sender> widget.
        Currently deletes the song on which the user clicked.
        """
        if sender == self.songListBox:
            song_id = self.songListBox.getValue(self.songListBox.getSelectedIndex())
            self.status.setText("selected song_id: %s" % song_id)
            id = self.remote.getSong(song_id, self)
            if id<0:
                self.status.setText("Server Error or Invalid Response")
        
	elif sender == self.addSongButton:
            id = self.remote.addSong(self.newSongTextBox.getText(), self)
            self.newSongTextBox.setText("")
            if id<0:
                self.status.setText("Server Error or Invalid Response")
 
        elif sender == self.deleteSongButton:
#.........这里部分代码省略.........
开发者ID:academicsam,项目名称:softChord,代码行数:103,代码来源:softchordapp.py

示例4: Milestones_Row

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
class Milestones_Row(SimplePanel):
    '''
    Create and edit projects
    '''
    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)
        
    def get_name_txt(self):
        '''Return project name.
        '''
        return self.name.getText()


    def get_milestone_data(self):
        '''Get milestone data and return in the form suitable for passing to
        the model.
        '''
        name = self.name.getItemText(self.name.getSelectedIndex())
        planned_completion = self.planned_completion.getText()
        expected_completion = self.expected_completion.getTextBox().getText()
        return (name, planned_completion, expected_completion)

    def _display_ok(self, obj):
        obj.setStyleName('form-input')

    def _display_error(self, obj):
        if len(obj.getTextBox().getText()) > 0:
            obj.setStyleName('form-group has-error')
        
    def on_milestone_changed(self, event):
        '''
        Change completion date if milestone changed
        '''
        ind = self.name.getSelectedIndex()
        self.planned_completion.setText(self.milestone_dates[ind])
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:67,代码来源:form.py

示例5: Impediments

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
class Impediments(SimplePanel):
    '''
    Create and edit projects
    '''
    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())

    def set_start_date(self, start_date):
        date_str = 'added on: ' + start_date
        self.status_lbl.setText(date_str)

    def get_impediment_data(self):
        '''Get impediment data as a list suitable to passing to model.
        '''
        desc = self.desc_box.getText()
        comment = self.comment.widget().getText()
        state = self.status_lst.getItemText(self.status_lst.getSelectedIndex())
        lbl_text = self.status_lbl.getText()
        #
        ind = lbl_text.find(':') + 1
        # We need just date
        start_date = lbl_text[ind:].strip()
        if state == 'Open':
            end_date = None
        else:
            end_date = datetime.date.today().strftime('%d/%m/%Y')
        
        return (desc, comment, start_date, end_date, state)
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:63,代码来源:form.py

示例6: onModuleLoad

# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import getText [as 别名]
class TodoApp:
    def onModuleLoad(self):
        self.remote = DataService()
        panel = VerticalPanel()

        self.todoTextBox = TextBox()
        self.todoTextBox.addKeyboardListener(self)

        self.todoList = ListBox()
        self.todoList.setVisibleItemCount(7)
        self.todoList.setWidth("200px")
        self.todoList.addClickListener(self)

        panel.add(Label("Add New Todo:"))
        panel.add(self.todoTextBox)
        panel.add(Label("Click to Remove:"))
        panel.add(self.todoList)

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

        RootPanel().add(panel)



    def onKeyUp(self, sender, keyCode, modifiers):
        pass

    def onKeyDown(self, sender, keyCode, modifiers):
        pass

    def onKeyPress(self, sender, keyCode, modifiers):
        """
        This functon handles the onKeyPress event, and will add the item in the text box to the list when the user presses the enter key.  In the future, this method will also handle the auto complete feature.
        """
        if keyCode == KeyboardListener.KEY_ENTER and sender == self.todoTextBox:
            id = self.remote.addTask(sender.getText(),self)
            sender.setText("")

            if id<0:
                self.status.setText("Server Error or Invalid Response")


    def onClick(self, sender):
        id = self.remote.deleteTask(sender.getValue(sender.getSelectedIndex()),self)
        if id<0:
            self.status.setText("Server Error or Invalid Response")

    def onRemoteResponse(self, response, request_info):
        self.status.setText("response received")
        if request_info.method == 'getTasks' or request_info.method == 'addTask' or request_info.method == 'deleteTask':
            self.status.setText(self.status.getText() + "HERE!")
            self.todoList.clear()
            for task in response:
                self.todoList.addItem(task[0])
                self.todoList.setValue(self.todoList.getItemCount()-1,task[1])
        else:
            self.status.setText(self.status.getText() + "none!")

    def onRemoteError(self, code, errobj, request_info):
        message = errobj['message']
        self.status.setText("Server Error or Invalid Response: ERROR %s - %s" % (code, message))
开发者ID:Afey,项目名称:pyjs,代码行数:64,代码来源:TodoApp.py


注:本文中的pyjamas.ui.Label.Label.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。