Show a window before calling a terminal command in python

  • Hey i am a newbie in in python and qt so forgive me if my question is silly.In the following code i have a single window with exit and execute button from the class example. When i click the execute button i try to create a new window from the class newwin and then execute some terminal commands. In this case i execute three simple commands. The problem is that the commands is executed first and the window shows up after the commands ended . How i can fix that?
    import sys
    import os
    from PyQt4 import QtCore, QtGui

    class newwin(QtGui.QWidget):
    def cancel(self):
    def init(self,parent=None):
    QtGui.QWidget.init(self, parent)

        self.resize(320, 128)
        self.label = QtGui.QLabel('Pleace wait. This may take a while', self)
        self.label.setGeometry(60, 30, 225, 31)

    self.quit=QtGui.QPushButton('Cancel', self)
    self.quit.setGeometry(190, 90, 88, 27)

    class Example(QtGui.QWidget):

    def __init__(self, parent=None):

    self.Window2 = newwin()
    QtGui.QWidget.init(self, parent)

    def initUI(self):                     
        self.pushButton_4 = QtGui.QPushButton("Execute",self)
        self.pushButton_4.setGeometry(QtCore.QRect(20, 300, 88, 27))
        self.pushButton_5 = QtGui.QPushButton("Exit",self)
        self.pushButton_5.setGeometry(QtCore.QRect(270, 300, 88, 27))
        self.resize(394, 345)
    def execute(self,state):

    os.system("sleep 2s")
    os.system("echo the window is not appeared yet")
    os.system("sleep 2s")

    def main():

    app = QtGui.QApplication(sys.argv)
    ex = Example()    

    if name == 'main':

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.