Abaqus GUI程序开发之常用控件使用方法(十四):带复选框的树控件AFXOptionTreeList使用方法

带有复选框的树列表控件是Abaqus/CAE操作中常用的一类控件,用户在step模块下选择输出变量时会反复使用到此类控件。该控件将多个复选框按钮集成在一起,方便用户对多个特征进行选择或者反选。其特点是当用户勾选父级复选框时,其子集会自动全部被选择。带有复选框的树列表控件同样无法在RSG对话框构造器中直接创建,需要用户自己编写GUI命令。其创建语法如下。

基本语法

AFXOptionTreeList(p, nvis, opts=0,x=0, y=0, w=0, h=0, pl=DEFAULT_SPACING,         pr=DEFAULT_SPACING,pt=DEFAULT_SPACING,pb=DEFAULT_SPACING,         hs=DEFAULT_SPACING,vs=DEFAULT_SPACING)

实例展示

 

代码展示

注册文件【testoptiontreelist_plugin.py】 

#-*-coding: UTF-8-*-
from abaqusGui import *
from abaqusConstants import ALL
import osutils, os

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

class testoptiontreelist_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)
        self.treeKw = AFXFloatKeyword(self.cmd, 'tree', True)
        pickedDefault = ''

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

        import testoptiontreelistDB
        return testoptiontreelistDB.testoptiontreelistDB(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 optiontreelist', 
    object=testoptiontreelist_plugin(toolset),
    messageId=AFXMode.ID_ACTIVATE,
    icon=None,
    kernelInitString='',
    applicableModules=ALL,
    version='N/A',
    author='N/A',
    description='N/A',
    helpUrl='N/A'
)

界面文件【testoptiontreelistDB.py】

#-*-coding: UTF-8-*-
from abaqusConstants import *
from abaqusGui import *
from kernelAccess import mdb, session
import os
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)
class testoptiontreelistDB(AFXDataDialog):
    def __init__(self, form):

        AFXDataDialog.__init__(self, form, '控件测试',
            self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)          

        okBtn = self.getActionButton(self.ID_CLICKED_OK)
        okBtn.setText('OK')            
        vf = FXHorizontalFrame(p=self, opts=FRAME_SUNKEN|FRAME_THICK,    
            x=0, y=0, w=0, h=0,                                              
            pl=0, pr=DEFAULT_SPACING, pt=DEFAULT_SPACING, pb=DEFAULT_SPACING)

            
        tree = AFXOptionTreeList(vf, 8)           #创建一个带复选框的树对象   
        
        item1 = tree.addItemLast('非线性')        #在树上挂一个树枝,为“非线性”
        item1.addItemLast('材料非线性')           #在“非线性”下添加若干分支
        item1.addItemLast('几何非线性')
        item1.addItemLast('接触非线性')
        
        item2 =tree.addItemLast('失效判据')       #在树上挂一个树枝,为“失效判据”                                                                                                                                        
        item2.addItemLast('二维判据')             #在“失效判据”下添加若干分支
        item2.addItemLast('三维判据')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

是刃小木啦~

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

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

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

打赏作者

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

抵扣说明:

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

余额充值