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


Python Button.Button类代码示例

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


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

示例1: onModuleLoad

class TestDict:

    def onModuleLoad(self):

        self.r = WrapperDict()

        self.kbox = TextBox()
        self.addbutton = Button("Click to look up key value (hello or goodbye)")
        self.addbutton.addClickListener(self)

        self.kbox.setText("hello") # default to make life easier

        RootPanel().add(HTML("Key:"))
        RootPanel().add(self.kbox)
        RootPanel().add(self.addbutton)

    def display_value(self):

        key = self.kbox.getText()

        RootPanel().add(HTML("Value using python:" ))
        RootPanel().add(HTML(self.r.python_get_value(key)))
        RootPanel().add(HTML("Value using javascript:" ))
        RootPanel().add(HTML(self.r.javascript_get_value(key)))

    def onClick(self, sender):

        self.display_value()
开发者ID:Afey,项目名称:pyjs,代码行数:28,代码来源:TestDict.py

示例2: __init__

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

        self.roleList = ListBox()
        self.roleList.setWidth('300px')
        self.roleList.setVisibleItemCount(6)
        self.roleList.addChangeListener(self.onListChange)
        #self.roleList.addKeyboardListener(self)
        self.roleCombo = ListBox()
        self.roleCombo.addKeyboardListener(self)
        self.roleCombo.addChangeListener(self.onComboChange)
        self.addBtn = Button("Add")
        self.addBtn.setEnabled(False)
        self.removeBtn = Button("Remove")
        self.removeBtn.setEnabled(False)

        vpanel = VerticalPanel()
        vpanel.add(self.roleList)
        hpanel = HorizontalPanel()
        hpanel.add(self.roleCombo)
        hpanel.add(self.addBtn)
        hpanel.add(self.removeBtn)
        vpanel.add(hpanel)

        self.add(vpanel)
        self.clearForm()
        return
开发者ID:Afey,项目名称:pyjs,代码行数:27,代码来源:components.py

示例3: PopupPanelDemo

class PopupPanelDemo(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)

        vPanel = VerticalPanel(Spacing=4)

        self._btn = Button("Click Me", getattr(self, "showPopup"))

        vPanel.add(HTML("Click on the button below to display the popup."))
        vPanel.add(self._btn)

        self.add(vPanel)


    def showPopup(self, event):
        contents = HTML("Hello, World!")
        contents.addClickListener(getattr(self, "onClick"))

        self._popup = PopupPanel(autoHide=True)
        self._popup.add(contents)
        self._popup.setStyleName("showcase-popup")

        left = self._btn.getAbsoluteLeft() + 10
        top  = self._btn.getAbsoluteTop() + 10
        self._popup.setPopupPosition(left, top)
        self._popup.show()


    def onClick(self, sender=None):
        self._popup.hide()
开发者ID:Afey,项目名称:pyjs,代码行数:30,代码来源:popupPanel.py

示例4: __init__

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

示例5: __init__

    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")
开发者ID:aprovodi,项目名称:mlServerCalculations,代码行数:32,代码来源:kMeans.py

示例6: __init__

    def __init__(self):
        DockPanel.__init__(self)
        self.setSize('100%', '100%')

        self.geocoder = Geocoder()

        # widgets

        topPanel = HorizontalPanel()
        self.add(topPanel, DockPanel.NORTH)

        self.address = TextBox()
        self.address.setText("Sydney, NSW")
        self.address.addChangeListener(self.codeAddress)

        topPanel.add(self.address)

        button = Button("Geocode")
        button.addClickListener(self.codeAddress)

        topPanel.add(button)

        # now, the map

        mapPanel = SimplePanel()
        mapPanel.setSize('600', '400')
        self.add(mapPanel, DockPanel.CENTER)

        options = MapOptions(zoom=8, center=LatLng(-34.397, 150.644),
                           mapTypeId=MapTypeId.ROADMAP)

        self.map = Map(mapPanel.getElement(), options)
开发者ID:Afey,项目名称:pyjs,代码行数:32,代码来源:GeocodingSimple.py

示例7: htmlElements

	def htmlElements(self, addList = None):
		if not self._htmlElements:
			h = HTML("<h1>Run data</h1>", StyleName='font-s07em')
			p = HTML('<p>Enter <em>weighed</em> data to get information, through the neural network...</p>')
			b=Button('addField', self, StyleName='link')
			b.setID(ADD_FIELD_BUTTON)

			f = FormPanel()
			_f = self.fieldPanel([self.getWidgetObj(),0,0])
			f.add(_f)
			"""
			t = TextArea(StyleName='page-textarea')
			s=Button('submit', self, StyleName='link')
			s.setID('submitButton')
			"""
			self._htmlElements = [['h', h], ['p', p], ['b', b], ['f', f]]
			for i in range(len(self._htmlElements)):
 				RootPanel().add(self._htmlElements[i][1])

		if addList:
			self._htmlElements+=addList
			for i in range(len(self._htmlElements)):
 				RootPanel().add(addList[i][1])

		return self._htmlElements
开发者ID:molhokwai,项目名称:libraries,代码行数:25,代码来源:RunForm.py

示例8: __init__

    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)
开发者ID:Afey,项目名称:pyjs,代码行数:27,代码来源:DynaTableWidget.py

示例9: themesPanel

	def themesPanel(self, themes=None):
		Window.alert('line:111')
		themes = None
		if not themes: themes=['0','1', 'cms', 'pypress']

		vPanel = VerticalPanel()
		for i in range(len(themes)):
			"""
			a_n = location.getPathName().split('/')[1]
			lambda1 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/'+x+'/')+'?theme='+x
        	lambda2 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/a/')+'?theme='+x
			href = {
				'cms' : lambda1, 
				'pypress' : lambda1,
				'o' : lambda2, 
				'1' : lambda2 
			}.get(themes[i], lambda2)(themes[i])
			"""

			a=Button('theme '+themes[i], 
					lambda x: location.setSearchDict({'theme': x.getID()}), 
					StyleName='link')
			a.setID(themes[i])
			vPanel.add(a)
	
		return vPanel
开发者ID:molhokwai,项目名称:libraries,代码行数:26,代码来源:Index0.py

示例10: redraw

    def redraw(self):
        self.data.sort(self.sortfn)

        rows = len(self.data)
        cols = 0
        if rows > 0:
            cols = len(self.data[0])

        self.grid.resize(rows, cols)
        self.header.resize(1, cols)

        cf = self.grid.getCellFormatter()

        for (nrow, row) in enumerate(self.data):
            for (ncol, item) in enumerate(row):
                self.grid.setHTML(nrow, ncol, str(item))
                cf.setWidth(nrow, ncol, "200px")

        cf = self.header.getCellFormatter()
        self.sortbuttons = []
        for ncol in range(cols):
            sb = Button("sort col %d" % ncol)
            sb.addClickListener(self)
            self.header.setWidget(0, ncol, sb)
            cf.setWidth(0, ncol, "200px")
            self.sortbuttons.append(sb)
开发者ID:Afey,项目名称:pyjs,代码行数:26,代码来源:SortedGridThing.py

示例11: onModuleLoad

class TestRect:

    def onModuleLoad(self):

        self.r = Rect(0.0, 0.0)

        self.xbox = TextBox()
        self.ybox = TextBox()
        self.addbutton = Button("Click to add x and y to Rectangle")
        self.addbutton.addClickListener(self)

        self.xbox.setText("2")
        self.ybox.setText("5")

        RootPanel().add(HTML("X Value:"))
        RootPanel().add(self.xbox)
        RootPanel().add(HTML("Y Value:"))
        RootPanel().add(self.ybox)
        RootPanel().add(self.addbutton)

        RootPanel().add(HTML("Current value: %d %d" % ( self.r.get_x(), self.r.get_y())))

    def onClick(self, sender):

        x = int(self.xbox.getText())
        y = int(self.ybox.getText())

        r = Rect(x, y)

        self.r.add(r)

        RootPanel().add(HTML("New value: %d" % ( self.r.get_x())))
        RootPanel().add(HTML("New value: %d" % ( self.r.get_y())))
        RootPanel().add(HTML("New value: %d %d" % ( self.r.get_x(), self.r.get_y())))
        RootPanel().add(HTML("New Area: %d" % self.r.area()))
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:35,代码来源:TestRect.py

示例12: onModuleLoad

    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)
开发者ID:CodeSturgeon,项目名称:slipcover,代码行数:27,代码来源:viewer.py

示例13: GettextExample

class GettextExample(object):

    def __init__(self):
        self.b = Button(_("Click me"), self.greet, StyleName='teststyle')
        self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle')
        self.l = Label(_("Hello World (label)"), StyleName='teststyle')
        self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(),
                         StyleName='teststyle')
        RootPanel().add(self.b)
        RootPanel().add(self.h)
        RootPanel().add(self.l)
        RootPanel().add(self.base)

    def change_texts(self, text):
        self.b.setText(_("Click me"))
        self.h.setHTML(_("<b>Hello World</b> (html)"))
        self.l.setText(_("Hello World (label)"))
        text = [_("Hello from %s") % pygwt.getModuleBaseURL()]
        for i in range(4):
            text.append(ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i))
        text = '<br />'.join(text)
        self.base.setHTML(text)

    def greet(self, fred):
        fred.setText(_("No, really click me!"))
        Window.alert(_("Hello, there!"))
        i18n.load(lang=lang[0], onCompletion=self.change_texts)
        lang.append(lang.pop(0))
开发者ID:Afey,项目名称:pyjs,代码行数:28,代码来源:Gettext.py

示例14: make_panel

    def make_panel(self):
        message = Label(
            'The configuration has been changed.\n'
            'You must apply the changes in order for them to take effect.')
        DOM.setStyleAttribute(message.getElement(), "whiteSpace", 'pre')

        msgbox = Grid(1, 2, StyleName='changes')
        msgbox.setWidget(0, 0, Image('icons/exclam.png'))
        msgbox.setWidget(0, 1, message)
        msgbox.getCellFormatter().setStyleName(0, 0, 'changes-image')
        msgbox.getCellFormatter().setStyleName(0, 1, 'changes-text')

        button = Button('apply changes')
        button.addClickListener(self.apply_clicked)

        self.changes = VerticalPanel()
        self.changes.setHorizontalAlignment('right')
        self.changes.setVisible(False)
        self.changes.add(msgbox)
        self.changes.add(button)

        panel = VerticalPanel()
        panel.setSpacing(10)
        panel.add(self.table)
        panel.add(self.status)
        panel.add(self.changes)

        return panel
开发者ID:christophgysin,项目名称:schoolbell,代码行数:28,代码来源:alarmwidget.py

示例15: YChanger

class YChanger (HorizontalPanel):

    def __init__(self, chart):
        self.chart = chart
        HorizontalPanel.__init__(self)
        # y-changing, x,y coordinate displaying, widget
        self.incrementY = Button("Increment Y")
        self.coordinates = HTML(""); # x,y of selected point
        self.decrementY = Button("Decrement Y")
        self.incrementY.addClickListener(self)
        self.decrementY.addClickListener(self)
        self.add(self.incrementY)
        self.add(self.coordinates)
        self.add(self.decrementY)

    def onClick(self, sender):
        if sender == self.incrementY:
            self.chart.getTouchedPoint().setY(
                                self.chart.getTouchedPoint().getY() + 1)
        else:
            self.chart.getTouchedPoint().setY(
                                self.chart.getTouchedPoint().getY() - 1)
        self.chart.update()

    # The 2 HoverUpdateable interface methods:
    def hoverCleanup(self, hoveredAwayFrom):
        pass

    def hoverUpdate(self, hoveredOver):
        # update (x,y) display when they click point
        self.coordinates.setHTML(hoveredOver.getHovertext())
开发者ID:Afey,项目名称:pyjs,代码行数:31,代码来源:GChartExample21.py


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