Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/contributed/sumopy/agilepy/lib_wx/modulegui.py
169689 views
1
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
2
# Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.
3
# SUMOPy module
4
# Copyright (C) 2012-2021 University of Bologna - DICAM
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file modulegui.py
16
# @author Joerg Schweizer
17
# @date 2012
18
19
import os
20
import wx
21
22
import agilepy.lib_base.classman as cm
23
from agilepy import AGILEDIR
24
25
26
def get_agileicon(name):
27
return wx.Bitmap(os.path.join(AGILEDIR, 'lib_wx', 'images', name))
28
29
30
class ModuleGui:
31
"""Manages all GUIs to interact between the widgets from mainframe
32
and the specific functions of the module.
33
"""
34
35
def __init__(self, ident):
36
37
self._init_common(ident,
38
module=cm.BaseObjman('empty'),
39
priority=9999999,
40
icondirpath=os.path.join(os.path.dirname(__file__), 'images')
41
)
42
# self._init_constants()
43
44
# def _init_constants(self):
45
# self._is_needs_refresh = False
46
47
def get_initpriority(self):
48
return self._initpriority
49
50
def _init_common(self, ident, module=None, priority=9999999, icondirpath=''):
51
"""
52
ident: any string to identify this gui
53
module: the module which interacts with this gui
54
priority: specifies priority with wich this gui initialized in mainframe
55
Initialization of widgets in init_widgets
56
"""
57
58
self._ident = ident
59
self._set_module(module)
60
self._initpriority = priority
61
self._icondirpath = icondirpath
62
self._is_needs_refresh = False
63
64
def get_icon(self, name):
65
return wx.Bitmap(os.path.join(self._icondirpath, name))
66
67
def get_agileicon(self, name):
68
return wx.Bitmap(os.path.join(AGILEDIR, 'lib_wx', 'images', name))
69
70
def _set_module(self, module):
71
self._module = module
72
73
def get_module(self):
74
return self._module
75
76
def get_ident(self):
77
return self._ident
78
79
def get_logger(self):
80
return self._mainframe.get_logger()
81
82
# def set_logger(self, logger):
83
# self._logger = logger
84
85
def init_widgets(self, mainframe):
86
"""
87
Set mainframe and initialize widgets to various places.
88
"""
89
self._mainframe = mainframe
90
self.make_menu()
91
self.make_toolbar()
92
93
def refresh_widgets(self):
94
"""
95
Check through mainframe what the state of the application is
96
and reset widgets. For exampe enable/disable widgets
97
dependent on the availability of data.
98
"""
99
pass
100
101
def make_toolbar(self):
102
pass
103
104
def make_menu(self):
105
pass
106
107
def on_browse_obj(self, event=None):
108
self._mainframe.browse_obj(self.get_module())
109
110