Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Python3/QT设计器-在控制台中显示重复值的单选按钮_Python 3.x_Duplicates_Radio Button_Qt Designer - Fatal编程技术网

Python 3.x Python3/QT设计器-在控制台中显示重复值的单选按钮

Python 3.x Python3/QT设计器-在控制台中显示重复值的单选按钮,python-3.x,duplicates,radio-button,qt-designer,Python 3.x,Duplicates,Radio Button,Qt Designer,我正在使用QT designer尝试制作两个单选按钮,带有一个标签,显示我在一个名为URL的变量中选择的按钮 到目前为止,我已获得以下代码: self.radioButton.toggled.connect(self.myradioButton1_function) self.radioButton_2.toggled.connect(self.myradioButton1_function) def myradioButton1_function(self): staging = '

我正在使用QT designer尝试制作两个单选按钮,带有一个标签,显示我在一个名为URL的变量中选择的按钮

到目前为止,我已获得以下代码:

self.radioButton.toggled.connect(self.myradioButton1_function)
self.radioButton_2.toggled.connect(self.myradioButton1_function)

def myradioButton1_function(self):
    staging = 'https://staging/URL'
    live= 'https://live/URL'

    if self.radioButton.isChecked()==True:
        URL=staging
    if self.radioButton_2.isChecked()==True:
        URL=live

    self.label.setText("URL is : " +str(URL))
    print(URL)
标签显示工作正常,可以在实时和暂存之间完美切换,但问题在于Python控制台中的变量,当在两个按钮之间切换时-这会多次打印变量,例如

https://staging/URL  
https://live/URL  
https://live/URL  
https://staging/URL  
https://staging/URL  
https://live/URL  
https://live/URL 

我想在另一个函数中使用URL变量,所以需要在选择单选按钮时存储1个值,您能建议吗?非常感谢。

我通过将切换更改为单击来修复此问题,例如

self.radioButton.clicked.connect(self.myradioButton1_function)
self.radioButton_2.clicked.connect(self.myradioButton1_function)