Skip to content

Commit

Permalink
Improve upgrade and reset colors (robotframework#2892)
Browse files Browse the repository at this point in the history
* Initial Run upgrade process

* Fix update notifier utests

* Fix reset colors, remove color settings in Windows. WIP need to use General color

* Correct colors for Grid, Text and Runner Preferences. WIP

* Correct colors. Broken close RIDE dialog on language change. WIP

* Fix broken restart, use secondary colors for buttons. WIP missing buttons Grid, Edit and Run

* Final fix in preferences colors

* Disable theme in TestRunner options panels

* Update unit tests

* Update docs
  • Loading branch information
HelioGuilherme66 authored Sep 29, 2024
1 parent 10308bb commit 86c11f4
Show file tree
Hide file tree
Showing 27 changed files with 398 additions and 279 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.2, but RIDE is known to work w

`pip install -U robotframework-ride`

(3.8 <= python <= 3.12) Install current development version (**2.1b1**) with:
(3.8 <= python <= 3.12) Install current development version (**2.1dev82**) with:

`pip install -U https://github.com/robotframework/RIDE/archive/master.zip`

Expand Down
23 changes: 12 additions & 11 deletions src/robotide/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ class Message:
self.SetTopWindow(self.frame)
self.frame.aui_mgr.Update()
if self._updatecheck:
wx.CallAfter(UpdateNotifierController(self.settings).notify_update_if_needed, UpdateDialog)
wx.CallAfter(UpdateNotifierController(self.settings, self.frame.notebook).notify_update_if_needed,
UpdateDialog)
self.Bind(wx.EVT_ACTIVATE_APP, self.on_app_activate)
PUBLISHER.subscribe(self.SetGlobalColour, RideSettingsChanged)
PUBLISHER.subscribe(self.update_excludes, RideSettingsChanged)
RideSettingsChanged(keys=('Excludes', 'init'), old=None, new=None).publish()
PUBLISHER.subscribe(self.change_locale, RideSettingsChanged)
RideSettingsChanged(keys=('General', 'ui interface'), old=None, new=None).publish()
RideSettingsChanged(keys=('General', 'ui language'), old=None, new=None).publish()
wx.CallLater(600, ReleaseNotes(self).bring_to_front)
return True

Expand All @@ -174,9 +175,9 @@ def _ApplyThemeToWidget(widget, fore_color=wx.BLUE, back_color=wx.LIGHT_GREY, th
aui_default_tool_bar_art = AuiDefaultToolBarArt()
aui_default_tool_bar_art.SetDefaultColours(wx.GREEN)
widget.SetBackgroundColour(background)
widget.SetOwnBackgroundColour(background)
# widget.SetOwnBackgroundColour(background)
widget.SetForegroundColour(foreground)
widget.SetOwnForegroundColour(foreground)
# widget.SetOwnForegroundColour(foreground)
"""
widget.SetBackgroundColour(Colour(200, 222, 40))
widget.SetOwnBackgroundColour(Colour(200, 222, 40))
Expand All @@ -188,13 +189,13 @@ def _ApplyThemeToWidget(widget, fore_color=wx.BLUE, back_color=wx.LIGHT_GREY, th
if not isinstance(widget, (wx.Button, wx.BitmapButton, ButtonWithHandler)):
widget.SetForegroundColour(foreground)
widget.SetBackgroundColour(background)
widget.SetOwnBackgroundColour(background)
widget.SetOwnForegroundColour(foreground)
# widget.SetOwnBackgroundColour(background)
# widget.SetOwnForegroundColour(foreground)
else:
widget.SetForegroundColour(secondary_foreground)
widget.SetBackgroundColour(secondary_background)
widget.SetOwnBackgroundColour(secondary_background)
widget.SetOwnForegroundColour(secondary_foreground)
# widget.SetOwnBackgroundColour(secondary_background)
# widget.SetOwnForegroundColour(secondary_foreground)
elif isinstance(widget, (wx.TextCtrl, TabFrame, AuiTabCtrl)):
widget.SetForegroundColour(foreground_text) # or fore_color
widget.SetBackgroundColour(background_help) # or back_color
Expand All @@ -207,9 +208,9 @@ def _ApplyThemeToWidget(widget, fore_color=wx.BLUE, back_color=wx.LIGHT_GREY, th
# print(f"DEBUG: Application ApplyTheme wx.MenuItem {type(widget)}")
else:
widget.SetBackgroundColour(background)
widget.SetOwnBackgroundColour(background)
# widget.SetOwnBackgroundColour(background)
widget.SetForegroundColour(foreground)
widget.SetOwnForegroundColour(foreground)
# widget.SetOwnForegroundColour(foreground)

def _WalkWidgets(self, widget, indent=0, indent_level=4, theme=None):
# print(' ' * indent + widget.__class__.__name__)
Expand Down Expand Up @@ -333,8 +334,8 @@ def change_locale(self, message):
from multiprocessing import shared_memory
from .restartutil import restart_dialog
new_locale = self._locale.GetName()
# print(f"DEBUG: application.py RIDE change_locale from {initial_locale} to {new_locale}")
if initial_locale != new_locale:
# print(f"DEBUG: application.py RIDE change_locale CHANGED from {initial_locale} to {new_locale}")
if restart_dialog(): # DEBUG: See the in implementation why we don't restart
# print("DEBUG: application.py RIDE change_locale Restart accepted.")
# Shared memory to store language definition
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def set_content(self, html_win, content):
<pre class="literal-block">python -m robotide.postinstall -install</pre>
<p>or</p>
<pre class="literal-block">ride_postinstall.py -install</pre>
<p>RIDE {VERSION} was released on 22/September/2024.</p>
<p>RIDE {VERSION} was released on 29/September/2024.</p>
<!-- <br/>
<h3>May The Fourth Be With You!</h3>
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/application/restartutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def restart_dialog():
f"{SPC}{_('Language change will only be correct after re-opening RIDE.')}"
f"{SPC}\n{SPC}{_('Do you want to CLOSE RIDE now?')}\n{SPC}"
# f"{_('After restarting RIDE you will see another dialog informing to close this RIDE instance.')}"
f"{SPC}\n", wx.GetActiveWindow(), no_default=True):
f"{SPC}\n", wx.GetTopLevelWindows()[0], no_default=True):
return False
else:
# do_restart()
Expand Down
61 changes: 41 additions & 20 deletions src/robotide/application/updatenotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import time
import urllib.request as urllib2
import xmlrpc.client as xmlrpclib
from dataclasses import dataclass

import psutil
import wx
Expand All @@ -45,8 +46,9 @@ class UpdateNotifierController(object):
VERSION = version.VERSION
SECONDS_IN_WEEK = 60*60*24*7

def __init__(self, settings):
def __init__(self, settings, notebook):
self._settings = settings
self._notebook = notebook

def notify_update_if_needed(self, update_notification_callback, ignore_check_condition=False, show_no_update=False):
if ignore_check_condition:
Expand All @@ -55,9 +57,10 @@ def notify_update_if_needed(self, update_notification_callback, ignore_check_con
checking_version = self._should_check()
dev_version = parse_version(self.VERSION).is_devrelease
if checking_version and self._is_new_version_available():
update_notification_callback(self._newest_version, self._download_url, self._settings)
update_notification_callback(self._newest_version, self._download_url, self._settings, self._notebook)
if checking_version and dev_version:
upgrade_from_dev_dialog(version_installed=self.VERSION, show_no_update=show_no_update)
upgrade_from_dev_dialog(version_installed=self.VERSION, notebook=self._notebook,
show_no_update=show_no_update)

def _should_check(self):
if self._settings.get(_CHECK_FOR_UPDATES_SETTING, None) is None:
Expand Down Expand Up @@ -98,7 +101,7 @@ def _get_response(params, method):
return xml


def upgrade_from_dev_dialog(version_installed, show_no_update=False):
def upgrade_from_dev_dialog(version_installed, notebook, show_no_update=False):
dev_version = urllib2.urlopen('https://raw.githubusercontent.com/robotframework/'
'RIDE/master/src/robotide/version.py', timeout=1).read().decode('utf-8')
matches = re.findall(r"VERSION\s*=\s*'([\w.]*)'", dev_version)
Expand All @@ -114,7 +117,7 @@ def upgrade_from_dev_dialog(version_installed, show_no_update=False):
f"{SPC}\n", wx.GetActiveWindow(), no_default=True):
return False
else:
do_upgrade(command)
do_upgrade(command, notebook)
return True
else:
if show_no_update:
Expand Down Expand Up @@ -147,9 +150,29 @@ def _add_content_to_clipboard(content):
wx.TheClipboard.Close()


def do_upgrade(command):
@dataclass
class Command:
def __init__(self, name, command, documentation):
self.name = name
self.command = command
self.documentation = documentation


def do_upgrade(command, notebook):
_add_content_to_clipboard(command)
# print("DEBUG: Here will be the installation step.")
# print("DEBUG: Here will be the installation step.") # DEBUG 'pip list'
from ..run import ui
config = Command('Upgrade RIDE', command, 'Uses pip to upgrade RIDE.')
result = ui.Runner(config, notebook).run()

# result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{result}){SPC}",
# wx.GetActiveWindow())

print(f"DEBUG: do_upgrade result={result}")
result = 0
time.sleep(10)
# wx.Exit()
"""
my_pid = psutil.Process()
my_pip = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = None
Expand All @@ -165,16 +188,8 @@ def do_upgrade(command):
result = my_pip.returncode
if result == 0:
break
""" DEBUG: need to get outs line by line
except subprocess.SubprocessError:
my_pip.kill()
outs, errs = my_pip.communicate()
result = False
# DEBUG: Add output to a notebook tab
print(f"{outs}\n")
print(f"{errs}\n")
"""
time.sleep(1)
"""
if result != 0:
_askyesno(_("Failed to Upgrade"), f"{SPC}{_('An error occurred when installing new version')}",
wx.GetActiveWindow())
Expand All @@ -185,8 +200,13 @@ def do_upgrade(command):
""" Not working well:
wx.CallLater(10000, psutil.Process.kill, my_pid.pid)
"""
_askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}",
wx.GetActiveWindow())
result = _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{result}){SPC}",
wx.GetActiveWindow())
if result:
time.sleep(10)
wx.App.Get().OnExit()
# _askyesno(_("Completed Upgrade"), f"\n{SPC}{_('You should close this RIDE (Process ID = ')}{my_pid.pid}){SPC}",
# wx.GetActiveWindow())


class LocalHtmlWindow(HtmlWindow):
Expand All @@ -201,8 +221,9 @@ def OnLinkClicked(self, link): # Overrides wx method

class UpdateDialog(RIDEDialog):

def __init__(self, uversion, url, settings, modal=True):
def __init__(self, uversion, url, settings, notebook, modal=True):
self._settings = settings
self._notebook = notebook
self._command = sys.executable + f" -m pip install -U robotframework-ride=={uversion}"
_add_content_to_clipboard(self._command)
RIDEDialog.__init__(self, title=_("Update available"), size=(600, 400),
Expand Down Expand Up @@ -262,4 +283,4 @@ def on_checkbox_change(self, event):
def on_upgrade_now(self, event):
__ = event
_add_content_to_clipboard(self._command)
do_upgrade(self._command)
do_upgrade(self._command, self._notebook)
15 changes: 11 additions & 4 deletions src/robotide/contrib/testrunner/runprofiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,12 @@ def _get_log_options_panel(self, parent):
self.on_collapsible_pane_changed,
collapsible_pane)
pane = collapsible_pane.GetPane()
pane.SetThemeEnabled(False)
pane.SetBackgroundColour(self._mysettings.color_background)
pane.SetForegroundColour(self._mysettings.color_foreground)
label = Label(pane, label=_("Output directory: "))
label.SetBackgroundColour(self._mysettings.color_background)
label.SetForegroundColour(self._mysettings.color_foreground)
self._output_directory_text_ctrl = \
self._create_text_ctrl(pane, self.output_directory,
"removed due unicode_error (delete this)",
Expand Down Expand Up @@ -499,6 +502,7 @@ def _get_arguments_panel(self, parent):
self.on_collapsible_pane_changed,
collapsible_pane)
pane = collapsible_pane.GetPane()
pane.SetThemeEnabled(False)
pane.SetBackgroundColour(self._mysettings.color_background)
pane.SetForegroundColour(self._mysettings.color_foreground)
self._args_text_ctrl = \
Expand Down Expand Up @@ -567,6 +571,7 @@ def _get_tags_panel(self, parent):
self.on_collapsible_pane_changed,
collapsible_pane)
pane = collapsible_pane.GetPane()
pane.SetThemeEnabled(False)
pane.SetBackgroundColour(self._mysettings.color_background)
pane.SetForegroundColour(self._mysettings.color_foreground)
include_cb = self._create_checkbox(pane, self.apply_include_tags,
Expand Down Expand Up @@ -620,20 +625,22 @@ def on_exclude_tags_changed(self, evt):
_ = evt
self.set_setting("exclude_tags", self._exclude_tags_text_ctrl.GetValue())

@staticmethod
def _create_checkbox(parent, value, title, handler):
def _create_checkbox(self, parent, value, title, handler):
checkbox = wx.CheckBox(parent, wx.ID_ANY, title)
checkbox.SetValue(value)
checkbox.SetBackgroundColour(self._mysettings.color_background)
checkbox.SetForegroundColour(self._mysettings.color_foreground)
parent.Bind(wx.EVT_CHECKBOX, handler, checkbox)
return checkbox

@staticmethod
def _create_text_ctrl(parent, value, value_for_error,
def _create_text_ctrl(self, parent, value, value_for_error,
text_change_handler, enable=True):
try:
text_ctrl = wx.TextCtrl(parent, wx.ID_ANY, value=value)
except UnicodeError:
text_ctrl = wx.TextCtrl(parent, wx.ID_ANY, value=value_for_error)
text_ctrl.SetBackgroundColour(self._mysettings.color_background)
text_ctrl.SetForegroundColour(self._mysettings.color_foreground)
text_ctrl.Bind(wx.EVT_TEXT, text_change_handler)
text_ctrl.Enable(enable)
return text_ctrl
Expand Down
12 changes: 6 additions & 6 deletions src/robotide/editor/contentassist.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ def __init__(self, parent, suggestion_source, size=wx.DefaultSize):
super().__init__(suggestion_source, parent=parent,
size=size, style=wx.WANTS_CHARS | wx.TE_NOHIDESEL)
self.SetBackgroundColour(Colour(self.color_background_help))
self.SetOwnBackgroundColour(Colour(self.color_background_help))
# self.SetOwnBackgroundColour(Colour(self.color_background_help))
self.SetForegroundColour(Colour(self.color_foreground_text))
self.SetOwnForegroundColour(Colour(self.color_foreground_text))
# self.SetOwnForegroundColour(Colour(self.color_foreground_text))


class ContentAssistTextEditor(_ContentAssistTextCtrlBase):
Expand All @@ -373,9 +373,9 @@ def __init__(self, parent, suggestion_source, pos, size=wx.DefaultSize):
style=wx.WANTS_CHARS | wx.BORDER_NONE | wx.WS_EX_TRANSIENT | wx.TE_PROCESS_ENTER |
wx.TE_NOHIDESEL)
self.SetBackgroundColour(Colour(self.color_background_help))
self.SetOwnBackgroundColour(Colour(self.color_background_help))
# self.SetOwnBackgroundColour(Colour(self.color_background_help))
self.SetForegroundColour(Colour(self.color_foreground_text))
self.SetOwnForegroundColour(Colour(self.color_foreground_text))
# self.SetOwnForegroundColour(Colour(self.color_foreground_text))


class ContentAssistFileButton(FileBrowseButton):
Expand All @@ -389,9 +389,9 @@ def __init__(self, parent, suggestion_source, label, controller, size=wx.Default
self._browsed = False

self.SetBackgroundColour(Colour(context.POPUP_BACKGROUND))
self.SetOwnBackgroundColour(Colour(context.POPUP_BACKGROUND))
# self.SetOwnBackgroundColour(Colour(context.POPUP_BACKGROUND))
self.SetForegroundColour(Colour(context.POPUP_FOREGROUND))
self.SetOwnForegroundColour(Colour(context.POPUP_FOREGROUND))
# self.SetOwnForegroundColour(Colour(context.POPUP_FOREGROUND))

def Bind(self, *args):
self.textControl.Bind(*args)
Expand Down
4 changes: 2 additions & 2 deletions src/robotide/editor/editordialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def _create_buttons(self, **kwargs):
for item in self.GetChildren():
if isinstance(item, (wx.Button, wx.BitmapButton, ButtonWithHandler)):
item.SetBackgroundColour(Colour(self.color_secondary_background))
item.SetOwnBackgroundColour(Colour(self.color_secondary_background))
# item.SetOwnBackgroundColour(Colour(self.color_secondary_background))
item.SetForegroundColour(Colour(self.color_secondary_foreground))
item.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
# item.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
self._sizer.Add(buttons, 0, wx.ALIGN_CENTER | wx.ALL, 5)
self._sizer.Fit(self)

Expand Down
8 changes: 4 additions & 4 deletions src/robotide/editor/fieldeditors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def _create_editor(self, value, label, settings):
def _get_text_ctrl(self):
editor = wx.TextCtrl(self, size=(600, -1))
editor.SetBackgroundColour(Colour(self.color_secondary_background))
editor.SetOwnBackgroundColour(Colour(self.color_secondary_background))
# editor.SetOwnBackgroundColour(Colour(self.color_secondary_background))
editor.SetForegroundColour(Colour(self.color_secondary_foreground))
editor.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
# editor.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
return editor

def set_validator(self, validator):
Expand Down Expand Up @@ -199,9 +199,9 @@ def _create_column_selector(self, cols):
tool_tip.GetWindow().SetForegroundColour(Colour(self.color_foreground_text))
# DEBUG attributes = self.GetClassDefaultAttributes()
combo.SetBackgroundColour(Colour(self.color_secondary_background))
combo.SetOwnBackgroundColour(Colour(self.color_secondary_background))
# combo.SetOwnBackgroundColour(Colour(self.color_secondary_background))
combo.SetForegroundColour(Colour(self.color_secondary_foreground))
combo.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
# combo.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
self.Bind(wx.EVT_COMBOBOX, self.on_columns, source=combo)
sizer.Add(combo)
# DEBUG children = self.GetChildren()
Expand Down
4 changes: 2 additions & 2 deletions src/robotide/editor/listeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def __init__(self, parent, columns, color_foreground='black',
self.color_foreground = color_foreground
self.color_background = color_background
self.SetBackgroundColour(Colour(color_background))
self.SetOwnBackgroundColour(Colour(color_background))
# self.SetOwnBackgroundColour(Colour(color_background))
self.SetForegroundColour(Colour(color_foreground))
self.SetOwnForegroundColour(Colour(color_foreground))
# self.SetOwnForegroundColour(Colour(color_foreground))
# self.EnableAlternateRowColours(True)
self._parent = parent
self._doc_language = None
Expand Down
Loading

0 comments on commit 86c11f4

Please sign in to comment.