Abaqus GUI程序开发之常用控件使用方法(四):复选框FXCheckButton使用方法

 

复选框指可以同时选中多个选项的按钮。

复选框的基本语法

FXCheckButton(p, text, tgt=None, sel=0, opts=CHECKBUTTON_NORMAL,
        x=0, y=0, w=0, h=0, pl=DEFAULT_PAD,
        pr=DEFAULT_PAD, pt=DEFAULT_PAD, pb=DEFAULT_PAD)

参数的含义和前面的单选框、按钮都差不多,在这不再展示。

注意:每个复选框对应一个关键字,推荐使用RSG对话框对构造器中创建复选框,方便快捷。

实例演示

本实例是一个简单的复选框测试插件,主要由图形界面文件【testcheckbuttonDB.py】以及注册文件【testcheckbutton_plugin.py】组成。

 

判断复选框是否被选中

对于复选框按钮,其关键字的返回值为True或者False,例如上述实例中复选框“SOLID”对应的关键字分别为ele_solid,如果该复选框被勾选了,则ele_solid值为True,反之为False。因此在内核文件中添加一个if语句即可判断其是否被选中。

def testcheckbutton(ele_solid,ele_shell):
	if cle_solid =-True:
		#表示被勾选
		#省略执行代码
	else:
		#表示未被勾选
		#省略执行代码

附代码

【testcheckbutton_plugin.py】

from abaqusGui import *
from abaqusConstants import ALL
import osutils, os


###########################################################################
# Class definition
###########################################################################

class testcheckbutton_plugin(AFXForm):

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def __init__(self, owner):
        
        # Construct the base class.
        #
        AFXForm.__init__(self, owner)
        self.radioButtonGroups = {}

        self.cmd = AFXGuiCommand(mode=self, method='',
            objectName='', registerQuery=False)
        pickedDefault = ''
        self.ele_solidKw = AFXBoolKeyword(self.cmd, 'ele_solid', 
            AFXBoolKeyword.TRUE_FALSE, True, True)
        self.ele_shellKw = AFXBoolKeyword(self.cmd, 'ele_shell', 
            AFXBoolKeyword.TRUE_FALSE, True, False)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def getFirstDialog(self):

        import testcheckbuttonDB
        return testcheckbuttonDB.testcheckbuttonDB(self)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def doCustomChecks(self):

        # Try to set the appropriate radio button on. If the user did
        # not specify any buttons to be on, do nothing.
        #
        for kw1,kw2,d in self.radioButtonGroups.values():
            try:
                value = d[ kw1.getValue() ]
                kw2.setValue(value)
            except:
                pass
        return True

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def okToCancel(self):

        # No need to close the dialog when a file operation (such
        # as New or Open) or model change is executed.
        #
        return False

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Register the plug-in
#
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)

toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerGuiMenuButton(
    buttonText='test checkbutton', 
    object=testcheckbutton_plugin(toolset),
    messageId=AFXMode.ID_ACTIVATE,
    icon=None,
    kernelInitString='',
    applicableModules=ALL,
    version='N/A',
    author='N/A',
    description='N/A',
    helpUrl='N/A'
)

【testcheckbuttonDB.py】

from abaqusConstants import *
from abaqusGui import *
from kernelAccess import mdb, session
import os
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)
class testcheckbuttonDB(AFXDataDialog):
    def __init__(self, form):
        AFXDataDialog.__init__(self, form, 'Test Check Button',
            self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)
        okBtn = self.getActionButton(self.ID_CLICKED_OK)
        okBtn.setText('OK')          
        GroupBox_1 = FXGroupBox(p=self, text='Element type', opts=FRAME_GROOVE)
        FXCheckButton(p=GroupBox_1, text='SOLID', tgt=form.ele_solidKw, sel=0)
        FXCheckButton(p=GroupBox_1, text='SEHLL', tgt=form.ele_shellKw, sel=0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是刃小木啦~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值