Exemple #1
0
    def showGUI(
        self,
        master=None,
        root=None,
        width=200,
        height=80,
        titleStr="player",
        gotoStartfile="go_to_start.gif",
        gotoEndfile="go_to_end.gif",
        ff_revfile="ff_rev.gif",
        ff_fwdfile="ff_fwd.gif",
        stopfile="stop.gif",
        playfile="play_fwd.gif",
        playRevfile="play_rev.gif",
        chmodfile="chmod.gif",
        closefile="close.gif",
        iconpath=None,
    ):
        """ function to display the player gui."""

        if hasattr(self, "form"):
            if hasattr(self.form, "deiconify"):
                self.form.deiconify()
                return
        self.master = master
        self.root = root

        if not self.form2:
            self.form = self.buildForm(titleStr)  # pass some arguments here
            self.form2 = 0
        else:
            if iconpath is None:
                iconpath = ("mglutil.gui.BasicWidgets.Tk", "icons")
            ICONDIR = findFilePath(iconpath[1], iconpath[0])
            # if findFilePath failed, already returned
            gotoStartfile = os.path.join(ICONDIR, gotoStartfile)
            gotoEndfile = os.path.join(ICONDIR, gotoEndfile)
            ff_revfile = os.path.join(ICONDIR, ff_revfile)
            ff_fwdfile = os.path.join(ICONDIR, ff_fwdfile)
            stopfile = os.path.join(ICONDIR, stopfile)
            playfile = os.path.join(ICONDIR, playfile)
            playRevfile = os.path.join(ICONDIR, playRevfile)
            chmodfile = os.path.join(ICONDIR, chmodfile)
            closefile = os.path.join(ICONDIR, closefile)
            recordfile = os.path.join(ICONDIR, "record.gif")
            record1file = os.path.join(ICONDIR, "record1.gif")

            self.gotoStartIcon = Tkinter.PhotoImage(file=gotoStartfile, master=master)
            self.gotoEndIcon = Tkinter.PhotoImage(file=gotoEndfile, master=master)
            self.ff_revIcon = Tkinter.PhotoImage(file=ff_revfile, master=master)
            self.ff_fwdIcon = Tkinter.PhotoImage(file=ff_fwdfile, master=master)
            self.stopIcon = Tkinter.PhotoImage(file=stopfile, master=master)
            self.playIcon = Tkinter.PhotoImage(file=playfile, master=master)
            self.playRevIcon = Tkinter.PhotoImage(file=playRevfile, master=master)
            self.recIcon = Tkinter.PhotoImage(file=recordfile, master=master)
            self.rec1Icon = Tkinter.PhotoImage(file=record1file, master=master)
            self.chmodIcon = Tkinter.PhotoImage(file=chmodfile, master=master)
            self.closeIcon = Tkinter.PhotoImage(file=closefile, master=master)
            self.form = self.buildForm2(titleStr)  # pass some argument here
Exemple #2
0
    def __init__(self,
                 master=None,
                 height=80,
                 width=100,
                 title="Video recorder",
                 icondir=None,
                 filetypes=[("MPG", ".mpg")],
                 fileName=None,
                 camera=None,
                 gui=True):
        self.ifd = None
        self.form = None
        self.paramForm = None
        self.ifd2 = None
        self.fileName = fileName

        self.autoPauseDelay = 1  # auto pause after 1 second
        self.pauseLength = 30
        self.cameraw = 0
        self.camerah = 0
        self.camera = weakref.ref(camera)
        if self.camera():
            self.cameraw = camera.width
            self.camerah = camera.height

        if not icondir:
            icondir = findFilePath('icons', 'mglutil.gui.BasicWidgets.Tk')
        self.stopIcon = Tkinter.PhotoImage(file=os.path.join(
            icondir, "stop3.gif"),
                                           master=master)
        self.pauseIcon = Tkinter.PhotoImage(file=os.path.join(
            icondir, "stop2.gif"),
                                            master=master)
        self.recordIcon = Tkinter.PhotoImage(file=os.path.join(
            icondir, "record.gif"),
                                             master=master)
        self.record1Icon = Tkinter.PhotoImage(file=os.path.join(
            icondir, "record1.gif"),
                                              master=master)
        self.chmodIcon = Tkinter.PhotoImage(file=os.path.join(
            icondir, 'chmod.gif'),
                                            master=master)
        self.closeIcon = Tkinter.PhotoImage(file=os.path.join(
            icondir, 'close.gif'),
                                            master=master)
        self.fileTypes = filetypes
        if gui:
            self.RecVar = Tkinter.IntVar()
            self.RecVar.set(0)
            self.PauseVar = Tkinter.IntVar()
            self.PauseVar.set(0)
            form = self.buildForm(master=master,
                                  title=title,
                                  height=height,
                                  width=width)
            form.deiconify()
Exemple #3
0
    def __init__(self):

        CADD_Vision.__init__(self)

        # name used by Vision for this network
        name = 'vs_opal'
        
        # find the path to CADD networks in the AutoDockTools package
        from mglutil.util.packageFilePath import findFilePath
        netpath = findFilePath('CADD', 'AutoDockTools')

        # build full path to VS_net.py network
        filename = os.path.join(netpath, 'VisionNetworks', 'VS_net.py')

        # load the network
        self.net = self.ed.loadNetworkNOGUI(name, filename)
Exemple #4
0
    def __init__(self):

        CADD_Vision.__init__(self)

        # name used by Vision for this network
        name = 'vs_opal'
        
        # find the path to CADD networks in the AutoDockTools package
        from mglutil.util.packageFilePath import findFilePath
        netpath = findFilePath('CADD', 'AutoDockTools')

        # build full path to VS_net.py network
        filename = os.path.join(netpath, 'VisionNetworks', 'VS_net.py')

        # load the network
        self.net = self.ed.loadNetworkNOGUI(name, filename)
 def loadNetwork(self):
     self.cms_network = self.vf.vision.ed.getNetworkByName("CoarseMolSurface")
     if self.cms_network:
         self.cms_network = self.cms_network[0]
     else:
         from mglutil.util.packageFilePath import findFilePath
         network_path = findFilePath("CoarseMolSurface_net.py", "Pmv.VisionInterface")
         self.vf.vision.ed.loadNetwork(network_path, takefocus=False)
         self.cms_network = self.vf.vision.ed.getNetworkByName("CoarseMolSurface")[0]
     res = self.resolutions[self.resolution_type]
     self.cms_network.getNodeByName('UT Blur')[0].inputPorts[5].widget.set(res, run=0)
     isoval = self.isovalue = self.piecewiseLinearInterpOnIsovalue(res)
     self.cms_network.getNodeByName('UT-Isocontour')[0].inputPorts[1].widget.set(isoval,run=0 )
     self.cms_network.getNodeByName('UT-Isocontour')[0].inputPorts[2].widget.set(0, run = 0)
     self.cms_network.nodes[4].inputPortByName['name'].widget.set("coarseMolSurface", run = 0)
     self.cms_network.nodes[7].getInputPortByName("onegeom").widget.set(1)
     self.cms_network.getNodeByName("Dial")[0].run()
     self.cms_network.freeze()
Exemple #6
0
    def __init__(self, balloonmaster=None, master=None, name=None, icon1=None,
                 icon2=None, command=None, balloonhelp='',
                 statushelp='', height=20, width=21,
                 bd=1, activebackground='lightgrey', padx=0, pady=0,
                 state='normal', bg=None, iconpath=None):

        assert master is not None

        # this list stores the buttons
        if not hasattr(master, 'toolbarButtonDict'):
            master.toolbarButtonDict = {}
        # assert the button name doesn't exist already
        assert not master.toolbarButtonDict.has_key(name), name

        self.activebackground = activebackground
        self.name = name
        self.icommand = command
        self.command  = self.activate
        self.buttonPressed = 0  # 0 if button not pressed, 1 if pressed
        self.buttonFocus = 0    # 0 if cursor not over button, 1 if over button
        
        Tkinter.Label.__init__(self, master, height=height, width=width,
                       relief='flat', bd=bd, bg=bg)

        if iconpath is None:
            from mglutil.util.packageFilePath import findFilePath
            iconpath = findFilePath('Tk','mglutil.gui.BasicWidgets')
            iconpath = os.path.join(iconpath,'icons' )
            #iconpath = 'mglutil.gui.BasicWidgets.Tk.icons'
        if icon1 is not None:
            ICONPATH1 = os.path.join(iconpath, icon1)
            if string.splitfields(icon1, '.')[1] == 'bmp':
                self.icon1 = Tkinter.BitmapImage(file=ICONPATH1, master=master)
            else:
                self.icon1 = Tkinter.PhotoImage(file=ICONPATH1, master=master)
        else:
            self.icon1 = None

        if icon2 is not None:
            ICONPATH2 = os.path.join(iconpath, icon2)
            if string.splitfields(icon2, '.')[1] == 'bmp':
                self.icon2 = Tkinter.BitmapImage(file=ICONPATH2, master=master)
            else:
                self.icon2 = Tkinter.PhotoImage(file=ICONPATH2, master=master)
        else:
            self.icon2 = self.icon1

        self.config(image=self.icon1)

        # to prevent binding of the balloon overriding the binding of
        # Leave and Enter events, first the balloon is bound

        if balloonmaster is None:
            master.balloons = Pmw.Balloon(master, yoffset=0)
            balloonmaster = master

        if balloonhelp or statushelp:
            if hasattr(balloonmaster, 'balloons'):
                balloonmaster.balloons.bind(self, balloonhelp, statushelp)

        # a little trick: the '+' adds this binding, otherwise it might
        # be overwritten
        self.bind("<Enter>",           self.buttonEnter, '+')
        self.bind("<Leave>",           self.buttonLeave, '+')
        self.bind("<ButtonPress-1>",   self.buttonDown)
        self.bind("<ButtonRelease-1>", self.buttonUp)
        self.pack(side='left', anchor=Tkinter.NW, padx=padx, pady=pady)
        self.state = state    

        # add the button to the list stored in the master
        master.toolbarButtonDict[name] = self

        if bg is None:
            self.bg = self.configure()['background'][-1]
        else:
            self.bg = bg
Exemple #7
0
    def __init__(self, name='Default', **kw):
        """Constructor for class APBSParams"""
        from mglutil.util.packageFilePath import getBinary, findFilePath, which
        if not hasattr(self,'APBS_Path'):
            try:
                self.APBS_Path = getBinary("apbs", 'binaries')
            except ImportError:
                self.APBS_Path = None
            if not self.APBS_Path:
                self.APBS_Path = which('apbs')
                 
        self.pdb2pqr_Path = findFilePath('pdb2pqr.py','MolKit.pdb2pqr')
        self.name = name    # name of the APBS Param instance
        
        self.pdb2pqr_ForceField = 'amber'
        self.calculationType = 'Electrostatic potential'
        self.pbeType = 'Linearized'
        self.boundaryConditions = 'Single Debye-Huckel'
        self.chargeDiscretization = 'Cubic B-spline'
        self.surfaceCalculation = 'Cubic B-spline'
        self.sdens = 10.0
        self.splineWindow = 0.3
        self.molecule1Path = ''
        self.molecule2Path = ''
        self.complexPath = ''
        self.energyOutput = 'Total'
        self.forceOutput = ''
        self.projectFolder = 'apbs-project'
        self.chargeDistributionFile = ''
        self.potentialFile = 'OpenDX'
        self.solventAccessibilityFile = ''
        self.splineBasedAccessibilityFile = ''
        self.VDWAccessibilityFile = ''
        self.ionAccessibilityFile = ''
        self.laplacianOfPotentialFile = ''
        self.energyDensityFile = ''
        self.ionNumberFile = ''
        self.ionChargeDensityFile = ''
        self.xShiftedDielectricFile = ''
        self.yShiftedDielectricFile = ''
        self.zShiftedDielectricFile = ''
        self.kappaFunctionFile = ''

        #Grid parameters
        self.gridPointsX = 65
        self.gridPointsY = 65
        self.gridPointsZ = 65
        self.coarseLengthX = 40
        self.coarseLengthY = 50
        self.coarseLengthZ = 60
        self.coarseCenterX = 0
        self.coarseCenterY = 0
        self.coarseCenterZ = 0
        self.fineLengthX = 20
        self.fineLengthY = 35
        self.fineLengthZ = 30
        self.fineCenterX = 0
        self.fineCenterY = 0
        self.fineCenterZ = 0

        # Physical Parameters
        self.proteinDielectric = 2.0
        self.solventDielectric = 78.54
        self.solventRadius = 1.4
        self.systemTemperature = 298.15
        self.saltConcentration = 0.01
        self.ions = []

        apply( self.Set, (), kw )
    def __init__(self, master=None, name='Tree', multi_choice=False,
                 width=800, height=200, treeWidth=140, treeHeight=100,
                 historyWidth=100, historyHeight=100, mode='Extended',
                 historyVisible=False,nohistory=False,
                 mouseBinding=None,obj2Node=True, displayValue=False,
                 offx=0, offy=0):

        TreeView. __init__(self, master=master, name=name,
                           multi_choice=multi_choice,
                           width=width, height=height,
                           treeWidth=treeWidth, treeHeight=treeHeight,
                           historyWidth=historyWidth,
                           historyHeight=historyHeight,
                           mode=mode, historyVisible=historyVisible,
                           nohistory=nohistory,
                           mouseBinding=mouseBinding, obj2Node=obj2Node,
                           displayValue=displayValue,
                           offx=offx, offy=offy, canvasHeaderCol=True)

        KeySelectable.__init__(self, self.canvas)
        # assign method that need to be overriden
        self.match = self.findFirstMatchNodeFromName
        self.selectItem = self.showNode
        self.ctrlModCallback = self.handleControlKey

        self.sets = None # used to save pmv.sets so that the selector can
                         # use it to allow selecting sets
        self.balloons = Pmw.Balloon(master, yoffset=0)
        
        self.inChain = False  # true when calling chained commands.
                              # used to prevent calling chained or chained
        
        nbcol = self.nbColumns = 15
        #nbcol += 10
        self.callbacks = [None]*nbcol
            # will be the list of call backs associated with
            # columns of checkbuttons
        self.names = [None]*nbcol
            # will be the list of names associated with
            # columns of checkbuttons
        self.colHeaderButtons = [None]*nbcol
        self.colHeaderTkVars = [None]*nbcol
        self.colOptionPanels = [None]*nbcol
        self.pmvcmd = [None]*nbcol
        self.chainWith = [None]*nbcol
        for i in range(nbcol):
            self.chainWith[i] = [None]*nbcol
        self.balloonText = ['No Help']*nbcol

        self.buttonValFunc = [None]*nbcol # function for getting the current values

        # force molecule visible when selecting, displaying or labeling
        # parts of molecules
        for i in range(1,9): # chains command 0 after command 1 through 9
            # 'Checked': call 0 when command 1 is checked
            # 'True': always check the button of the chained command
            # 'All': apply to the whole moelcular fragment
            self.chainWith[i][0] = ('Checked', 'True', 'All')

        # make display lines, S&B and CPK mutually exclusive
        for i in range(2,5):
            for j in range(2,5):
                if i==j: continue
                self.chainWith[i][j] = ('Checked','False','All')

        # make color commands (9-14) radio
        for i in range(9,15):
            for j in range(9,15):
                if i==j: continue
                self.chainWith[i][j] = ('Checked','False','All')

        self.bbmode = ['All']*nbcol
        self.colHeaderTkVars = [None]*nbcol # list of button in the header

        from mglutil.util.packageFilePath import findFilePath
        self.ICONPATH = os.path.abspath(findFilePath('Icons', 'Pmv'))
        self.ICONDIR = os.path.join(self.ICONPATH, '32x32')
        self.iconList = [None]*nbcol # save references to icon images to 
            # prevent them from being garbage collected

        # add the backbone menu option
        self.bbmodevar = Tkinter.StringVar()
        self.bbmodevar.set("Cmd setting")
        self.bbmode_menu = Pmw.OptionMenu(
            self.master, labelpos = 'w', label_text = 'Protein:',
        menubutton_textvariable = self.bbmodevar,
        items = ['Cmd setting', 'Backbone', 'Sidechain',
                         'Sidechains+CA', 'All'],
        menubutton_width = 8
    )
        cid = self.canvasHeaderCol.create_window(
            10, 15, window=self.bbmode_menu, anchor='w')
        self.proteinHelp = """This option menu allows to specify for peptidic molecular fragments
whether the command should be applied to the backbone atoms only,
the side chain atoms only, the sidechain atoms and CA atoms or the
full molecular frament."""
        self.balloons.bind(self.bbmode_menu, self.proteinHelp)

        # add a compound selector entry
        self.selectorEntry = Pmw.EntryField(
            self.master, labelpos = 'w', label_text = 'Select:  ',
            entry_width=12, validate = None, command=self.selectFromString)

        cid = self.canvasHeaderCol.create_window(
            10, 40, window=self.selectorEntry, anchor='w')
        self.selectorHelp = """This entry allows selecting enties in the Tree using a Pmv compound selector.
Only expanded nodes will be selected.  Selected nodes are outlined with a
yellow selection box.  When a button is checked for a selected node, the
command is applied to all selecte nodes.
The syntax for a compound selector is a ; separated list of expressions.
Each expression is a : separated list of selectors applying at the various
levels of the tree.
for instance:
    :::CA selects all carbon alpha atoms
    :A::CA selects all CA in chain A
    ::CYS* selects all cysteins"""
        self.balloons.bind(self.selectorEntry, self.selectorHelp)

        from MolKit.stringSelector import CompoundStringSelector
        self.selector = CompoundStringSelector()
Exemple #9
0
    def createGUI(self):
        """
        Create a ScrolledFrame to hold MAA entries
        """
        if self.master is None:
            self.master = master = Tkinter.Toplevel()
            self.ownsMaster = True
        else:
            self.ownsMaster = False
        self.balloon = Pmw.Balloon(self.master)

        ##
        ## Action Container
        ##
        parent = Pmw.Group(self.master, tag_text='Actions')

        # create container
        w = self.MAAContainer = Pmw.ScrolledListBox(
            parent.interior(),  #labelpos='nw', label_text='AnimationClips',
            listbox_height=6,
            selectioncommand=self.selectionCommand_cb,
            #dblclickcommand=self.defCmd,
            usehullsize=0,
            #hull_width = 300,
            #hull_height = 200,
        )
        ##
        ## Action manipulation group
        ##
        #w.grid(sticky='nesw', column=0, row=0, rowspan=3)
        w.pack(fill='both', expand=1, side="left")
        w._listbox.config(exportselection=False)

        ICONDIR = findFilePath('icons', 'mglutil.gui.BasicWidgets.Tk')
        manipGroup = Pmw.Group(parent.interior(),
                               tag_text='Manipulate Actions')
        master = manipGroup.interior()
        self.gotoStartIcon = im = Tkinter.PhotoImage(file=os.path.join(
            ICONDIR, 'go_to_start.gif'),
                                                     master=master)
        w = self.startActionb = Tkinter.Button(master,
                                               image=im,
                                               command=self.gotoActionStart_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "goto action's start")

        self.gotoEndIcon = im = Tkinter.PhotoImage(file=os.path.join(
            ICONDIR, 'go_to_end.gif'),
                                                   master=master)
        w = self.endActionb = Tkinter.Button(master,
                                             image=im,
                                             command=self.gotoActionEnd_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "goto action's end")

        self.moveUpIcon = im = Tkinter.PhotoImage(file=os.path.join(
            ICONDIR, 'arrowup.gif'),
                                                  master=master)
        w = self.upb = Tkinter.Button(master, image=im, command=self.moveUp_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "Move selected action one position up")

        self.moveDownIcon = im = Tkinter.PhotoImage(file=os.path.join(
            ICONDIR, 'arrowdown.gif'),
                                                    master=master)
        w = self.downb = Tkinter.Button(master,
                                        image=im,
                                        command=self.moveDown_cb)
        w.pack(side='top', anchor='n')
        self.balloon.bind(w, "Move selected action one position down")

        self.deleteIcon = im = Tkinter.PhotoImage(file=os.path.join(
            ICONDIR, 'close.gif'),
                                                  master=master)
        w = self.deleteb = Tkinter.Button(master,
                                          image=im,
                                          command=self.delete_cb)
        w.pack(side='top', anchor='n')
        self.balloon.bind(w, "Delete selected action")

        manipGroup.pack(side='top')

        ##
        ## Action Group
        ##
        self.actionGroup = Pmw.Group(parent.interior(), tag_text='force')
        actionFrame = self.actionGroup.interior()
        self.forceOrientTk = Tkinter.IntVar()
        w = self.orientb = Tkinter.Checkbutton(actionFrame,
                                               text='Orientation',
                                               variable=self.forceOrientTk,
                                               command=self.orient_cb)
        w.pack(side='top', fill='x', anchor='nw')
        w.configure(state='disabled')
        self.balloon.bind(
            w,
            "Force the original orientation on the first frame of this action")

        self.forceRenderingTk = Tkinter.IntVar()
        w = self.renderingb = Tkinter.Checkbutton(
            actionFrame,
            text='Rendering',
            variable=self.forceRenderingTk,
            command=self.rendering_cb)
        w.pack(side='top', fill='x', anchor='nw')
        w.configure(state='disabled')
        self.balloon.bind(
            w,
            "Force the original rendering on the first frame of this action")
        self.actionGroup.pack(side='top', anchor='n', fill='x')

        w = self.editb = Tkinter.Button(parent.interior(),
                                        text='Edit ...',
                                        command=self.edit_cb)
        w.pack(side='top', fill='x', anchor='n')
        self.balloon.bind(w, "Edit selected clip")

        ##
        ## Start Group
        ##
        startgroup = Pmw.Group(parent.interior(), tag_text='Start')
        startframe = startgroup.interior()
        self.startW = sw = Pmw.RadioSelect(startframe,
                                           selectmode='single',
                                           orient='vertical',
                                           buttontype='radiobutton',
                                           command=self.setStartFlag_cb)

        for text in ['after previous', 'with previous']:
            sw.add(text)

        sw.pack(side='top', anchor='n', fill='x', padx=5, pady=5)

        self.balloon.bind(sw.button("after previous"),
                          "Start selected item after the previous one")
        self.balloon.bind(sw.button("with previous"),
                          "Start selected item with the previous one")

        #sw.setvalue('after previous')
        self.offsetw = offw = Pmw.Counter(
            startframe,
            labelpos='w',
            label_text='Offset:',
            entry_width=6,
            entryfield_value=0,
            entryfield_command=self.setOffset_cb,
            datatype=self.setOffset_cb,
            entryfield_validate={'validator': 'integer'})

        self.balloon.bind(
            offw, "positive or negative offset from starting position")

        offw.pack(side='top', anchor='n', fill='x')

        parent.pack(fill='both', expand=1, padx=5, pady=5)
        startgroup.pack(side='top')

        #self.frameCounter = Tkinter.Label(master, text='Frame 000000')
        #self.frameCounter.pack(side='top')
        frame = Tkinter.Frame(self.master)
        self.pl = PlayerControls(
            self.animator,
            root=frame,  #root=self.master,
            form2=1,
            hasSlider=True)
        frame.pack(side='top')

        self.selectionCommand_cb()  # called to configure the buttons
    def createGUI(self):
        """
        Create a ScrolledFrame to hold MAA entries
        """
        if self.master is None:
            self.master = master = Tkinter.Toplevel()
            self.ownsMaster = True
        else:
            self.ownsMaster = False
        self.balloon = Pmw.Balloon(self.master)

        ##
        ## Action Container
        ##        
        parent =  Pmw.Group(self.master, tag_text='Actions')

        # create container
	w = self.MAAContainer = Pmw.ScrolledListBox(
            parent.interior(), #labelpos='nw', label_text='AnimationClips',
            listbox_height = 6,
            selectioncommand = self.selectionCommand_cb,
            #dblclickcommand=self.defCmd,
            usehullsize = 0,
            #hull_width = 300,
            #hull_height = 200,
            )
        ##
        ## Action manipulation group
        ##        
	#w.grid(sticky='nesw', column=0, row=0, rowspan=3)
        w.pack(fill='both', expand=1, side="left")
        w._listbox.config(exportselection = False)
        
        ICONDIR = findFilePath('icons', 'mglutil.gui.BasicWidgets.Tk')
        manipGroup =  Pmw.Group(parent.interior(),
                                 tag_text='Manipulate Actions')
        master = manipGroup.interior()
        self.gotoStartIcon = im = Tkinter.PhotoImage(
            file=os.path.join(ICONDIR, 'go_to_start.gif'), master=master)
        w = self.startActionb =  Tkinter.Button(
            master, image=im, command=self.gotoActionStart_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "goto action's start") 

        self.gotoEndIcon = im = Tkinter.PhotoImage(
            file=os.path.join(ICONDIR, 'go_to_end.gif'), master=master)
        w = self.endActionb =  Tkinter.Button(
            master, image=im, command=self.gotoActionEnd_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "goto action's end") 
        
        self.moveUpIcon = im = Tkinter.PhotoImage(
            file=os.path.join(ICONDIR, 'arrowup.gif'), master=master)
        w = self.upb =  Tkinter.Button(master, image=im, command=self.moveUp_cb)
        w.pack(side='left', anchor='n')
        self.balloon.bind(w, "Move selected action one position up") 
        
        self.moveDownIcon = im = Tkinter.PhotoImage(
            file=os.path.join(ICONDIR, 'arrowdown.gif'), master=master)
        w = self.downb =  Tkinter.Button(
            master, image=im, command=self.moveDown_cb)
        w.pack(side='top', anchor='n')
        self.balloon.bind(w, "Move selected action one position down")         
        
        self.deleteIcon = im = Tkinter.PhotoImage(
            file=os.path.join(ICONDIR, 'close.gif'), master=master)
        w = self.deleteb =  Tkinter.Button(
            master, image=im, command=self.delete_cb)
        w.pack(side='top', anchor='n')
        self.balloon.bind(w, "Delete selected action")         

        manipGroup.pack(side='top')

        ##
        ## Action Group
        ##
        self.actionGroup =  Pmw.Group(parent.interior(), tag_text='force')
        actionFrame = self.actionGroup.interior()
        self.forceOrientTk = Tkinter.IntVar()
        w = self.orientb =  Tkinter.Checkbutton(
            actionFrame, text='Orientation', variable=self.forceOrientTk,
            command=self.orient_cb)
        w.pack(side='top', fill='x', anchor='nw')
        w.configure(state='disabled')
        self.balloon.bind(w, "Force the original orientation on the first frame of this action")
        
        self.forceRenderingTk = Tkinter.IntVar()
        w = self.renderingb =  Tkinter.Checkbutton(
            actionFrame, text='Rendering', variable=self.forceRenderingTk,
            command=self.rendering_cb)
        w.pack(side='top', fill='x', anchor='nw')
        w.configure(state='disabled')
        self.balloon.bind(w, "Force the original rendering on the first frame of this action")    
        self.actionGroup.pack(side='top', anchor='n', fill='x')

        w = self.editb =  Tkinter.Button(parent.interior(), text='Edit ...',
                                         command=self.edit_cb)
        w.pack(side='top', fill='x', anchor='n')
        self.balloon.bind(w, "Edit selected clip")    


        ##
        ## Start Group
        ##
        startgroup =  Pmw.Group(parent.interior(), tag_text='Start')
        startframe = startgroup.interior()
        self.startW = sw = Pmw.RadioSelect(
            startframe, selectmode='single', orient='vertical',
            buttontype='radiobutton', command=self.setStartFlag_cb)

        for text in ['after previous', 'with previous']:
            sw.add(text)

        sw.pack(side='top', anchor='n', fill='x',
                padx=5, pady=5)

        self.balloon.bind(sw.button("after previous"),
                          "Start selected item after the previous one")
        self.balloon.bind(sw.button("with previous"),
                          "Start selected item with the previous one")

        #sw.setvalue('after previous')
        self.offsetw = offw = Pmw.Counter(
            startframe, labelpos = 'w', label_text = 'Offset:',
            entry_width = 6, entryfield_value = 0,
            entryfield_command = self.setOffset_cb,
            datatype = self.setOffset_cb,
            entryfield_validate = {'validator' : 'integer' } )

        self.balloon.bind(offw,
                          "positive or negative offset from starting position")

        offw.pack(side='top', anchor='n', fill='x')

        parent.pack(fill='both', expand=1, padx=5, pady=5)
        startgroup.pack(side='top')
        

        #self.frameCounter = Tkinter.Label(master, text='Frame 000000')
        #self.frameCounter.pack(side='top')
        frame = Tkinter.Frame(self.master)               
        self.pl = PlayerControls( self.animator, root=frame, #root=self.master,
                                  form2=1, hasSlider=True)
        frame.pack(side='top')


        self.selectionCommand_cb() # called to configure the buttons
Exemple #11
0
    def showGUI(self,
                master=None,
                root=None,
                width=200,
                height=80,
                titleStr='player',
                gotoStartfile='go_to_start.gif',
                gotoEndfile='go_to_end.gif',
                ff_revfile='ff_rev.gif',
                ff_fwdfile='ff_fwd.gif',
                stopfile='stop.gif',
                playfile='play_fwd.gif',
                playRevfile='play_rev.gif',
                chmodfile='chmod.gif',
                closefile='close.gif',
                iconpath=None):
        """ function to display the player gui."""

        if hasattr(self, 'form'):
            if hasattr(self.form, "deiconify"):
                self.form.deiconify()
                return
        self.master = master
        self.root = root

        if not self.form2:
            self.form = self.buildForm(titleStr)  # pass some arguments here
            self.form2 = 0
        else:
            if iconpath is None:
                iconpath = ('mglutil.gui.BasicWidgets.Tk', 'icons')
            ICONDIR = findFilePath(iconpath[1], iconpath[0])
            #if findFilePath failed, already returned
            gotoStartfile = os.path.join(ICONDIR, gotoStartfile)
            gotoEndfile = os.path.join(ICONDIR, gotoEndfile)
            ff_revfile = os.path.join(ICONDIR, ff_revfile)
            ff_fwdfile = os.path.join(ICONDIR, ff_fwdfile)
            stopfile = os.path.join(ICONDIR, stopfile)
            playfile = os.path.join(ICONDIR, playfile)
            playRevfile = os.path.join(ICONDIR, playRevfile)
            chmodfile = os.path.join(ICONDIR, chmodfile)
            closefile = os.path.join(ICONDIR, closefile)
            recordfile = os.path.join(ICONDIR, "record.gif")
            record1file = os.path.join(ICONDIR, "record1.gif")

            self.gotoStartIcon = Tkinter.PhotoImage(file=gotoStartfile,
                                                    master=master)
            self.gotoEndIcon = Tkinter.PhotoImage(file=gotoEndfile,
                                                  master=master)
            self.ff_revIcon = Tkinter.PhotoImage(file=ff_revfile,
                                                 master=master)
            self.ff_fwdIcon = Tkinter.PhotoImage(file=ff_fwdfile,
                                                 master=master)
            self.stopIcon = Tkinter.PhotoImage(file=stopfile, master=master)
            self.playIcon = Tkinter.PhotoImage(file=playfile, master=master)
            self.playRevIcon = Tkinter.PhotoImage(file=playRevfile,
                                                  master=master)
            self.recIcon = Tkinter.PhotoImage(file=recordfile, master=master)
            self.rec1Icon = Tkinter.PhotoImage(file=record1file, master=master)
            self.chmodIcon = Tkinter.PhotoImage(file=chmodfile, master=master)
            self.closeIcon = Tkinter.PhotoImage(file=closefile, master=master)
            self.form = self.buildForm2(titleStr)  # pass some argument here
Exemple #12
0
    def addButtonsToButtonBar(self, master):
        # balloons were moved from the cursor to fix a problem with
        # node library balloons flashing

        buttonList = [
            {
                'sep1': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'new': {
                    'icon1': 'new.gif',
                    'icon2': None,
                    'state': 'normal',
                    'func': self.newNet_cb,
                    'balloon': 'new network'
                }
            },
            {
                'open': {
                    'icon1': 'open.gif',
                    'icon2': 'lib-close.gif',
                    'state': 'normal',
                    'func': self.loadNetwork_cb,
                    'balloon': 'open network'
                }
            },
            {
                'merge': {
                    'icon1': 'merge1.gif',
                    'icon2': 'merge2.gif',
                    'state': 'disabled',
                    'func': self.mergeNetwork_cb,
                    'balloon': 'merge networks'
                }
            },
            {
                'loadLib': {
                    'type': 'menubutton',
                    'icon1': 'loadLib2.gif',
                    'func': self.showLoadLibraryForm2_cb,
                    'balloon': 'load library'
                }
            },
            {
                'showHideLib': {
                    'state': 'normal',
                    'icon1': 'lib-open.gif',
                    'icon2': 'lib-close.gif',
                    'func': self.showHideLibraries_cb,
                    'balloon': 'show/hide library'
                }
            },
            {
                'save': {
                    'icon1': 'save1.gif',
                    'icon2': 'save2.gif',
                    'state': 'disabled',
                    'func': self.saveNetwork_cb,
                    'balloon': 'save network'
                }
            },
            {
                'print': {
                    'icon1': 'print1.gif',
                    'icon2': 'print2.gif',
                    'state': 'disabled',
                    'func': self.print_cb,
                    'balloon': 'print network'
                }
            },
            {
                'sep3': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'runOnNewData': {
                    'type': 'checkbutton',
                    'icon1': 'tapclosed.gif',
                    'icon2': 'tapopen.gif',
                    'func': self.setRunOnNewData_cb,
                    'balloon': 'toggle immediate run'
                }
            },
            {
                'softrun': {
                    'icon1': 'run1.gif',
                    'icon2': 'runGreen.gif',
                    'state': 'disabled',
                    'func': self.softrunCurrentNet_cb,
                    'balloon': 'soft run current network'
                }
            },
            {
                'run': {
                    'icon1': 'run1.gif',
                    'icon2': 'run2.gif',
                    'state': 'disabled',
                    'func': self.runCurrentNet_cb,
                    'balloon': 'hard run current network (force run)'
                }
            },
            {
                'pause': {
                    'icon1': 'pause1.gif',
                    'icon2': 'pause2.gif',
                    'state': 'disabled',
                    'func': self.togglePauseCurrentNet_cb,
                    'balloon': "pause current network's execution"
                }
            },
            {
                'stop': {
                    'icon1': 'stop1.gif',
                    'icon2': 'stop2.gif',
                    'state': 'disabled',
                    'func': self.stopCurrentNet_cb,
                    'balloon': "stop current network's execution"
                }
            },
            {
                'sep4': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'runWithoutGui': {
                    'icon1':
                    'run1.gif',
                    'icon2':
                    'runBlack.gif',
                    'state':
                    'disabled',
                    'func':
                    self.runWithoutGui_cb,
                    'balloon':
                    'run current network without GUI in a separate process'
                }
            },
            {
                'stopWithoutGui': {
                    'icon1': 'stop1.gif',
                    'icon2': 'stop2.gif',
                    'state': 'disabled',
                    'func': self.stopWithoutGui_cb,
                    'balloon': "stop execution without GUI"
                }
            },
            {
                'sep5': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'gantt': {
                    'icon1': 'teprla1.gif',
                    'icon2': 'teprla1.gif',
                    'state': 'enabled',
                    'func': self.toggleGantt_cb,
                    'balloon': "show/hide GANTT diagram of execution times"
                }
            },
            {
                'debug': {
                    'icon1':
                    'flowengine_6.gif',
                    'icon2':
                    'flowengine_6.gif',
                    'state':
                    'enabled',
                    'func':
                    self.debugCurrentNet_cb,
                    'balloon':
                    "build the list of node to execute and step through them"
                }
            },
            {
                'step': {
                    'icon1': 'stepover_6.gif',
                    'icon2': 'stepover_6.gif',
                    'state': 'disabled',
                    'func': self.debugStep_cb,
                    'balloon': "Execute current node in node list"
                }
            },
            {
                'sep5a': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'cut': {
                    'icon1': 'cut1.gif',
                    'icon2': 'cut2.gif',
                    'state': 'disabled',
                    'func': self.cutNetwork_cb,
                    'balloon': 'cut'
                }
            },
            {
                'copy': {
                    'icon1': 'copy1.gif',
                    'icon2': 'copy2.gif',
                    'state': 'disabled',
                    'func': self.copyNetwork_cb,
                    'balloon': 'copy'
                }
            },
            {
                'paste': {
                    'icon1': 'paste1.gif',
                    'icon2': 'paste2.gif',
                    'state': 'disabled',
                    'func': self.pasteNetwork_cb,
                    'balloon': 'paste'
                }
            },
            {
                'sep6': {
                    'icon1': 'sep.gif',
                    'icon2': None,
                    'state': 'disabled',
                    'func': None,
                    'balloon': None
                }
            },
            {
                'find': {
                    'icon1': 'find2.gif',
                    'icon2': 'find2.gif',
                    'state': 'enabled',
                    'func': self.searchNodes_cb,
                    'balloon': 'open search nodes panel'
                }
            },
        ]

        from mglutil.util.packageFilePath import findFilePath
        ICONPATH = findFilePath('Icons', 'CADD')

        self.buttonIcons = {
        }  #otherwise the icon is lost and not displayed (tk bug)
        for item in buttonList:
            name = item.keys()[0]
            icon1 = item[name]['icon1']
            func = item[name]['func']
            balloon = item[name]['balloon']
            self.buttonBarFunc[name] = func
            if item[name].has_key('type') is False:
                icon2 = item[name]['icon2']
                state = item[name]['state']
                # Note: we pass balloonmaster=None to class ToolBarButton
                # so it will create an attribute 'balloons' in self.buttonBar
                # so Pmw.Balloon will be an instance in self.buttonBar.balloons
                CADDToolBarButton(None,
                                  self.buttonBar,
                                  name=name,
                                  icon1=icon1,
                                  icon2=icon2,
                                  state=state,
                                  command=self.selectFunc,
                                  balloonhelp=balloon,
                                  statushelp=balloon,
                                  bg=self.bg,
                                  iconpath=ICONPATH)
            else:
                head, ext = os.path.splitext(icon1)
                ICONPATH1 = os.path.join(ICONPATH, icon1)
                if ext == '.gif':
                    Icon = Tkinter.PhotoImage(
                        file=ICONPATH1, master=master)  #, master=self.ROOT)
                else:
                    import Image
                    import ImageTk
                    image = Image.open(ICONPATH1)
                    Icon = ImageTk.PhotoImage(image=image, master=master)
                if item[name]['type'] == 'menubutton':
                    self.buttonIcons[name] = Icon
                    #lButton = Tkinter.Menubutton(self.buttonBar,
                    lButton = CADDMenubutton(self.buttonBar,
                                             text='load library',
                                             image=Icon)
                    self.fastLibsMenu2 = Tkinter.Menu(lButton, tearoff=0)
                    self.updateFastLibs()
                    lButton.menu = self.fastLibsMenu2
                    lButton['menu'] = lButton.menu
                elif item[name]['type'] == 'checkbutton':
                    if hasattr(self, 'buttonVariables') is False:
                        self.buttonVariables = {}
                    if self.buttonVariables.has_key(name) is False:
                        self.buttonVariables[name] = Tkinter.IntVar()
                    self.buttonIcons[name] = [
                        Icon,
                    ]
                    #lButton = Tkinter.Checkbutton(self.buttonBar,
                    lButton = CADDCheckbutton(
                        self.buttonBar,
                        image=Icon,
                        indicatoron=0,
                        variable=self.buttonVariables[name],
                        command=func,
                        selectcolor='lightgrey',
                        bg=self.bg,
                        #background='white',
                    )

                    if item[name].has_key('icon2'):
                        icon2 = item[name]['icon2']
                        head2, ext2 = os.path.splitext(icon2)
                        ICONPATH2 = os.path.join(ICONPATH, icon2)
                        if ext2 == '.gif':
                            Icon2 = Tkinter.PhotoImage(
                                file=ICONPATH2,
                                master=master)  #, master=self.ROOT)
                        else:
                            image2 = Image.open(ICONPATH2)
                            Icon2 = ImageTk.PhotoImage(image=image2,
                                                       master=master)
                        self.buttonIcons[name].append(Icon2)
                        lButton.configure(selectimage=Icon2)

                # add ballon to this button
                if hasattr(self.buttonBar, 'balloons') is False:
                    self.buttonBar.balloons = Pmw.Balloon(self.buttonBar,
                                                          yoffset=0)
                self.buttonBar.balloons.bind(lButton, balloon, balloon)

                lButton.pack(side=Tkinter.LEFT, padx="1m")
                # add the button to the list stored in the master
                self.buttonBar.toolbarButtonDict[name] = lButton
Exemple #13
0
 def showFAQ(self, event=None):
     from mglutil.util.packageFilePath import findFilePath
     file = findFilePath('FAQ.html', 'CADD')
     if file:
         webbrowser.open(file)
    def __init__(self, name='Default', **kw):
        """Constructor for class APBSParams"""
        from mglutil.util.packageFilePath import getBinary, findFilePath, which
        if not hasattr(self,'APBS_Path'):
            try:
                self.APBS_Path = getBinary("apbs", 'binaries')
            except ImportError:
                self.APBS_Path = None
            if not self.APBS_Path:
                self.APBS_Path = which('apbs')
                 
        self.pdb2pqr_Path = findFilePath('pdb2pqr.py','MolKit.pdb2pqr')
        self.name = name    # name of the APBS Param instance
        
        self.pdb2pqr_ForceField = 'amber'
        self.calculationType = 'Electrostatic potential'
        self.pbeType = 'Linearized'
        self.boundaryConditions = 'Single Debye-Huckel'
        self.chargeDiscretization = 'Cubic B-spline'
        self.surfaceCalculation = 'Cubic B-spline'
        self.sdens = 10.0
        self.splineWindow = 0.3
        self.molecule1Path = ''
        self.molecule2Path = ''
        self.complexPath = ''
        self.energyOutput = 'Total'
        self.forceOutput = ''
        self.projectFolder = 'apbs-project'
        self.chargeDistributionFile = ''
        self.potentialFile = 'OpenDX'
        self.solventAccessibilityFile = ''
        self.splineBasedAccessibilityFile = ''
        self.VDWAccessibilityFile = ''
        self.ionAccessibilityFile = ''
        self.laplacianOfPotentialFile = ''
        self.energyDensityFile = ''
        self.ionNumberFile = ''
        self.ionChargeDensityFile = ''
        self.xShiftedDielectricFile = ''
        self.yShiftedDielectricFile = ''
        self.zShiftedDielectricFile = ''
        self.kappaFunctionFile = ''

        #Grid parameters
        self.gridPointsX = 65
        self.gridPointsY = 65
        self.gridPointsZ = 65
        self.coarseLengthX = 40
        self.coarseLengthY = 50
        self.coarseLengthZ = 60
        self.coarseCenterX = 0
        self.coarseCenterY = 0
        self.coarseCenterZ = 0
        self.fineLengthX = 20
        self.fineLengthY = 35
        self.fineLengthZ = 30
        self.fineCenterX = 0
        self.fineCenterY = 0
        self.fineCenterZ = 0

        # Physical Parameters
        self.proteinDielectric = 2.0
        self.solventDielectric = 78.54
        self.solventRadius = 1.4
        self.systemTemperature = 298.15
        self.saltConcentration = 0.01
        self.ions = []

        apply( self.Set, (), kw )
from DejaVu.Spheres import Spheres
from DejaVu.Points import CrossSet
from DejaVu.Cylinders import Cylinders
from Pmv.mvCommand import MVInteractiveCmdCaller
from mglutil.util.packageFilePath import getResourceFolderWithVersion, findFilePath
from mglutil.util.recentFiles import RecentFiles
import thread
from types import StringType, ListType
import Pmw
import os
from numpy.oldnumeric import array, fabs, maximum
from string import find, replace, split
from MolKit.tree import TreeNode, TreeNodeSet

from mglutil.util.packageFilePath import findFilePath
ICONPATH = findFilePath('Icons', 'Pmv')

class MolGeomContainer(GeomContainer):
    """
    Class to hold geometries used to represent molecules in a viewer.
    An instance of such a class called geomContainer is added to each Molecule
    as it is loaded into a Viewer
    """
    def __init__(self, mol, viewer):
        """constructor of the geometry container"""

        GeomContainer.__init__(self)

        self.mol = mol
        mol.geomContainer = self