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


Python Button.setStyleName方法代码示例

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


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

示例1: Projects_Editor

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

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setStyleName [as 别名]
class ContentItemToolbar(HorizontalPanel):
    def __init__(self, contentitem, onPublish, onLike, onDislike):
        """Create a ContentItemToolbar.

        Event handlers should be methods that take: sender
        """
        HorizontalPanel.__init__(self)
        self.contentitem = contentitem
        self.publishBtn = Button('Publish', listener=onPublish, StyleName=Styles.TOOLBAR_BUTTON)
        self.add(self.publishBtn)
        self.likeBtn = Button('FOO', listener=onLike, StyleName=Styles.TOOLBAR_BUTTON)
        self.add(self.likeBtn)
        self.dislikeBtn = Button('Dislike', listener=onDislike, StyleName=Styles.TOOLBAR_BUTTON)
        self.add(self.dislikeBtn)
        self.updateStatusFromItem()
        return
    def updateStatusFromItem(self, updatedItem=None):
        if updatedItem:
            self.contentitem = updatedItem
        likes = self.contentitem['metadata']['likes']
        self.likeBtn.setText('Like (%s)' % likes)
        isPublished = self.contentitem['metadata']['is_published']
        self.publishBtn.setStyleName(Styles.TOOLBAR_BUTTON_PUBLISHED if isPublished else Styles.TOOLBAR_BUTTON)
开发者ID:satyam07,项目名称:taoggregator,代码行数:25,代码来源:feedpublisherwebui.py

示例3: kMeans

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setStyleName [as 别名]
class kMeans(Algorithm):
    def __init__(self):
        Algorithm.__init__(self)
	self.MLAlgorithmService = MLAlgorithmService(self)
        self.image=Image(self.baseURL() + "services/kMeansPictures/lenna.png",Width="320px", Height="360px")
        self.resultImage=Image("",Width="320px", Height="360px")
        self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif")
        self.calculateButton = Button("RUN", self.onButtonClick)
        self.log = Button("SHOW LOG", self.openLogFile)
        self.log.setEnabled(False)

        self.image.addLoadListener(self)
        
        topPanel = DockPanel()
        topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        topPanel.add(self.calculateButton, DockPanel.WEST)
        topPanel.add(self.loadingImage, DockPanel.CENTER)
        topPanel.add(self.log, DockPanel.EAST)
        
        panel = DockPanel()
        panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
        panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        #panel.add(HTML("<h2>Image compression</h2>", True))
        panel.add(topPanel, DockPanel.NORTH)
        panel.add(self.image, DockPanel.WEST)
        panel.add(self.resultImage, DockPanel.EAST)
        
        panel.setWidth("100%")
        self.initWidget(panel)
        self.image.setStyleName("ks-images-Image")
        self.calculateButton.setStyleName("ks-images-Button")
        
        self.loadImage("picturem.png")

    def onButtonClick(self, sender):
        Window.alert("Starting image compression...")
        self.MLAlgorithmService.callMethod("lenna.png")


    def onError(self, sender):
        pass

    def onLoad(self, sender=None):
        self.loadingImage.setUrl(self.baseURL() + "images/blanksearching.gif")

    def loadImage(self, picture):
        self.loadingImage.setUrl(self.baseURL() + "images/searching.gif")
        self.image.setUrl(self.baseURL() + "services/kMeansPictures/lenna.png")
        self.resultImage.setUrl(self.baseURL() + "services/kMeansPictures/lenna.png")
        self.resultImage.setUrl(self.baseURL() + "services/kMeansPictures/" + picture)

    def onImageClicked(self):
        Window.alert("picture!")

    def openLogFile(self, sender):
###TODO: make logging output
        fileLocation = self.baseURL() + "services/contactjson.txt"
        dlg = FileOpenDlg(fileLocation=fileLocation)
        dlg.show()

    def showStatus(self, msg):
        Window.alert(msg)
开发者ID:aprovodi,项目名称:mlServerCalculations,代码行数:64,代码来源:kMeans.py

示例4: Input_Form

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setStyleName [as 别名]
class Input_Form(Abstract_View):
    '''Input form that modifies itself depending on the proejct.
    '''
    def __init__(self):
        Abstract_View.__init__(self)
        self.dev_fields = Dev_Fields()
        

    def register(self, controller):
        '''Register controller for view and its subviews'''
        self.controller = controller
        self.dev_fields.register(controller)
        
    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)

    def _load_project(self, project):
        '''Load project specific fields in the panel
        '''
        if self.dev_fields is not None:
            self.project_panel.remove(self.dev_fields)
        # Remove the old one and add brand new
        self.dev_fields = Dev_Fields()
        self.project_panel.add(self.dev_fields)

    def send_data(self):
        '''Retrieve data for the active project fields and send to flask.
        '''
        #data = self.dev_fields.prep_data()
        self.controller.process_msg(SEND_DATA_MSG)
        
    def on_project_changed(self, event):
        '''Change form fields depending on the proejct.
        '''
        proj_list = self.proj_row.widget()
        project = proj_list.getItemText(proj_list.getSelectedIndex())
        if project != '':
            self.controller.process_msg(PROJ_CHANGED_MSG, project)
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:84,代码来源:form.py

示例5: Dev_Fields

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setStyleName [as 别名]
class Dev_Fields(VerticalPanel, Abstract_View):
    '''Fields for a development project:
    Status
    Impediment
       Desc
       Status: Open | Closed
       Comment
    Risks
       Milestone
       Name
       Target End Date
       Actual End Date
    '''
    def __init__(self):
        '''Initialize widget'''
        VerticalPanel.__init__(self)
        Abstract_View.__init__(self)
        # Keep list of all milestones, we will add milestones from controller
        # when we create the form
        self.milestone_names = []
        # Corresponding dates
        self.milestone_dates = []
        # These two variables keep track of added milestone and impediments objects
        self.milestones = []
        self.impediments = []
        
        self.status_area = Text_Area_Row('Status', help='status of the project')

        # Keeps milestones
        self.main_mlst_panel = VerticalPanel()

        hp_mlst = HorizontalPanel()
        self.add_milestone_btn = Button('Add',
                                        getattr(self, 'on_add_milestone_btn_click'))
        self.add_milestone_btn.setStyleName('btn btn-info')

        self.remove_milestone_btn = Button('Remove',
                                        getattr(self, 'remove_milestone'))
        self.remove_milestone_btn.setStyleName('btn btn-danger')

        milestone_panel = VerticalPanel()
        self.milestone_row = Form_Row('Milestones', milestone_panel,
                                      help='add milestone and provide expected completion date')
        
        hp_mlst.add(Label(Width='330px'))

        hp_mlst.add(self.add_milestone_btn)
        hp_mlst.add(Label(Width='10px'))
        hp_mlst.add(self.remove_milestone_btn)
        
        self.main_mlst_panel.add(self.milestone_row.panel())
        self.main_mlst_panel.add(hp_mlst)
        
        self.risks_area = Text_Area_Row('Risks', help='short / long term risks')

        # Keeps impediments
        self.main_impd_panel = VerticalPanel()

        hp_impd = HorizontalPanel()
        self.add_impediment_btn = Button('Add',
                                         getattr(self, 'add_impediment'))
        self.add_impediment_btn.setStyleName('btn btn-info')
    
        # Remove button
        self.remove_impediment_btn = Button('Remove',
                                         getattr(self, 'remove_impediment'))
        self.remove_impediment_btn.setStyleName('btn btn-danger')
        
        impediment_panel = VerticalPanel()
        self.impediment_row = Form_Row('Impediments', impediment_panel,
                                       help='add impediments, one per section, please')
        hp_impd.add(Label(Width='330px'))

        hp_impd.add(self.add_impediment_btn)
        hp_impd.add(Label(Width='10px'))
        hp_impd.add(self.remove_impediment_btn)
        self.main_impd_panel.add(self.impediment_row.panel())
        self.main_impd_panel.add(hp_impd)
        # Add those to itself
        self.add(self.status_area.panel())
        self.add(self.risks_area.panel())
        self.add(self.main_mlst_panel)
        self.add(self.main_impd_panel)

    def on_add_milestone_btn_click(self):
        '''Inform controller we want to add a milestone.
        '''
        self.controller.process_msg(ADD_MLS_MSG)
        
        
    def add_milestone(self):
        '''Add milestone to the development project.
        '''
        # Pass list of milestones when we create the row
        milestone = Milestones_Row(self.milestone_names, self.milestone_dates)
        self.milestone_row.widget().add(Label(Height='5px'))
        self.milestone_row.widget().add(milestone.hpanel)
        self.milestones.append(milestone)
        

#.........这里部分代码省略.........
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:103,代码来源:form.py

示例6: Milestones_Editor

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

示例7: Milestones_View

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

        spacer1 = Label()
        spacer1.setHeight('10px')
        spacer2 = Label()
        spacer2.setHeight('10px')
        
        self.tbl_panel = VerticalPanel(Width='755px')
        # First is a row count
        self.grid = Reports_Grid()
        self.grid.create_grid(1, 4, ['Milestone Name', 'Milestone State', 'Start Date', 'End Date'])
        self.tbl_panel.add(self.grid)

        self.editor = Milestones_Editor()
        self.submit_btn = Button('Submit', getattr(self, 'send_data'))
        self.submit_btn.setStyleName('btn btn-primary btn-lg')

        hpanel = HorizontalPanel()
        hpanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        hpanel.add(self.submit_btn)

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

        self.root = RootPanel('projects_')
        self.root.add(spacer1)
        self.root.add(self.editor.hpanel)
        self.root.add(spacer2)
        self.root.add(self.tbl_panel)

        spacer3 = Label()
        spacer3.setHeight('20px')

        self.root.add(self.msg_lbl)
        self.root.add(spacer3)
        self.root.add(hpanel)
        self.root.add(Label(Height='20px'))
        

        # Add listeners and initialize components
        self._add_listeners()
        self._iniate_states()
        
    def _add_listeners(self):
        '''Register listeners here.
        '''
        self.editor.add_btn.addClickListener(getattr(self, 'on_add_btn_click'))
        self.editor.del_btn.addClickListener(getattr(self, 'on_del_btn_click'))
        self.editor.name.addKeyboardListener(self)
        

    def _iniate_states(self):
         self.editor.add_btn.setEnabled(False)
         self.editor.del_btn.setEnabled(False)
         self.editor.name.setFocus(True)   
        

    def register(self, controller):
        '''Register controller for a view and related controls.
        '''
        self.controller = controller
        self.grid.register(controller)
        self.editor.start.register(controller)
        self.editor.end.register(controller)
        

    def on_add_btn_click(self, event):
        '''Process click on Add button.
        '''
        (valid, data) = self.editor.get_milestone_data()
        if self.editor.add_btn.getText() == 'Add':
            self.controller.process_msg(ADD_ROW_MSG, data)
        else:
            self.controller.process_msg(EDT_ROW_MSG, self.grid.selected_row, data)


    def on_del_btn_click(self, event):
        '''Process click on Add button.
        '''
        if self.grid.selected_row > 0:
            self.controller.process_msg(DEL_ROW_MSG, self.grid.selected_row)

    def send_data(self):
        '''Notify controller that we need to send data to db and let it
        do the work'''
        self.controller.process_msg(COMMIT_MLS_MSG)

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

#.........这里部分代码省略.........
开发者ID:mcsquaredjr,项目名称:Reports,代码行数:103,代码来源:milestones.py


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