コード例 #1
0
    def getWorkingDialog(text):
        """
        Generates a working dialog object which blocks the UI.

        :param text: Text to display while working
        :return: The created working dialog widget
        """

        progressDialog = QProgressDialog(text,
                                         "",
                                         0,
                                         0,
                                         parent=Globals.ui.tabWidgetMain)

        progressDialog.setMinimumDuration(0)
        progressDialog.setMinimum(0)
        progressDialog.setMaximum(0)
        progressDialog.setRange(0, 0)

        progressDialog.setFixedSize(progressDialog.width(),
                                    progressDialog.height())

        # No cancel button <:
        progressDialog.setCancelButton(None)
        # No X button
        progressDialog.setWindowFlags(progressDialog.windowFlags()
                                      & ~QtCore.Qt.WindowCloseButtonHint)

        progressBar = progressDialog.findChild(QProgressBar)
        # :S:S
        progressBar.setMinimumWidth(progressDialog.width() + 20)

        return progressDialog
コード例 #2
0
ファイル: Client.py プロジェクト: yxsu/Suvermemo
 def DownloadNotes(self, notebook_guid):
     #set progress dialog
     progress = QProgressDialog("Read data from server...", "Abort downloading", 0, 100)
     progress.setWindowModality(Qt.WindowModal)
     #read note data from server
     note_filter = NoteStore.NoteFilter()
     note_filter.notebookGuid = notebook_guid
     offset = 0
     note_list = self.note_store.findNotes(self.authToken, note_filter, 0, 10000)
     full_note_list = note_list.notes
     progress.setMaximum(note_list.totalNotes + 1)
     while(len(full_note_list) < note_list.totalNotes):
         progress.setValue(offset)
         offset = offset + len(note_list.notes)
         note_list = self.note_store.findNotes(self.authToken, note_filter, offset, 10000)
         full_note_list.extend(note_list.notes)
     #set content of progress dialog
     progress.setMaximum(len(full_note_list))
     progress.setLabelText("Downloading content of notebook...")
     #download the content of note
     if(not hasattr(self, 'note_list')):
         self.note_list = []
         self.timestamp_list = dict()
         guid_list = []
     else:
         guid_list = [note.guid for note in self.note_list]
         
     count = 0
     for note in full_note_list:
         #load content
         if(note.guid not in guid_list):
             #add new note
             note.content = self.note_store.getNoteContent(self.authToken, note.guid)
             self.note_list.append(note)
             self.timestamp_list[note.guid] = [date.today(), 0]
         else:
             #update existed note
             note_index = guid_list.index(note.guid)
             if(self.note_list[note_index].updated < note.updated):
                 self.note_list[note_index].content = self.note_store.getNoteContent(self.authToken, note.guid)
         #set counter
         progress.setValue(count)
         count = count + 1
         if(progress.wasCanceled()):
             raise RuntimeError("Downloading was canceled")
     #save note_list to file
     saved_file = open(self.notebook_base_path + notebook_guid, 'w')
     pickle.dump(self.note_list, saved_file)
     saved_file.close()
     #save timestamp file
     timestamp_file = open(self.notebook_base_path + 'time_' + notebook_guid, 'w')
     pickle.dump(self.timestamp_list, timestamp_file)
     timestamp_file.close()
コード例 #3
0
class UpdatesView(QDialog, Ui_UpdatesView):
  def __init__(self, parent, appargs):
    QDialog.__init__(self, parent)
    self.setupUi(self)
    self._app = esky.Esky(sys.executable,
        "http://10.78.55.218/pyrite/downloads")
    self._appargs = appargs

    self.connectActions()
    self.updateView()

  def connectActions(self):
    self.btnCheckForUpdates.clicked.connect(self.updateView)
    self.btnInstallUpdate.clicked.connect(self.installUpdate)
    self.btnClose.clicked.connect(self.reject)

  def updateView(self):
    self.lblCurrentVersion.setText("You are currently running Pyrite version:"
        " {0}".format(version.version))
    update = self._app.find_update()
    if update is not None:
      self.lblAvailableUpdate.setText("Pyrite version {0} is available for"
          " download".format(update))
      self.btnInstallUpdate.setEnabled(True)
    else:
      self.lblAvailableUpdate.setText("There are no new updates available at"
          " this time.")

  def installUpdate(self):
    try:
      # setup progress dialog
      self._progressDlg = QProgressDialog(self)
      self._progressDlg.setWindowModality(Qt.WindowModal)
      self._progressDlg.setAutoClose(True)
      self._progressDlg.setMinimum(0)
      self._progressDlg.setMaximum(100)
      self._progressDlg.setLabelText("Auto-Updating")
      self._progressDlg.setCancelButton(None)
      self._progressDlg.setValue(0)

      self._app.auto_update(self.autoUpdateCallback)

      appexe = esky.util.appexe_from_executable(sys.executable)
      os.execv(appexe, self._appargs)
      QMessageBox.information(None, "Updating", "Update complete!")
      self._app.cleanup()
      self._progressDlg.reset()
      sys.exit()
    except Exception, e:
      print("ERROR AUTO-UPDATING APP: {0}".format(e))
コード例 #4
0
    def collectNoise(self, seconds):
        """
        Collect noise data and update ``noiseData``.
        Uses the processes/threads started in :func:`startSnifferAndAdder`.

        :param seconds: Amount of seconds to capture noise

        :return: True if noise was captured. False if the user pressed "Cancel"
        """

        self.noiseData = []
        # Setup the ProgressDialog
        progressDialog = QProgressDialog(
            Strings.filterTabCollectingNoiseMessageBoxText, "Cancel", 0,
            seconds)

        progressDialog.setMinimumDuration(0)
        progressDialog.setMinimum(0)
        progressDialog.setMaximum(seconds)
        progressDialog.adjustSize()
        progressDialog.setFixedSize(progressDialog.width() + 40,
                                    progressDialog.height())

        # Users still can click on the "X"
        progressDialog.setCancelButton(None)

        # Start collecting
        self.startSnifferAndAdder(adderMethod=self.addSniffedNoise)

        progressDialog.open()

        secondsToCollect = seconds
        while secondsToCollect > 0 and not progressDialog.wasCanceled():
            time.sleep(0.5)
            secondsToCollect -= 0.5
            self.updateNoiseCollectProgress(progressDialog,
                                            seconds - secondsToCollect)

        self.stopSnifferAndAdder()
        return not progressDialog.wasCanceled()
コード例 #5
0
class setupApp:
    def __init__(self, params):
        loader = QUiLoader()
        infile = QFile("gui/ui/Setup.ui")
        infile.open(QFile.ReadOnly)
        self.window = loader.load(infile, None)
        
        self.loadPrefs()
        
        self.window.quitButton.clicked.connect(self.closeApp)
        self.window.saveButton.clicked.connect(self.savePrefs)
        self.window.runButton.clicked.connect(self.runSV)
        
        self.splash = QProgressDialog("Loading", "Cancel", 0, 100, parent=None)
        self.splash.setWindowModality(Qt.WindowModal)
        self.splash.setAutoReset(False)
        self.splash.setAutoClose(False)
        self.splash.hide()
        self.canceled = False
        
        self.window.show()
        self.runningApp = None
    
    def loadPrefs(self):
        infile = open(PREFS_FILE,'r')
        self.window.textEdit.setPlainText(infile.read())
        infile.close()
    
    def savePrefs(self):
        outfile=open(PREFS_FILE,'w')
        outfile.write(self.window.textEdit.toPlainText())
        outfile.close()
    
    def showProgressWidget(self, estimate=100, message="Loading..."):
        self.splash.setLabelText(message)
        self.splash.setMaximum(estimate)
        self.splash.setValue(0)
        self.splash.show()
    
    def tickProgressWidget(self, numTicks=1, message=None):
        if self.canceled:
            return
        if message != None:
            self.splash.setLabelText(message)
        newValue = min(self.splash.maximum(),numTicks+self.splash.value())
        self.splash.setValue(newValue)
        self.canceled = self.splash.wasCanceled()
        return self.canceled
    
    def runSV(self, params=PREFS_FILE):
        self.savePrefs()
        self.window.hide()
        
        appPrefs = prefs.generateFromText(self.window.textEdit.toPlainText())
        
        self.showProgressWidget(appPrefs.maxTicks, "Loading files...")
        
        self.canceled = False
        vData = appPrefs.loadDataObjects(callback=self.tickProgressWidget)
        if self.canceled:
            self.splash.hide()
            self.window.show()
            return
        
        self.showProgressWidget(vData.estimateTicks(), "Writing files...")
        
        success = vData.dumpVcfFile(path='/Users/Home/Desktop/chr3-seq_parsed.vcf',callback=self.tickProgressWidget)
        if not success:
            self.splash.hide()
            self.window.show()
            return
        
        sys.exit(0)
        # TODO write to file
    
    def closeApp(self):
        self.window.reject()