19 locale.setlocale(locale.LC_ALL,
'C')
21 from contextlib
import contextmanager
23 from ..namespace
import Namespace
24 from ..controller
import Project
25 from ..spec
import librarydatabase
26 from ..ui
import LoadProgressObserver
27 from ..ui.mainframe
import RideFrame
28 from ..
import publish
29 from ..
import context, contrib
30 from ..context
import coreplugins
31 from ..preferences
import Preferences, RideSettings
32 from ..application.pluginloader
import PluginLoader
33 from ..application.editorprovider
import EditorProvider
34 from ..application.releasenotes
import ReleaseNotes
35 from ..application.updatenotifier
import UpdateNotifierController, UpdateDialog
36 from ..ui.mainframe
import ToolBar
37 from ..ui.treeplugin
import TreePlugin
38 from ..ui.fileexplorerplugin
import FileExplorerPlugin
39 from ..utils
import RideFSWatcherHandler, run_python_command
40 from ..lib.robot.utils.encodingsniffer
import get_system_encoding
41 from ..publish
import PUBLISHER
42 from ..publish.messages
import RideSettingsChanged
43 from ..preferences.settings
import _Section
45 from ..widgets.button
import ButtonWithHandler
50 BaseException.__init__(self,
'HELP! I have no clue how to theme this.')
55 def __init__(self, path=None, updatecheck=True):
59 wx.App.__init__(self, redirect=
False)
66 wx.HelpProvider.Set(wx.SimpleHelpProvider())
68 librarydatabase.initialize_database()
76 coreplugins.get_core_plugins())
78 perspective = self.
settingssettings.get(
'AUI Perspective',
None)
80 self.
frameframe._mgr.LoadPerspective(perspective,
True)
82 nb_perspective = self.
settingssettings.get(
'AUI NB Perspective',
None)
84 self.
frameframe.notebook.LoadPerspective(nb_perspective)
85 except Exception
as e:
86 print(f
"RIDE: There was a problem loading panels position."
87 f
" Please delete the definition 'AUI NB Perspective' in "
88 f
"{os.path.join(context.SETTINGS_DIRECTORY, 'settings.cfg')}")
89 if not isinstance(e, IndexError):
92 if self.
treeplugintreeplugin.settings[
'_enabled']:
109 self.
frameframe.Show()
110 self.
frameframe._mgr.Update()
115 self.Bind(wx.EVT_ACTIVATE_APP, self.
OnAppActivateOnAppActivate)
116 PUBLISHER.subscribe(self.
SetGlobalColourSetGlobalColour, RideSettingsChanged)
120 foreColor=wx.BLUE, backColor=wx.LIGHT_GREY, theme={}):
121 background = theme[
'background']
122 foreground = theme[
'foreground']
123 secondary_background = theme[
'secondary background']
124 secondary_foreground = theme[
'secondary foreground']
125 background_help = theme[
'background help']
126 foreground_text = theme[
'foreground text']
129 if isinstance(widget, wx.lib.agw.aui.auibar.AuiToolBar)
or isinstance(widget, ToolBar):
130 auiDefaultToolBarArt = wx.lib.agw.aui.AuiDefaultToolBarArt()
131 auiDefaultToolBarArt.SetDefaultColours(wx.GREEN)
132 widget.SetBackgroundColour(background)
133 widget.SetOwnBackgroundColour(background)
134 widget.SetForegroundColour(foreground)
135 widget.SetOwnForegroundColour(foreground)
137 widget.SetBackgroundColour(Colour(200, 222, 40))
138 widget.SetOwnBackgroundColour(Colour(200, 222, 40))
139 widget.SetForegroundColour(Colour(7, 0, 70))
140 widget.SetOwnForegroundColour(Colour(7, 0, 70))
143 elif isinstance(widget, wx.Control):
144 if not isinstance(widget, (wx.Button, wx.BitmapButton, ButtonWithHandler)):
145 widget.SetForegroundColour(foreground)
146 widget.SetBackgroundColour(background)
147 widget.SetOwnBackgroundColour(background)
148 widget.SetOwnForegroundColour(foreground)
150 widget.SetForegroundColour(secondary_foreground)
151 widget.SetBackgroundColour(secondary_background)
152 widget.SetOwnBackgroundColour(secondary_background)
153 widget.SetOwnForegroundColour(secondary_foreground)
154 elif isinstance(widget, (wx.TextCtrl, wx.lib.agw.aui.auibook.TabFrame, wx.lib.agw.aui.auibook.AuiTabCtrl)):
155 widget.SetForegroundColour(foreground_text)
156 widget.SetBackgroundColour(background_help)
157 elif isinstance(widget, (RideFrame, wx.Panel)):
158 widget.SetForegroundColour(foreground)
159 widget.SetBackgroundColour(background)
160 elif isinstance(widget, wx.MenuItem):
161 widget.SetTextColour(foreground)
162 widget.SetBackgroundColour(background)
165 widget.SetBackgroundColour(background)
166 widget.SetOwnBackgroundColour(background)
167 widget.SetForegroundColour(foreground)
168 widget.SetOwnForegroundColour(foreground)
178 for child
in widget.GetChildren():
179 if (
not child.IsTopLevel()):
180 indent += indentLevel
181 self.
_WalkWidgets_WalkWidgets(child, indent, indentLevel, theme)
182 indent -= indentLevel
186 if message.keys[0] !=
"General":
193 _root = app.GetTopWindow()
194 theme = self.
settingssettings.get(
'General',
None)
195 font_size = theme[
'font size']
196 font_face = theme[
'font face']
197 font = _root.GetFont()
198 font.SetFaceName(font_face)
199 font.SetPointSize(font_size)
203 if theme[
'apply to panels']
and self.
fileexplorerpluginfileexplorerplugin.settings[
'_enabled']:
204 self.
fileexplorerpluginfileexplorerplugin.settings[
'background'] = theme[
'background']
205 self.
fileexplorerpluginfileexplorerplugin.settings[
'foreground'] = theme[
'foreground']
206 self.
fileexplorerpluginfileexplorerplugin.settings[
'foreground text'] = theme[
'foreground text']
207 self.
fileexplorerpluginfileexplorerplugin.settings[
'background help'] = theme[
'background help']
212 if theme[
'apply to panels']
and self.
treeplugintreeplugin.settings[
'_enabled']:
213 self.
treeplugintreeplugin.settings[
'background'] = theme[
'background']
214 self.
treeplugintreeplugin.settings[
'foreground'] = theme[
'foreground']
215 self.
treeplugintreeplugin.settings[
'foreground text'] = theme[
'foreground text']
216 self.
treeplugintreeplugin.settings[
'background help'] = theme[
'background help']
217 self.
treeplugintreeplugin.settings[
'font size'] = theme[
'font size']
218 self.
treeplugintreeplugin.settings[
'font face'] = theme[
'font face']
219 if self.
treeplugintreeplugin.settings[
'opened']:
223 general = self.settings.get('General', None)
224 # print(f"DEBUG: Application General {general['background']} Type message {type(message)}")
225 # print(f"DEBUG: Application General message keys {message.keys} old {message.old} new {message.new}")
226 background = general['background']
227 foreground = general['foreground']
228 background_help = general['background help']
229 foreground_text = general['foreground text']
230 font_size = general['font size']
231 font_face = general['font face']
232 font = _root.GetFont()
233 font.SetFaceName(font_face)
234 font.SetPointSize(font_size)
237 def _iterate_all_windows(root):
238 if hasattr(root, 'GetChildren'):
239 children = root.GetChildren()
242 _iterate_all_windows(c)
243 all_windows.append(root)
245 _iterate_all_windows(_root)
247 for w in all_windows:
248 if hasattr(w, 'SetHTMLBackgroundColour'):
249 w.SetHTMLBackgroundColour(wx.Colour(background_help))
250 w.SetForegroundColour(wx.Colour(foreground_text)) # 7, 0, 70))
251 elif hasattr(w, 'SetBackgroundColour'):
252 w.SetBackgroundColour(wx.Colour(background)) # 44, 134, 179))
254 # if hasattr(w, 'SetOwnBackgroundColour'):
255 # w.SetOwnBackgroundColour(wx.Colour(background)) # 44, 134, 179))
257 if hasattr(w, 'SetForegroundColour'):
258 w.SetForegroundColour(wx.Colour(foreground)) # 7, 0, 70))
260 # if hasattr(w, 'SetOwnForegroundColour'):
261 # w.SetOwnForegroundColour(wx.Colour(foreground)) # 7, 0, 70))
263 if hasattr(w, 'SetFont'):
278 os.path.join(self.
settingssettings[
'install root'],
'site-plugins'),
279 contrib.CONTRIB_PATH]
282 from ..editor
import EditorPlugin
283 from ..editor.texteditor
import TextEditorPlugin
285 maybe_editor = pl._plugin
286 if (isinstance(maybe_editor, EditorPlugin)
or
287 isinstance(maybe_editor, TextEditorPlugin))
and \
288 maybe_editor.__getattr__(
"_enabled"):
295 observer = LoadProgressObserver(self.
frameframe)
300 [
'import robot; print(robot.__file__ + \", \" + robot.__version__)'])
301 robot_found = b
"ModuleNotFoundError" not in output
and output
304 rf_file, rf_version = output.strip().split(b
", ")
306 str(rf_version, system_encoding), str(os.path.dirname(rf_file), system_encoding))).publish()
310 publish.get_html_message(
'no_robot'), notify_user=
True
315 if not recent
or not recent.recent_files:
317 return recent.recent_files[0]
320 from ..recentfiles
import RecentFilesPlugin
322 if isinstance(pl._plugin, RecentFilesPlugin):
344 self.
_editor_provider_editor_provider.set_active_editor(object_class, editor_class)
357 loop = wx.EventLoop()
358 wx.EventLoop.SetActive(loop)
363 if loop
and wx.EventLoopBase.IsMain(loop):
364 RideFSWatcherHandler.create_fs_watcher(self.
workspace_pathworkspace_path)
367 if self.
workspace_pathworkspace_path
is not None and RideFSWatcherHandler.is_watcher_created():
368 if event.GetActive():
372 if RideFSWatcherHandler.is_workspace_dirty():
373 self.
frameframe.show_confirm_reload_dlg(event)
374 RideFSWatcherHandler.stop_listening()
376 RideFSWatcherHandler.start_listening(self.
workspace_pathworkspace_path)
def OnAppActivate(self, event)
def _find_robot_installation(self)
def register_editor(self, object_class, editor_class, activate)
def unregister_editor(self, object_class, editor_class)
def get_editors(self, object_class)
def _get_latest_path(self)
def activate_editor(self, object_class, editor_class)
def _ApplyThemeToWidget(self, widget, foreColor=wx.BLUE, backColor=wx.LIGHT_GREY, theme={})
def _get_plugin_dirs(self)
def _publish_system_info(self)
def OnEventLoopEnter(self, loop)
def _WalkWidgets(self, widget, indent=0, indentLevel=4, theme={})
def get_editor(self, object_class)
def __init__(self, path=None, updatecheck=True)
def SetGlobalColour(self, message)
def active_event_loop(self)
def _get_recentfiles_plugin(self)
_editor_provider
DEBUG self.frame.Show()
def register_preference_panel(self, panel_class)
Add the given panel class to the list of known preference panels.
def unregister_preference_panel(self, panel_class)
Remove the given panel class from the known preference panels.
Shows release notes of the current version.
This class represents a general purpose log message.
Provides a tree view for Files and Folders.
Provides a tree view for Test Suites.
def get_system_encoding()
def get_path(name, basedir)
def run_python_command(command, mode='c')