Python PyQt5.QtWidgets.QApplication.processEvents() Examples

The following are code examples for showing how to use PyQt5.QtWidgets.QApplication.processEvents(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: RRPam-WDS   Author: asselapathirana   File: test_rrpamwds_projects.py    (license) View Source Project 6 votes vote down vote up
def create_a_new_project(self):
        import tempfile
        with mock.patch.object(self.aw.projectgui, '_getSaveFileName', autospec=True) as mock__getSaveFileName:
            with mock.patch.object(self.aw.projectgui, '_getSaveFileName2', autospec=True) as mock__getSaveFileName2:
                sf = os.path.join(tempfile.tempdir, "xxx3xp")
                mock__getSaveFileName.return_value = (sf, c.PROJECTEXTENSION)
                mock__getSaveFileName2.return_value = (networks[0], '*.inp')
                self.aw._new_project()
                time.sleep(.1)
                self.app.processEvents()

                # make sure the thread finishes
                self.aw.pm.wait_to_finish()
                self.app.processEvents()
                time.sleep(.1)
                return sf 
Example 2
Project: acbDecrypter   Author: Rieksee   File: window_progress.py    (license) View Source Project 5 votes vote down vote up
def setval(self, barNo, val):
        if type(val) != int:
            return False
        if barNo == 0:
            self.ui.progress_all.setValue(val)
        elif barNo == 1:
            self.ui.progress_now.setValue(val)
        else:
            return False
        QApplication.processEvents()
        return True 
Example 3
Project: gpvdm   Author: roderickmackenzie   File: gui_util.py    (license) View Source Project 5 votes vote down vote up
def process_events():
	if gui_get()==True:
		QApplication.processEvents() 
Example 4
Project: gpvdm   Author: roderickmackenzie   File: cmp_class.py    (license) View Source Project 5 votes vote down vote up
def save_image(self,file_name):
		file_ext="jpg"
		types=self.plot.fig.canvas.get_supported_filetypes()
		if "jpg" in types:
			file_ext="jpg"
		elif "png" in  types:
			file_ext="png"

		dir_name, ext = os.path.splitext(file_name)

		if (ext=="."+file_ext):
			self.plot.fig.savefig(file_name)
		elif ext==".avi":

			if os.path.isdir(dir_name)==False:
				os.mkdir(dir_name)

			jpgs=""
			for i in range(0,self.slider.slider_max):
				self.slider.slider0.setValue(i)
				QApplication.processEvents()
				self.update()
				self.plot.do_plot()
				image_name=os.path.join(dir_name,"image_"+str(i)+"."+file_ext)
				print(image_name)
				self.plot.fig.savefig(image_name)
				jpgs=jpgs+" mf://"+image_name

			os.system("mencoder "+jpgs+" -mf type="+file_ext+":fps=1.0 -o "+file_name+" -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=800")
			#msmpeg4v2
		else:
			print("Unknown file extension") 
Example 5
Project: Mac-Python-3.X   Author: L1nwatch   File: qtdemo.py    (license) View Source Project 5 votes vote down vote up
def artisticSleep(sleepTime):
    time = QTime()
    time.restart()
    while time.elapsed() < sleepTime:
        QApplication.processEvents(QEventLoop.AllEvents, 50) 
Example 6
Project: pyqt5-example   Author: guinslym   File: qtdemo.py    (license) View Source Project 5 votes vote down vote up
def artisticSleep(sleepTime):
    time = QTime()
    time.restart()
    while time.elapsed() < sleepTime:
        QApplication.processEvents(QEventLoop.AllEvents, 50) 
Example 7
Project: RRPam-WDS   Author: asselapathirana   File: test_rrpamwds_projects.py    (license) View Source Project 5 votes vote down vote up
def test_project_managers_new_project_will_cause_project_to_be_opend_in_main_window(
            self, other=None):
        ds = self.aw.pm.project_data
        # see run_in_a_thread
        if (other):
            self = other
        with mock.patch.object(self.aw, '_display_project', autospec=True) as mock__display_project:
            with mock.patch.object(ds, "get_epanetfile", autospect=True) as mock_get_epanetfile:
                mock_get_epanetfile.return_value = networks[0]
                self.aw.pm.new_project()
                self.aw.pm.wait_to_finish()
                QApplication.processEvents()  # this is very important before the assertion.
                # that is because we are not testing this within the Qt's main loop.
                time.sleep(0.1)
                mock__display_project.assert_called_with(self.aw.pm.workerthread.result)