Python 3 / QT Designer - 单选按钮在控制台中显示重复值

Python 3 / QT Designer - Radio Buttons showing duplicate values in console

我正在使用 QT 设计器尝试制作几个带有标签的单选按钮,该标签显示我在名为 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)