/[ascend]/trunk/pygtk/interface/gtkbrowser.py
ViewVC logotype

Diff of /trunk/pygtk/interface/gtkbrowser.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 477 by johnpye, Sun Apr 16 10:18:16 2006 UTC revision 478 by johnpye, Mon Apr 17 08:10:48 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/usr/bin/env python
2    
3  import sys  import sys
4  sys.stderr.write("Loading...\r")  def print_loading_status(status,msg=None):
5  sys.stderr.flush()      sys.stderr.write("\r                                                 \r")
6        if msg!=None:
7            sys.stderr.write(msg+"\n")
8        sys.stderr.write(status+"...")
9        sys.stderr.flush()
10    
11    print_loading_status("Loading PSYCO")
12    
13  try:  try:
14      import psyco      import psyco
# Line 11  try: Line 17  try:
17  except ImportError:  except ImportError:
18      pass      pass
19    
 import pygtk  
 pygtk.require('2.0')  
 import gtk  
 import gtk.glade  
20    
21  import pango  print_loading_status("Loading python standard libraries")
22    
23  import re  import re
24  import preferences # loading/saving of .ini options  import preferences # loading/saving of .ini options
25  import urlparse  import urlparse
26  import optparse  import optparse
27    import platform
28    import sys
29    
30    if platform.system() != "Windows":
31        import dl
32        # This sets the flags for dlopen used by python so that the symbols in the
33        # ascend library are made available to libraries dlopened within ASCEND:
34        sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_NOW)
35        
36    print_loading_status("Loading PyGTK, glade, pango")
37    
38    import pygtk
39    pygtk.require('2.0')
40    import gtk
41    import gtk.glade
42    import pango
43    
44    print_loading_status("Loading ASCEND python modules...")
45    
46  from solverparameters import * # 'solver parameters' window  from solverparameters import * # 'solver parameters' window
47  from help import *             # viewing help files  from help import *             # viewing help files
# Line 32  from diagnose import *            # for dia Line 53  from diagnose import *            # for dia
53  from solverreporter import * # solver status reporting  from solverreporter import * # solver status reporting
54  import config  import config
55    
56  import platform  print_loading_status("Loading LIBASCEND/ascpy")
 if platform.system() != "Windows":  
     import sys, dl  
     # This sets the flags for dlopen used by python so that the symbols in the  
     # ascend library are made available to libraries dlopened within ASCEND:  
     sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_NOW)  
   
57  import ascpy  import ascpy
58    
59    print_loading_status("Starting GUI")
60    
61  # This is my first ever GUI code so please be nice :)  # This is my first ever GUI code so please be nice :)
62  # But I *have* at least read  # But I *have* at least read
63  # http://www.joelonsoftware.com/uibook/chapters/fog0000000057.html  # http://www.joelonsoftware.com/uibook/chapters/fog0000000057.html
# Line 51  import ascpy Line 68  import ascpy
68  # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/300304  # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/300304
69  # for the original source code on which my implementation was based.  # for the original source code on which my implementation was based.
70    
 VERSION = "0.9.6-dev"  
   
71  ESCAPE_KEY = 65307  ESCAPE_KEY = 65307
72    
73  HELP_ROOT = None  HELP_ROOT = None
# Line 71  class Browser: Line 86  class Browser:
86          #--------          #--------
87          # load the file referenced in the command line, if any          # load the file referenced in the command line, if any
88    
89            print_loading_status("Parsing options")
90            
91          parser = optparse.OptionParser(usage="%prog [[-m typename] file]", version="gtkbrowser $rev$" )          parser = optparse.OptionParser(usage="%prog [[-m typename] file]", version="gtkbrowser $rev$" )
92          # add options here if we want          # add options here if we want
93    
# Line 101  class Browser: Line 118  class Browser:
118          #--------          #--------
119          # load up the preferences ini file          # load up the preferences ini file
120    
121            print_loading_status("Loading preferences")
122    
123          self.prefs = preferences.Preferences()          self.prefs = preferences.Preferences()
124    
125          #--------          #--------
126          # initialise ASCEND          # initialise ASCEND
127    
128            print_loading_status("Creating ASCEND 'Library' object")
129    
130          self.assets_dir = options.assets_dir          self.assets_dir = options.assets_dir
131                    
132          _prefpath = self.prefs.getStringPref("Directories","librarypath",None)          _prefpath = self.prefs.getStringPref("Directories","librarypath",None)
# Line 125  class Browser: Line 146  class Browser:
146          #--------          #--------
147          # Prepare the ASCEND icon          # Prepare the ASCEND icon
148    
149            print_loading_status("Setting up windows")
150    
151          if config.ICON_EXTENSION:          if config.ICON_EXTENSION:
152              _icon = gtk.Image()              _icon = gtk.Image()
153              _iconpath = self.assets_dir+'ascend'+config.ICON_EXTENSION              _iconpath = self.assets_dir+'ascend'+config.ICON_EXTENSION
# Line 1000  class Browser: Line 1023  class Browser:
1023          _about = _xml.get_widget("aboutdialog")          _about = _xml.get_widget("aboutdialog")
1024          _about.set_position(gtk.WIN_POS_CENTER_ON_PARENT)          _about.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
1025          _about.set_transient_for(self.window);          _about.set_transient_for(self.window);
1026          _about.set_version(VERSION)          _about.set_version(config.VERSION)
1027          _about.run()          _about.run()
1028          _about.destroy()          _about.destroy()
1029    
# Line 1145  class Browser: Line 1168  class Browser:
1168          self.do_quit()            self.do_quit()  
1169          return False          return False
1170    
1171  def test():  if __name__ == "__main__":
     import ascpy  
1172      b = Browser();      b = Browser();
1173      b.run()      b.run()
   
 if __name__ == "__main__":  
     test()  

Legend:
Removed from v.477  
changed lines
  Added in v.478

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22