PyQt5 GUI restarts after calling a function with a button [closed]









up vote
-1
down vote

favorite












so, everytime a call a function with a button and the function contains something other than print(), the program restarts and PyQt5 GUI closes. I don't know what to do right now.
`



attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"] 

def clicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
`









share|improve this question













closed as off-topic by eyllanesc, ekad, Vega, Pearly Spencer, Makyen Nov 10 at 19:52


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – eyllanesc, ekad, Vega, Pearly Spencer, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Can you show more context for how you are calling the function from the button and how it's organized?
    – Karl
    Nov 10 at 18:22














up vote
-1
down vote

favorite












so, everytime a call a function with a button and the function contains something other than print(), the program restarts and PyQt5 GUI closes. I don't know what to do right now.
`



attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"] 

def clicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
`









share|improve this question













closed as off-topic by eyllanesc, ekad, Vega, Pearly Spencer, Makyen Nov 10 at 19:52


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – eyllanesc, ekad, Vega, Pearly Spencer, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Can you show more context for how you are calling the function from the button and how it's organized?
    – Karl
    Nov 10 at 18:22












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











so, everytime a call a function with a button and the function contains something other than print(), the program restarts and PyQt5 GUI closes. I don't know what to do right now.
`



attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"] 

def clicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
`









share|improve this question













so, everytime a call a function with a button and the function contains something other than print(), the program restarts and PyQt5 GUI closes. I don't know what to do right now.
`



attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"] 

def clicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
`






python user-interface button crash pyqt5






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 16:52









Bill Scott

1




1




closed as off-topic by eyllanesc, ekad, Vega, Pearly Spencer, Makyen Nov 10 at 19:52


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – eyllanesc, ekad, Vega, Pearly Spencer, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by eyllanesc, ekad, Vega, Pearly Spencer, Makyen Nov 10 at 19:52


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – eyllanesc, ekad, Vega, Pearly Spencer, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 1




    Can you show more context for how you are calling the function from the button and how it's organized?
    – Karl
    Nov 10 at 18:22












  • 1




    Can you show more context for how you are calling the function from the button and how it's organized?
    – Karl
    Nov 10 at 18:22







1




1




Can you show more context for how you are calling the function from the button and how it's organized?
– Karl
Nov 10 at 18:22




Can you show more context for how you are calling the function from the button and how it's organized?
– Karl
Nov 10 at 18:22












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Could you explain better that you do not get?



import sys
import random
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget,
QVBoxLayout, QTextEdit, QPushButton)

attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"]

class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)

centralWidget = QWidget()
self.setCentralWidget(centralWidget)

self.textEdit = QTextEdit()
self.btn = QPushButton("Click me")
self.btn.clicked.connect(self.btnClicked)

layoutV = QVBoxLayout(centralWidget)
layoutV.addWidget(self.textEdit)
layoutV.addWidget(self.btn)

def btnClicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
self.textEdit.append(rand_op)


if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


enter image description here






share|improve this answer




















  • in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
    – Bill Scott
    Nov 11 at 13:47

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Could you explain better that you do not get?



import sys
import random
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget,
QVBoxLayout, QTextEdit, QPushButton)

attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"]

class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)

centralWidget = QWidget()
self.setCentralWidget(centralWidget)

self.textEdit = QTextEdit()
self.btn = QPushButton("Click me")
self.btn.clicked.connect(self.btnClicked)

layoutV = QVBoxLayout(centralWidget)
layoutV.addWidget(self.textEdit)
layoutV.addWidget(self.btn)

def btnClicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
self.textEdit.append(rand_op)


if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


enter image description here






share|improve this answer




















  • in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
    – Bill Scott
    Nov 11 at 13:47














up vote
0
down vote













Could you explain better that you do not get?



import sys
import random
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget,
QVBoxLayout, QTextEdit, QPushButton)

attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"]

class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)

centralWidget = QWidget()
self.setCentralWidget(centralWidget)

self.textEdit = QTextEdit()
self.btn = QPushButton("Click me")
self.btn.clicked.connect(self.btnClicked)

layoutV = QVBoxLayout(centralWidget)
layoutV.addWidget(self.textEdit)
layoutV.addWidget(self.btn)

def btnClicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
self.textEdit.append(rand_op)


if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


enter image description here






share|improve this answer




















  • in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
    – Bill Scott
    Nov 11 at 13:47












up vote
0
down vote










up vote
0
down vote









Could you explain better that you do not get?



import sys
import random
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget,
QVBoxLayout, QTextEdit, QPushButton)

attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"]

class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)

centralWidget = QWidget()
self.setCentralWidget(centralWidget)

self.textEdit = QTextEdit()
self.btn = QPushButton("Click me")
self.btn.clicked.connect(self.btnClicked)

layoutV = QVBoxLayout(centralWidget)
layoutV.addWidget(self.textEdit)
layoutV.addWidget(self.btn)

def btnClicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
self.textEdit.append(rand_op)


if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


enter image description here






share|improve this answer












Could you explain better that you do not get?



import sys
import random
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget,
QVBoxLayout, QTextEdit, QPushButton)

attackers_list = ["Atak1", "Atak2", "Atak3", "Atak4"]

class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.resize(400, 200)

centralWidget = QWidget()
self.setCentralWidget(centralWidget)

self.textEdit = QTextEdit()
self.btn = QPushButton("Click me")
self.btn.clicked.connect(self.btnClicked)

layoutV = QVBoxLayout(centralWidget)
layoutV.addWidget(self.textEdit)
layoutV.addWidget(self.btn)

def btnClicked(self):
print("s")
rand_op = random.choice(attackers_list)
print(rand_op)
self.textEdit.append(rand_op)


if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 17:24









S. Nick

2,156237




2,156237











  • in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
    – Bill Scott
    Nov 11 at 13:47
















  • in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
    – Bill Scott
    Nov 11 at 13:47















in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
– Bill Scott
Nov 11 at 13:47




in my case if I clicked btn Click me the shell would RESTART and the GUI disappear
– Bill Scott
Nov 11 at 13:47



這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3