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


Python FlexTable.insertRow方法代码示例

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


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

示例1: StatusTab

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import insertRow [as 别名]
class StatusTab(RPCBase):
    def __init__(self,app):
        self.app=app
        self.vpanel = VerticalPanel()
        self.vpanel.setWidth("100%")
        self.table = FlexTable()
        self.vpanel.add(self.table)
        btn = Button('Update',self.update)
        self.vpanel.add(btn)
        self.id2row = {}
        self.table.setHTML(0, 0, "<b>Time</b>")
        self.table.setHTML(0, 1, "<b>Problem</b>")
        self.table.setHTML(0, 2, "<b>User</b>")
        self.table.setHTML(0, 3, "<b>Status</b>")
        self.cnt=1
        self.time=None
        #self.update()
        Timer(4000,self)
        
    def onTimer(self, x):
        #self.update()
        Timer(4000,self)

    def update(self,_=None):
        global gw
        gw.listSubmissions(self.time, self)
    
    def problemLambda(self, pid):
        return lambda: ProblemTab(self.app, pid)

    def userLambda(self,uid):
        return lambda: UserTab(self.app, uid)

    def submissionLambda(self,sid):
        return lambda: SubmissionTab(self.app, sid)

    def onRemoteResponse(self, response, request_info):
#0  (x.id,               
#1 x.problem.name, 
#2 x.problem_id, 
#3 x.submitter.handle, 
#4 x.submitter_id,  
#5 status(x.code),
#6 x.judgeTime,
#7 x.submitTime )
        if response:
            for line in response:
                if line[0] in self.id2row:
                    idx =self.cnt- self.id2row[line[0]]
                    #alert(self.id2row[line[0]] + " " + idx + " " + self.cnt);
                    #return
                else:
                    idx = 1
                    self.table.insertRow(1)
                    self.id2row[line[0]] = self.cnt
                    self.cnt += 1          
                #Hyperlink
                self.table.setText(idx, 0, line[7])
                pl=Hyperlink(line[1])
                pl.addClickListener(self.problemLambda(line[2]));
                self.table.setWidget(idx, 1, pl)
                ul=Hyperlink(line[3])
                ul.addClickListener(self.userLambda(line[4]) );
                self.table.setWidget(idx, 2, ul)
                sl=Hyperlink(line[5])
                sl.addClickListener(self.submissionLambda(line[0]))
                self.table.setWidget(idx, 3, sl)
                if line[6] != 'None': self.time = max(self.time, line[6], line[7])
                else: self.time = max(self.time, line[7])

    def getRoot(self):
        return self.vpanel
开发者ID:antialize,项目名称:djudge,代码行数:74,代码来源:main.py

示例2: AlarmWidget

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import insertRow [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.insertRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。