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

wxGUI: add recent_files param to print a list of wxGUI component recent files #2503

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tmszi
Copy link
Member

@tmszi tmszi commented Jul 30, 2022

With this new functionality #2469 I added a wxGUI command line recent_files param to print a list of wxGUI component recent files.

Main wxGUI component:

GRASS nc_basic_spm_grass7/PERMANENT:~ > g.gui recent_files=main
/tmp/w2.gxw
/tmp/w1.gxw

Simple Python Editor wxGUI component:

GRASS nc_basic_spm_grass7/PERMANENT:~ > g.gui recent_files=pyedit
/tmp/test.py

@tmszi tmszi added enhancement New feature or request GUI wxGUI related labels Jul 30, 2022
@tmszi tmszi added this to the 8.4.0 milestone Jul 30, 2022
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

I don't know what the CLI for recent files is for. However, if you have a use case, then I think it is okay to include it.

It seems to me that feature like this needs more a Python API rather than CLI because that's the context where it will be needed (e.g., implementing alternative startup sequence or loading 3D view settings in the Animation Tool).

To avoid duplication and adding text output code into a class which manages GUI (wx.Menu), this PR itself requires extending the API, e.g., adding a method to RecentFilesMenu or creating a separate class or set of functions which take care of recent file separately from menus.

If needed, I would be happy to discuss this further.

general/g.gui/main.c Outdated Show resolved Hide resolved
gui/wxpython/gui_core/menu.py Outdated Show resolved Hide resolved
@tmszi tmszi changed the title wxGUI: add -l flag to print a list of recent workspace files wxGUI: add recent_files param to print a list of wxGUI component recent files Aug 2, 2022
@tmszi tmszi requested a review from wenzeslaus August 2, 2022 08:05
@tmszi
Copy link
Member Author

tmszi commented Aug 2, 2022

I don't know what the CLI for recent files is for. However, if you have a use case, then I think it is okay to include it.

My simple use case is if I want copy my recent files (script which create archive from recent files) which are stored on different paths / disk partitions / disks etc. (recent files are currently implemented for Main wxGUI component - workspace files, Python Simple Editor wxGUI component - Python scripts files) from one computer to another. Maybe in the future could be create module which pack and unpack wxGUI components recent files same as raster / vector maps for simple exchanging / backup recent files between computers.

gui/wxpython/wxgui.py Outdated Show resolved Hide resolved
@wenzeslaus
Copy link
Member

Now I'm thinking the CLI of wxgui.py is a better fit for this task. Adding this to the g.gui interface is a much bigger commitment. g.gui CLI is our official API, wxgui.py CLI is not.

This seems to be similar to grass.benchmark. We have both API and CLI there, but it is documented as experimental and not stable. Perfectly fine for one-time use and for developers closely tracking the main branch, but we don't want to guarantee it will behave the same in the next version.

Additionally, the definition of recent is somewhat problematic. If you want to get "recent file just like in GUI" that's fine (I'm thinking some GUI helper tool), but if you want "recent files I worked with", it is not reliable enough. For example, we can decide to decrease or increase the number of recent files.

general/g.gui/main.c Outdated Show resolved Hide resolved
```
GRASS nc_basic_spm_grass7/PERMANENT:~ > g.gui -l
/tmp/w2.gxw
/tmp/w1.gxw
```
…nt files

Main wxGUI component:

```
GRASS nc_basic_spm_grass7/PERMANENT:~ > g.gui recent_files=main
/tmp/w2.gxw
/tmp/w1.gxw
```

Simple Python Editor wxGUI component:

```
GRASS nc_basic_spm_grass7/PERMANENT:~ > g.gui recent_files=pyedit
/tmp/test.py
```
@tmszi tmszi force-pushed the wxgui_get_list_of_recent_workspace_files branch from 8c1484d to d98ade6 Compare September 15, 2022 16:30
@wenzeslaus wenzeslaus modified the milestones: 8.3.0, 8.4.0 Feb 10, 2023
@wenzeslaus
Copy link
Member

While I'm in favor of scripting our GUI in general (like m.printws), I still think this is too many changes and too spread out for what it brings.

I'm sorry to coming back to this only now. If you still needed, I suggest to limit the interface to each file, so that the commands look something like this:

python gui/wxpython/lmgr/workspace.py get recent
python gui/wxpython/gui_core/pyedit.py --get-recent-files

A completely different alternative is to make these available in the Python console in GUI with some function similarly to how AddLayer is done.

Migrating from one computer to another or other syncs seems like a good use case, something to discuss further.

@petrasovaa petrasovaa modified the milestones: 8.4.0, Future Apr 27, 2024
@echoix
Copy link
Member

echoix commented Oct 17, 2024

Solved conflicts

@github-actions github-actions bot added the Python Related code is in Python label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants