PyMe用户技术论坛

🏠 ← 返回首页

[普通] 【案例】RadioButton的简单应用

头像 宋大头
2025-05-18 14:05:53

一些关于RadioButton的简单应用,具体效果如下动图

抛砖引玉,等大佬分享高能代码


代码如下

#coding=utf-8
import sys
import os
from   os.path import abspath, dirname
sys.path.insert(0,abspath(dirname(__file__)))
import tkinter
from   tkinter import *
import Fun
uiName="RadioButtonExamples"
ElementBGArray={}  
ElementBGArray_Resize={} 
ElementBGArray_IM={} 


#Form 'Form_1's Load Event :
def Form_1_onLoad(uiName,threadings=0):
    pass
#Button 'Button_1' 's Command Event :
def Button_1_onCommand(uiName,widgetName,threadings=0):
    value1 = Fun.GetCurrentValue(uiName,'RadioButton_1')
    value2 = Fun.GetCurrentValue(uiName,'RadioButton_10')
    Fun.SetText(uiName,'Label_2',f"当前选择的为分组1数值{value1},分数2数值{value2}的RadioButton")
    
    
#RadioButton 'RadioButton_1' 's Command Event :
def RadioButton_1_onCommand(uiName,widgetName,threadings=0):
    value = Fun.GetCurrentValue(uiName,'RadioButton_1')
    
    Fun.SetText(uiName,'Label_2',f"当前点击了为分组1数值{value}的RadioButton")
#RadioButton 'RadioButton_10' 's Command Event :
def RadioButton_10_onCommand(uiName,widgetName,threadings=0):
    value = Fun.GetCurrentValue(uiName,'RadioButton_10')
    Fun.SetText(uiName,'Label_2',f"当前点击了为分组2数值{value}的RadioButton")
#Button 'Button_2' 's Command Event :
def Button_2_onCommand(uiName,widgetName,threadings=0):
    Fun.SetCurrentValue(uiName,'RadioButton_1',3)
    
#Button 'Button_3' 's Command Event :
def Button_3_onCommand(uiName,widgetName,threadings=0):
    Fun.SetCurrentValue(uiName,'RadioButton_10',2)


回复

头像 admin
2025-05-21 15:06:54

赞!

登录后才能回复帖子