Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/contributed/sumopy/sumopy_gui.py
169679 views
1
#!/usr/bin/env python2
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.
4
# SUMOPy module
5
# Copyright (C) 2012-2021 University of Bologna - DICAM
6
# This program and the accompanying materials are made available under the
7
# terms of the Eclipse Public License 2.0 which is available at
8
# https://www.eclipse.org/legal/epl-2.0/
9
# This Source Code may also be made available under the following Secondary
10
# Licenses when the conditions for such availability set forth in the Eclipse
11
# Public License 2.0 are satisfied: GNU General Public License, version 2
12
# or later which is available at
13
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15
16
# @file sumopy_gui.py
17
# @author Joerg Schweizer
18
# @date 2012
19
20
"""SUMOPy is intended to expand the user-base of the traffic micro-simulator SUMO (Simulation of Urban MObility) by providing a user-friendly, yet flexible simulation suite.
21
22
A further scope of SUMOPy is to manage the huge amount of data necessary to run complex multi-modal simulations.
23
This includes different demand generation models as well as a large range of modes, such as public transport,
24
bicycle and Personal Rapid Transit (PRT). SUMOPy consists of a GUI interface, network editor as well as a simple to use scripting language which facilitates the use of SUMO.
25
"""
26
__appname__ = "SUMOPy"
27
__version__ = "2.4"
28
__licence__ = "SUMOPy is licensed under the EPL-2.0 OR GPL-2.0-or-later."
29
__copyright__ = "(c) 2012-2021 University of Bologna - DICAM"
30
__author__ = "Joerg Schweizer"
31
32
import sys
33
import os
34
try:
35
import wxversion
36
wxversion.select("2.8")
37
except:
38
try:
39
import wxversion
40
wxversion.select("3")
41
except:
42
#sys.exit('ERROR: wxPython versions 2.8 or 3.x not available.')
43
print 'No wxversion module available, try import default wx version'
44
print 'If wx import shall fail, please install wxPython versions 2.8 or 3.x together with the wxversion module.'
45
sys.exit(0)
46
47
48
49
from agilepy.lib_wx.mainframe import AgileMainframe
50
import wx
51
__usage__ = """USAGE:
52
from command line:
53
Open with empty scenario:
54
python sumopy_gui.py
55
56
Open new scenario and import all SUMO xml files with scenariobasename:
57
python sumopy_gui.py <scenariobasename> <scenariodir>
58
59
Open binary scenario file:
60
python sumopy_gui.py <path/scenarioname.obj>
61
62
SUMOPy is part of the SUMO distribution and is located in
63
SUMO_HOME/tools/contributed/sumopy
64
65
use for debugging:
66
python sumopy_gui.py --debug > debug.txt 2>&1
67
"""
68
print ' _ '
69
print ' ____________|______|||___________________ '
70
print ' / _ | / \ _ _ _ _ _ \ '
71
print ' / | / | \ v / _ \ _|_|_|_|_ / '
72
print ' \ __o-o__/ | \ \ | / / / \ \ ____/ '
73
print ' \ / \|o|/ \ \|/ / / o/\ \ | _|__/_ '
74
print ' \ / \|o|/ \ | / / /| \ \ | | | '
75
print ' | | | | | / \|0|/ \ v / \_/ \_/ \_| | '
76
print ' | | | | |/_____________\_/____________/ ____/ '
77
print ' |/ '
78
print ''
79
print __appname__+' version '+__version__+'\n'+__copyright__
80
81
print '\n using wx python version', wx.__version__
82
83
###############################################################################
84
# IMPORTS
85
86
87
# Load modules
88
moduledirs = ['coremodules', 'plugins']
89
APPDIR = ''
90
if __name__ == '__main__':
91
# search SUMOPy in local directory (where this file is located)
92
try:
93
APPDIR = os.path.dirname(os.path.abspath(__file__))
94
except:
95
APPDIR = os.path.dirname(os.path.abspath(sys.argv[0]))
96
97
# if 'SUMO_HOME' in os.environ:
98
# APPDIR = os.path.join(os.environ['SUMO_HOME'],'tools','contributed','sumopy')
99
#
100
# else:
101
# try:
102
# APPDIR = os.path.dirname(os.path.abspath(__file__))
103
# except:
104
# APPDIR = os.path.dirname(os.path.abspath(sys.argv[0]))
105
106
# print 'APPDIR',APPDIR
107
#libpaths = [APPDIR,]
108
sys.path.append(APPDIR)
109
#libpaths = [APPDIR, os.path.join(APPDIR,"agilepy"), os.path.join(APPDIR,"agilepy","lib_base"), os.path.join(APPDIR,"agilepy","lib_wx")]
110
for moduledir in moduledirs:
111
# #print ' libpath=',libpath
112
lp = os.path.abspath(os.path.join(APPDIR, moduledir))
113
if not lp in sys.path:
114
# print ' append',lp
115
sys.path.append(lp)
116
117
#
118
119
120
###############################################################################
121
122
class MyApp(wx.App):
123
124
def __init__(self, redirect=False, filename=None):
125
wx.App.__init__(self, redirect, filename)
126
# print 'init',__appname__, sys.argv
127
self.mainframe = AgileMainframe(
128
title=__appname__,
129
moduledirs=moduledirs, # subdirectories containing modules
130
appdir=APPDIR,
131
args=sys.argv,
132
is_maximize=True, is_centerscreen=True,
133
size_toolbaricons=(32, 32),
134
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE
135
)
136
icon = wx.Icon(os.path.join(APPDIR, 'images', 'icon_sumopy.png'), wx.BITMAP_TYPE_PNG, 16, 16)
137
self.mainframe.SetIcon(icon)
138
self.mainframe.Show()
139
140
self.mainframe.refresh_moduleguis()
141
142
self.mainframe.menubar.append_menu('About')
143
self.mainframe.menubar.append_item('About/Info...', self.on_about,
144
info='About SUMOPy',
145
bitmap=wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_MENU)
146
)
147
148
def on_about(self, event):
149
info = wx.AboutDialogInfo()
150
151
#info.SetIcon(wx.Icon('hunter.png', wx.BITMAP_TYPE_PNG))
152
info.SetName(__appname__)
153
info.SetVersion(__version__)
154
info.SetDescription(__doc__)
155
info.SetCopyright(__copyright__)
156
info.SetWebSite('http://sumo.dlr.de/wiki/Contributed/SUMOPy')
157
# info.SetWebSite('http://distart041.ing.unibo.it/~mait/projects/sim/users_guide/users_guide.html')
158
info.SetLicence(__licence__)
159
info.AddDeveloper(__author__)
160
info.AddDeveloper(
161
"Cristian Poliziani\nwith the friendly support of the SUMO team at the German Aerospace Center (DLR)")
162
info.AddDocWriter(__author__ + ', Cristian Poliziani')
163
info.AddArtist(__author__)
164
#info.AddTranslator('Jan Bodnar')
165
166
wx.AboutBox(info)
167
event.Skip()
168
169
170
if __name__ == '__main__':
171
myapp = MyApp(0)
172
myapp.MainLoop()
173
174