Beremiz.py
changeset 117 32099ee16154
parent 116 ff860001a377
child 118 185d0d371ea4
equal deleted inserted replaced
116:ff860001a377 117:32099ee16154
    22 #License along with this library; if not, write to the Free Software
    22 #License along with this library; if not, write to the Free Software
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24 
    24 
    25 __version__ = "$Revision$"
    25 __version__ = "$Revision$"
    26 
    26 
    27 import wx
    27 import os, sys, getopt, wx
    28 import wx.lib.buttons
    28 
    29 import wx.lib.statbmp
    29 CWD = os.path.split(os.path.realpath(__file__))[0]
    30 
    30 
    31 import types
    31 if __name__ == '__main__':
    32 
    32     def usage():
    33 import time
    33         print "\nUsage of Beremiz.py :"
    34 
    34         print "\n   %s [Projectpath]\n"%sys.argv[0]
    35 import os, re, platform, sys, time, traceback, getopt, commands
    35     
       
    36     try:
       
    37         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
       
    38     except getopt.GetoptError:
       
    39         # print help information and exit:
       
    40         usage()
       
    41         sys.exit(2)
       
    42     
       
    43     for o, a in opts:
       
    44         if o in ("-h", "--help"):
       
    45             usage()
       
    46             sys.exit()
       
    47     
       
    48     if len(args) > 1:
       
    49         usage()
       
    50         sys.exit()
       
    51     elif len(args) == 1:
       
    52         projectOpen = args[0]
       
    53     else:
       
    54         projectOpen = None
       
    55     
       
    56     app = wx.PySimpleApp()
       
    57     wx.InitAllImageHandlers()
       
    58     
       
    59     bmp = wx.Image(os.path.join(CWD,"images","splash.png")).ConvertToBitmap()
       
    60     splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None)
       
    61     wx.Yield()
       
    62 
       
    63 import wx.lib.buttons, wx.lib.statbmp 
       
    64 import types, time, re, platform, time, traceback, commands
    36 
    65 
    37 from plugger import PluginsRoot
    66 from plugger import PluginsRoot
    38 
    67 
    39 SCROLLBAR_UNIT = 10
    68 SCROLLBAR_UNIT = 10
    40 WINDOW_COLOUR = wx.Colour(240,240,240)
    69 WINDOW_COLOUR = wx.Colour(240,240,240)
    53               'helv' : 'Helvetica',
    82               'helv' : 'Helvetica',
    54               'other': 'new century schoolbook',
    83               'other': 'new century schoolbook',
    55               'size' : 18,
    84               'size' : 18,
    56              }
    85              }
    57 
    86 
    58 CWD = os.path.split(os.path.realpath(__file__))[0]
       
    59 
    87 
    60 # Some helpers to tweak GenBitmapTextButtons
    88 # Some helpers to tweak GenBitmapTextButtons
    61 # TODO: declare customized classes instead.
    89 # TODO: declare customized classes instead.
    62 gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
    90 gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID)
    63 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
    91 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,))
   338         
   366         
   339         self.Log = LogPseudoFile(self.LogConsole)
   367         self.Log = LogPseudoFile(self.LogConsole)
   340         
   368         
   341         # Add beremiz's icon in top left corner of the frame
   369         # Add beremiz's icon in top left corner of the frame
   342         if wx.Platform == '__WXMSW__':
   370         if wx.Platform == '__WXMSW__':
   343             icon = wx.Icon(os.path.join(CWD,"brz.ico"),wx.BITMAP_TYPE_ICO)
   371             icon = wx.Icon(os.path.join(CWD,"images","brz.ico"),wx.BITMAP_TYPE_ICO)
   344         else:
   372         else:
   345             icon = wx.Icon(os.path.join(CWD,"brz.png"),wx.BITMAP_TYPE_PNG)
   373             icon = wx.Icon(os.path.join(CWD,"images","brz.png"),wx.BITMAP_TYPE_PNG)
   346         self.SetIcon(icon)
   374         self.SetIcon(icon)
   347         
   375         
   348         self.PluginRoot = PluginsRoot(self)
   376         self.PluginRoot = PluginsRoot(self)
   349         self.DisableEvents = False
   377         self.DisableEvents = False
   350         
   378         
  1261 
  1289 
  1262     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
  1290     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
  1263     sys.excepthook = handle_exception
  1291     sys.excepthook = handle_exception
  1264 
  1292 
  1265 if __name__ == '__main__':
  1293 if __name__ == '__main__':
  1266     def usage():
       
  1267         print "\nUsage of Beremiz.py :"
       
  1268         print "\n   %s [Projectpath]\n"%sys.argv[0]
       
  1269     
       
  1270     try:
       
  1271         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
       
  1272     except getopt.GetoptError:
       
  1273         # print help information and exit:
       
  1274         usage()
       
  1275         sys.exit(2)
       
  1276     
       
  1277     for o, a in opts:
       
  1278         if o in ("-h", "--help"):
       
  1279             usage()
       
  1280             sys.exit()
       
  1281     
       
  1282     if len(args) > 1:
       
  1283         usage()
       
  1284         sys.exit()
       
  1285     elif len(args) == 1:
       
  1286         projectOpen = args[0]
       
  1287     else:
       
  1288         projectOpen = None
       
  1289     
       
  1290     app = wx.PySimpleApp()
       
  1291     wx.InitAllImageHandlers()
       
  1292     
       
  1293     # Install a exception handle for bug reports
  1294     # Install a exception handle for bug reports
  1294     AddExceptHook(os.getcwd(),__version__)
  1295     AddExceptHook(os.getcwd(),__version__)
  1295     
  1296     
  1296     frame = Beremiz(None, projectOpen)
  1297     frame = Beremiz(None, projectOpen)
  1297     
       
  1298     frame.Show()
  1298     frame.Show()
       
  1299     splash.Hide()
       
  1300 
  1299     app.MainLoop()
  1301     app.MainLoop()