Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plugin with TreeList

Status
Not open for further replies.

mikechy

Mechanical
Sep 18, 2008
37
I created the plugin for Abaqus as an AFXList (Abaqus GUI Toolkit User's manual, Section 3.3.1 Lists) and it works (send selected item to main script). Now I want to create similar ones, but using FXTreeList (ibid., Section 3.5.1 Tree list) or AFXOptionTreeList (ibid., Section 3.5.1 Option tree list), however they do not pass a selected item.

So, I've created AFXList, which works properly, and FXTreeList and AFXOptionTreeList, which do not work:

1) Some code for AFXList from file *DB.py -

def __init__(self, form):
AFXDataDialog.__init__(self, form, 'Research',
self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)
self.form = form
okBtn = self.getActionButton(self.ID_CLICKED_OK)
okBtn.setText('OK')
gb = FXGroupBox(self, 'MyLab', FRAME_GROOVE|LAYOUT_FILL_X)
hf = FXHorizontalFrame(gb, LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
vf = FXVerticalFrame(hf, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X,
0,0,0,0, 0,0,0,0)
# -------------------------------------------------------------------
List = AFXList(p=vf, nvis=5, tgt=form.mdlCodeKw, sel=0,
opts=HSCROLLING_OFF|LIST_SINGLESELECT|LAYOUT_FILL_X)
List.appendItem(text='Study_1')
List.appendItem(text='Research_2')
List.appendItem(text='Test_3')
List.appendItem(text='Case_4')
List.appendItem(text='Project_5')
2) Some code for FXTreeList -

def __init__(self, form):
AFXDataDialog.__init__(self, form, 'Research',
self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)
self.form = form
okBtn = self.getActionButton(self.ID_CLICKED_OK)
okBtn.setText('OK')
gb = FXGroupBox(self, 'MyLab', FRAME_GROOVE|LAYOUT_FILL_X)
hf = FXHorizontalFrame(gb, LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
vf = FXVerticalFrame(hf, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X,
0,0,0,0, 0,0,0,0)
# -------------------------------------------------------------------
self.tree = FXTreeList(vf, 15, form.MdlDistKw, 0,
TREELIST_SHOWS_BOXES|TREELIST_SHOWS_LINES|
TREELIST_ROOT_BOXES|
HSCROLLING_OFF|TREELIST_SINGLESELECT|LAYOUT_FILL_X)
option1 = self.tree.addItemLast(None, 'Numerical analysis')
self.tree.addItemLast(option1, 'Study_1')
self.tree.addItemLast(option1, 'Research_2')
option2 = self.tree.addItemLast(None, 'Laboratory tests')
self.tree.addItemLast(option2, 'Test_3')
self.tree.addItemLast(option2, 'Case_4')
option3 = self.tree.addItemLast(None, 'General publication')
option3a = self.tree.addItemLast(option3, 'Other researches')
self.tree.addItemLast(option3a, 'Ref-1_Project_5')
self.tree.expandTree(option1)
self.tree.expandTree(option2)
self.tree.expandTree(option3)
self.tree.expandTree(option3a)​

3) Code for AFXOptionTreeList -

def __init__(self, form):
AFXDataDialog.__init__(self, form, 'Research',
self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)
self.form = form
okBtn = self.getActionButton(self.ID_CLICKED_OK)
okBtn.setText('OK')
gb = FXGroupBox(self, 'MyLab', FRAME_GROOVE|LAYOUT_FILL_X)
hf = FXHorizontalFrame(gb, LAYOUT_FILL_X, 0,0,0,0, 0,0,0,0)
vf = FXVerticalFrame(hf, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X,
0,0,0,0, 0,0,0,0)
# -------------------------------------------------------------------
tree = AFXOptionTreeList(vf, 10)
item = tree.addItemLast('Numerical_analysis')
item.addItemLast('Study_1')
item.addItemLast('Research_2')
item = tree.addItemLast('Laboratory tests')
item.addItemLast('Test_3')
item.addItemLast('Case_4')
item = tree.addItemLast('Other researches')
item.addItemLast('Ref-1_Project_5')​

The item selected in the list should be sent to the main code
I should clarify my question. The plugin creates a FXTreeList, for example, and after clicking OK creates a new model in Abaqus, but only with a default name 'MyMdl', regardless of which item in the tree is selected.

4) Code from *_plugin.py -

class TreeListEx_plugin(AFXForm):
def __init__(self, owner):
AFXForm.__init__(self, owner)
self.cmd = AFXGuiCommand(mode=self, method='createModel',
objectName='TreeListExCreate')
self.MdlDistKw = AFXStringKeyword(self.cmd, 'MdlDist', True, 'MyMdl')
def getFirstDialog(self):
import TreeListExDB
return TreeListExDB.TreeListExDB(self)​

In other words, item selection does not work. How to fix this? Thanks.
 
 https://files.engineering.com/getfile.aspx?folder=03201104-6bf6-436c-8256-6a09550340a3&file=tree.png
Status
Not open for further replies.

Part and Inventory Search

Sponsor