def updateArticles(self): w = QtGui.QWidget(self) vbox = QtGui.QVBoxLayout(w) font = QtGui.QFont("Arial") i = 0 self.rssLinks.clear() # remove all previous articles while i < 20: for feed in self.feedList: if i >= len(feed.entries): # verify that an entry exists continue _l = QtGui.QHBoxLayout() _d = QtGui.QHBoxLayout() self.rssLinks[feed.entries[i].title] = feed.entries[i].link title = ClickableQLabel(feed.entries[i].title) self.connect(title, QtCore.SIGNAL('clicked()'), self.emitOpenArticle) title.setWordWrap(True) title.setMinimumWidth(self.parent().geometry().width()-100) font.setPointSize(12) font.setBold(True) title.setFont(font) try: description = self.getDescription(feed.entries[i].summary) # shorten the description if longer than desired except: description = "" desc = QtGui.QLabel(" " + description) desc.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) desc.setMinimumWidth(self.parent().geometry().width()-100) desc.setWordWrap(True) font.setPointSize(10) font.setBold(False) desc.setFont(font) _l.addWidget(title) _d.addWidget(desc) _l.addStretch(1) _d.addStretch(1) vbox.addLayout(_l) vbox.addLayout(_d) i += 1 return w
def initUI(self): self.grid = QtGui.QGridLayout(self) # Gridlayout to contain all widgets # Today date label date = QtGui.QLabel() date.setText("Today") ff = QtGui.QFont() ff.setPointSize(14) ff.setBold(True) date.setFont(ff) date.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) # Today Icon label pic = ClickableQLabel() self.connect(pic, QtCore.SIGNAL('clicked()'), self.startWeatherThread) pic.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) self.origIcons.append(QtGui.QPixmap()) # Today temps label temp = QtGui.QLabel() temp.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) # Today weather details label det = QtGui.QLabel() det.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) self.grid.addWidget(date, 0, 0) self.grid.addWidget(pic, 1, 0) self.grid.addWidget(temp, 2, 0) self.grid.addWidget(det, 3, 0) # Initialize 4-day Forecast widgets i = 1 while i < 5: date = QtGui.QLabel() date.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) pic = ClickableQLabel() self.connect(pic, QtCore.SIGNAL('clicked()'), self.startForecastThread) pic.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) self.origIcons.append(QtGui.QPixmap()) temp = QtGui.QLabel() temp.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) det = QtGui.QLabel() det.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignVCenter) self.grid.addWidget(date, 0, i) self.grid.addWidget(pic, 1, i) self.grid.addWidget(temp, 2, i) self.grid.addWidget(det, 3, i) i = i + 1 self.updateWeather() self.updateForecast() # populate with weather self.grid.setContentsMargins(2, 2, 2, 2) self.grid.setSpacing(3) self.show() # SHOW YOURSELF