[英]Import variables between two interfaces python qgis
I am developing a plugin in qgis. 我正在qgis中开发一个插件。 I have one interface (MMMM.py) with several buttons and one of them opens a new interface (ABC.py) where I introduce values.
我有一个带有几个按钮的界面(MMMM.py),其中一个打开了一个新界面(ABC.py),在其中引入了值。 My objective is to read these values in the main interface (the first one).
我的目标是在主界面(第一个界面)中读取这些值。 So I have a script to each interface but when I import the variables, I have several errors.
所以我对每个接口都有一个脚本,但是当我导入变量时,我有几个错误。 I have troubles to import these variables.
我很难导入这些变量。
second script named ABC.py 第二个脚本名为ABC.py
class ABC(QDialog, Ui_ABC):
def __init__(self, iface):
...
def defineABC(self):
x = self.input_x.text()
y = self.input_y.text()
return x, y
first (main) script named MMMM.py 第一个(主)脚本,名为MMMM.py
class MMMM(QDialog, Ui_MMMM):
def __init__(self, iface):
...
def graph(self):
import ABC
x = ABC.ABC()
xc = x.defineABC()
I tried some ways to import the values x and y to main interface but I have always errors. 我尝试了一些将值x和y导入主界面的方法,但是我总是出错。 I am working in qgis.
我在qgis工作。
What I am doing wrong? 我做错了什么?
that would work: 那会工作:
from ABC import ABC
class MMMM(QDialog, Ui_MMMM):
def __init__(self, iface):
...
def graph(self):
c = ABC()
x, y = c.defineABC()
otherwise, you can set x and y in ABC (by doing self.x = ...
) and then access them by cx
否则,您可以在ABC中设置x和y(通过
self.x = ...
),然后通过cx
访问它们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.