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


Python Button.setEnabled方法代码示例

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


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

示例1: FormulaBuilder

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class FormulaBuilder(DialogWindow):

    def __init__(self, operations,after,type='rel'):
        DialogWindow.__init__(self, modal=True, close=True)
        self.formula = Formula([])
        self.after=after

        left = 100
        top = 100

        self.ops_with_buttons = [{"op": op, "button": Button(op.name, self)} for op in operations if op.available]
        dock = DockPanel()
        dock.setSpacing(3)

        for owb in self.ops_with_buttons:
            dock.add(owb['button'], DockPanel.NORTH)

        dock.setWidth("300")

        self.image = Image(latex_to_url(self.formula.fill_with_placeholders().to_latex()))
        dock.add(self.image, DockPanel.EAST)
        dock.setCellHorizontalAlignment(self.image, HasAlignment.ALIGN_TOP)

        self.doneButton=Button("Done",self)
        self.doneButton.setEnabled(False)
        dock.add(self.doneButton,DockPanel.SOUTH)

        dock.add(HTML(""),DockPanel.CENTER)

        self.setText("opkop")
        self.setPopupPosition(left, top)
        self.setStyleAttribute("background-color", "#ffffff")
        self.setStyleAttribute("color", "blue")
        self.setStyleAttribute("border-width", "5px")
        self.setStyleAttribute("border-style", "solid")

        self.setWidget(dock)

    def onClick(self, sender):
        if sender==self.doneButton:
            self.hide()
            self.after(self.formula)

        op=None
        for owb in self.ops_with_buttons:
            if owb['button'] == sender:
                self.setText(sender.getText())
                op=owb['op']

        if not self.formula.is_closed():
            self.formula.add_one_op(op,type)
            self.image.setUrl(latex_to_url(self.formula.fill_with_placeholders().to_latex()))
            if self.formula.is_closed():
                self.doneButton.setEnabled(True)
开发者ID:vizafogo123,项目名称:pokpok,代码行数:56,代码来源:Trees.py

示例2: __init__

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class Editor:
    def __init__(self, db_url, parent_panel):
        self.db_url = db_url
        self.doc_id = None
        self.parent_panel = parent_panel

    def loadDocument(self, doc_id):
        # Load document into editor
        HTTPRequest().asyncGet(None, None, url=self.db_url+doc_id,
                                handler=DocLoader(self))
    def reloadDocument(self):
        if self.doc_id is None:
            Window.Alert('Trying to reload blank doc')
        else:
            self.loadDocument(self.doc_id)

    def updateDoc(self, json):
        doc_obj = JSONParser().decode(json)
        self.doc_id = doc_obj['_id']
        self.id_label.setText('ID : %s'%doc_obj['_id'])
        self.rev_label.setText('REV: %s'%doc_obj['_rev'])
        self.save_button.setEnabled(True)
        self.doc_area.setText(json)
        self.doc_area.setEnabled(True)
        self.doc_area.setFocus(True)

    def saveDocument(self):
        self.doc_area.setEnabled(False)
        self.save_button.setEnabled(False)
        HTTPRequest().asyncPut(None, None, url=self.db_url+self.doc_id,
                                postData=self.doc_area.getText(),
                                handler=DocSaver(self))

    def onModuleLoad(self):
        # Editor
        self.editor_panel = VerticalPanel()
        self.id_label = Label('ID: ')
        self.editor_panel.add(self.id_label)
        self.rev_label = Label('REV: ')
        self.editor_panel.add(self.rev_label)
        self.doc_area = TextArea()
        self.doc_area.setCharacterWidth(80)
        self.doc_area.setVisibleLines(24)
        self.doc_area.setEnabled(False)
        self.editor_panel.add(self.doc_area)
        self.parent_panel.add(self.editor_panel)

        # Buttons
        self.button_panel = HorizontalPanel()
        self.save_button = Button("Save", self.saveDocument)
        self.save_button.setEnabled(False)
        self.button_panel.add(self.save_button)
        self.parent_panel.add(self.button_panel)
开发者ID:CodeSturgeon,项目名称:slipcover,代码行数:55,代码来源:editor.py

示例3: CalibrateChannelTrimsView

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class CalibrateChannelTrimsView(object) :
	"""
	Class that takes care of the purely UI parts of the trim calibration
	"""
	def __init__( self ) :
		numberOfLoopsPanel=HorizontalPanel()
		numberOfLoopsPanel.add( HTML("Maximum number of loops") )
		self.maximumNumberOfLoops=TextBox()
		self.maximumNumberOfLoops.setText(10)
		numberOfLoopsPanel.add( self.maximumNumberOfLoops )
		numberOfLoopsPanel.setCellHorizontalAlignment( self.maximumNumberOfLoops, HasHorizontalAlignment.ALIGN_RIGHT )
		numberOfLoopsPanel.setWidth("100%")
		
		aimPointPanel=HorizontalPanel()
		aimPointPanel.add( HTML("Aim point") )
		self.aimPoint=TextBox()
		self.aimPoint.setText(127)
		aimPointPanel.add( self.aimPoint )
		aimPointPanel.setCellHorizontalAlignment( self.aimPoint, HasHorizontalAlignment.ALIGN_RIGHT )
		aimPointPanel.setWidth("100%")

		self.start=Button("Start")
		
		self.echo=HTML("Initiating...")
		
		self.mainPanel = VerticalPanel()
		self.mainPanel.add( numberOfLoopsPanel )
		self.mainPanel.add( aimPointPanel )
		self.mainPanel.add( self.start )
		self.mainPanel.add( self.echo )

	def getMaxNumberOfLoops( self ) :
		return int(self.maximumNumberOfLoops.getText())

	def getAimPoint( self ) :
		return int(self.aimPoint.getText())

	def getStartButton( self ) :
		return self.start

	def setEchoText( self, text ) :
		self.echo.setText( text )

	def enable( self ) :
		self.start.setEnabled(True)

	def disable( self ) :
		self.start.setEnabled(False)

	def getPanel( self ) :
		return self.mainPanel
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:53,代码来源:CalibrateChannelTrimsPanel.py

示例4: GridWidget

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class GridWidget(AbsolutePanel):

    def __init__(self):
        AbsolutePanel.__init__(self)

        self.page=0
        self.min_page=1
        self.max_page=10
        
        self.addb=Button("Next >", self)
        self.subb=Button("< Prev", self)
        self.clearb=Button("Clear", self)
        
        self.g=Grid()
        self.g.resize(5, 5)
        self.g.setWidget(0, 0, HTML("<b>Grid Test</b>"))
        self.g.setBorderWidth(2)
        self.g.setCellPadding(4)
        self.g.setCellSpacing(1)
        
        self.updatePageDisplay()

        self.add(self.subb)
        self.add(self.addb)
        self.add(self.clearb)
        self.add(self.g)

    def onClick(self, sender):
        if sender == self.clearb:
            print "clear"
            self.g.clear()
            return
        elif sender==self.addb:
            self.page+=1
        elif sender==self.subb:
            self.page-=1
        self.updatePageDisplay()
        

    def updatePageDisplay(self):
        if self.page<self.min_page: self.page=self.min_page
        elif self.page>self.max_page: self.page=self.max_page
        total_pages=(self.max_page-self.min_page) + 1
        
        self.g.setHTML(0, 4, "<b>page %d of %d</b>" % (self.page, total_pages))
        
        if self.page>=self.max_page:
            self.addb.setEnabled(False)
        else:
            self.addb.setEnabled(True)
            
        if self.page<=self.min_page:
            self.subb.setEnabled(False)
        else:
            self.subb.setEnabled(True)

        for y in range(1, 5):
            for x in range(5):
                self.g.setText(y, x, "%d (%d,%d)" % (self.page, x, y))
开发者ID:anandology,项目名称:pyjamas,代码行数:61,代码来源:GridTest.py

示例5: Cancel

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class Cancel(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Cancel:', StyleName='section'))
        self.name = TextBox()
        self.name.setMaxLength(18)
        self.name.setVisibleLength(18)
        self.add(self.name)
        self.cancel = Button('Do it', self)
        self.add(self.cancel)
        self.err = Label()
        self.add(self.err)

    def onClick(self, sender):
        self.err.setText('')
        name = self.name.getText().strip()
        if name == '':
            return
        else:
            self.cancel.setEnabled(False)
            remote = server.AdminService()
            id = remote.cancel(name, self)
            if id < 0:
                self.err.setText('oops: could not cancel')

    def onRemoteResponse(self, result, request_info):
        self.cancel.setEnabled(True)
        self.name.setText('')

    def onRemoteError(self, code, message, request_info):
        self.cancel.setEnabled(True)
        self.err.setText('Could not cancel: ' + message['data']['message'])
开发者ID:fluidinfo,项目名称:Tickery,代码行数:34,代码来源:cancel.py

示例6: NavBar

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class NavBar(Composite):

    def __init__(self, owner):
        Composite.__init__(self)
        self.owner = owner
        self.bar = DockPanel()
        self.gotoFirst = Button("&lt;&lt;", self)
        self.gotoNext = Button("&gt;", self)
        self.gotoPrev = Button("&lt;", self)
        self.status = HTML()

        self.initWidget(self.bar)
        self.bar.setStyleName("navbar")
        self.status.setStyleName("status")

        buttons = HorizontalPanel()
        buttons.add(self.gotoFirst)
        buttons.add(self.gotoPrev)
        buttons.add(self.gotoNext)
        self.bar.add(buttons, DockPanel.EAST)
        self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT)
        self.bar.add(self.status, DockPanel.CENTER)
        self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT)
        self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellWidth(self.status, "100%")

        self.gotoPrev.setEnabled(False)
        self.gotoFirst.setEnabled(False)

    def onClick(self, sender):
        if sender == self.gotoNext:
            self.owner.startRow += self.owner.getDataRowCount()
            self.owner.refresh()
        elif sender == self.gotoPrev:
            self.owner.startRow -= self.owner.getDataRowCount()
            if self.owner.startRow < 0:
                self.owner.startRow = 0
            self.owner.refresh()
        elif sender == self.gotoFirst:
            self.owner.startRow = 0
            self.owner.refresh()
开发者ID:Afey,项目名称:pyjs,代码行数:44,代码来源:DynaTableWidget.py

示例7: PreferencesDlg

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class PreferencesDlg(DialogBox):

    fileLocation = None

    def __init__(self, left = 50, top = 50):
        DialogBox.__init__(self, modal = False)

        self.setPopupPosition(left, top)
        self.setText("Preferences")
        ftable = FlexTable()
        ftableFormatter = ftable.getFlexCellFormatter()
        row = 0

        self.fileLocation = getCookie("fileLocation")

        row += 1
        ftable.setWidget(row, 0, Label("Sheet loaded on startup", wordWrap=False))
        self.fileLocationInput = TextBox()
        self.fileLocationInput.addChangeListener(self.checkValid)
        self.fileLocationInput.addKeyboardListener(self)
        self.fileLocationInput.setVisibleLength(30)
        self.fileLocationInput.setText(self.fileLocation)
        ftable.setWidget(row, 1, self.fileLocationInput)

        row += 1
        hpanel = HorizontalPanel()
        self.saveBtn = Button("Save", self.onSave)
        self.saveBtn.setEnabled(False)
        hpanel.add(self.saveBtn)
        self.cancelBtn = Button("Cancel", self.onCancel)
        hpanel.add(self.cancelBtn)
        ftable.setWidget(row, 0, hpanel)
        ftableFormatter.setColSpan(row, 0, 2)

        self.setWidget(ftable)

    def onCancel(self, sender):
        self.hide()

    def onSave(self, sender):
        setCookie("fileLocation", self.fileLocationInput.getText(), 1000000000)
        self.hide()

    def checkValid(self, evt=None):
        if self.fileLocation != self.fileLocationInput.getText():
            self.saveBtn.setEnabled(True)
        else:
            self.saveBtn.setEnabled(False)

    def onClick(self, sender):
        pass

    def onKeyUp(self, sender, keyCode, modifiers):
        self.checkValid()

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

    def onKeyPress(self, sender, keyCode, modifiers):
        pass
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:62,代码来源:PreferencesDlg.py

示例8: QueueSize

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
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()
开发者ID:jdunck,项目名称:Tickery,代码行数:36,代码来源:size.py

示例9: BulkDirectAdd

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class BulkDirectAdd(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Directly add in bulk:', StyleName='section'))
        self.names = TextArea(VisibleLines=5)
        self.add(self.names)
        self.update = Button('Add', self)
        self.add(self.update)
        self.err = HTML()
        self.add(self.err)

    def onClick(self, sender):
        self.err.setHTML('')
        names = self.names.getText().strip()
        if names == '':
            return
        else:
            self.update.setEnabled(False)
            remote = server.AdminService()
            id = remote.bulkAddUsers(names, self)
            if id < 0:
                self.err.setText('oops: could not add')
            
    def onRemoteResponse(self, result, request_info):
        self.update.setEnabled(True)
        self.err.setText('OK, adding.')

    def onRemoteError(self, code, message, request_info):
        self.update.setEnabled(True)
        self.err.setHTML('Errors:<br/>' +
                         '<br/>'.join(message['data']['message']))
开发者ID:jdunck,项目名称:Tickery,代码行数:33,代码来源:directadd.py

示例10: add_button

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
    def add_button ( self, action, bbox, method=None, enabled=True,
                     name=None ):
        """ Creates a button.
        """
        ui = self.ui
        if ((action.defined_when != '') and
            (not ui.eval_when( action.defined_when ))):
            return None

        if name is None:
            name = action.name
        id     = action.id
        button = Button(name)
        bbox.add(button)
#        button.setAutoDefault(False)
        button.setEnabled(enabled)
        if (method is None) or (action.enabled_when != '') or (id != ''):
            editor = ButtonEditor( ui      = ui,
                                   action  = action,
                                   control = button )
            if id != '':
                ui.info.bind( id, editor )
            if action.visible_when != '':
                ui.add_visible( action.visible_when, editor )
            if action.enabled_when != '':
                ui.add_enabled( action.enabled_when, editor )
            if method is None:
                method = editor.perform

        if method is not None:
            button.addClickListener(method)

        if action.tooltip != '':
#            button.setToolTip(action.tooltip)
            print "Tooltips for buttons are not implemeted,"

        return button
开发者ID:rwl,项目名称:traitsbackendpyjamas,代码行数:39,代码来源:ui_base.py

示例11: Underway

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class Underway(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Underway:', StyleName='section'))
        s = ScrollPanel()
        self.add(s)
        v = VerticalPanel()
        s.add(v)
        self.queued = Grid(StyleName='users')
        v.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.getUnderway(self)
        if id < 0:
            self.err.setText('oops: could not call getUnderway')

    def onRemoteResponse(self, result, request_info):
        self.button.setEnabled(True)
        self.queued.clear()
        if not result:
            self.queued.resize(1, 1)
            self.queued.setText(0, 0, 'No users are currently being added.')
        else:
            self.queued.resize(len(result) + 1, 6)
            self.queued.setText(0, 0, 'Pos')
            self.queued.setText(0, 1, 'Name')
            self.queued.setText(0, 2, 'Friends')
            self.queued.setText(0, 3, '% done')
            self.queued.setText(0, 4, 'Queued at')
            self.queued.setText(0, 5, 'Started at')
            row = 1
            for name, nFriends, done, queuedAt, startTime in result:
                self.queued.setText(row, 0, row)
                self.queued.setText(row, 1, name)
                self.queued.setText(row, 2, nFriends)
                self.queued.setText(row, 3, '%.2f' % done)
                self.queued.setText(row, 4, queuedAt)
                self.queued.setText(row, 5, startTime)
                row += 1

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

    def onClick(self, sender):
        self.err.setText('')
        self.button.setEnabled(False)
        self.update()
开发者ID:fluidinfo,项目名称:Tickery,代码行数:56,代码来源:underway.py

示例12: Queued

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class Queued(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label("Queued:", StyleName="section"))
        s = ScrollPanel()
        self.add(s)
        v = VerticalPanel()
        s.add(v)
        self.queued = Grid(StyleName="users")
        v.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.getQueued(self)
        if id < 0:
            self.err.setText("oops: could not call getQueued")

    def onRemoteResponse(self, result, request_info):
        self.button.setEnabled(True)
        self.queued.clear()
        if not result:
            self.queued.resize(1, 1)
            self.queued.setText(0, 0, "No users are queued for addition.")
        else:
            self.queued.resize(len(result) + 1, 4)
            self.queued.setText(0, 0, "Pos")
            self.queued.setText(0, 1, "Name")
            self.queued.setText(0, 2, "Friends")
            self.queued.setText(0, 3, "Queued at")
            row = 1
            for name, nFriends, time in result:
                self.queued.setText(row, 0, row)
                self.queued.setText(row, 1, name)
                self.queued.setText(row, 2, nFriends)
                self.queued.setText(row, 3, time)
                row += 1

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

    def onClick(self, sender):
        self.err.setText("")
        self.button.setEnabled(False)
        self.update()
开发者ID:jdunck,项目名称:Tickery,代码行数:52,代码来源:queued.py

示例13: TweetEditor

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class TweetEditor(Grid):
    def __init__(self, query, nUsers, tabName, popup, preparePanel, topPanel):
        Grid.__init__(self, 3, 2)
        self.tweet = text.TextAreaFocusHighlight(
            Text="Tickery query %r has %d results. See them at" % (
                query, nUsers),
            VisibleLines=3, MaxLength=1000, StyleName='large-query-area')
        self.tweet.addKeyboardListener(self)
        self.query = query
        self.tabName = tabName
        self.popup = popup
        self.preparePanel = preparePanel
        self.topPanel = topPanel
        self.button = Button('Tweet!', self)
        self.count = Label('')
        
        self.setWidget(0, 0, HTML(_instructions))
        self.setWidget(0, 1, self.count)
        self.setWidget(1, 0, self.tweet)
        self.setWidget(1, 1, self.button)

        formatter = self.getCellFormatter()
        formatter.setVerticalAlignment(0, 1, 'bottom')
        formatter.setVerticalAlignment(1, 1, 'bottom')
        
        self.setCount()

    def onClick(self, sender):
        self.button.setEnabled(False)
        text = self.tweet.getText().strip()
        remote = server.TickeryService()
        id = remote.tweet(
            self.topPanel.loginPanel.oauthCookie, text, self.query,
            self.tabName, userlist._sortKey, self)
        if id < 0:
            self.setWidget(2, 0, Label('Oops!'))

    def onRemoteResponse(self, response, request_info):
        self.button.setEnabled(True)
        if response['result']:
            self.popup.hide()
            self.preparePanel.link.setHTML('<a href="%s"> %s</a>' %
                                           (response['URL'], _doneText))
        else:
            self.setWidget(2, 0, Label('Oops: %r' % response))

    def onRemoteError(self, code, message, request_info):
        self.button.setEnabled(True)
        self.setWidget(2, 0,
                       Label('Server Err or Invalid Response: ERROR %d - %s' %
                             (code, message)))

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

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

    def onKeyPress(self, sender, keycode, modifiers):
        self.setCount()

    def setCount(self):
        n = TWEET_LIMIT - len(self.tweet.getText())
        if n >= 0:
            self.count.setStyleName('tweet-char-count-ok')
        else:
            self.count.setStyleName('tweet-char-count-excessive')
        self.count.setText(str(n))
开发者ID:jdunck,项目名称:Tickery,代码行数:70,代码来源:tweet.py

示例14: DisplayHistogramsView

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class DisplayHistogramsView(object) :
	"""
	@brief View in the MVP pattern for displaying histograms.

	@author Mark Grimes ([email protected])
	@date 09/Feb/2014
	"""
	def __init__( self ) :
		self.cbcList=ListBox(MultipleSelect=True, VisibleItemCount=4)
		self.channelList=ListBox(MultipleSelect=True, VisibleItemCount=20)
		self.updateButton=Button("Update")

		controls=VerticalPanel()
		controls.add(self.updateButton)
		controls.add(self.cbcList)
		controls.add(self.channelList)

		controls.setCellHorizontalAlignment( self.updateButton, HasHorizontalAlignment.ALIGN_CENTER )
		self.cbcList.setWidth("95%")
		self.channelList.setWidth("95%")

		self.cbcList.addItem( "waiting..." )
		for index in range(0,254) :
			self.channelList.addItem( "Channel %3d"%index )

		self.histogram = Image()
		self.mainPanel = HorizontalPanel()
		self.mainPanel.add( controls )
		self.mainPanel.add( self.histogram )
		self.histogram.setUrl( "defaultScurveHistogram.png" )

	def getPanel( self ) :
		return self.mainPanel

	def setAvailableCBCs( self, cbcNames ) :
		self.cbcList.clear()
		for name in cbcNames :
			self.cbcList.addItem( name )

	def enable( self ) :
		self.updateButton.setEnabled(True)
		self.cbcList.setEnabled(True)
		self.channelList.setEnabled(True)

	def disable( self ) :
		self.updateButton.setEnabled(False)
		self.cbcList.setEnabled(False)
		self.channelList.setEnabled(False)
	
	def getUpdateButton( self ) :
		return self.updateButton
	
	def getSelectedCBCChannels( self ) :
		"""
		Returns a dictionary of which channels are selected, with CBC name as a key and
		an array of the channels for that CBC as the value.
		"""
		# The way this view is currently set up, the selected channels have to be the same
		# for each selected CBC.
		selectedChannels=[]
		for index in range(self.channelList.getItemCount()) :
			if self.channelList.isItemSelected(index) :
				selectedChannels.append(index)
		returnValue={}
		for index in range(self.cbcList.getItemCount()) :
			if self.cbcList.isItemSelected(index) : returnValue[self.cbcList.getItemText(index)]=selectedChannels

		return returnValue

	def setImage( self, url ) :
		self.histogram.setUrl( url )
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:73,代码来源:DisplayHistogramsPanel.py

示例15: __init__

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import setEnabled [as 别名]
class Viewer:
    def __init__(self, db_url, parent_panel, doc_callback=None, page_size=5):
        self.db_url = db_url
        self.parent_panel = parent_panel
        self.doc_callback = doc_callback
        self.page_size = page_size

    def onModuleLoad(self):

        ## Grid setup
        self.grid = Grid()
        # Note: The resize method args are Rows,Cols (Curses style)
        self.grid.resize(1,4)
        self.grid.setBorderWidth(1)
        self.grid.setHTML(0,0,'#')
        self.grid.setHTML(0,1,'ID')
        self.grid.setHTML(0,2,'Revision')
        self.grid.setHTML(0,3,'Delete')
        self.grid.addTableListener(self)
        self.parent_panel.add(self.grid)

        ## Buttons
        self.button_panel = HorizontalPanel()
        # Prev
        self.first_button = Button("<-", self.firstPage)
        self.first_button.setEnabled(False)
        self.button_panel.add(self.first_button)
        self.prev_button = Button("Previous", self.prevPage)
        self.prev_button.setEnabled(False)
        self.button_panel.add(self.prev_button)
        self.next_button = Button("Next", self.nextPage)
        self.next_button.setEnabled(False)
        self.button_panel.add(self.next_button)
        self.parent_panel.add(self.button_panel)

    def populate(self, json):
        view_obj = JSONParser().decode(json)
        view_rows = view_obj['rows']
        offset = view_obj['offset']
        num_rows = len(view_rows)
        
        self.first_key = view_rows[0]['key']

        if offset != 0:
            self.first_button.setEnabled(True)

        if num_rows > self.page_size:
            self.next_key = view_rows[-1:][0]['key']
            self.next_button.setEnabled(True)
            self.grid.resize(self.page_size+1,4)
        else:
            self.grid.resize(num_rows+1,4)

        for row_num in range(num_rows):
            if row_num < self.page_size:
                self.grid.setHTML(row_num+1, 0, 1+offset+row_num)
                self.grid.setHTML(row_num+1, 1, view_rows[row_num]['key'])
                self.grid.setHTML(row_num+1, 2,
                                    view_rows[row_num]['value']['rev'])
                self.grid.setHTML(row_num+1, 3, '<b>X O X</b>')
        
        if len(self.prev_keys)>0:
            self.prev_button.setEnabled(True)

    def onCellClicked(self, sender, row, col):
        doc_id = self.grid.getHTML(row, 1)
        if col == 3:
            doc_rev = self.grid.getHTML(row, 2)
            url = self.db_url+doc_id+'?rev='+doc_rev
            HTTPRequest().asyncDelete(None, None, url=url,
                                        handler=DeleteHandler(self))
        else:
            if self.doc_callback is not None:
                self.doc_callback(doc_id)

    def firstPage(self):
        self.loadPage(None)

    def nextPage(self):
        self.prev_keys.append(self.first_key)
        self.loadPage(self.next_key)

    def prevPage(self):
        self.loadPage(self.prev_keys.pop())

    def setView(self, view_path, first_key = None):
        self.view_path = view_path
        #self.prev_keys = []
        #self.next_key = None
        self.loadPage(first_key)

    def loadPage(self, startkey=None):
        limit = int(self.page_size)+1
        view_url = self.db_url+self.view_path+'?limit=%d'%limit
        if startkey is not None:
            view_url += '&startkey="%s"'%startkey
        else:
            self.prev_keys = []

        self.first_button.setEnabled(False)
#.........这里部分代码省略.........
开发者ID:CodeSturgeon,项目名称:slipcover,代码行数:103,代码来源:viewer.py


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