I hope someone can help me...
The Goal: When the button "button_trog" is clicked it should start a loop that opens up a new window a specific amount of time based on the number chosen from the spinbox "spinbox_count" giving the possiblity to enter something.
Situation: That works so far but the problem is that the window only opens up one time.
It should open up again when I click the accepted button.
I am not sure what to try next, because for my understanding it should open up the window again... I mean the loop is working, I tried that with the print() function.
This is the code from the main window file:
CODE: spinbox_count
self.spinbox_count = QtWidgets.QSpinBox(self.centralwidget)
self.spinbox_count.setGeometry(QtCore.QRect(370, 430, 70, 30))
font = QtGui.QFont()
font.setPointSize(15)
self.spinbox_count.setFont(font)
self.spinbox_count.setObjectName("spinbox_count")
CODE: button_trog
self.button_trog = QtWidgets.QPushButton(self.centralwidget)
self.button_trog.setGeometry(QtCore.QRect(530, 390, 200, 100))
font = QtGui.QFont()
font.setPointSize(15)
self.button_trog.setFont(font)
self.button_trog.setObjectName("button_trog")
self.button_trog.clicked.connect(self.scanning)
CODE: def scanning
def scanning(self):
count = self.spinbox_count.value()
self.lcount = 0
if count < 1:
print("Bitte geben Sie eine Stückzahl ein!")
while self.lcount < count:
self.window = QtWidgets.QDialog()
self.ui = Ui_window_scanning()
self.ui.setupUi(self.window)
self.window.show()
self.lcount = self.lcount + 1
Here starts the code from the second file for the "pop up" dialog window.
CODE: window dialog
class Ui_window_scanning(object):
def setupUi(self, window_scanning):
window_scanning.setObjectName("window_scanning")
window_scanning.resize(400, 300)
window_scanning.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
# Label Description Scanning
self.label_scanning = QtWidgets.QLabel(window_scanning)
self.label_scanning.setGeometry(QtCore.QRect(30, 20, 341, 71))
font = QtGui.QFont()
font.setPointSize(15)
self.label_scanning.setFont(font)
self.label_scanning.setAlignment(QtCore.Qt.AlignCenter)
self.label_scanning.setObjectName("label_scanning")
# Input Barcode
self.lineedit_scanning = QtWidgets.QLineEdit(window_scanning)
self.lineedit_scanning.setGeometry(QtCore.QRect(100, 120, 200, 30))
font = QtGui.QFont()
font.setPointSize(12)
self.lineedit_scanning.setFont(font)
self.lineedit_scanning.setObjectName("lineedit_scanning")
# Button Accept and Cancel
self.buttonbox_scanning = QtWidgets.QDialogButtonBox(window_scanning)
self.buttonbox_scanning.setGeometry(QtCore.QRect(120, 210, 156, 23))
self.buttonbox_scanning.setStandardButtons(
QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
self.buttonbox_scanning.setObjectName("buttonbox_scanning")
self.buttonbox_scanning.rejected.connect(window_scanning.reject)
self.buttonbox_scanning.accepted.connect(window_scanning.accept)
Thanks in advance!