[Mumps2Py:] [161] reworked code for updating the window, use a dictionary/ hash-table for selecting individual routines, instead of going through the list of routines, and added *. mrt files as a File->Open option. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
- To: discuss@xxxxxxxxxxxxxxxxxx
- Subject: [Mumps2Py:] [161] reworked code for updating the window, use a dictionary/ hash-table for selecting individual routines, instead of going through the list of routines, and added *. mrt files as a File->Open option.
- From: subversion@xxxxxxxxxxxxx
- Date: Sat, 08 Mar 2008 21:31:46 +0100
Revision: 161
Author: pgallot
Date: 2008-03-08 20:31:45 +0000 (Sat, 08 Mar 2008)
Log Message:
-----------
reworked code for updating the window, use a dictionary/hash-table for selecting individual routines, instead of going through the list of routines, and added *.mrt files as a File->Open option.
Modified Paths:
--------------
trunk/mumps2py_ui.pyw
Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw 2008-03-08 20:28:10 UTC (rev 160)
+++ trunk/mumps2py_ui.pyw 2008-03-08 20:31:45 UTC (rev 161)
@@ -118,6 +118,7 @@
self.show_after = True
self.current_file = None
self.current_module = None
+ self.module_dict = {}
self.query = { "from": \
("Enter the approximate line # to parse from:", 7, \
@@ -174,12 +175,20 @@
fileinput.close()
self.busy(False)
+ def title(self):
+ """set the window title based on the current file and routine"""
+ the_title = "Mumps2Py"
+ if self.current_file:
+ the_title = "%s: %s" % (the_title, self.current_file)
+ if self.current_module:
+ the_title = "%s: %s" % (the_title, self.current_module)
+ self.root.title(the_title)
+
def colorize_routine(self):
""" colorize the current module in the 'before' window"""
if not self.current_module:
return
-
textwin = self.before_window
the_module = self.current_module
tag = {LABEL:'label', COMMENT:'comment', TEXTVAL:'comment',
@@ -246,15 +255,12 @@
def select_mod(self, mod_name):
""" make the selected routine the current routine"""
- if self.modules:
- for the_module in self.modules:
- if the_module.mod_name == mod_name:
- self.current_module = the_module
- self.root.title("Mumps2py: %s: %s" % \
- (os.path.basename(self.current_file),
- the_module))
- self.process_current_routine()
- return
+ the_module = self.module_dict.get(mod_name, None)
+ if the_module:
+ self.current_module = the_module
+ self.title()
+ self.process_current_routine()
+ return
def parsegivenmodule(self, popup):
"""select the routine specified by the popup"""
@@ -507,13 +513,15 @@
self.modules = None
self.current_module = None
self.current_file = None
- self.root.title("Mumps2Py")
+ self.title()
+ self.module_dict = {}
def file_open(self):
""" open a file of Mumps code"""
mumps_file = tkFileDialog.askopenfilename(\
parent = self.root,
filetypes = [ ("m2p files","*.m2p"), ("MUMPS files", "*.mps"),
+ ("Mumps Routines as Text", "*.mrt"),
("RSA files","*.rsa"), ("RTN files","*.rtn")],
initialdir = "./testfiles")
#initialfile = "VistA.m2p")
@@ -524,12 +532,15 @@
self.file_close()
self.current_file = mumps_file
- self.root.title("Mumps2Py: %s" % os.path.basename(mumps_file))
+ self.title()
tstart = time.time()
self.modules = mumps2py.parse_for_routines(mumps_file, m2py_dir)
print time.time() - tstart,"seconds to load %d routines" \
% len(self.modules)
+ for routine in self.modules:
+ self.module_dict[routine.mod_name] = routine
+
if len(self.modules) == 1:
self.current_module = self.modules[0]
self.__display_before(self.current_module)
@@ -705,7 +716,7 @@
def make_dialog(self):
"""Set up the User Interface"""
- self.root.title('Mumps2Py')
+ self.title()
self.root.geometry("+0+0")
menu_bar = Frame( self.root, relief = RAISED, borderwidth = 2)
menu_bar.pack(fill = X)