Debian Codegraph @

modules/pmg_tk/skins/demo/__init__.py

raw symbols SCIP
1
2 # Demonstration of how you would create a new skin
3 # from scratch
4
5 import os
6
7 from tkinter import *
8 from tkinter.filedialog import *
9
10 import Pmw
11
12 from pmg_tk.skins import PMGSkin
13
14 class Demo(PMGSkin):
15
16 def fileOpenDialog(self):
17 if not hasattr(self,'fileOpenPath'):
18 self.fileOpenPath = os.getcwd()
19 ofile_list = askopenfilename(initialdir = self.fileOpenPath,
20 filetypes=self.app.getLoadableFileTypes(),
21 multiple=1)
22 for ofile in ofile_list:
23 if len(ofile):
24 self.fileOpenPath = os.path.dirname(ofile)
25 self.cmd.load(ofile,quiet=0)
26
27 def quit(self):
28 self.cmd.log_close()
29 self.cmd.quit()
30
31 def createMenuBar(self):
32 self.menuBar = Pmw.MenuBar(self.root, # balloon=self.balloon,
33 hull_relief=RAISED, hull_borderwidth=1)
34 self.menuBar.pack(fill=X)
35
36 self.menuBar.addmenu('File', 'File Menu',tearoff=TRUE)
37
38 self.menuBar.addmenuitem('File', 'command', 'Open file',
39 label='Open...',
40 command=self.fileOpenDialog)
41
42 self.menuBar.addcascademenu('File', 'Skin', 'Skin',
43 label='Skin',tearoff=TRUE)
44
45 self.app.addSkinMenuItems(self.menuBar,'Skin')
46
47 self.menuBar.addmenuitem('File', 'command', 'Quit PyMOL',
48 label='Quit',
49 command=self.quit)
50
51 def destroyMenuBar(self):
52 self.menuBar.pack_forget()
53 self.menuBar.destroy()
54 del self.menuBar
55
56 def createInterface(self):
57
58 # create the menu bar
59 self.createMenuBar()
60
61 def setup(self):
62
63 # call the parent method
64 PMGSkin.setup(self)
65
66 # name the application
67 self.root.title("Demonstration PyMOL Skin")
68
69 # create the user interface
70 self.createInterface()
71
72 # pack the root window
73 self.app._hull.pack(side=TOP, anchor=CENTER, expand=NO, fill=NONE,
74 padx=0, pady=0, ipadx=0, ipady=0)
75
76 def takedown(self):
77 self.destroyMenuBar()
78 PMGSkin.takedown(self)
79
80 def __init__(self,app):
81
82 PMGSkin.__init__(self,app)
83 self.app = app
84 self.pymol = app.pymol
85 self.cmd = app.pymol.cmd
86
87 def __init__(app):
88 return Demo(app)
89