Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Show a window before calling a terminal command in python
Forum Updated to NodeBB v4.3 + New Features

Show a window before calling a terminal command in python

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gioullis
    wrote on 10 Feb 2012, 10:17 last edited by
    #1

    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):
    self.close()
    def init(self,parent=None):
    QtGui.QWidget.init(self, parent)

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

    self.label.show()
    self.quit=QtGui.QPushButton('Cancel', self)
    self.quit.setGeometry(190, 90, 88, 27)
    self.quit.show()
    self.quit.clicked.connect(self.cancel)

    class Example(QtGui.QWidget):

    def __init__(self, parent=None):
    

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

    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.pushButton_5.clicked.connect(QtCore.QCoreApplication.instance().quit)
        self.pushButton_4.clicked.connect(self.execute)
       
        self.resize(394, 345)
        self.setWindowTitle('QtSimple')    
        self.show()
    
    def execute(self,state):
    

    self.Window2.show()
    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()    
    sys.exit(app.exec_())
    

    if name == 'main':
    main()
    @

    1 Reply Last reply
    0

    1/1

    10 Feb 2012, 10:17

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved