i am making Gui using qt designer and python.I have two classes on demo.py and demo2.py which are on the same directory/folder.when button clicks on demo,i can show demo2 and hide demo using OOP composition like down below. But then i am so confused why i can't hide demo2(like this down below). This is demo.py
From demo2 import Ui_Form
Class Ui_For(object):
def log(s):
s.U=QtGui.QWidget()
s.x=Ui_Form()
s.x.setupUi(s.U)
s.U.show()
Form.hide()
def setupUi(self,Form):
'''the things that are going to be stated here are the Qlabels(QtGui.Qlabel),Qline edit,the button that connects to method log also,which is working good and other things of this window just like the qt designer write it'''
If __name__=='__main__':
import sys
app=QtGui.QApplication(sys.argv)
Form=QtGui.QWidget()
ui=Ui_For()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
And this is demo2
Class Ui_Form(object):
def oy(o):
ui.U.hide()#this the the one bringing error
def setupUi(self,Form):
'''And the rest of the code(there is push button here that connects to method oy,and it works good'''
When i go to demo2 widget,when i push a button and connect to method oy,"name 'ui' is not defined" error comes.But why?
Things i tried:
1.def oy(o):
o.x=3
print(getattr(o,'x'))#works great and gives me 3 as expected
But if i did this instead,`
print(getattr(ui.x,'x'))#i get "name 'ui' is not defined" error
Why is this?isn't 'o' the same as 'ui.x' in this case?