Python Referencing
I want to read data from a text field. The name of the text field is not defined of found in the other class with methods of reading the text field. The textfield is defined in the Design class. now how do I access this field from another class, so I can read data from it. Thanks!!
Edit:
I have 2 Classes: FeatureImportCommonWidget(QtGui.QWidget) and MetaDataBrowser. 开发者_如何学PythonFeatureImportCommonWidget contains a Text Field called placesGroupBox. I want to access this text field in the MetaDataBrowser Class.
I tried it using "filename = get_metadata.placesGroupBox.text()", but it gives an error about placesGroupBox not being defined in the MetaDataBrowser class.
If the field's an ordinary attribute called text
and your Design
instance is called design
, you can access (read/write) it from anywhere as design.text
.
1. if object of FeatureImportCommonWidget class is created inside of MetaDataBrowser class, you can access your text field anywhere inside MetaDataBrowser class like this: FeatureImportCommonWidgetObjectName.placesGroupBox.text()
2 if object of FeatureImportCommonWidget class is created before MetaDataBrowser class, you can pass that object as parameter to MetaDataBrowser class and then access your text field anywhere inside MetaDataBrowser class like in step 1
精彩评论