def __init__(self, api_data=None, preferences=None, post_limit=None, parent=None): """Initialize a new ThumbnailArea. api_data is a reference to a Danbooru object, while preferences is a reference to a KConfigXT instance.""" super(DanbooruTabWidget, self).__init__(parent) loadUi(WIDGET_UI, self) self.preferences = preferences self.api_data = api_data self.__pages = list() self.__firstpage = True self.__current_index = 0 self.post_limit = post_limit # Generate and set the two widgets self.fetchwidget = FetchWidget( limit=preferences.thumbnail_no, default_rating=preferences.max_allowed_rating, parent=self.parent()) self.connectwidget = ConnectWidget(preferences.boards_list, self) self.messagewidget = KMessageWidget(self) # Ugly hacks to have the widgets in proper positions self.gridLayout.removeWidget(self.thumbnailTabWidget) spacer = self.gridLayout.itemAtPosition(1, 0) self.gridLayout.removeItem(spacer) self.gridLayout.removeWidget(self.nextPageButton) self.gridLayout.addWidget(self.messagewidget, 0, 0, 1, -1) self.gridLayout.addWidget(self.connectwidget, 1, 0, 1, -1) self.gridLayout.addWidget(self.fetchwidget, 2, 0, 1, -1) self.gridLayout.addWidget(self.thumbnailTabWidget, 3, 0, 1, 2) self.gridLayout.addItem(spacer, 4, 0, 1, 1) self.gridLayout.addWidget(self.nextPageButton, 5, 1, 1, 1) self.connectwidget.hide() self.fetchwidget.hide() self.messagewidget.hide() self.messagewidget.setMessageType(KMessageWidget.Error) KAcceleratorManager.setNoAccel(self.thumbnailTabWidget) self.nextPageButton.setDisabled(True) button_toggle = partial(self.nextPageButton.setDisabled, False) self.api_data.postDownloadFinished.connect(button_toggle) self.api_data.postDownloadFinished.connect(self.__check) self.nextPageButton.clicked.connect(self.update_search_results) self.api_data.downloadError.connect(self.display_error) self.new_page()