def launch(app, MW=None): if MW is None: from manuskript.functions import mainWindow MW = mainWindow() MW.show() # Support for IPython Jupyter QT Console as a debugging aid. # Last argument must be --console to enable it # Code reference : # https://github.com/ipython/ipykernel/blob/master/examples/embedding/ipkernel_qtapp.py # https://github.com/ipython/ipykernel/blob/master/examples/embedding/internal_ipkernel.py if len(sys.argv) > 1 and sys.argv[-1] == "--console": try: from IPython.lib.kernel import connect_qtconsole from ipykernel.kernelapp import IPKernelApp # Only to ensure matplotlib QT mainloop integration is available import matplotlib # Create IPython kernel within our application kernel = IPKernelApp.instance() # Initialize it and use matplotlib for main event loop integration with QT kernel.initialize(['python', '--matplotlib=qt']) # Create the console in a new process and connect console = connect_qtconsole(kernel.abs_connection_file, profile=kernel.profile) # Export MW and app variable to the console's namespace kernel.shell.user_ns['MW'] = MW kernel.shell.user_ns['app'] = app kernel.shell.user_ns['kernel'] = kernel kernel.shell.user_ns['console'] = console # When we close manuskript, make sure we close the console process and stop the # IPython kernel's mainloop, otherwise the app will never finish. def console_cleanup(): app.quit() console.kill() kernel.io_loop.stop() app.lastWindowClosed.connect(console_cleanup) # Very important, IPython-specific step: this gets GUI event loop # integration going, and it replaces calling app.exec_() kernel.start() except Exception as e: print( "Console mode requested but error initializing IPython : %s" % str(e)) print( "To make use of the Interactive IPython QT Console, make sure you install : " ) print("$ pip3 install ipython qtconsole matplotlib") qApp.exec_() else: qApp.exec_() qApp.deleteLater()
def launch(): from .mainWindow import MainWindow main = MainWindow() main.show() qApp.exec_() qApp.deleteLater()
def launch(MW=None): if MW is None: from manuskript.functions import mainWindow MW = mainWindow() MW.show() qApp.exec_() qApp.deleteLater()
def launch(): from .mainWindow import MainWindow main = MainWindow() # We store the system default cursor flash time to be able to restore it # later if necessary main._defaultCursorFlashTime = qApp.cursorFlashTime() main.show() qApp.exec_() qApp.deleteLater()
def launch(app, MW = None): if MW is None: from manuskript.functions import mainWindow MW = mainWindow() MW.show() # Support for IPython Jupyter QT Console as a debugging aid. # Last argument must be --console to enable it # Code reference : # https://github.com/ipython/ipykernel/blob/master/examples/embedding/ipkernel_qtapp.py # https://github.com/ipython/ipykernel/blob/master/examples/embedding/internal_ipkernel.py if len(sys.argv) > 1 and sys.argv[-1] == "--console": try: from IPython.lib.kernel import connect_qtconsole from ipykernel.kernelapp import IPKernelApp # Only to ensure matplotlib QT mainloop integration is available import matplotlib # Create IPython kernel within our application kernel = IPKernelApp.instance() # Initialize it and use matplotlib for main event loop integration with QT kernel.initialize(['python', '--matplotlib=qt']) # Create the console in a new process and connect console = connect_qtconsole(kernel.abs_connection_file, profile=kernel.profile) # Export MW and app variable to the console's namespace kernel.shell.user_ns['MW'] = MW kernel.shell.user_ns['app'] = app kernel.shell.user_ns['kernel'] = kernel kernel.shell.user_ns['console'] = console # When we close manuskript, make sure we close the console process and stop the # IPython kernel's mainloop, otherwise the app will never finish. def console_cleanup(): app.quit() console.kill() kernel.io_loop.stop() app.lastWindowClosed.connect(console_cleanup) # Very important, IPython-specific step: this gets GUI event loop # integration going, and it replaces calling app.exec_() kernel.start() except Exception as e: print("Console mode requested but error initializing IPython : %s" % str(e)) print("To make use of the Interactive IPython QT Console, make sure you install : ") print("$ pip3 install ipython qtconsole matplotlib") qApp.exec_() else: qApp.exec_() qApp.deleteLater()
def handleException(excType, value, tb): """Handle uncaught exceptions, show debug info to the user. Called from sys.excepthook. Arguments: excType -- execption class value -- execption error text tb -- the traceback object """ import miscdialogs global exceptDialog exceptDialog = miscdialogs.ExceptionDialog(excType, value, tb) exceptDialog.show() if not QApplication.activeWindow(): qApp.exec_() # start event loop in case it's not running yet
def _loginwindow(): from nprstuff.gui2.gui_common import get_database_data from nprstuff.gui2 import login_window statusdict = get_database_data() print('message = %s' % statusdict['message']) qApp = QApplication(sys.argv) lw = login_window.LoginWindow() lw.setFromStatus(statusdict) sys.exit(qApp.exec_())
def on_database_created(connectionqt): from xulpymoney.database_update import database_update from xulpymoney.version import __versiondatetime__ from xulpymoney.ui.myqwidgets import qmessagebox database_update(connectionqt, "xulpymoney", __versiondatetime__, "Console") connectionqt.commit() qmessagebox( qApp.translate( "Mem", "Xulpymoney have been correctly installed. Please login again")) exit(qApp.exec_())
def sButtonClicked(self): if self.stopOrContinue == "stop": self.calc.stopSignal.emit("stop") self.stopOrContinue = "continue" elif self.stopOrContinue == "continue": self.calc.wCndt.wakeAll() self.calc.continueToSend = True self.stopOrContinue = "stop" else: print("There has been an unexpected error.") sys.exit(qApp.exec_())
def run(wavFileName2, bagFile2): global wavFileName global bagFile global xStart global xEnd global annotationFlag, annotations, shadesAndSpeaker, greenIndex global spf, duration, signal time = 0 segmentDuration = 0 segments = [] # >> Open WAVfile #---------------------- #wavFileName -> global variable wavFileName = wavFileName2 bagFile = bagFile2 spf = wave.open(wavFileName, 'r') #Extract Raw Audio from Wav File signal = spf.readframes(-1) signal = np.fromstring(signal, 'Int16') #self.axes.clear() #Get wavFile duration frames = spf.getnframes() rate = spf.getframerate() duration = frames / float(rate) # >> Open CSVfile #---------------------- # check if .csv exists csvFileName = bagFile.replace(".bag", "_audio.csv") if os.path.isfile(csvFileName): # print '.csv Found !' annotationFile = open(csvFileName, 'rb') read = csv.reader(annotationFile) for row in read: row[0] = float(row[0]) row[1] = float(row[1]) annotations.append([row[0], row[1], row[2]]) # get speakers unic colors for annotation plot and ganttChart for shadeIndex in range(len(annotations)): if annotations[shadeIndex][2][:8] == 'Speech::': shadesAndSpeaker.append( [annotations[shadeIndex][2], GreenShades[greenIndex]]) if greenIndex > len(GreenShades): greenIndex = 0 else: greenIndex = greenIndex + 1 # >> Call Classifier in case CSVFile not exists #---------------------- else: # print 'classifier...' [flagsInd, classesAll, acc] = aS.mtFileClassification(wavFileName, 'svmModelTest', 'svm', False) # declare classes [segs, classes] = aS.flags2segs(flagsInd, 1) lengthClass = len(classesAll) className = np.arange(lengthClass, dtype=np.float) for j in range(len(segs)): # no Annotation for Silence segments for i in range(len(classesAll)): if classes[j] == className[i] and classesAll[i] != 'Silence': annotations.append( [segs[j][0] * 1000, segs[j][1] * 1000, classesAll[i]]) # >> Initialize GUI #---------------------- qApp = QtWidgets.QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("Audio") aw.show() # >> Terminate GUI #---------------------- sys.exit(qApp.exec_())
def run(wavFileName2,bagFile2): global wavFileName global bagFile global xStart global xEnd global annotationFlag, annotations, shadesAndSpeaker, greenIndex global spf, duration, signal time = 0 segmentDuration = 0 segments = [] # >> Open WAVfile #---------------------- #wavFileName -> global variable wavFileName = wavFileName2 bagFile = bagFile2 spf = wave.open(wavFileName,'r') #Extract Raw Audio from Wav File signal = spf.readframes(-1) signal = np.fromstring(signal, 'Int16') #self.axes.clear() #Get wavFile duration frames = spf.getnframes() rate = spf.getframerate() duration = frames / float(rate) # >> Open CSVfile #---------------------- # check if .csv exists csvFileName = bagFile.replace(".bag","_audio.csv") if os.path.isfile(csvFileName): # print '.csv Found !' annotationFile = open(csvFileName, 'rb') read = csv.reader(annotationFile) for row in read: row[0] = float(row[0]) row[1] = float(row[1]) annotations.append([row[0], row[1], row[2]]) # get speakers unic colors for annotation plot and ganttChart for shadeIndex in range(len(annotations)): if annotations[shadeIndex][2][:8] == 'Speech::': shadesAndSpeaker.append([annotations[shadeIndex][2], GreenShades[greenIndex]]) if greenIndex > len(GreenShades): greenIndex = 0 else: greenIndex = greenIndex + 1 # >> Call Classifier in case CSVFile not exists #---------------------- else: # print 'classifier...' [flagsInd, classesAll, acc] = aS.mtFileClassification(wavFileName, 'svmModelTest', 'svm', False) # declare classes [segs, classes] = aS.flags2segs(flagsInd, 1) lengthClass = len(classesAll) className = np.arange(lengthClass, dtype=np.float) for j in range(len(segs)): # no Annotation for Silence segments for i in range(len(classesAll)): if classes[j] == className[i] and classesAll[i] != 'Silence': annotations.append([segs[j][0]*1000, segs[j][1]*1000, classesAll[i]]) # >> Initialize GUI #---------------------- qApp = QtWidgets.QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("Audio") aw.show() # >> Terminate GUI #---------------------- sys.exit(qApp.exec_())
def _maingui(): from nprstuff.gui import maingui qApp = QApplication(sys.argv) mg = maingui.MainGui() sys.exit(qApp.exec_())
def _vqronline(): from nprstuff.gui import vqronline qApp = QApplication(sys.argv) nyf = vqronline.VQROnlineFrame( iconPath=os.path.join(resourceDir, 'icons', 'vqr.png')) sys.exit(qApp.exec_())
def _nytimes(): from nprstuff.gui import nytimes qApp = QApplication(sys.argv) nyf = nytimes.NYTimesFrame( iconPath=os.path.join(resourceDir, 'icons', 'nytimes.png')) sys.exit(qApp.exec_())
def _newyorker(): from nprstuff.gui import newyorker qApp = QApplication(sys.argv) nyf = newyorker.NewYorkerFrame() sys.exit(qApp.exec_())
def _medium(): from nprstuff.gui import medium qApp = QApplication(sys.argv) nyf = medium.MediumFrame( iconPath=os.path.join(resourceDir, 'icons', 'medium.png')) sys.exit(qApp.exec_())
def _lightspeed(): from nprstuff.gui import lightspeed qApp = QApplication(sys.argv) lsf = lightspeed.LightSpeedFrame() sys.exit(qApp.exec_())
def exitTheProgram(self): sys.exit(qApp.exec_())
def clickToPlayMusic(self, music): sender = self.sender() if sender.text() == "Play": if music.getBusy() == 0: self.buton.setIcon( QtGui.QIcon( 'C:\\Users\\yekta\\PycharmProjects\\music_player_python\\icons\\pause.png' )) #If you click Play button while a music is already playing, the progress bar should be set to 0 again. if music.getSOP() == 1: if self.calc.isRunning(): self.calc.stop() self.progressButtonClicked(music) self.stopOrContinue = "stop" elif music.getSOP( ) == 1: # If music is ready to play,the icon must be play icon self.buton.setIcon( QtGui.QIcon( 'C:\\Users\\yekta\\PycharmProjects\\music_player_python\\icons\\play_icon.png' )) self.sButtonClicked() elif music.getSOP( ) == 0: # If music is playing,when you press this button it will pause the music.So icon must be pause icon. self.buton.setIcon( QtGui.QIcon( 'C:\\Users\\yekta\\PycharmProjects\\music_player_python\\icons\\pause.png' )) self.sButtonClicked() music.playTheMusic() elif sender.text() == "Previous": if self.r_mode != 0: if self.index > 0: self.index -= 1 data1 = self.sequence[self.index] self.table1.setCurrentCell(data1, 0) self.clickToChooseMusic(music) music.playTheMusic() else: pygame.mixer.music.rewind( ) # There is no going backwards.So,rewind the music. else: cRow1 = self.table1.currentRow() if cRow1 == 1: # There is no way down. pygame.mixer.music.rewind() else: self.table1.setCurrentCell(cRow1 - 1, 0) self.clickToChooseMusic(music) music.playTheMusic() if self.calc.isRunning(): self.calc.stop() self.progressButtonClicked(music) else: self.progressButtonClicked(music) elif sender.text() == "Next": if self.r_mode != 0: # It means we are on the random mode. self.index += 1 if self.index == len( self.sequence ): # If it reaches the end of our playlist,we will initiate reshuffle. self.r_mode = 0 self.random_mode(music) else: # Else,we will continue with the random mode using next button. data1 = self.sequence[self.index] self.table1.setCurrentCell(data1, 0) self.clickToChooseMusic(music) music.playTheMusic() else: cRow = self.table1.currentRow() if cRow + 1 >= self.table1.rowCount( ): # You cannot go further. pygame.mixer.music.rewind() else: self.table1.setCurrentCell(cRow + 1, 0) self.clickToChooseMusic(music) music.playTheMusic() if self.calc.isRunning(): self.calc.stop() self.progressButtonClicked(music) else: self.progressButtonClicked(music) elif sender.text() == "Delete": tempMusic = self.prevMusic # I need to get the data of the current music playing. checker = self.table1.currentRow() query = "DELETE FROM musics m WHERE m.m_id=%s" txt = self.table1.item(checker, 0) data = (txt.text(), ) try: self.mycursor.execute(query, data) self.mydb.commit() except mysql.connector.Error as err: self.popupError(err) sys.exit(qApp.exec_()) self.etiket2.setText("You have just deleted a music.") self.etiket3.setText('') self.table1.removeRow(checker) # If we are in the random mode,i must remove that element so that we can continue properly. if self.r_mode != 0: if checker in self.sequence: self.sequence.remove(checker) self.buton2.click() else: """ What i am doing with the while loop is that: -I have stored the current playing music inside tempMusic -And i am comparing it with the tables elements so that if i can find it i can play the current music even i after delete a music """ i = 1 while i < self.table1.rowCount(): if tempMusic == self.table1.item(i, 2).text(): self.table1.setCurrentCell(i, 0) self.clickToChooseMusic(music) music.setBusy(1) break i += 1 return # Just so that the line below won't be executed. self.volumeAndInfo(music)
def myload(self, urlOrRequest): """A convenient method that loads a QUrl or a QWebEngineHttpRequest. It blocks until the source is ready.""" self.load(urlOrRequest) qApp.exec_() self.loadedSem.acquire()
if user_input: terminal_n = int(user_input.pop(-1)) method_names = ['Exact', 'Euler', 'Improved Euler', 'Runge-Kutta'] exact = Exact(*user_input) e = Euler(*user_input) imp = ImprovedEuler(*user_input) r = RungeKutta(*user_input) methods = dict(zip(method_names, [exact, e, imp, r])) cur_i = self.tabWindow.currentIndex() for t in range(len(self.tabWindow.tabs)): self.tabWindow.plot_on_tabs(t, methods, terminal_n) self.tabWindow.setCurrentIndex((cur_i + 1) % len(self.tabWindow.tabs)) self.tabWindow.setCurrentIndex(cur_i) if __name__ == '__main__': app = QApplication(sys.argv) aw = ApplicationWindow() aw.setWindowTitle("DE solving") aw.show() sys.exit(qApp.exec_()) # app.exec_()