--- a/Beremiz.py Thu Mar 09 18:03:57 2017 +0300
+++ b/Beremiz.py Fri Mar 10 17:09:48 2017 +0300
@@ -5,6 +5,7 @@
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
+# Copyright (C) 2016: Andrey Skvortsov <andrej.skvortzov@gmail.com> # See COPYING file for copyrights details.
@@ -22,10 +23,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -35,114 +34,9 @@
beremiz_dir = os.path.dirname(os.path.realpath(__file__))
-if __name__ == '__main__':
- wxversion.select(['2.8', '3.0'])
-from wx.lib.agw.advancedsplash import AdvancedSplash
return os.path.join(beremiz_dir,*args)
- bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap()
- #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000)
- splash = AdvancedSplash(None, bitmap=bmp)
- # even the events generated by splash themself during showing
-if __name__ == '__main__':
- print "\nUsage of Beremiz.py :"
- print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0]
- opts, args = getopt.getopt(sys.argv[1:], "hu:e:", ["help", "updatecheck=", "extend="])
- except getopt.GetoptError:
- # print help information and exit:
- if o in ("-h", "--help"):
- if o in ("-u", "--updatecheck"):
- if o in ("-e", "--extend"):
- if os.path.exists("BEREMIZ_DEBUG"):
- __builtin__.__dict__["BMZ_DBG"] = True
- __builtin__.__dict__["BMZ_DBG"] = False
- if wx.VERSION >= (3, 0, 0):
- app = wx.App(redirect=BMZ_DBG)
- app = wx.PySimpleApp(redirect=BMZ_DBG)
- app.SetAppName('beremiz')
- if wx.VERSION < (3, 0, 0):
- wx.InitAllImageHandlers()
- splash = ShowSplashScreen()
- # load internatialization files
- from util.misc import InstallLocalRessources
- InstallLocalRessources(beremiz_dir)
- if updateinfo_url is not None:
- updateinfo = _("Fetching %s") % updateinfo_url
- # warn for possible updates
- updateinfo = urllib2.urlopen(updateinfo_url,None).read()
- updateinfo = _("update info unavailable.")
- from threading import Thread
- splash.SetText(text=updateinfo)
- updateinfoThread = Thread(target=updateinfoproc)
- updateinfoThread.start()
- updateinfoThread.join(2)
- splash.SetText(text=updateinfo)
- for extfilename in extensions:
- from util.TranslationCatalogs import AddCatalog
- from util.BitmapLibrary import AddBitmapFolder
- extension_folder = os.path.split(os.path.realpath(extfilename))[0]
- sys.path.append(extension_folder)
- AddCatalog(os.path.join(extension_folder, "locale"))
- AddBitmapFolder(os.path.join(extension_folder, "images"))
- execfile(extfilename, locals())
import wx.lib.buttons, wx.lib.statbmp, wx.stc
@@ -1281,14 +1175,3 @@
sys.excepthook(*sys.exc_info())
self.run = run_with_except_hook
threading.Thread.__init__ = init
-if __name__ == '__main__':
- # Install a exception handle for bug reports
- logpath = tempfile.gettempdir()+os.sep+'Beremiz'
- AddExceptHook(logpath ,version.app_version)
- frame = Beremiz(None, projectOpen, buildpath)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/BeremizIDELauncher.py Fri Mar 10 17:09:48 2017 +0300
@@ -0,0 +1,187 @@
+# This file is part of Beremiz, a Integrated Development Environment for +# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. +# Copyright (C) 2016 - 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> +# See COPYING file for copyrights details. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +class BeremizIDELauncher: + self.updateinfo_url = None + self.app_dir = os.path.dirname(os.path.realpath(__file__)) + self.projectOpen = None + self.splashPath = self.Bpath("images", "splash.png") + def Bpath(self, *args): + return os.path.join(self.app_dir,*args) + def ShowSplashScreen(self): + from wx.lib.agw.advancedsplash import AdvancedSplash + bmp = wx.Image(self.splashPath).ConvertToBitmap() + self.splash = AdvancedSplash(None, bitmap=bmp) + # even the events generated by splash themself during showing + if wx.Platform == '__WXMSW__': + self.splash.ProcessEvent(wx.PaintEvent()) + print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] + def SetCmdOptions(self): + self.shortCmdOpts = "hu:e:" + self.longCmdOpts = ["help", "updatecheck=", "extend="] + def ProcessOption(self, o, a): + if o in ("-h", "--help"): + if o in ("-u", "--updatecheck"): + self.updateinfo_url = a + if o in ("-e", "--extend"): + self.extensions.append(a) + def ProcessCommandLineArgs(self): + opts, args = getopt.getopt(sys.argv[1:], self.shortCmdOpts, self.longCmdOpts) + except getopt.GetoptError: + # print help information and exit: + self.ProcessOption(o, a) + self.projectOpen = args[0] + self.projectOpen = args[0] + self.buildpath = args[1] + def CreateApplication(self): + if os.path.exists("BEREMIZ_DEBUG"): + __builtin__.__dict__["BMZ_DBG"] = True + __builtin__.__dict__["BMZ_DBG"] = False + wxversion.select(['2.8', '3.0']) + if wx.VERSION >= (3, 0, 0): + self.app = wx.App(redirect=BMZ_DBG) + self.app = wx.PySimpleApp(redirect=BMZ_DBG) + self.app.SetAppName('beremiz') + if wx.VERSION < (3, 0, 0): + wx.InitAllImageHandlers() + self.ShowSplashScreen() + self.BackgroundInitialization() + def BackgroundInitialization(self): + self.InstallExceptionHandler() + from util.misc import InstallLocalRessources + InstallLocalRessources(self.app_dir) + def LoadExtensions(self): + for extfilename in self.extensions: + from util.TranslationCatalogs import AddCatalog + from util.BitmapLibrary import AddBitmapFolder + extension_folder = os.path.split(os.path.realpath(extfilename))[0] + sys.path.append(extension_folder) + AddCatalog(os.path.join(extension_folder, "locale")) + AddBitmapFolder(os.path.join(extension_folder, "images")) + execfile(extfilename, locals()) + def CheckUpdates(self): + if self.updateinfo_url is not None: + updateinfo = _("Fetching %s") % self.updateinfo_url + updateinfo = urllib2.urlopen(self.updateinfo_url,None).read() + updateinfo = _("update info unavailable.") + from threading import Thread + self.splash.SetText(text=updateinfo) + updateinfoThread = Thread(target=updateinfoproc) + updateinfoThread.start() + updateinfoThread.join(2) + self.splash.SetText(text=updateinfo) + def ImportModules(self): + def InstallExceptionHandler(self): + logpath = tempfile.gettempdir()+os.sep+'Beremiz' + Beremiz.AddExceptHook(logpath,version.app_version) + self.frame = Beremiz.Beremiz(None, self.projectOpen, self.buildpath) + self.ProcessCommandLineArgs() + self.CreateApplication() +if __name__ == '__main__': + beremiz = BeremizIDELauncher()