You’re creating a new instance of the Window class when you call ren.Window() and then immediately querying the text (which will presumably be initialised empty). Maybe I don’t understand what you’re trying to do. What do you expect it to be other than blank at the point you are querying it?
If you want the script to pause to wait for user input while your ren.Window() instance is open then maybe you want to use a modal dialogue instead?
Also, can we assume the Window class code you posted is just an incomplete extract? (from what you posted it doesn’t look like Window.createUI() ever gets called)
so do you mean if i can have createUI() function return(since the GUI widgets are in createUI) something in the form of list i can get value of QLineEdit ?
I want to believe u about the value of QLineEdit() at the time of ren.Window() be initilized will be empty …
Have to make a few assumptions in helping you with this one.
Assuming that you want to have two windows, one in which you type and another in which you want to query the first one. Lets call them A and B.
class A(QtGui.QLineEdit):
def __init__(self, parent=None):
super(A, self).__init__(parent)
class B(QtGui.QWidget):
def __init__(self, child, parent=None):
super(B, self).__init__(parent)
child.changed.connect(self.getText)
self.child = child
def getText(self):
print self.child.text()
if __name__ == '__main__':
a = A()
a.show()
b = B(a)
b.show()
Now B will print what is typed into A anytime A changes its text. Sorry, not infront of Qt atm so this is psuedo-text, hopefully it makes sense. From here you could hook anything into the child of B. The key is to not instantiate the copy of A inside of B, but rather feed B with A upon first instantiation. The programming pattern would be called Composition.