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


Python FlexTable.getRowCount方法代码示例

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


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

示例1: onModuleLoad

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowCount [as 别名]

#.........这里部分代码省略.........
		if len(name) > 100:
			Window.alert("Movie name is too long. Maximum length is 100 characters.")
			return False
		if len(category) == 0:
			Window.alert("Category cannot be empty.")
			return False
		p = re.compile('^[0-9A-Za-z\\.\\-\\(\\) ]{1,100}$')
		if p.match(category) == None:
			Window.alert('"%s" is not a valid category.' % category)
			return False
		return True
	
	def addMovieButton_Click(self, event):		
		name = self.newMovieNameTextBox.getText().trim()
		cat = self.newMovieCategoryTextBox.getText().trim().lower()
		category = cat[0].upper() + cat[1:]
		rating = self.newMovieRatingListBox.getSelectedIndex()
		
		if not self.verifyInputs(name, category):
			return
			
		movie = Movie(name, category, rating)
			
		if movie in self.movies:
			Window.alert("'" + name + "' is already in table.")
			self.newMovieNameTextBox.selectAll()
			return
			
		self.remote.addMovie((name, category, rating), self)
		self.newMovieNameTextBox.setText('')
		
	def addMovie(self, sender, movie):						
		self.movies.append(movie)
		row = self.moviesFlexTable.getRowCount()
		
		self.moviesFlexTable.setText(row, 1, movie.category)
		self.moviesFlexTable.setText(row, 2, movie.name)
		self.moviesFlexTable.setText(row, 3, movie.rating)
					
		# Adds buttons for remove, edit, save and cancel
		removeMovieButton = Button("x")
		editMovieButton = Button("Edit")
		saveButton = Button("Save")
		cancelButton = Button("Cancel")	
			
		# Save and cancel are hidden by default
		saveButton.setVisible(False)
		cancelButton.setVisible(False)
		
		# Add buttons to row
		buttons = HorizontalPanel()
		buttons.add(removeMovieButton)
		buttons.add(editMovieButton)
		buttons.add(cancelButton)
		buttons.add(saveButton)
		self.moviesFlexTable.setWidget(row, 0, buttons)
		
		def removeMovieButton_Click(sender):
			self.remote.deleteMovie((movie.name, movie.category), self)
		removeMovieButton.addClickListener(removeMovieButton_Click)
		
		def editMovieButton_Click(sender):   		
    	    # Add textboxes and listbox
			editMovieButton.setVisible(False)
			cancelButton.setVisible(True)
			saveButton.setVisible(True)
开发者ID:FloorLamp,项目名称:CS3300-HW4,代码行数:70,代码来源:MovieRatings.py

示例2: onModuleLoad

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowCount [as 别名]
class StockWatcher:
    def onModuleLoad(self):
        '''
        This is the main entry point method.
        '''
        
        # Setup JSON RPC
        self.remote = DataService()
        
        # Initialize member variables
        self.mainPanel = VerticalPanel()
        self.stocksFlexTable = FlexTable()
        self.addPanel = HorizontalPanel()
        self.newSymbolTextBox = TextBox()
        self.lastUpdatedLabel = Label()
        self.addStockButton = Button('Add', self.addStock)
        self.stocks = []
        self.stocksTableColumns = ['Symbol', 'Price', 'Change', 'Remove']
        
        # Add styles to elements in the stock list table
        self.stocksFlexTable.getRowFormatter().addStyleName(0, 'watchListHeader')
        self.stocksFlexTable.addStyleName('watchList')
        self.stocksFlexTable.getCellFormatter().addStyleName(0, 1, 'watchListNumericColumn')
        self.stocksFlexTable.getCellFormatter().addStyleName(0, 2, 'watchListNumericColumn')
        self.stocksFlexTable.getCellFormatter().addStyleName(0, 3, 'watchListRemoveColumn')
        
        # Create table for stock data
        for i in range(len(self.stocksTableColumns)):
            self.stocksFlexTable.setText(0, i, self.stocksTableColumns[i])
        
        # Assemble Add Stock panel
        self.addPanel.add(self.newSymbolTextBox)
        self.addPanel.add(self.addStockButton)
        self.addPanel.addStyleName('addPanel')
        
        # Assemble Main panel
        self.mainPanel.add(self.stocksFlexTable)
        self.mainPanel.add(self.addPanel)
        self.mainPanel.add(self.lastUpdatedLabel)
        
        # Associate the Main panel with the HTML host page
        RootPanel().add(self.mainPanel)
        
        # Move cursor focus to the input box
        self.newSymbolTextBox.setFocus(True)
        
        # Setup timer to refresh list automatically
        refresh = self.refreshWatchlist
        class MyTimer(Timer):
            def run(self):
                refresh()
        refreshTimer = MyTimer()
        refreshTimer.scheduleRepeating(5000)
        
        # Listen for keyboard events in the input box
        self_addStock = self.addStock
        class StockTextBox_KeyboardHandler():
            def onKeyPress(self, sender, keycode, modifiers):
                if keycode == KEY_ENTER:
                    self_addStock()
            def onKeyDown(self, sender, keycode, modifiers): return
            def onKeyUp(self, sender, keycode, modifiers): return
        self.newSymbolTextBox.addKeyboardListener(StockTextBox_KeyboardHandler())
        
        # Load the stocks
        self.remote.getStocks(self)
    
    def addStock(self, sender, symbol=None):
        '''
        Add stock to FlexTable. Executed when the user clicks the addStockButton
        or presses enter in the newSymbolTextBox
        '''
        
        if symbol is None:
            # Get the symbol
            symbol = self.newSymbolTextBox.getText().upper().trim()
            self.newSymbolTextBox.setText('')
            # Don't add the stock if it's already in the table
            if symbol in self.stocks:
                return
            # Tell the server that we're adding this stock
            self.remote.addStock(symbol, self)
            self.newSymbolTextBox.setFocus(True)
            # Stocks code must be between 1 and 10 chars that are numbers/letters/dots
            p = re.compile('^[0-9A-Z\\.]{1,10}$')
            if p.match(symbol) == None:
                Window.alert('"%s" is not a valid symbol.' % symbol)
                self.newSymbolTextBox.selectAll()
                return    
        
        # Add the stock to the table
        row = self.stocksFlexTable.getRowCount()
        self.stocks.append(symbol)
        self.stocksFlexTable.setText(row, 0, symbol)
        self.stocksFlexTable.setWidget(row, 2, Label())
        self.stocksFlexTable.getCellFormatter().addStyleName(row, 1, 'watchListNumericColumn')
        self.stocksFlexTable.getCellFormatter().addStyleName(row, 2, 'watchListNumericColumn')
        self.stocksFlexTable.getCellFormatter().addStyleName(row, 3, 'watchListRemoveColumn')
        
        # Add a button to remove this stock from the table
#.........这里部分代码省略.........
开发者ID:fedenko,项目名称:StockWatcher2,代码行数:103,代码来源:StockWatcher.py

示例3: AlarmWidget

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowCount [as 别名]

#.........这里部分代码省略.........
        self.time = {}

        self.time['hour'] = ListBox()
        self.time['hour'].setVisibleItemCount(1)
        for hour in range(24):
            self.time['hour'].addItem('%02d' % hour)
        self.time['hour'].setSelectedIndex(12)

        self.time['minute'] = ListBox()
        self.time['minute'].setVisibleItemCount(1)
        for minute in range(0, 60, 5):
            self.time['minute'].addItem('%02d' % minute)
        self.time['minute'].setSelectedIndex(0)

        time_panel = HorizontalPanel()
        time_panel.setVerticalAlignment('center')
        time_panel.add(self.time['hour'])
        time_panel.add(Label(':'))
        time_panel.add(self.time['minute'])
        self.table.setWidget(1, 0, time_panel)

        weekdays_panel = HorizontalPanel()
        weekdays_panel.setSpacing(5)
        self.weekdays = {}
        for i in range(7):
            self.weekdays[i] = CheckBox(AlarmWidget.weekday_name[i])
            self.weekdays[i].setChecked(i < 6)
            weekdays_panel.add(self.weekdays[i])
        self.table.setWidget(1, 1, weekdays_panel)

        self.duration = ListBox()
        self.duration.setVisibleItemCount(1)
        choices = [ 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60 ]
        for seconds in choices:
            self.duration.addItem(
                    '%ds' % seconds if seconds < 60 else '%dm' % (seconds / 60),
                    seconds)
        self.duration.setSelectedIndex(2)
        self.table.setWidget(1, 2, self.duration)

        image = Image('icons/plus.png')
        image.setTitle('add');
        image.addClickListener(self.plus_clicked)
        self.table.setWidget(1, 3, image)

        for col in range(4):
            self.table.getCellFormatter().setStyleName(1, col, 'tablecell noborder')

    def fill_table(self):
        for idx, alarm in enumerate(self.alarms.get()):
            self.add(alarm['time'], alarm['weekdays'], alarm['duration'])

    def add(self, time, weekdays=range(5), duration=3):
        row = self.table.getRowCount()-1
        self.table.insertRow(row)
        self.table.setText(row, 0, time)
        weekdays_str = []
        for weekday in weekdays:
            weekdays_str.append(AlarmWidget.weekday_name[weekday])

        self.table.setText(row, 1, ', '.join(weekdays_str))
        self.table.setText(row, 2, str(duration) + 's')

        image = Image('icons/x.png')
        image.setTitle('delete');
        image.addClickListener(lambda x: self.x_clicked(row-1))
        self.table.setWidget(row, 3, image)

        for col in range(3):
            self.table.getCellFormatter().setStyleName(row, col, 'tablecell')
        self.table.getCellFormatter().setStyleName(row, 3, 'tablecell noborder')

    def remove(self, idx):
        if idx >= 0 and idx < self.table.getRowCount()-2:
            #self.status.setText('removing idx: %d' % idx)
            self.table.removeRow(idx+1)
        else:
            #self.status.setText('tried to remove idx: %d' % idx)
            pass

    def plus_clicked(self):
        self.changes.setVisible(True)
        getSelectedValue = lambda widget: widget.getValue(widget.getSelectedIndex())
        hour = getSelectedValue(self.time['hour'])
        minute = getSelectedValue(self.time['minute'])
        time = '%02d:%02d:%02d' % ( hour, minute, 0 )
        weekdays = [ i for i in range(7) if self.weekdays[i].isChecked() ]
        duration = getSelectedValue(self.duration)

        self.add(time, weekdays, duration)
        self.alarms.add({'time': time, 'weekdays': weekdays, 'duration': duration})

    def x_clicked(self, idx):
        self.changes.setVisible(True)
        self.remove(idx)
        #self.alarms.remove(idx)

    def apply_clicked(self):
        self.alarms.save()
        self.changes.setVisible(False)
开发者ID:christophgysin,项目名称:schoolbell,代码行数:104,代码来源:alarmwidget.py


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