Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade rose edit to Python 3 #2808

Open
wants to merge 186 commits into
base: master
Choose a base branch
from

Conversation

astroDimitrios
Copy link
Contributor

@astroDimitrios astroDimitrios commented Sep 10, 2024

As discussed this change updates rose config-edit (or just rose edit) to Python 3 / Gtk3.

All seems to function par some cosmetic bugs which are outlined in the Issues on my fork.

J-J-Abram and others added 24 commits September 27, 2024 10:28
* 33 vertical padding added to widgets for a 'soft' distinction

* Vertical padding removed, line disctinctions added using css styling
This means that they get included in the wheel file when the package is
built, and they actually get found at runtime.

Fixes #37
…eck (#48)

* Removing instances of 'SuiteRunner' for flake8 undefined name F821 check

* Removed launch_scheduler function as no longer required
@astroDimitrios astroDimitrios marked this pull request as ready for review October 29, 2024 15:58
@oliver-sanders
Copy link
Member

Wow!

Screenshot from 2024-10-31 11-06-48

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made a first pass over the code, looking good.

There's 186 commits here! We could do with squashing these down a bit to make it a bit more manageable.

@@ -697,7 +697,8 @@ def get_dialog_parent():
"""Find the currently active window, if any, and reparent dialog."""
ok_windows = []
max_size = -1
for window in Gtk.window_list_toplevels():
# not sure if this window change is correct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

if new_size[i] < max_size[i]:
# Factor in existence of a scrollbar in the other dimension.
# For horizontal dimension, add width of vertical scroll bar + 2
# For vertical dimension, add height of horizontal scroll bar + 2
new_size[i] += scrollbar_cls().size_request()[i] + 2
# What is the value in rose 2019? - here it is zero on load.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

locator = metomi.rose.resource.ResourceLocator(paths=sys.path)
iname = "rose-gtk-scheduler"
# iname = "rose-gtk-scheduler"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Comment on lines +181 to +187
# None of this works anymore and needs to be set by CSS
# which does not look simple
# style = Gtk.RcStyle()
# style.xthickness = 0
# style.ythickness = 0
# setattr(style, "inner-border", [0, 0, 0, 0])
# self._console_launcher.modify_style(style)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

@@ -228,8 +228,7 @@ def _update_buffered(self, *args, **kwargs):
__call__ = update

def start(self):
file_name = __file__.rsplit(".", 1)[0] + ".py"
self.process = Popen([file_name] + list(self.args), stdin=PIPE)
self.process = Popen(" ".join(["rose launch-splash-screen"] + list(self.args)), shell=True, stdin=PIPE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to avoid using shell=True here (security implications).

I think this should work:

self.process = Popen(["rose", "launch-splash-screen"] + self.args), stdin=PIPE)

Comment on lines 1 to 4
entry {
background-color: coral;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

Comment on lines -193 to -194
if module_prefix is None:
as_name = module_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module_prefix support appears to have been removed.

This might be ok, I have no idea if this is used. If we are removing this, we should probably remove the kwarg with it though.

Comment on lines 379 to 395
val_array = []
# Prevent str without "" breaking the underlying Python syntax
for e in self.entries:
v = e.get_text()
if v in ("False", "True"): # Boolean
val_array.append(v)
elif (len(v) == 0) or (v[:1].isdigit()): # Empty or numeric
val_array.append(v)
elif not v.startswith('"'): # Str - add in leading and trailing "
val_array.append('"' + v + '"')
e.set_text('"' + v + '"')
e.set_position(len(v)+1)
elif (not v.endswith('"')) or (len(v) == 1): # Str - add in trailing "
val_array.append(v + '"')
e.set_text(v + '"')
e.set_position(len(v))
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliver-sanders, please go through this.

@@ -465,7 +465,7 @@ def popup_panel_menu(self, base_ns, event):
(
action_name,
Gtk.STOCK_ADD,
metomi.rose.config_editor.TREE_PANEL_ADD_SECTION.format(
metomi.rose.config_editor.TREE_PANEL_ADD_SECTION.format( # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines can be wrapped, e.g:

foo.bar.baz
foo
    .bar
    .baz
(
    foo
).bar.baz

@@ -723,7 +723,7 @@
META_PROP_WIDGET_SUB_NS = "widget[rose-config-edit:sub-ns]"

# Miscellaneous
COPYRIGHT = """Copyright (C) 2012-2024 British Crown (Met Office) & Contributors.
COPYRIGHT = """Crown Copyright (C) 2012-2024 (Met Office) & Contributors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
COPYRIGHT = """Crown Copyright (C) 2012-2024 (Met Office) & Contributors.
COPYRIGHT = """Copyright (C) British Crown (Met Office) & Contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants