class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) PyQt4.uic.loadUi('ui/pyrex.ui', self) self.adv_search = TabAdvSearch(self.tabs) self.peers = TabPeers(self.tabs) self.downloads = TabDownloads(self.tabs) self.options = TabOptions(self.tabs) self.shares = TabShares(self.tabs) self.tabs.insertTab(1, self.adv_search, u"Recherche avancée") self.tabs.insertTab(2, self.downloads, u"Téléchargements") self.tabs.insertTab(3, self.peers, u"Utilisateurs") self.tabs.insertTab(4, self.options, u'Options') self.tabs.insertTab(5, self.shares, u'Mes partages') self.tabs_results = TabsResults(self.widget_recherches) self.widget_recherches.layout().addWidget(self.tabs_results) def change_tab(self, tab): if tab == 3: self.peers.update_peers() if tab == 6: self.update_informations() def update_informations(self): self.stats_get = StatisticsGet() self.stats_get.do_get(self.set_statistics) self.version_get = VersionGet() self.version_get.do_get(self.set_version) def set_statistics(self, stats): txt = u"Utilisateurs connectés : %d\n" % stats.users txt += u"Taille de vos fichiers dans la base : %s\n" % stats.shares_size_mine_str txt += u"Taille des fichiers dans la base : %s" % stats.shares_size_total_str self.statistics_label.setText(txt) def set_version(self, version): txt = "%s version %d.%d.%d\n" % \ (version.name, version.major, version.minor, version.minor_minor) txt += "PyRex version 0.0.1" self.version_label.setText(txt) def search(self): query = str(self.search_edit1.text()) if len(query) > 1: search = Search(query) tab_result = TabResults(search, parent=self.tabs_results) self.tabs_results.addTab(tab_result, query) def adv_search(self): print "hello world"
def __init__(self, search, tab_downloads, parent): QWidget.__init__(self, parent) TabSearch.instance = self self.tab_downloads = tab_downloads self.tabs = parent # Load de l'UI PyQt4.uic.loadUi('ui/search.ui', self) # Init self.tabs_results = TabsResults(self.widget_searches) self.widget_searches.layout().addWidget(self.tabs_results)
class TabSearch(QWidget): instance = None def __init__(self, search, tab_downloads, parent): QWidget.__init__(self, parent) TabSearch.instance = self self.tab_downloads = tab_downloads self.tabs = parent # Load de l'UI PyQt4.uic.loadUi('ui/search.ui', self) # Init self.tabs_results = TabsResults(self.widget_searches) self.widget_searches.layout().addWidget(self.tabs_results) def search(self): query = unicode(self.search_edit.text().toUtf8(), 'utf-8') if len(query) > 1: self.add_search(Search(query)) def add_search(self, search): tab_result = TabResults(search, self.tabs_results, self.tab_downloads, self.tabs) self.tabs_results.addTab(tab_result, search.query) self.tabs_results.setCurrentWidget(tab_result)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) PyQt4.uic.loadUi('ui/pyrex.ui', self) self.adv_search = TabAdvSearch(self.tabs) self.peers = TabPeers(self.tabs) self.downloads = TabDownloads(self.tabs) self.options = TabOptions(self.tabs) self.shares = TabShares(self.tabs) self.tabs.insertTab(1, self.adv_search, u"Recherche avancée") self.tabs.insertTab(2, self.downloads, u"Téléchargements") self.tabs.insertTab(3, self.peers, u"Utilisateurs") self.tabs.insertTab(4, self.options, u'Options') self.tabs.insertTab(5, self.shares, u'Mes partages') self.tabs_results = TabsResults(self.widget_recherches) self.widget_recherches.layout().addWidget(self.tabs_results)