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

编程入门 行业动态 更新时间:2024-10-03 23:26:25

Abaqus GUI程序开发之常用<a href=https://www.elefans.com/category/jswz/34/1769529.html style=控件使用方法(十四):带复选框的树控件AFXOptionTreeList使用方法"/>

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 testoptiontreelistDBreturn 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:passreturn 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('三维判据')

更多推荐

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

本文发布于:2024-02-28 05:40:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1768610.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   使用方法   程序开发   复选框   常用

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!