Answer the question
In order to leave comments, you need to log in
Why can't I start the terminal by pressing a button in the application?
When you click on the "run" button, a terminal should open and execute the ls -l command. But the button doesn't work. Here is the main application code main.py:
import sys
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication
from PyQt5.QtCore import QCoreApplication
import os, subprocess
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
qbtn = QPushButton('Выполнить', self)
qbtn.clicked.connect(self.btnClicked)
qbtn.resize(qbtn.sizeHint())
qbtn.move(50, 50)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Quit button')
self.show()
def btnClicked():
subprocess.Popen(['xterm', '-hold', '-e', 'ls -ahl'])
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question