-
Notifications
You must be signed in to change notification settings - Fork 2
/
sg2DReadFileDB.py
71 lines (54 loc) · 2.98 KB
/
sg2DReadFileDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from abaqusConstants import *
from abaqusGui import *
from kernelAccess import mdb, session
import os
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)
###########################################################################
# Class definition
###########################################################################
class SG2DReadFileDB(AFXDataDialog):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, form):
# Construct the base class.
#
AFXDataDialog.__init__(self, form, '2D Structure Genome - Read from File',
self.OK|self.CANCEL, DIALOG_ACTIONS_SEPARATOR)
okBtn = self.getActionButton(self.ID_CLICKED_OK)
okBtn.setText('OK')
VAligner_1 = AFXVerticalAligner(p=self, opts=0, x=0, y=0, w=0, h=0,
pl=0, pr=0, pt=0, pb=0)
AFXTextField(p=VAligner_1, ncols=32, labelText='Project name: ', tgt=form.project_nameKw, sel=0)
fileHandler = PsaDBFileHandler(form, 'profile_name', 'Airfoil main file (*.xml)')
fileTextHf = FXHorizontalFrame(p=VAligner_1, opts=0, x=0, y=0, w=0, h=0,
pl=0, pr=0, pt=0, pb=0, hs=DEFAULT_SPACING, vs=DEFAULT_SPACING)
# Note: Set the selector to indicate that this widget should not be
# colored differently from its parent when the 'Color layout managers'
# button is checked in the RSG Dialog Builder dialog.
fileTextHf.setSelector(99)
AFXTextField(p=fileTextHf, ncols=32, labelText='Airfoil main file: ', tgt=form.profile_nameKw, sel=0,
opts=AFXTEXTFIELD_STRING|LAYOUT_CENTER_Y)
icon = afxGetIcon('fileOpen', AFX_ICON_SMALL )
FXButton(p=fileTextHf, text=' Select File\nFrom Dialog', ic=icon, tgt=fileHandler, sel=AFXMode.ID_ACTIVATE,
opts=BUTTON_NORMAL|LAYOUT_CENTER_Y, x=0, y=0, w=0, h=0, pl=1, pr=1, pt=1, pb=1)
###########################################################################
# Class definition
###########################################################################
class PsaDBFileHandler(FXObject):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, form, keyword, patterns='*'):
self.form = form
self.patterns = patterns
self.patternTgt = AFXIntTarget(0)
exec('self.fileNameKw = form.%sKw' % keyword)
self.readOnlyKw = AFXBoolKeyword(None, 'readOnly', AFXBoolKeyword.TRUE_FALSE)
FXObject.__init__(self)
FXMAPFUNC(self, SEL_COMMAND, AFXMode.ID_ACTIVATE, PsaDBFileHandler.activate)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def activate(self, sender, sel, ptr):
fileDb = AFXFileSelectorDialog(getAFXApp().getAFXMainWindow(), 'Select a File',
self.fileNameKw, self.readOnlyKw,
AFXSELECTFILE_ANY, self.patterns, self.patternTgt)
fileDb.setReadOnlyPatterns('*.odb')
fileDb.create()
fileDb.showModal()