def select(self,items,deselect=0):
     icomLevel = self.vf.ICOMbar.LevelOption._menubutton.config()['text'][-1]
     if icomLevel == 'Atom':
         msg = "The selection level is currently ATOM. Continuing will\nchange it to RESIDUE"
         d = SimpleDialog(self.vf.GUI.ROOT,text=msg,
                          buttons = ["Abort","Continue"],
                          title = "Warning",
                          default=1)
         if not d.go():
             return
     AlignmentEditor.select(self,items,deselect)
     lastSelect = self.lastSelect #just been updated by previous line
     negate=lastSelect[0]
     selStrings={}
     for item in lastSelect[1]:
         resTag,seqTag,uniqTag = self.canvas.gettags(item)[:3]
         # if the item is part of a sequence linked to a molecule,
         # the selection can be applied to Pmv. Since the resTag in this case
         # is the unique object identifier for the residue, this is easy
         if seqTag in self.vf.Mols.name:
             molName = seqTag
             selectionKey = molName+':'+resTag[:1]+':'
             resnum = resTag[1:]
             if selectionKey in selStrings.keys():
                 selStrings[selectionKey]=selStrings[selectionKey]+','+resnum
             else:
                 selStrings[selectionKey]=','+resnum
     for selStr in selStrings.keys():
         print selStr+selStrings[selStr]
         self.vf.select(selStr+selStrings[selStr],negate)
Пример #2
0
 def select(self,items,deselect=0):
     icomLevel = self.vf.ICOMbar.LevelOption._menubutton.config()['text'][-1]
     if icomLevel == 'Atom':
         msg = "The selection level is currently ATOM. Continuing will\nchange it to RESIDUE"
         d = SimpleDialog(self.vf.GUI.ROOT,text=msg,
                          buttons = ["Abort","Continue"],
                          title = "Warning",
                          default=1)
         if not d.go():
             return
     AlignmentEditor.select(self,items,deselect)
     lastSelect = self.lastSelect #just been updated by previous line
     negate=lastSelect[0]
     selStrings={}
     for item in lastSelect[1]:
         resTag,seqTag,uniqTag = self.canvas.gettags(item)[:3]
         # if the item is part of a sequence linked to a molecule,
         # the selection can be applied to Pmv. Since the resTag in this case
         # is the unique object identifier for the residue, this is easy
         if seqTag in self.vf.Mols.name:
             molName = seqTag
             selectionKey = molName+':'+resTag[:1]+':'
             resnum = resTag[1:]
             if selectionKey in selStrings.keys():
                 selStrings[selectionKey]=selStrings[selectionKey]+','+resnum
             else:
                 selStrings[selectionKey]=','+resnum
     for selStr in selStrings.keys():
         print selStr+selStrings[selStr]
         self.vf.select(selStr+selStrings[selStr],negate)
Пример #3
0
 def _srcDialog(self):
     paramDict = MyOrderedDict()
     paramDict['Source Model File'] = Param('file', '*.xml')
     paramDict['optimizer'] = Param('string', 'Minuit')
     root = SimpleDialog(paramDict, title="Define SrcAnalysis Object:")
     root.mainloop()
     xmlFile = _resolveFileList(paramDict['Source Model File'].value())[0]
     output = (xmlFile, paramDict['optimizer'].value())
     return output
Пример #4
0
	def _obsDialog(self, mosaicFile):
		paramDict = MyOrderedDict()
		if mosaicFile is None:
			paramDict['mosaicFile'] = Param('file', '*.fits')
		else:
			paramDict['mosaicFile'] = Param('file', mosaicFile)

		root = SimpleDialog(paramDict, title="Mosaic Elements:")
		root.mainloop()
		output = (paramDict['mosaicFile'].value())
		return output
Пример #5
0
 def _obsDialog(self):
     paramDict = MyOrderedDict()
     paramDict['eventFile'] = Param('file', '*.fits')
     paramDict['scFile'] = Param('file', '*scData*.fits')
     paramDict['expMap'] = Param('file', '')
     paramDict['expCube'] = Param('file', '')
     paramDict['irfs'] = Param('string', 'TEST')
     root = SimpleDialog(paramDict, title="Observation Elements:")
     root.mainloop()
     eventFiles = _resolveFileList(paramDict['eventFile'].value())
     scFiles = _resolveFileList(paramDict['scFile'].value())
     output = (eventFiles, scFiles, paramDict['expMap'].value(),
               paramDict['expCube'].value(), paramDict['irfs'].value())
     return output
Пример #6
0
 def kill_cb(self, event=None):
     if not mswin:
         import signal, Tkinter
         from SimpleDialog import SimpleDialog
         text = "Do you really want to kill this process?"
         d = SimpleDialog(Tkinter._default_root, text=text,
                          buttons=["Yes", "No"],
                          default=0, title="Kill process")
         result = d.go()
         if result==0:
             try:
                 os.kill(self.com.pid,signal.SIGKILL)
             except:
                 pass
     else:
         pass
Пример #7
0
 def _obsDialog(self, srcMaps, expCube):
     paramDict = MyOrderedDict()
     if srcMaps is None:
         paramDict['srcMaps'] = Param('file', '*.fits')
     else:
         paramDict['srcMaps'] = Param('file', srcMaps)
     if expCube is None:
         paramDict['expCube'] = Param('file', '*.fits')
     else:
         paramDict['expCube'] = Param('file', expCube)
     paramDict['binnedExpMap'] = Param('file', '')
     paramDict['irfs'] = Param('string', 'DC1A')
     root = SimpleDialog(paramDict, title="Binned Analysis Elements:")
     root.mainloop()
     output = (paramDict['srcMaps'].value(), paramDict['expCube'].value(),
               paramDict['binnedExpMap'].value(), paramDict['irfs'].value())
     return output
Пример #8
0
 def kill_cb(self, event=None):
     if not mswin:
         import signal, Tkinter
         from SimpleDialog import SimpleDialog
         text = "Do you really want to kill this process?"
         d = SimpleDialog(Tkinter._default_root,
                          text=text,
                          buttons=["Yes", "No"],
                          default=0,
                          title="Kill process")
         result = d.go()
         if result == 0:
             try:
                 os.kill(self.com.pid, signal.SIGKILL)
             except:
                 pass
     else:
         pass
Пример #9
0
def getparams():
	rootdir = os.path.abspath( os.path.curdir )
	
	tkroot = Tk()
	
	rootdir = askdirectory( initialdir=rootdir, title='Choose Root Directory' )
#   NO  '-message' on win32 tk   # 	message='Choose root directory to process' )
	
	bb = [_DVD, 'CDR', 'TEST', 'Cancel' ]
	d = SimpleDialog( tkroot,  
				text="Please choose media type for   " + rootdir,
				buttons=bb,
				default=bb.index(_DVD), 
				cancel=bb.index('Cancel'),
				title='Media' )		
	
	d.frame.winfo_toplevel().tkraise()
	media = bb[d.go()]
	tkroot.destroy()
	return rootdir, media
Пример #10
0
def getparams():
    rootdir = os.path.abspath(os.path.curdir)

    tkroot = Tk()

    rootdir = askdirectory(initialdir=rootdir, title='Choose Root Directory')
    #   NO  '-message' on win32 tk   # 	message='Choose root directory to process' )

    bb = [_DVD, 'CDR', 'TEST', 'Cancel']
    d = SimpleDialog(tkroot,
                     text="Please choose media type for   " + rootdir,
                     buttons=bb,
                     default=bb.index(_DVD),
                     cancel=bb.index('Cancel'),
                     title='Media')

    d.frame.winfo_toplevel().tkraise()
    media = bb[d.go()]
    tkroot.destroy()
    return rootdir, media
Пример #11
0
 def checkIfExists(self):
     """Check if self.file exists. If yes - creates a dialog,
     asking to ovwrwrite the file.
     Function returns: 1 if file exists - no overwritting;
                       0 if no file or file exists - overwrite. """
     if os.path.exists(self.file):
         root = Tkinter.Toplevel()
         root.withdraw()
         d = SimpleDialog(root,
                          title = "Overwrite Existing File Question",
                          text = "File %s exists. Overwrite it?"% self.file,
                          buttons=["Yes", "Cancel"],
                          default = 1,
                          cancel = 1).go()
         root.destroy()
         return d
     else: return 0
Пример #12
0
 def _buttonPress(self, event):
     if self.orientation is Tk.VERTICAL:
         crd = event.y
     else:
         crd = event.x
     gapIndex = -1
     for i in range(len(self.gapList)):
         if crd < self.gapList[i]:
             gapIndex = i
             break
     if gapIndex == -1:
         raise SystemError, 'cannot identify sash gap'
     paneAbove = None
     for above in range(gapIndex, -1, -1):
         pane = self.paneList[above]
         if not _isCollapsed(pane):
             paneAbove = pane
             break
     if paneAbove is None:
         d = SimpleDialog(self.winfo_toplevel(),
                          text='There is no adjustable pane above',
                          buttons=['Okay'],
                          title='User Error')
         d.go()
         return
     paneBelow = None
     for below in range(gapIndex + 1, len(self.paneList)):
         pane = self.paneList[below]
         if not _isCollapsed(pane):
             paneBelow = pane
             break
     if paneBelow is None:
         d = SimpleDialog(self.winfo_toplevel(),
                          text='There is no adjustable pane below',
                          buttons=['Okay'],
                          title='User Error')
         d.go()
         return
     self.adjustAbove = paneAbove
     self.adjustBelow = paneBelow
     self.drag = crd
     self.bind('<Motion>', self._buttonDrag)
Пример #13
0
 def guiCallback(self):
     if not hasattr(self.vf, "SL"):
         self.warningMsg(
             "This command requires 'SLCommands' module. Load the module.")
         return
     file = self.vf.askFileOpen(types=[('BSPT file', '*.bsp')],
                                title="Read .bsp")
     if file:
         root = Tkinter.Toplevel()
         root.withdraw()
         from SimpleDialog import SimpleDialog
         ans = SimpleDialog(root,
                            text="Bind object to molecule?",
                            buttons=["Yes", "No", "Cancel"],
                            default=0,
                            title="new data dialog").go()
         root.destroy()
         mol = None
         if ans == 0:
             from Pmv.guiTools import MoleculeChooser
             ans = MoleculeChooser(self.vf).go()
             if ans:
                 mol = ans.name
         apply(self.doitWrapper, (file, mol), {})
Пример #14
0
	def _buttonPress(self, event):
		if self.orientation is Tk.VERTICAL:
			crd = event.y
		else:
			crd = event.x
		gapIndex = -1
		for i in range(len(self.gapList)):
			if crd < self.gapList[i]:
				gapIndex = i
				break
		if gapIndex == -1:
			raise SystemError, 'cannot identify sash gap'
		paneAbove = None
		for above in range(gapIndex, -1, -1):
			pane = self.paneList[above]
			if not _isCollapsed(pane):
				paneAbove = pane
				break
		if paneAbove is None:
			d = SimpleDialog(self.winfo_toplevel(),
				text='There is no adjustable pane above',
				buttons=['Okay'],
				title='User Error')
			d.go()
			return
		paneBelow = None
		for below in range(gapIndex + 1, len(self.paneList)):
			pane = self.paneList[below]
			if not _isCollapsed(pane):
				paneBelow = pane
				break
		if paneBelow is None:
			d = SimpleDialog(self.winfo_toplevel(),
				text='There is no adjustable pane below',
				buttons=['Okay'],
				title='User Error')
			d.go()
			return
		self.adjustAbove = paneAbove
		self.adjustBelow = paneBelow
		self.drag = crd
		self.bind('<Motion>', self._buttonDrag)
Пример #15
0
        def createActor(self, object, propname, variable = None, check = True,
                        addToDirector = True, actorData=None,
                        redraw = True, valueGenerator = None):
            #if not object.hasBeenCurrent :
            #    self.setCurrentObjectAttrList(object)
            #if not hasattr(object, 'animatedProperties'):
            #    object.animatedProperties = {}
            if not hasattr(object, 'animatableProps'):
                object.animatableProps = getAnimatableAttributes(object)
            # create an actor for object.propname
            descr = object.animatableProps[0][propname]
            actorname = getActorName(object, propname)
            director = self._director()
            newactor = True
            if check:
                for i, a in enumerate(director.actors):
                    if a.name == actorname:
                        text = "Actor %s exists. Do you want to overwrite it?\n"%actorname
                        d = SimpleDialog(director.gui.root, text=text,
                                         buttons=["Yes", "No"],
                                         default=1, title="Overwrite Actor Dialog")
                        result = d.go()

                        if result == 1:
                            return None
                        else:
                            newactor = False #
                            actorind = i
                            break
            #create the actor
            actorClass, args, kw = descr['actor']
            if valueGenerator is not None:
                kw['interp'] = valueGenerator
            if actorData is not None:
                from scenario.actor import FileActor
                actor = FileActor(*(propname, object, actorClass, actorData)+args, **kw)
                actorname = actor.name
            else:
                actor = actorClass( *(propname, object)+args, **kw )
            actor.scenario = self
            #object.animatedProperties[actorname] = actor
            self.animatedProperties[actorname] = actor
            if not newactor: # director already has an actor with name "actorname",
                             # and the user wishes to overwrite it
                # replace existing actor whith the new one
                oldactor = director.actors.pop(actorind)
                director.gui.deleteActor(oldactor)
                director.actors.insert(actorind, actor)
                actor._director = weakref.ref(director)
                posy = oldactor._posy
                director.gui.drawActor(actor, posy)
                if oldactor.guiVar:
                    variable = oldactor.guiVar
            
            else:
                if addToDirector:
                    # add actor to the director
                    director.addActor(actor, redraw)
            if variable:
                actor.guiVar = variable
            return actor
Пример #16
0
try:
    # try to import pygame
    import pygame
    from pygame.locals import *
except:
    from Tkinter import *
    from SimpleDialog import SimpleDialog

    root = Tk()

    common.error(
        "pygame is not available. Please install pygame on your system.")

    SimpleDialog(root,
                 i18n.get_text(common.get_user_lang(), 102) + "\n" +
                 i18n.get_text(common.get_user_lang(), 104), ["OK"],
                 0,
                 title="Omnitux").go()

    exit()

try:
    # try to import pygtk
    import pygtk

except:
    from Tkinter import *
    from SimpleDialog import SimpleDialog

    root = Tk()
Пример #17
0
 def _complain(self, text):
     d = SimpleDialog(self.winfo_toplevel(),
                      text=text,
                      buttons=['Okay'],
                      title='User Error')
     d.go()