I have 2 python files, from one file want to call and run a QDialog with Qlistview. I want to contruct in pythonic way getting value of index just before terminating first python file.
Structure of files:
---Widgetclass.py
---Class_test.py
The code:
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
class Widget(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(Widget, self).__init__(parent)
        lay = QtWidgets.QVBoxLayout(self)
        self.button = QtWidgets.QPushButton("Okay")
        self.listView = QtWidgets.QListView()
        lay.addWidget(self.listView)
        self.entry = QtGui.QStandardItemModel()
        self.listView.setModel(self.entry) 
        self.listView.setSpacing(5)
        for text in ("One", "two", "Three", "Four", 
                     "Five etc.."):
            it = QtGui.QStandardItem(text)
            self.entry.appendRow(it)
        Code_Group = QtWidgets.QGroupBox(self)
        Code_Group.setTitle("&Test")
        Code_Group.setLayout(lay)
        Vlay = QtWidgets.QVBoxLayout(self)
        Vlay.addWidget(Code_Group)
        Vlay.addWidget(self.button, alignment=QtCore.Qt.AlignCenter)
        Vlay.setSizeConstraint(Vlay.SetFixedSize)
        self.listView.selectionModel().currentChanged.connect(self.on_row_changed)
        self._INDEX = 0
    def on_row_changed(self, current, previous):
        self._INDEX = current.row()
        print('Row %d selected' % current.row())
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = Widget()
    w.show()
    sys.exit(app.exec_())
The constructor:
from Widgetclass import Widget as ls
from PyQt5 import QtCore, QtGui, QtWidgets
def value():
    print('Row index:', ls._INDEX, ':')       #<---- Value not callable?
    ls.close()
subwindow=ls()
subwindow.setWindowModality(QtCore.Qt.ApplicationModal)
subwindow.button.clicked.connect(value)
subwindow.exec_()
Error getting:
AttributeError: type object 'Widget' has no attribute '_INDEX'
I want to achieve value and close the file. but seems not working?!
