当前位置: 首页>>代码示例>>Python>>正文


Python PThread.start方法代码示例

本文整理汇总了Python中pds.thread.PThread.start方法的典型用法代码示例。如果您正苦于以下问题:Python PThread.start方法的具体用法?Python PThread.start怎么用?Python PThread.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pds.thread.PThread的用法示例。


在下文中一共展示了PThread.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWidget

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class MainWidget(QWidget, PM, Ui_MainWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)

        self.setupUi(self)
        self.parent = parent

        self._selectedGroups = []
        self._preexceptions  = []
        self._postexceptions = []

        self.state = StateManager(self)
        self.currentState = None
        self.completer = None
        self._updatesCheckedOnce = False

        #set style
        self._style = "/usr/share/kde4/apps/package-manager/data/style.qss"
        self.setStyleSheet(file(self._style).read())

        # Search Thread
        self._searchThread = PThread(self, self.startSearch, self.searchFinished)

        self.statusUpdater = StatusUpdater()
        self.basket = BasketDialog(self.state, self.parent)
        self._postexceptions.append(lambda: self.basket.setActionEnabled(True))
        self.searchButton.setIcon(KIcon("edit-find"))
        self.initializeUpdateTypeList()

        self.morewidgets = MoreWidgets(self.state, self.parent)
        self.morewidgets._show()

        self.webdialog = WebDialog(self.state, self.parent)

        model = PackageModel(self)
        proxy = PackageProxy(self)
        proxy.setSourceModel(model)
        self.packageList.setModel(proxy)
        self.packageList.setItemDelegate(PackageDelegate(self, self.parent))
        self.packageList.setColumnWidth(0, 32)

        self.connect(self.packageList.model(), SIGNAL("dataChanged(QModelIndex,QModelIndex)"), self.statusChanged)
        self.connect(self.packageList, SIGNAL("updateRequested()"), self.initialize)
        self.connect(self.morewidgets.randomPackageList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.showWebdialog)

        self.updateSettings()
        self.setActionButton()

        self.operation = OperationManager(self.state)

        self.progressDialog = ProgressDialog(self.state, self.parent)
        self._preexceptions.append(self.progressDialog._hide)
        self.progressDialog.registerFunction(FINISHED, lambda: self.parent.statusBar().setVisible(not self.progressDialog.isVisible()))
        self.progressDialog.registerFunction(OUT, lambda: self.parent.statusBar().show())
        self.summaryDialog = SummaryDialog()

        self.connectOperationSignals()
        self.pdsMessageBox = PMessageBox(self.content)

    def connectMainSignals(self):
        self.connect(self.actionButton, SIGNAL("clicked()"), self.showBasket)
        self.connect(self.buttonMore, SIGNAL("clicked()"), self.showMoreWidgets)
        self.connect(self.checkUpdatesButton, SIGNAL("clicked()"), self.state.updateRepoAction)
        self.connect(self.searchButton, SIGNAL("clicked()"), self.searchActivated)
        self.connect(self.searchLine, SIGNAL("textEdited(const QString&)"), self.searchLineChanged)
        self.connect(self.searchLine, SIGNAL("returnPressed()"), self.searchActivated)
        self.connect(self.searchLine, SIGNAL("clearButtonClicked()"), self.groupFilter)
        self.connect(self.typeCombo, SIGNAL("activated(int)"), self.typeFilter)
        self.connect(self.stateTab, SIGNAL("currentChanged(int)"), self.switchState)
        self.connect(self.groupList, SIGNAL("groupChanged()"), self.groupFilter)
        self.connect(self.groupList, SIGNAL("groupChanged()"), lambda:self.searchButton.setEnabled(False))
        self.connect(self.packageList.select_all, SIGNAL("clicked(bool)"), self.toggleSelectAll)
        self.connect(self.statusUpdater, SIGNAL("selectedInfoChanged(int, QString, int, QString)"), self.emitStatusBarInfo)
        self.connect(self.statusUpdater, SIGNAL("selectedInfoChanged(QString)"), lambda message: self.emit(SIGNAL("selectionStatusChanged(QString)"), message))
        self.connect(self.statusUpdater, SIGNAL("finished()"), self.statusUpdated)

    def initialize(self):
        waitCursor()
        self.searchLine.clear()
        self._started = False
        self._last_packages = None
        self.state.reset()
        self.initializePackageList()
        self.initializeGroupList()
        self.initializeStatusUpdater()
        self.statusChanged()
        self._selectedGroups = []
        self.packageList.select_all.setChecked(False)
        self.initializeBasket()
        self.searchLine.setFocus(True)
        if self.currentState == self.state.UPGRADE:
            if self.groupList.count() == 0:
                QTimer.singleShot(0, \
                lambda: self.pdsMessageBox.showMessage(i18n("All packages are up to date"), icon = "games-endturn"))
        if self.groupList.count() > 0:
            if self.state.inUpgrade():
                self.pdsMessageBox.hideMessage(force = True)
        restoreCursor()

    def initializeStatusUpdater(self):
#.........这里部分代码省略.........
开发者ID:aslanon,项目名称:pisilinux,代码行数:103,代码来源:mainwidget.py

示例2: Widget

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class Widget(QWidget, ScreenWidget):
    name = "timeSetup"

    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_DateTimeWidget()
        self.ui.setupUi(self)
        self.timer = QTimer(self)
        self.from_time_updater = True
        self.is_date_changed = False

        self.current_zone = ""

        self.tz_dict = {}
        self.continents = []
        self.countries = []

        for country, data in yali.localedata.locales.items():
            if country == ctx.consts.lang:
                if data.has_key("timezone"):
                    ctx.installData.timezone = data["timezone"]

        # Append continents and countries the time zone dictionary
        self.createTZDictionary()

        # Sort continent list
        self.sortContinents()

        # Append sorted continents to combobox
        self.loadContinents()

        # Load current continents country list
        self.getCountries(self.current_zone["continent"])

        # Highlight the current zone
        self.index = self.ui.continentList.findText(self.current_zone["continent"])
        self.ui.continentList.setCurrentIndex(self.index)

        self.index = self.ui.countryList.findText(self.current_zone["country"])
        self.ui.countryList.setCurrentIndex(self.index)

        # Initialize widget signal and slots
        self.__initSignals__()

        self.ui.calendarWidget.setDate(QDate.currentDate())

        self.pthread = None
        self.pds_messagebox = PMessageBox(self)
        self.pds_messagebox.enableOverlay()

        self.timer.start(1000)

    def __initSignals__(self):
        self.ui.timeEdit.timeChanged[QTime].connect(self.timerStop)
        self.ui.calendarWidget.dateChanged.connect(self.dateChanged)
        self.timer.timeout.connect(self.updateClock)
        self.ui.continentList.activated[str].connect(self.getCountries)

    def createTZDictionary(self):
        tz = TimeZoneList()
        zones = [ x.timeZone for x in tz.getEntries() ]
        zones.sort()

        for zone in zones:
            split = zone.split("/")

            # Human readable continent names
            continent_pretty_name = split[0].replace("_", " ")
            continent_pretty_name = continent_pretty_name

            # Some country names can be like Argentina/Catamarca so this fixes the splitting problem
            # caused by zone.split("/")
            #
            # Remove continent info and take the rest as the country name
            split.pop(0)
            country_pretty_name = " / ".join(split)

            # Human readable country names
            country_pretty_name = country_pretty_name.replace("_", " ")

            # Get current zone
            if zone == ctx.installData.timezone:
                self.current_zone = { "continent":continent_pretty_name, "country":country_pretty_name}

            # Append to dictionary
            if self.tz_dict.has_key(continent_pretty_name):
                self.tz_dict[continent_pretty_name].append([country_pretty_name, zone])
            else:
                self.tz_dict[continent_pretty_name] = [[country_pretty_name, zone]]


    def sortContinents(self):
        for continent in self.tz_dict.keys():
            self.continents.append(continent)
        self.continents.sort()

    def loadContinents(self):
        for continent in self.continents:
            self.ui.continentList.addItem(continent)

#.........这里部分代码省略.........
开发者ID:hrngultekin,项目名称:yali-family,代码行数:103,代码来源:ScrDateTime.py

示例3: UmMainScreen

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class UmMainScreen(QDialog, ui_mainscreen.Ui_UpgradeManager):

    def __init__(self, parent = None, step = 1):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        self.logger = SimpleLogger()
        self.log = self.logger.log

        self.target_repo = REPO_TEMPLATE % 'stable'
        self.iface = Iface(self)

        self.connect(self.iface, SIGNAL("notify(PyQt_PyObject)"), self.showMessage)

        self.msgbox = PMessageBox(self)
        self.msgbox.setStyleSheet("color:white;")
        self.msgbox.enableOverlay()
                                                          # Just for Fun :)
        self.pageWidget = QPageWidget(self.widget_screens)# , direction = 'ttb')
        self.layout.addWidget(self.pageWidget)

        self.button_next.clicked.connect(self.pageWidget.next)
        self.button_previous.clicked.connect(self.pageWidget.prev)
        self.button_cancel.clicked.connect(self.reject)

        # Threads
        self.thread_step_1 = PThread(self, self.step_1_start, self.step_1_end)
        self.thread_step_2 = PThread(self, self.step_2_start, self.step_2_end)
        self.thread_step_3 = PThread(self, self.step_3_start, self.step_3_end)

        # Update Page Title
        self.connect(self.pageWidget, SIGNAL("currentChanged()"), lambda:\
                     self.label_header.setText(self.pageWidget.getCurrentWidget().title))

        self.current_step = step

        if step == 1:
            self.thread_check = PThread(self, self.findMissingPackages, self.showResults)

            # Welcome
            self.pageWidget.createPage(
                    getWidget(ui_screen_1, _("Welcome to Upgrade Manager...")))

            # Repo Selection
            self.pageWidget.createPage(
                    getWidget(ui_screen_2, _("Select Upgrade Repository...")))

            # Check Results Page
            self.pageWidget.createPage(
                    getWidget(ui_screen_3, _("Checking your system...")),
                    inMethod = self.checkSystem, outMethod = self.hideMessage)

            resultWidget = self.pageWidget.getWidget(2).ui
            resultWidget.widget.hide()

            def updateButtons():
                if self.button_next.text() == _("Next"):
                    self.button_next.setText(_("Yes, Upgrade"))
                    self.button_previous.setText(_("Cancel"))
                    self.button_cancel.hide()
                else:
                    self.button_next.setText(_("Next"))
                    self.button_previous.setText(_("Previous"))
                    self.button_cancel.show()

            # Last Question
            self.pageWidget.createPage(
                    getWidget(ui_screen_4, ""), inMethod = updateButtons,
                                                outMethod= updateButtons)
        self._step_counter = 0

        # Progress Screen
        self.pageWidget.createPage(
                getWidget(ui_screen_5, _("Upgrading the system...")), inMethod = self.upgradeStep_1)

        # Shortcut for Progress Screen UI
        # Get the last added page as progress page
        # After the first step completed, um will use just this page !
        self.ps = self.pageWidget.getWidget(self.pageWidget.count() - 1).ui

        # Busy indicator to Progress Screen
        self.ps.busy = QProgressIndicator(self)
        self.ps.busy.hide()
        self.ps.layout.addWidget(self.ps.busy)

        if step == 2:
            self.upgradeStep_2()
        elif step == 3:
            self.upgradeStep_3()

    # Step 1 Method
    def checkSystem(self):
        self.showMessage(_("Checking your system..."))
        self.log("CHECKING CURRENT PACKAGES", "GUI")
        repoWidget = self.pageWidget.getWidget(1).ui

        for repo in ('stable', 'devel', 'testing'):
            if getattr(repoWidget, repo).isChecked():
                self.target_repo = REPO_TEMPLATE % repo

#.........这里部分代码省略.........
开发者ID:muratongan,项目名称:Pardus,代码行数:103,代码来源:gui.py

示例4: MainWidget

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class MainWidget(QWidget, PM, Ui_MainWidget):
    # Signal Emits
    updatingStatus = pyqtSignal()
    repositoriesUpdated = pyqtSignal()
    selectionStatusChanged = pyqtSignal([str])
    finished = pyqtSignal()
    cleanUp = pyqtSignal()
    
    def __init__(self, parent = None):
        super(MainWidget, self).__init__(parent)
        
        self.setupUi(self)
        self.parent = parent
        
        self._selectedGroups = []
        self._preexceptions  = []
        self._postexceptions = []

        self.state = StateManager(self)
        self.currentState = None
        self.completer = None
        self._updatesCheckedOnce = False
        
        
        # Search Thread
        self._searchThread = PThread(self, self.startSearch, self.searchFinished)

        self.statusUpdater = StatusUpdater()
        self.basket = BasketDialog(self.state, self.parent)
        self._postexceptions.append(lambda: self.basket.setActionEnabled(True))
        self.searchButton.setIcon(KIcon(("edit-find", "find")))
        self.initializeUpdateTypeList()

        model = PackageModel(self)
        proxy = PackageProxy(self)
        proxy.setSourceModel(model)
        self.packageList.setModel(proxy)
        self.packageList.setItemDelegate(PackageDelegate(self, self.parent))
        self.packageList.setColumnWidth(0, 32)
        
        
        
        self.packageList.dataChanged[QModelIndex,QModelIndex].connect(self.statusChanged)
        
        self.packageList.updateRequested.connect(self.initialize)

        self.updateSettings()
        self.setActionButton()

        self.operation = OperationManager(self.state)

        self.progressDialog = ProgressDialog(self.state, self.parent)
        self._preexceptions.append(self.progressDialog._hide)
        self.progressDialog.registerFunction(FINISHED, lambda: self.parent.statusBar().setVisible(not self.progressDialog.isVisible()))
        self.progressDialog.registerFunction(OUT, lambda: self.parent.statusBar().show())
        self.summaryDialog = SummaryDialog()

        self.connectOperationSignals()
        self.pdsMessageBox = PMessageBox(self.content)
        

    def connectMainSignals(self):
        self.actionButton.clicked.connect(self.showBasket)
        self.checkUpdatesButton.clicked.connect(self.state.updateRepoAction)
        self.searchButton.clicked.connect(self.searchActivated)
        self.searchLine.textEdited[str].connect(self.searchLineChanged)
        self.searchLine.returnPressed.connect(self.searchActivated)
        
        self.searchLine.textChanged[str].connect(self.slotSearchLineClear)       
        
        self.typeCombo.activated[int].connect(self.typeFilter)
        self.stateTab.currentChanged[int].connect(self.switchState)
        self.groupList.groupChanged.connect(self.groupFilter)
        self.groupList.groupChanged.connect(lambda:self.searchButton.setEnabled(False))
        self.packageList.select_all.clicked[bool].connect(self.toggleSelectAll)
        self.packageList.itemDelegate().packageSelected[bool].connect(self.toggleSelect)
        self.statusUpdater.selectedInfoChanged[int,str,int,str].connect(self.emitStatusBarInfo)
        self.statusUpdater.selectedInfoChanged[str].connect(lambda message: self.selectionStatusChanged[str].emit(message))
        self.statusUpdater.finished.connect(self.statusUpdated)

    def initialize(self):
        waitCursor()
        self.searchLine.clear()
        self._started = False
        self._last_packages = None
        self.state.reset()
        self.initializePackageList()
        self.initializeGroupList()
        self.initializeStatusUpdater()
        self.statusChanged()
        self._selectedGroups = []
        self.packageList.select_all.setChecked(False)
        self.initializeBasket()
        self.searchLine.setFocus(True)
        if self.currentState == self.state.UPGRADE:
            if self.groupList.count() == 0:
                QTimer.singleShot(0, \
                lambda: self.pdsMessageBox.showMessage(_translate("Packaga Manager","All packages are up to date"), icon = "info"))
        if self.groupList.count() > 0:
            if self.state.inUpgrade():
#.........这里部分代码省略.........
开发者ID:hrngultekin,项目名称:package-manager,代码行数:103,代码来源:mainwidget.py

示例5: WebDialog

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class WebDialog(PAbstractBox, Ui_WebDialog):
    def __init__(self, parent):
        PAbstractBox.__init__(self, parent)
        self.setupUi(self)

        self.iface = parent.iface

        # PDS Settings
        self._animation = 1
        self._duration = 400
        self.enableOverlay()
        self._disable_parent_in_shown = True

        self.registerFunction(IN, lambda: parent.statusBar().hide())
        self.registerFunction(FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible()))
        self._as = 'http://onurguzel.com/appinfo'
        self.cancelButton.clicked.connect(self._hide)
        self.cancelButton.setIcon(KIcon("dialog-close"))

        # Hide Scrollbars and context menu in webview
        self.webView.setContextMenuPolicy(Qt.NoContextMenu)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

        self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.webView.page().linkClicked.connect(self.redirectLinks)

        self.tabWidget.removeTab(0)

        self.busy = QProgressIndicator(self, "white")
        self.busy.setMaximumSize(QSize(48, 48))
        self.webLayout.addWidget(self.busy)
        self.busy.hide()

        self._filesThread = PThread(self, self.getFiles, self.getFilesFinished)
        self.filterLine.setListWidget(self.filesList)
        self.noconnection.hide()
        self.parent = parent

    def redirectLinks(self, url):
        if url.hasFragment():
            if url.fragment() == 'login':
                self.showLogin()
        else:
            PreviewDialog(self, url)

    def showLogin(self):
        self._hide()
        self.parent.settingsDialog.show()
        self.parent.settingsDialog.tabWidget.setCurrentIndex(4)

    def showPage(self, addr):
        if network_available():
            self.webView.load(QUrl(addr))
        else:
            self._sync_template(status = False)
        self.animate(start = BOTCENTER, stop = MIDCENTER)

    def getFiles(self):
        return self.iface.getPackageFiles(str(self.packageName.text()))

    def getFilesFinished(self):
        self.filesList.addItems(self._filesThread.get())
        self.filesList.sortItems()

    def _tabSwitched(self, index):
        if index == 0 and self.tabWidget.count() > 1:
            if self.filesList.count() == 0:
                self._filesThread.start()

    def _sync_template(self, status, package = '', summary = '', description = ''):
        def _replace(key, value):
            self.webView.page().mainFrame().evaluateJavaScript(\
                    '%s.innerHTML="%s";' % (key, value))

        self.busy.hide()
        self.busy.stopAnimation()

        if status:
            _replace('title', package)
            _replace('summary', summary)
            _replace('description', description)
            self.webWidget.show()
            self.noconnection.hide()
        else:
            self.noconnection.show()
            self.webWidget.hide()

        reset_proxy_settings()

    def showPackageDetails(self, package, installed, summary='', description=''):
        self.packageName.setText(package)
        self.key = config.PMConfig().getOpenDesktopKey()

        self.filesList.clear()
        self.webView.loadFinished.connect(lambda x: \
                self._sync_template(x, package, summary, description))

        if network_available():
            set_proxy_settings()
#.........这里部分代码省略.........
开发者ID:SamiBabat,项目名称:playground,代码行数:103,代码来源:webdialog.py

示例6: Widget

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class Widget(QWidget, ScreenWidget):
    name = "admin"
    finished=pyqtSignal()
    def __init__(self):
        QWidget.__init__(self)
        self.ui = Ui_RootPassWidget()
        self.ui.setupUi(self)
        self.intf = ctx.interface

        self.host_valid = True
        self.pass_valid = False

        if ctx.flags.install_type == ctx.STEP_DEFAULT:
            self.pthread = PThread(self, self.startInit, self.dummy)

        self.pds_messagebox = PMessageBox(self)
        self.pds_messagebox.enableOverlay()

        self.ui.pass1.textChanged[str].connect(self.slotTextChanged)
        self.ui.pass2.textChanged[str].connect(self.slotTextChanged)
        self.ui.pass2.returnPressed.connect(self.slotReturnPressed)
        self.ui.hostname.textChanged[str].connect(self.slotHostnameChanged)

    def update(self):
        if self.host_valid and self.pass_valid:
            ctx.mainScreen.enableNext()
        else:
            ctx.mainScreen.disableNext()

    def shown(self):
        if ctx.installData.hostName:
            self.ui.hostname.setText(str(ctx.installData.hostName))
        else:
            # Use first added user's name as machine name if its exists
            release_hostname = yali.util.product_release()
            if self.ui.hostname.text() == '':
                self.ui.hostname.setText(release_hostname)

        if ctx.installData.rootPassword:
            self.ui.pass1.setText(ctx.installData.rootPassword)
            self.ui.pass2.setText(ctx.installData.rootPassword)

        self.update()
        self.checkCapsLock()
        self.ui.pass1.setFocus()


    def dummy(self):
        pass

    def execute(self):
        ctx.installData.rootPassword = unicode(self.ui.pass1.text())
        ctx.installData.hostName = unicode(self.ui.hostname.text())

        if ctx.flags.install_type == ctx.STEP_DEFAULT:
            #FIXME:Refactor dirty code
            if ctx.storageInitialized:
                disks = filter(lambda d: not d.format.hidden, ctx.storage.disks)
                if len(disks) == 1:
                    ctx.storage.clearPartDisks = [disks[0].name]
                    ctx.mainScreen.step_increment = 2
                else:
                    ctx.mainScreen.step_increment = 1
            else:
                self.pds_messagebox.setMessage(_("Storage Devices initialising..."))
                self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER)
                ctx.mainScreen.step_increment = 0
                self.pthread.start()
                QTimer.singleShot(2, self.startStorageInitialize)
                return False

        return True

    def startInit(self):
        self.pds_messagebox.animate(start=MIDCENTER, stop=MIDCENTER)

    def startStorageInitialize(self):
        ctx.storageInitialized = yali.storage.initialize(ctx.storage, ctx.interface)
        self.initFinished()

    def initFinished(self):
        self.pds_messagebox.animate(start=CURRENT, stop=CURRENT, direction=OUT)
        disks = filter(lambda d: not d.format.hidden, ctx.storage.disks)
        if ctx.storageInitialized:
            if len(disks) == 1:
                ctx.storage.clearPartDisks = [disks[0].name]
                ctx.mainScreen.step_increment = 2
            else:
                ctx.mainScreen.step_increment = 1
            ctx.mainScreen.slotNext(dry_run=True)
            self.finished.emit()
        else:
            ctx.mainScreen.enableBack()

    def setCapsLockIcon(self, child):
        if type(child) == QLineEdit:
            if pardus.xorg.capslock.isOn():
                child.setStyleSheet("""QLineEdit {
                        background-image: url(:/gui/pics/caps.png);
                        background-repeat: no-repeat;
#.........这里部分代码省略.........
开发者ID:MusaSakizci,项目名称:yali-family,代码行数:103,代码来源:ScrAdmin.py

示例7: WebDialog

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class WebDialog(PAbstractBox, Ui_WebDialog):
    def __init__(self, state, parent):
        PAbstractBox.__init__(self, parent)
        self.setupUi(self)
        self.state = state
        self.iface = parent.iface
        # PDS Settings
        self._animation = 1
        self._duration = 400
        self.enableOverlay()
        self._disable_parent_in_shown = True
        self.webView.hide()
      
        #Url list for package pisi source files
        global packageUrlList
        packageUrlList = []
        
        self.registerFunction(IN, lambda: parent.statusBar().hide())
        self.registerFunction(FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible()))
        self._as = 'http://youtube.googleapis.com/v'
        self.cancelButton.clicked.connect(self._hide)
        self.cancelButton.setIcon(KIcon("dialog-close"))

        self.packageHomepage.clicked.connect(self.openWebsite)
        self.packagePisiSource.clicked.connect(self.openPisiSource)
        #self.wdInstallButton.clicked.connect(self.showBasket)
        # Hide Scrollbars and context menu in webview
        self.webView.setContextMenuPolicy(Qt.NoContextMenu)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.webView.page().linkClicked.connect(self.showFullImage)

        self.tabWidget.removeTab(0)

        self._filesThread = PThread(self, self.getFiles, self.getFilesFinished)
        self.filterLine.setListWidget(self.filesList)
        self.noconnection.hide()
        self.parent = parent


    def showFullImage(self, url):
        PreviewDialog(self, url)

    def getFiles(self):
        return self.iface.getPackageFiles(str(self.packageName.text()))

    def getFilesFinished(self):
        self.filesList.addItems(self._filesThread.get())
        self.filesList.sortItems()

    def _tabSwitched(self, index):
        if index == 0 and self.tabWidget.count() > 1:
            if self.filesList.count() == 0:
                self._filesThread.start()

    def _sync_template(self, status, package = '', summary = '', description = ''):
        def _replace(key, value):
            self.webView.page().mainFrame().evaluateJavaScript(\
                    '%s.innerHTML="%s";' % (key, value))
        if status:
            _replace('title', package)
            _replace('summary', summary)
            _replace('description', description)
            self.webWidget.show()
            self.noconnection.hide()
        else:
            self.noconnection.hide()
            self.webWidget.show()

        reset_proxy_settings()

    def openWebsite(self):
        webbrowser.open_new_tab(packageUrlList[1])
        
    def openPisiSource(self):
        webbrowser.open_new_tab(packageUrlList[0]) 
    
    def showBasket(self):
        package = [self.packageName.text()]
        print package
        self.basket.__initList(package)
        self.basket._show()
        
    def __makePath(self, path, package):
        #Package Component configure for PiSi source files url.
        #And added new urls to packageUrlList       
        global packageSourceUrl
        __make = path.split(".")
        newPath = ("/").join(__make)
        packageSourceUrl = "https://github.com/pisilinux/PisiLinux/tree/master/%s/%s" % (newPath, package)
        self.packagePisiSource.setToolTip(packageSourceUrl) 
        #packageUrlList[0] => pisi source files url
        #packageUrlList[1] => package home page url
        packageUrlList.append(packageSourceUrl)
        packageUrlList.append(self.packageHomepage.text())
        
    def showPackageDetails(self, package, installed, summary='', description='', homepage='', appIsa='', appComponent='', rate="", repository='', _icon=''):
        self.packageName.setText(package)
        self.packageSummary.setText(summary)
#.........这里部分代码省略.........
开发者ID:aslanon,项目名称:pisilinux,代码行数:103,代码来源:webdialog.py

示例8: WebDialog

# 需要导入模块: from pds.thread import PThread [as 别名]
# 或者: from pds.thread.PThread import start [as 别名]
class WebDialog(PAbstractBox, Ui_WebDialog):
    finished = pyqtSignal()
    
    def __init__(self, parent):
        PAbstractBox.__init__(self, parent)
        self.setupUi(self)

        self.iface = backend.pm.Iface()   #parent.iface

        # PDS Settings
        self._animation = 1
        self._duration = 1
        self.enableOverlay()
        self.setOverlayOpacity(150)
        self._disable_parent_in_shown = True

        self.registerFunction(IN, lambda: parent.statusBar().hide())
        self.registerFunction(FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible()))
        self._as = 'http://appinfo.pisilinux.org'
        self.cancelButton.clicked.connect(self._hide)
        self.cancelButton.setIcon(QIcon.fromTheme("cancel"))

        # Hide Scrollbars and context menu in webview
        self.webView.setContextMenuPolicy(Qt.NoContextMenu)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

        self.webView.page().setLinkDelegationPolicy(QtWebKitWidgets.QWebPage.DelegateAllLinks)
        self.webView.page().linkClicked.connect(self.showFullImage)

        self.tabWidget.removeTab(0)

        self.busy = QProgressIndicator(self, "white")
        self.busy.setMaximumSize(QSize(48, 48))
        self.webLayout.addWidget(self.busy)
        self.busy.hide()

        self._filesThread = PThread(self, self.getFiles, self.getFilesFinished)
        self.noconnection.hide()
        self.parent = parent
        
    def destroyed(self):
        self.finished.emit()

    def showFullImage(self, url):
        PreviewDialog(self, url)

    def showPage(self, addr):
        if network_available():
            self.webView.load(QUrl(addr))
        else:
            self._sync_template(status = False)
        self.animate(start = BOTCENTER, stop = MIDCENTER)

    def getFiles(self):
        files=self.iface.getPackageFiles(str(self.packageName.text()))
        self.filesList.addItems(files)
        self.filesList.sortItems()
        return files #self.iface.getPackageFiles(str(self.packageName.text()))

    def getFilesFinished(self):
        self.filesList.addItems(self._filesThread.get())
        self.filesList.sortItems()

    def _tabSwitched(self, index):
        if index == 0 and self.tabWidget.count() > 1:
            if self.filesList.count() == 0:
                self._filesThread.start()

    def _sync_template(self, status, package = '', summary = '', description = ''):
        def _replace(key, value):
            self.webView.page().mainFrame().evaluateJavaScript(\
                    '%s.innerHTML="%s";' % (key, value))

        self.busy.hide()
        self.busy.stopAnimation()

        if status:
            _replace('title', package)
            _replace('summary', summary)
            _replace('description', description)
            self.webWidget.show()
            self.noconnection.hide()
        else:
            self.noconnection.show()
            self.webWidget.hide()

        reset_proxy_settings()

    def showPackageDetails(self, package, installed, summary='', description=''):
        package = str(QVariant.value(package))
        summary = str(QVariant.value(summary))
        description = str(QVariant.value(description))
        
        self.packageName.setText(package)
        self.filesList.clear()
        
        
        self.tabWidget.insertTab(0, self.packageFiles, _translate("Packaga Manager",'Package Files'))
        self.tabWidget.currentChanged.connect(self._tabSwitched)
#.........这里部分代码省略.........
开发者ID:PisiLinuxNew,项目名称:package-manager,代码行数:103,代码来源:webdialog.py


注:本文中的pds.thread.PThread.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。