19
19
- ResetUndoCommand.
22
# $Header: /opt/cvs/python/packages/share1.5/ViewerFramework/basicCommand.py,v 1.125 2009/04/29 23:10:51 annao Exp $
22
# $Header: /opt/cvs/python/packages/share1.5/ViewerFramework/basicCommand.py,v 1.117.2.2 2009/02/26 18:28:23 sargis Exp $
24
# $Id: basicCommand.py,v 1.125 2009/04/29 23:10:51 annao Exp $
24
# $Id: basicCommand.py,v 1.117.2.2 2009/02/26 18:28:23 sargis Exp $
26
26
import os, sys, subprocess
30
30
from mglutil.gui.BasicWidgets.Tk.customizedWidgets import ListChooser, \
31
31
LoadButton, kbScrolledListBox
32
32
from mglutil.util.packageFilePath import findFilePath, \
33
findModulesInPackage, getResourceFolderWithVersion
33
findModulesInPackage,findAllPmvPackages, getResourceFolderWithVersion
35
35
import types, Tkinter, Pmw, os, sys, traceback
36
36
from string import join
44
def findAllVFPackages():
45
"""Returns a list of package names found in sys.path"""
47
for p in ['.']+sys.path:
49
if not os.path.exists(p) or not os.path.isdir(p):
53
pdir = os.path.join(p, f)
54
if not os.path.isdir(pdir):
56
if os.path.exists( os.path.join( pdir, '__init__.py')) :
58
fptr =open("%s/__init__.py" %pdir)
59
Lines = fptr.readlines()
60
flagline =filter(lambda x:x.startswith("packageContainsVFCommands"),Lines)
62
if not packages.has_key(f):
66
43
class UndoCommand(Command):
67
44
"""pops undo string from the stack and executes it in the ViewerFrameworks
494
471
self.vf.GUI.ROOT.config(cursor='watch')
495
472
self.vf.GUI.ROOT.update()
496
473
if self.allPack == {}:
497
self.allPack = findAllVFPackages()
474
self.allPack = findAllPmvPackages()
498
475
val = self.showForm('loadCmds', force=1,modal=0,blocking=0)
499
476
ebn = self.cmdForms['loadCmds'].descr.entryByName
500
477
# docb=ebn['docbutton']['widget']
1700
1677
if self.vf.logMode == 'no':
1701
1678
self.vf.warningMsg("No log information because logMode was set to no.")
1703
newfile = self.vf.askFileSave(types = [('all files','*.py')],
1680
newfile = self.vf.askFileSave(types = [('all files','*.*')],
1704
1681
title = 'Save Session in File:')
1705
1682
if not newfile is None:
1706
1683
self.doitWrapper(newfile, redraw=0)
2030
2007
self.vf.GUI.ROOT.after(10,self.vf.GUI.quit_cb)
2034
class customAnimationCommand(Command):
2035
"""Command to start Custom Animation notebook widget
2038
def __init__(self, func=None):
2039
Command.__init__(self, func)
2010
class ScenarioCommand(Command):
2012
"""Command to start scenario application """
2043
2013
def guiCallback(self):
2044
self.startCustomAnim_cb()
2014
self.startScenario_cb()
2047
2017
def __call__(self, **kw):
2048
"""None <- customAnimation"""
2018
"""None <- addScenario"""
2049
2019
add = kw.get('add', None)
2050
2020
if add is None:
2052
2022
else: assert add in (0, 1)
2053
if self.vf.GUI.toolbarCheckbuttons.has_key('customAnimation'):
2054
self.vf.GUI.toolbarCheckbuttons['customAnimation']['Variable'].set(add)
2055
self.startCustomAnim_cb()
2058
def startCustomAnim_cb(self):
2059
on = self.vf.GUI.toolbarCheckbuttons['customAnimation']['Variable'].get()
2062
from Pmv.scenarioInterface.animationGUI import AnimationNotebook
2063
self.root = Tkinter.Toplevel()
2064
self.root.title('Custom Animation')
2065
self.root.protocol("WM_DELETE_WINDOW", self.hide_cb)
2066
vi = self.vf.GUI.VIEWER
2067
self.animNB = AnimationNotebook(self.vf, self.root)
2023
if self.vf.GUI.toolbarCheckbuttons.has_key('scenario'):
2024
self.vf.GUI.toolbarCheckbuttons['scenario']['Variable'].set(add)
2025
self.startScenario_cb()
2028
def startScenario_cb(self):
2029
if hasattr(self.vf, "director"):
2030
on = self.vf.GUI.toolbarCheckbuttons['scenario']['Variable'].get()
2032
self.vf.director.start()
2033
if self.vf.director.scenarios.has_key("DejaVuScenario"):
2034
if not self.vf.GUI.VIEWER.GUI.shown:
2035
self.vf.GUI.showHideDejaVuGUI()
2036
if self.vf.director.gui is not None:
2037
self.vf.director.gui.root.lift()
2075
self.root.withdraw()
2076
self.vf.GUI.toolbarCheckbuttons['customAnimation']['Variable'].set(0)
2078
def show_cb(self, event=None):
2080
self.root.deiconify()
2081
self.vf.GUI.toolbarCheckbuttons['customAnimation']['Variable'].set(1)
2039
if self.vf.director.gui:
2040
self.vf.director.gui.root.withdraw()
2083
2043
def onAddCmdToViewer(self):
2044
from scenario.director import Director
2045
director = self.vf.director = Director()
2048
if DejaVu.enableScenario:
2049
from DejaVu.scenarioInterface import DejaVuScenario
2050
scenario = DejaVuScenario(self.vf.GUI.VIEWER, director)
2051
director.addScenario("DejaVuScenario", scenario)
2054
sceanrioCommandGuiDescr = {'widgetType':'Menu', 'barName':'Toolbar',
2055
'buttonName':'scenario'}