Package Pmv :: Module aboutCommands
[hide private]
[frames] | no frames]

Source Code for Module Pmv.aboutCommands

  1  # This modules implements Help-->About for PMV 
  2  # 
  3  # $Author: sargis $ 
  4  # $Header: /opt/cvs/python/packages/share1.5/Pmv/aboutCommands.py,v 1.3 2007/07/03 16:20:50 sargis Exp $ 
  5  # $Date: 2007/07/03 16:20:50 $ 
  6  # $Id: aboutCommands.py,v 1.3 2007/07/03 16:20:50 sargis Exp $ 
  7   
  8  from Pmv.mvCommand import MVCommand 
  9  from ViewerFramework.VFCommand import CommandGUI 
 10  import Tkinter, os, sys, Pmw 
 11  from mglutil.util.packageFilePath import findFilePath, getResourceFolderWithVersion 
 12   
 13  import fnmatch 
 14  import random 
 15  from PIL import Image, ImageTk 
 16   
 17   
18 -class About(MVCommand):
19 """Extends MVCommand, implements Help-->About for PMV""" 20 21
22 - def __init__(self):
23 """Constructor for class About""" 24 MVCommand.__init__(self) 25 self.master = None
26 27
28 - def getImage(self, image_dir):
29 files = os.listdir(image_dir) 30 files = fnmatch.filter(files,'*.jpg') + fnmatch.filter(files,'*.png') 31 32 rand = random.randint(0,len(files)-1) 33 image_file = os.path.join(os.path.join(image_dir ,files[rand])) 34 35 self.image = Image.open(image_file) 36 self.image1 = ImageTk.PhotoImage(self.image)
37 38
39 - def nextImage(self, event=None):
40 self.getImage(self.vf.help_about.image_dir) 41 self.vf.help_about.imageTk.configure(image=self.image1)
42 43
44 - def guiCallback(self):
45 if self.master == None: 46 self.master = Tkinter.Toplevel() 47 self.master.protocol('WM_DELETE_WINDOW',self.destroy) 48 49 self.vf.help_about.gui(master=self.master) 50 self.vf.help_about.imageTk.bind('<1>', self.nextImage) 51 52 53 notebook = Pmw.NoteBook(self.master) 54 notebook.pack(expand='yes', fill='both') 55 56 page = notebook.add('Authors') 57 #notebook.tab('Authors').focus_set() 58 # Authors 59 from PIL import Image, ImageTk 60 image = Image.open(self.vf.help_about.icon) 61 self.icon_image = ImageTk.PhotoImage(master=page, image=image) 62 self.image2 = Tkinter.Label(page, image=self.icon_image) 63 self.image2.pack(side='left') 64 65 Tkinter.Label(page, text=self.vf.help_about.authors, fg='#662626', 66 justify='left', anchor='w', 67 ).pack(side='left') 68 69 # 3rd party 70 if len(self.vf.help_about.third_party): 71 page = notebook.add('Third party software components') 72 73 Tkinter.Label(page, text=self.vf.help_about.third_party, fg='#0A3A75', 74 justify='left', anchor='w', 75 ).pack(side='left') 76 77 78 # app info group 79 if len(self.vf.help_about.path_data): 80 page = notebook.add('Path information') 81 Tkinter.Label(page, text=self.vf.help_about.path_data, 82 fg='#3A9E23', justify='left', anchor='w', 83 ).pack(side='left') 84 85 Tkinter.Label(self.master,text = ' ').pack(side='left') 86 l = Tkinter.Label(self.master, fg='Blue', cursor='hand1', 87 text='http://mgltools.scripps.edu') 88 l.pack(side='left') 89 l.bind(sequence="<Button-1>", func=self.openurl) 90 Tkinter.Label(self.master,text = ' ').pack(side='left') 91 92 registration = getResourceFolderWithVersion() + os.sep + '.registration' 93 if not os.path.exists(registration): 94 reg = Tkinter.Button(self.master,text=' Register ', 95 command=self.register) 96 reg.pack(side = 'left') 97 b = Tkinter.Button(self.master,text=' Close ', 98 command=self.destroy) 99 b.pack(side = 'left') 100 notebook.setnaturalsize() 101 else: 102 self.master.deiconify() 103 self.master.lift()
104
105 - def destroy(self):
106 self.master.destroy() 107 self.master = None
108
109 - def openurl(self, evt=None):
110 import webbrowser 111 webbrowser.open('http://mgltools.scripps.edu')
112
113 - def register(self):
114 self.master.withdraw() 115 from mglutil.splashregister.register import Register_User 116 Register_User(self.vf.help_about.version)
117 118 AboutGUI = CommandGUI() 119 AboutGUI.addMenuCommand('menuRoot', 'Help', 'About',separatorAbove = 1) 120 121 commandList = [{'name':'about','cmd':About(),'gui':AboutGUI}]
122 -def initModule(viewer):
123 for _dict in commandList: 124 viewer.addCommand(_dict['cmd'],_dict['name'],_dict['gui'])
125