Как сделать так чтобы элемент не заменялся, а как бы заполнял массив.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5 import QtGui
from PyQt5.QtWidgets import (QApplication, QWidget, QDesktopWidget,
QGridLayout, QVBoxLayout, QPushButton, QInputDialog, QLabel, QHBoxLayout,
QToolTip, QMessageBox, QLineEdit, QTextEdit,QFrame, QLCDNumber, QSlider)
from PyQt5.QtGui import QIcon, QFont, QColor
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.resize(800, 440)
self.center()
self.setWindowTitle('merge sort')
self.setWindowIcon(QIcon('web.png'))
self.btn = QPushButton('Enter array', self)
self.btn.clicked.connect(self.gettext)
layout = QHBoxLayout(self)
layout.addWidget(self.btn)
# Array input field
self.lbl = QLabel('<b>Enter array:</b>', self)
layout.addWidget(self.lbl)
# output element
self.le = QLabel(self)
layout.addWidget(self.le)
# Asked whether you really sure you want to close
def closeEvent(self, event):
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
# Makes the window was centered
def center(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter( cp )
self.move(qr.topLeft())
# Enter array
def gettext(self):
num, ok = QInputDialog.getInt(self, 'integer input dualog',
'Enter element:')
if ok:
self.le.setText(str(num))
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
ex = Example()
ex.show()
sys.exit(app.exec_())