def showNews(self): random_items = random.choices(population=self.all_head_lines, k=1)[0] date = parser.parse(random_items["date"]) str_date = QLocale().toString(date) self.date_pub.setText(str_date.capitalize()) self.title_pub.setText(random_items["title"]) print(random_items)