带有复选框的树列表控件是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('三维判据')