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


Python ListBox.setStyleName方法代码示例

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


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

示例1: onModuleLoad

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
    def onModuleLoad(self):
        '''Create initial view of the panel.
        '''
        # Container that keeps everything
        self.panel = VerticalPanel()
        self.panel.setSpacing(10)

        # Create list of projects 
        proj_list = ListBox(Height='34px')
       
        proj_list.addItem('')
       
        proj_list.setVisibleItemCount(0)
        proj_list.addChangeListener(getattr(self, 'on_project_changed'))
        proj_list.setStyleName('form-control input-lg')
        
        self.proj_row = Form_Row('Select project',
                            proj_list,
                            help='project, status of which you want to report')
        
        # Project-specific container
        self.project_panel = VerticalPanel()

        # Submit report button
        self.submit_btn = Button('Submit report', getattr(self, 'send_data'))
        self.submit_btn.setStyleName('btn btn-primary btn-lg')
        self.submit_btn.setEnabled(False)

        self.msg_lbl = HTMLPanel('', Width='475px')

        # Add controls here
        self.panel.add(self.proj_row.panel())
        self.panel.add(self.project_panel)
        self.panel.add(Label(Height='20px'))
        self.panel.add(self.msg_lbl)
        btn_holder = HorizontalPanel()
        btn_holder.add(self.submit_btn)
        help_btn = HTMLPanel('')

        help_btn.setHTML(MODAL_PNL)
        btn_holder.add(Label(Width='10px'))
        btn_holder.add(help_btn)
        self.panel.add(btn_holder)
        
        self.root = RootPanel('report')
        self.root.add(self.panel)
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:48,代码来源:form.py

示例2: Projects_Editor

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
class Projects_Editor(SimplePanel):
    '''
    Create and edit projects
    '''
    def __init__(self):
        # We need to use old form of inheritance because of pyjamas
        SimplePanel.__init__(self)
        self.hpanel = HorizontalPanel(Width='475px')
        self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM)
        
        self.name = TextBox()
        self.name.setStyleName('form-control')
        
        self.status = ListBox()
        self.status.addItem('Active')
        self.status.addItem('Inactive')
        self.status.setVisibleItemCount(0)
        self.status.setStyleName('form-control input-lg')
        self.status.setSize('100px', '34px')
        
        lbl = Label('', Width='10px')

        self.add_btn = Button('Add')
        self.add_btn.setStyleName('btn btn-primary')
        self.del_btn = Button('Delete')
        self.del_btn.setStyleName('btn btn-danger')

        self.hpanel.add(self.name)
        self.hpanel.add(lbl)
        self.hpanel.add(self.status)
        self.hpanel.add(self.add_btn)
        self.hpanel.add(self.del_btn)

 
    def get_name_txt(self):
        '''Return project name.
        '''
        return self.name.getText()

    def get_status(self):
        '''Return project status.
        '''
        return self.status.getItemText(self.status.getSelectedIndex())
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:45,代码来源:projects.py

示例3: onModuleLoad

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
    def onModuleLoad(self):

        self.layout = HorizontalPanel()

        # Each demo will set their own dimensions, so it doesn't matter
        # what we initialize the canvas to.
        canvas = GWTCanvas(400,400)

        canvas.addStyleName("gwt-canvas")

        self.demos = []
        # Create demos
        self.demos.append(StaticDemo(canvas))
        self.demos.append(LogoDemo(canvas))
        self.demos.append(ParticleDemo(canvas))
        self.demos.append(GradientDemo(canvas))
        self.demos.append(SuiteDemo(canvas))

        # Add them to the selection list box
        lb = ListBox()
        lb.setStyleName("listBox")

        for i in range(len(self.demos)):
            lb.addItem(self.demos[i].getName())

        lb.addChangeListener(self)

        # start off with the first demo
        self.currentDemo = self.demos[0]

        # Add widgets to self.layout and RootPanel
        vp = VerticalPanel()
        vp.add(lb)
        vp.add(canvas)
        self.layout.add(vp)
        if self.currentDemo.getControls() is not None:
            self.layout.add(self.currentDemo.getControls())

        RootPanel().add(self.layout)
        self.currentDemo.drawDemo()
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:42,代码来源:GWTCanvasDemo.py

示例4: MechOptionPanel

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
class MechOptionPanel(HorizontalPanel):
    def __init__(self, handle, idx, checkOptions = [False, True]):
        HorizontalPanel.__init__(self)
        self.log = logging.getConsoleLogger(type(self).__name__, lev)
        self.log.disabled = False
        self.log.debug('__init__: Instantiation')
        self.idx = idx
        self._handle = handle
        self._checkOptions = checkOptions
        self.setStyleName('os-mech-checkbox-options')
        #checkbox = CheckBox('symbol')
        #checkbox.setChecked(checkOptions[0])
        #checkbox.addClickListener(self.onClickOption)
        #checkbox.setID('CBSY%d'%idx)
        #self.append(checkbox)
        #checkbox = CheckBox('value')
        #checkbox.setChecked(checkOptions[1])
        #checkbox.addClickListener(self.onClickOption)
        #checkbox.setID('CBVA%d'%idx)
        #self.append(checkbox)
        
        self._textBoxRatio = TextBox('1:1')
        self._ratioCache = self._textBoxRatio.getText()
        self._textBoxRatio.setTitle('Ratio')
        self._ratioCache = self._textBoxRatio.getText()
        
        self._textBoxRatio.addChangeListener(self.onRatioChange) 
        self._textBoxRatio.setID('TXRT%d'%idx)
        self._textBoxRatio.setStyleName('os-mech-textbox-ratio')
        
        self._listBoxSize = ListBox()
        self._listBoxSize.addChangeListener(self.onSizeSet)
        self._listBoxSize.setVisibleItemCount(1)
        self._listBoxSize.setStyleName('os-mech-listbox-size')

        self._listBoxUnit = ListBox()
        self._listBoxUnit.addChangeListener(self.onUnitSet)
        self._listBoxUnit.setVisibleItemCount(1)
        self._listBoxUnit.setStyleName('os-mech-listbox-unit')

        self.append(Label('Ratio'))
        self.append(self._textBoxRatio)
        self.append(Label('Size'))
        self.append(self._listBoxSize)
        self.append(Label('Unit'))
        self.append(self._listBoxUnit)
    def onSizeSet(self, sender, event):
        value = sender.getSelectedItemText()[0]
        self.log.debug('Change size to %s'%value)
        self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'size', value)
    def onUnitSet(self, sender, event):
        value = sender.getSelectedValues()[0]
        self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'unit',int(value))
    def onRatioChange(self, sender, event):
        #validate ratio change
        matches = re.findall(r'^\d{1,4}:\d{1,4}$', self._textBoxRatio.getText())
        if len(matches) == 1: # correct
            self._ratioCache = self._textBoxRatio.getText()
            self._handle.remoteService.mech_options_set(self._handle._handle, self.idx, 'ratio', self._ratioCache)
        else: # invalid
            self._textBoxRatio.setText(self._ratioCache)
    def actSizeFill(self, options, value = 0):
        for idx, option in enumerate(options, idx):
            self._listBoxSize.addItem(option, idx)
        self._listBoxSize.setSelectedIndex(value)
    def actUnitFill(self, options, value = 0):
        for number, name in options.items():
            self._listBoxUnit.addItem(name, number)
        if value < 100000:
            self._listBoxUnit.setSelectedIndex(value)
        else:
            self._listBoxUnit.selectValue(value)
    def actSizeSet(self, value):
        self.log.debug('actSizeSet, setting value %s'%value)
        self._listBoxSize.selectValue(value)
    def actRatioChange(self, ratio):
        self._textBoxRatio.setText(ratio)
        self._ratioCache = ratio
    def onClickOption(self, sender, event):
        sendId = int(sender.getID()[4:])
        if sendId == 0:
            self._checkOptions[0] = sender.isChecked()
            self._checkOptions[1] = not(sender.isChecked())
        else:
            self._checkOptions[0] = not(sender.isChecked())
            self._checkOptions[1] = sender.isChecked()
        checkbox = self.getWidget(0)
        checkbox.setChecked(self._checkOptions[0])
        checkbox = self.getWidget(1)
        checkbox.setChecked(self._checkOptions[1])
        self._handle.remoteService.mech_options_set(self._handle._handle, self.idx,  'checkOptions', self._checkOptions)
开发者ID:OneSolver,项目名称:onesolver,代码行数:93,代码来源:Drawing.py

示例5: AutoCompleteTextBox

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
class AutoCompleteTextBox(TextBox):
    def __init__(self, **kwargs):
        self.choicesPopup = PopupPanel(True, False)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        self.choices.addClickListener(self)
        self.choices.addChangeListener(self)

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")
            
        self.choices.setStyleName("list")

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-AutoCompleteTextBox"

        TextBox.__init__(self, **kwargs)
        self.addKeyboardListener(self)

    def setCompletionItems(self, items):
        if not hasattr(items, 'getCompletionItems'):
            items = SimpleAutoCompletionItems(items)
        
        self.items = items

    def getCompletionItems(self):
        return self.items

    def onKeyDown(self, arg0, arg1, arg2):
        pass

    def onKeyPress(self, arg0, arg1, arg2):
        pass

    def onKeyUp(self, arg0, arg1, arg2):
        if arg1 == KeyboardListener.KEY_DOWN:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex += 1
            if selectedIndex >= self.choices.getItemCount():
                selectedIndex = 0
            self.choices.setSelectedIndex(selectedIndex)           
            return

        if arg1 == KeyboardListener.KEY_UP:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex -= 1
            if selectedIndex < 0:
                selectedIndex = self.choices.getItemCount() - 1
            self.choices.setSelectedIndex(selectedIndex)
            return

        if arg1 == KeyboardListener.KEY_ENTER:
            if self.visible:
                self.complete()      
            return

        if arg1 == KeyboardListener.KEY_ESCAPE:
            self.choices.clear()
            self.choicesPopup.hide()
            self.visible = False
            return

        text = self.getText()
        matches = []
        if len(text) > 0:
            matches = self.items.getCompletionItems(text)

        if len(matches) > 0:
            self.choices.clear()

            for i in range(len(matches)):
                self.choices.addItem(matches[i])
                
            if len(matches) == 1 and matches[0] == text:
                self.choicesPopup.hide()
            else:
                self.choices.setSelectedIndex(0)
                self.choices.setVisibleItemCount(len(matches) + 1)
                    
                if not self.popupAdded:
                    RootPanel().add(self.choicesPopup)
                    self.popupAdded = True

                self.choicesPopup.show()
                self.visible = True
                self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
                self.choices.setWidth("%dpx" % self.getOffsetWidth())
        else:
            self.visible = False
            self.choicesPopup.hide()

    def onChange(self, arg0):
        self.complete()

    def onClick(self, arg0):
        self.complete()

    def complete(self):
#.........这里部分代码省略.........
开发者ID:anandology,项目名称:pyjamas,代码行数:103,代码来源:AutoComplete.py

示例6: Milestones_Row

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [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

示例7: Impediments

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [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

示例8: Milestones_Editor

# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import setStyleName [as 别名]
class Milestones_Editor(SimplePanel):
    '''
    Create and edit projects
    '''
    def __init__(self):
        # We need to use old form of inheritance because of pyjamas
        SimplePanel.__init__(self)
        self.hpanel = HorizontalPanel(Width='755px')
        self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
        
        self.name = TextBox()
        self.name.setStyleName('form-control')

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

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

        self.status = ListBox()
        self.status.addItem('Active')
        self.status.addItem('Inactive')
        self.status.setVisibleItemCount(0)
        self.status.setStyleName('form-control input-lg')
        self.status.setSize('100px', '34px')
        
        spacer1 = Label(Width='10px')
        spacer2 = Label(Width='10px')
        spacer3 = Label(Width='10px')

        self.add_btn = Button('Add')
        self.add_btn.setStyleName('btn btn-primary')
        self.del_btn = Button('Delete')
        self.del_btn.setStyleName('btn btn-danger')

        self.hpanel.add(self.name)
        self.hpanel.add(spacer1)
        self.hpanel.add(self.status)
        self.hpanel.add(spacer2)
        self.hpanel.add(self.start)
        #self.hpanel.add(spacer3)
        self.hpanel.add(self.end)
        self.hpanel.add(self.add_btn)
        self.hpanel.add(Label(Width='10px'))
        self.hpanel.add(self.del_btn)

 
    def get_name_txt(self):
        '''Return project name.
        '''
        return self.name.getText()


    def get_status(self):
        '''Return project status.
        '''
        return self.status.getItemText(self.status.getSelectedIndex())


    def get_milestone_data(self):
        '''Return all data for a milestone and validation result.
        '''
        valid = False
        name_txt = self.get_name_txt()
        status_txt = self.get_status()
        start_txt = self.start.getTextBox().getText()
        end_txt = self.end.getTextBox().getText()
        data = [name_txt, status_txt, start_txt, end_txt]
        # We are only valid if these conditions are met
        if len(name_txt.strip()) > 0 and self.start.valid == True and self.end.valid == True:
            valid = True 
        return (valid, data)


    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')        
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:92,代码来源:milestones.py


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