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


Python TextBox.setStyleName方法代码示例

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


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

示例1: Projects_Editor

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

示例2: MechOptionPanel

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

示例3: Impediments

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

示例4: Milestones_Editor

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox 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.TextBox.TextBox.setStyleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。