support icon indicating copy to clipboard operation
support copied to clipboard

[Feature] Set default main program

Open laurensvalk opened this issue 1 year ago • 2 comments

My team is putting one file per mission model and one issue is that they often hit play from their mission model file instead of the main file that loads all of them. Any possibility of adding a "default" Play program file?

Originally posted by @davidyang in https://github.com/pybricks/support/discussions/1901

laurensvalk avatar Oct 28 '24 09:10 laurensvalk

Thanks @davidyang for suggesting this.

I've been wondering about this too some times. Use cases:

  • Working on a multi-mission program with one main entry point in another file (OPs case)
  • Working on a library file and having a main program to test it

This is also conventional in full editors, where you might do this with a launch config.

Alternatives considered Work with __name__ == "__main__" to make this work, but this can get a bit messy with many files.

Implementation idea 1

Mark file as main on file tab with an extra icon there.

Implementation idea 2

Enter main file in somewhere under settings.

Implementation idea 3 (my favorite) Making this completely persistent in local storage as above could be confusing when you open the editor later to work on something else.

So here's a variant that lets you mark the main file by right clicking on a tab and choosing "mark as starting point".

In fact, since we don't currently have any context dialog for tabs, maybe just double clicking to toggle this will work.

If having an "entry icon" is tricky in this layout framework, we could prefix the displayed name with (main).

image

laurensvalk avatar Oct 28 '24 09:10 laurensvalk

Hey @laurensvalk - thanks for getting back to me so quickly. For how we use pybricks, the kids don't really switch into and out of projects so having it as a setting that is persisted in localStorage makes sense to me.

If it's just in the tab (or right clicking a tab) I would be concerned about discoverability. This does seem like something that would be in settings if I'm looking for it. (Usually when I'm looking at a code project I'm looking for a run script somewhere in the home directory as a setting).

davidyang avatar Oct 28 '24 16:10 davidyang

I posted a similar request at #2175

bcfletcher avatar May 01 '25 00:05 bcfletcher