Home item selected gui dess
Reply: 0

item selected gui dess

user2833
1#
user2833 Published in April 25, 2018, 12:41 am

I find some code serves my purpose and I've incremented it a little bit that I

can add items on it but I couldn't manage to erase it from the screen.

it is the function which should erase the relative line when it selects:

        self.listWidget.removeItemWidget(self.list[self.list.indexAt(self.lineEdit.text())])

This is my whole code if you want to run it:

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(535, 302)
        self.listWidget = QtWidgets.QListWidget(Form)
        self.listWidget.setGeometry(QtCore.QRect(50, 60, 256, 192))
        self.listWidget.setObjectName("listWidget")
        self.list = self.listWidget
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(320, 130, 90, 33))
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        self.pushButton_2.setGeometry(QtCore.QRect(420, 130, 90, 33))
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(Form)
        self.pushButton_3.setGeometry(QtCore.QRect(329, 190, 181, 61))
        self.pushButton_3.setObjectName("pushButton_3")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(50, 10, 431, 31))
        self.label.setObjectName("label")
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setGeometry(QtCore.QRect(310, 70, 221, 33))
        self.lineEdit.setObjectName("lineEdit")
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "ekle"))
        self.pushButton.clicked.connect(self.list_add)
        self.pushButton_2.setText(_translate("Form", "sil"))
        self.pushButton_3.setText(_translate("Form", "kapat"))
        self.pushButton_3.clicked.connect(quit)
        self.pushButton_2.clicked.connect(self.f1)
        self.label.setText(_translate("Form", "veriler ekleniyor"))

    def list_add(self):
        self.label.setText(self.lineEdit.text() + " eklendi")
        self.listWidget.addItem(self.lineEdit.text())
    def f1(self):
        self.label.setText(self.lineEdit.text() + " silindi")
        self.listWidget.removeItemWidget(self.list[self.list.indexAt(self.lineEdit.text())])

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.451636 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO