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


Python Button.addClickListener方法代码示例

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


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

示例1: onModuleLoad

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
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,代码行数:37,代码来源:TestRect.py

示例2: YChanger

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
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,代码行数:33,代码来源:GChartExample21.py

示例3: redraw

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
    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,代码行数:28,代码来源:SortedGridThing.py

示例4: onModuleLoad

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
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,代码行数:30,代码来源:TestDict.py

示例5: make_panel

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
    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,代码行数:30,代码来源:alarmwidget.py

示例6: __init__

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
    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,代码行数:34,代码来源:GeocodingSimple.py

示例7: createTextThing

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
    def createTextThing(self, textBox):
        p = HorizontalPanel()
        p.setSpacing(4)

        p.add(textBox)

        echo = HTML()
        select_all = Button("select all")
        p.add(select_all)
        p.add(echo)

        listener=TextBoxListener(self, textBox, echo, select_all)
        select_all.addClickListener(listener)
        textBox.addKeyboardListener(listener)
        textBox.addClickListener(listener)

        return p
开发者ID:Afey,项目名称:pyjs,代码行数:19,代码来源:Text.py

示例8: make_panel

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
    def make_panel(self):
        duration = ListBox()
        duration.setVisibleItemCount(1)
        choices = [ 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60 ]
        for seconds in choices:
            duration.addItem(
                    '%ds' % seconds if seconds < 60 else '%dm' % (seconds / 60),
                    seconds)
        duration.setSelectedIndex(2)

        button = Button('test')
        handler = TestHandler(duration)
        button.addClickListener(handler.func)

        panel = HorizontalPanel()
        panel.add(duration)
        panel.add(button)
        return panel
开发者ID:christophgysin,项目名称:schoolbell,代码行数:20,代码来源:testwidget.py

示例9: onModuleLoad

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
 def onModuleLoad(self):
     self.panel = VerticalPanel()
     self.panel.setSpacing(10)
     RootPanel().add(self.panel)
     
     self.swfUpload = self.getSWFUpload()
     self.panel.add(self.swfUpload)
     
     self.fileids = []
     self.queue = VerticalPanel()
     self.panel.add(self.queue)
     
     startButton = Button('Start Upload')
     startButton.addClickListener(getattr(self, 'onStartUpload'))
     self.panel.add(startButton)
     
     self.progress = Label()
     self.panel.add(self.progress)
开发者ID:brodybits,项目名称:pyjs,代码行数:20,代码来源:swfu.py

示例10: drawControl

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
def drawControl(container):
    bar = HorizontalPanel(ID='aur-search-bar', VerticalAlignment='middle')
    adv = HorizontalPanel(ID='aur-search-advanced', Visible=False)
    adv_toggle = Hyperlink(Text='Advanced', StyleName='aur-link-stateless aur-search-bar-advanced', TargetHistoryToken=History.getToken())
    query = TextBox(Text='enter search term...', StyleName='aur-search-bar-query')
    go = Button(HTML='Go', StyleName='aur-search-bar-submit')

    container.add(bar)
    container.add(adv)

    # slight workaround to make sure the 'Advanced' toggle doesn't change the page
    def updateAdvToken(token):
        adv_toggle.setTargetHistoryToken(token)
    obj = object()
    setattr(obj, 'onHistoryChanged', updateAdvToken)
    History.addHistoryListener(obj)

    # clickListener to toggle the advanced section
    def toggleAdv(sender):
        if adv.isVisible():
            adv.setVisible(False)
            query.setEnabled(True)
            adv_toggle.setText('Advanced')
        else:
            adv.setVisible(True)
            query.setEnabled(False)
            adv_toggle.setText('Basic')
    adv_toggle.addClickListener(toggleAdv)

    def doGo():
        History.newItem('/package/search')
    go.addClickListener(doGo)

    bar.add(Label('Search Criteria', StyleName='aur-search-bar-label'))
    bar.add(query)
    bar.add(go)
    bar.add(Button(HTML='Orphans', StyleName='aur-search-bar-submit'))
    bar.add(adv_toggle)

    drawAdvanced(adv)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:42,代码来源:Search.py

示例11: DbTest

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

    def __init__(self):

        self.tb = TextBox()
        self.b = Button("add")
        self.g = Grid()
        self.g.resize(4, 2)

        RootPanel().add(HTML("Add Phrase.  Press Button."))
        RootPanel().add(self.tb)
        RootPanel().add(self.b)
        RootPanel().add(self.g)
        self.b.addClickListener(self)

        try:
            self.db = Factory.createDatabase()
            self.db.open('database-demo')
            self.db.execute('create table if not exists Demo' +
                       ' (Phrase varchar(255), Timestamp int)')
        except ex:
            log("could not create database" + str(ex))

    def onClick(self, sender):
        phrase = self.tb.getText()
        currTime = time()
        self.db.execute('insert into Demo values (?, ?)', phrase, currTime);

        rs = self.db.execute('select * from Demo order by Timestamp desc');
        index = 0
        while rs.isValidRow():
            if index <4:
                self.g.setHTML(index, 0, rs.field(0))
                self.g.setHTML(index, 1, rs.field(1))
            else:
                self.db.execute('delete from Demo where Timestamp=?', rs.field(1));
            index += 1

            rs.next()
        rs.close()
开发者ID:jaredly,项目名称:pyjamas,代码行数:42,代码来源:GearsDemo.py

示例12: HomePanel

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

    def __init__(self, parent):
        AbsolutePanel.__init__(self)
        self.home_header = Label("Blogjamas", StyleName="header_label")
        self.write_button = Button("Write a Post")
        self.edit_hidden_button = Button("", StyleName="hidden_button")
        self.delete_hidden_button = Button("", StyleName="hidden_button")
        self.add(self.home_header)
        self.add(self.write_button)
        self.add(self.edit_hidden_button)
        self.add(self.delete_hidden_button)

    def update_posts(self, posts):
        self.contents = VerticalPanel(Spacing=1)
        for i in range(len(posts)):
            self.divider = HTML("----------------------------------------------------")
            self.contents.add(self.divider)
            self.post_title = Label(posts[i].title, StyleName="title_label")
            self.contents.add(self.post_title)
            self.post_content = Label(posts[i].content, StyleName="content_label")
            self.contents.add(self.post_content)
            self.edit_button = Button("Edit")
            self.edit_button.setID("edit_" + posts[i].post_id)
            self.edit_button.addClickListener(self.show_edit_box)
            self.contents.add(self.edit_button)
            self.delete_button = Button("Delete")
            self.delete_button.setID("delete_" + posts[i].post_id)
            self.delete_button.addClickListener(self.delete_post)
            self.contents.add(self.delete_button)
        self.add(self.contents)

    def show_edit_box(self, sender):
        self.edit_hidden_button.setID(sender.getID())
        self.edit_hidden_button.click(self)

    def delete_post(self, sender):
        self.delete_hidden_button.setID(sender.getID())
        self.delete_hidden_button.click(self)
开发者ID:Afey,项目名称:pyjs,代码行数:41,代码来源:components.py

示例13: add_button

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

示例14: TestrunTimeDeltas

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
class TestrunTimeDeltas(GChart):
    """
    Draws a stacked bar chart of the time deltas 
    for a testrun

    The central datastructure for the testrun_dts is:-

    @rtype: A list of [C{tuple} of (C{str}, 
                         [C{list} of 
                            [C{list} of C{float}]])]
    @rparam: A tuple of the testrun_id and the time deltas
                  for all the steps in the testrun 
    """

    COLORS = ['#a5cee3', '#1f78b3', '#b2de89',
              '#fcbf6f','#fb9a99', '#693d9a']

    STATE_COLORS = {None : '#FFFFFF',
                    '0' : '#FFA500',
                    '1' : '#FFA500', 
                    '2' : '#008000', 
                    '3' : '#FF0000', 
                    '4' : '#FF0000'}
        
    WIDTH = 600
    SIZE = 220
    MARGIN = 7
    MAX_X_LABEL_LENGTH = 6
    CHUNK_SIZE = 20
    BAR_WIDTH = 15
    Y_AXIS_SCALING = [1, 2, 3, 5, 7]
        
    def __init__(self):
        GChart.__init__(self)
        self.first = True
        self._steps = None
        self._end_step = None
        self._testrun_states = None
        self._timedeltas = None
        self._no_of_runs = None
        DEVICE_GROUP = None # Fixme
        self.remote = DataService()
        self.remote.get_total_no_of_testruns(DEVICE_GROUP, self)
        self.remote.get_event_sequence(self)
        #
        self.backButton = Button("<b><<</b>")
        self.backButton.addClickListener(self.onBack)

        self.forwardButton = Button("<b>>></b>")
        self.forwardButton.addClickListener(self.onForward)
        self.setChartFootnotes("")
      
    ##############################
    # SCALING
    ##############################

    def _get_longest_time(self, testrun_dts):
        """
        @type: See class docstring
        @param: The Testrun timedeltas for this `chunk`

        @rtype: C{int}
        @rparam: The longest time taken for this chunk of runs
        """
        longest_time = 0
        for testrun_idx in range(len(testrun_dts)):
            testrun_id, all_dts = testrun_dts[testrun_idx]
            testrun_time = sum([sum(step_dts) for step_dts in all_dts])
            longest_time = max(longest_time , testrun_time)
        return longest_time

    def _get_y_axis_size(self, longest_time):
        """
        Propose a size for the y axis

        @rtype: C{int}
        @rparam: The longest time taken for this chunk of runs
        """
        #FIXME: This is crude and ugly 
        #no doubt gchart provides something better natively
        candidate = 1
        for p in range(4):
            for scale in self.Y_AXIS_SCALING:
                candidate = scale*pow(10,p)
                if  candidate > longest_time:
                    break
        return candidate 
                
    ##############################
    # CHART RENDERING
    ##############################

    def _vertical_label(self, label, color):
        """
        The label rendered as vertical html

        @type label: C{str}
        @rparam label: The x axis label
        
        @rtype: C{str}
#.........这里部分代码省略.........
开发者ID:mileskin,项目名称:ots-mirror,代码行数:103,代码来源:testrun_timedeltas.py

示例15: onModuleLoad

# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addClickListener [as 别名]
class SoftChordApp:
    def onModuleLoad(self):
        """
        Gets run when the page is first loaded.
        Creates the widgets.
        """

        self.remote = DataService()
        
        main_layout = VerticalPanel()

        h_layout = HorizontalPanel()
        h_layout.setPadding(10)
        
        songlist_layout = VerticalPanel()
        
        songlist_layout.add(Label("Add New Song:"))
 	

        self.newSongTextBox = TextBox()
	self.newSongTextBox.addKeyboardListener(self)
        songlist_layout.add(self.newSongTextBox)
        
       	self.addSongButton = Button("Add Song")
	self.addSongButton.addClickListener(self)
	songlist_layout.add(self.addSongButton)

        #songlist_layout.add(Label("Click to Remove:"))

        self.songListBox = ListBox()
        self.songListBox.setVisibleItemCount(7)
        self.songListBox.setWidth("300px")
        self.songListBox.setHeight("400px")
        self.songListBox.addClickListener(self)
        songlist_layout.add(self.songListBox)
        
        self.deleteSongButton = Button("Delete")
        self.deleteSongButton.addClickListener(self)
        songlist_layout.add(self.deleteSongButton)
         
        h_layout.add(songlist_layout)
        
        #self.textArea = TextArea()
        #self.textArea.setCharacterWidth(30)
        #self.textArea.setVisibleLines(50)
        #h_layout.add(self.textArea)
        
        #self.scrollPanel = ScrollPanel(Size=("400px", "500px"))
        self.songHtml = HTML("<b>Please select a song in the left table</b>")
        #self.scrollPanel.add(self.songHtml)
        #h_layout.add(self.scrollPanel)
        h_layout.add(self.songHtml)
        
        main_layout.add(h_layout)
        
        self.status = Label()
        main_layout.add(self.status)
        
        RootPanel().add(main_layout)
        
        # Populate the song table:
        self.remote.getAllSongs(self)
    

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

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

    def onKeyPress(self, sender, keyCode, modifiers):
        """
        This functon handles the onKeyPress event
        """
        if keyCode == KeyboardListener.KEY_ENTER and sender == self.newSongTextBox:
            id = self.remote.addSong(self.newSongTextBox.getText(), self)
            self.newSongTextBox.setText("")

            if id<0:
                self.status.setText("Server Error or Invalid Response")

    def onClick(self, sender):
        """
        Gets called when a user clicked in the <sender> widget.
        Currently deletes the song on which the user clicked.
        """
        if sender == self.songListBox:
            song_id = self.songListBox.getValue(self.songListBox.getSelectedIndex())
            self.status.setText("selected song_id: %s" % song_id)
            id = self.remote.getSong(song_id, self)
            if id<0:
                self.status.setText("Server Error or Invalid Response")
        
	elif sender == self.addSongButton:
            id = self.remote.addSong(self.newSongTextBox.getText(), self)
            self.newSongTextBox.setText("")
            if id<0:
                self.status.setText("Server Error or Invalid Response")
 
        elif sender == self.deleteSongButton:
#.........这里部分代码省略.........
开发者ID:academicsam,项目名称:softChord,代码行数:103,代码来源:softchordapp.py


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