コード例 #1
0
class Main(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.connect(self.ui.pushButtonRefresh, QtCore.SIGNAL("clicked()"), self._refreshData)
        self._bd = BusData("service.urls")

    def _refreshData(self):
        print("Refreshing data")
        data = self._bd.getData()
        self.ui.tableWidgetTimes.setRowCount(len(data))
        for i in range(len(data)):
            twiBusnum = QtGui.QTableWidgetItem(data[i][0])
            twiDest = QtGui.QTableWidgetItem(data[i][1])
            twiArrive = QtGui.QTableWidgetItem(data[i][2].strftime("%H:%M"))

            twiBusnum.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
            twiArrive.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)

            self.ui.tableWidgetTimes.setItem(i, 1, twiBusnum)
            self.ui.tableWidgetTimes.setItem(i, 2, twiDest)
            self.ui.tableWidgetTimes.setItem(i, 0, twiArrive)
        # auto resize our columns
        hh = self.ui.tableWidgetTimes.horizontalHeader()
        # hide row numbering
        self.ui.tableWidgetTimes.verticalHeader().hide()
        hh.setResizeMode(QtGui.QHeaderView.ResizeToContents)
コード例 #2
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.connect(self.ui.pushButtonRefresh, QtCore.SIGNAL("clicked()"), self._refreshData)
        self._bd = BusData("service.urls")