Ticket #9270 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Provide Way to Wipe Saved Variables in Python Scripting Window

Reported by: Peter Parker Owned by: Martyn Gigg
Priority: major Milestone: Release 3.2
Component: GUI Keywords:
Cc: Blocked By:
Blocking: Tester: Arturs Bekasovs

Description

Currently the functionality of the Python Scripting Window is such that each tab in the window remembers the values of variables that have been set, and also which modules have been imported.

There have been a few cases where this has lead users to mistakenly believe that the script contains something which it doesn't, so that when it is run on someone else's PC it reports an error.

In any case, it would be nice to see whether or not a script would run just after being loaded without having to save -> close -> reopen it.

Possible solutions:

  • Have a button in one of the menus that users can click to clear the stored information.
  • Since the current functionality was meant to facilitate "Execute Selection" and doesn't really apply to "Execute All", clear the stored information whenever the entire script is run.

Change History

comment:1 Changed 7 years ago by Peter Parker

Triage note: I have left the milestone field blank.

comment:2 Changed 7 years ago by Martyn Gigg

  • Owner set to Martyn Gigg
  • Status changed from new to assigned
  • Milestone set to Release 3.2

comment:3 Changed 6 years ago by Martyn Gigg

  • Status changed from assigned to inprogress

comment:4 Changed 6 years ago by Martyn Gigg

Clear python variables in script window when executing whole script

Refs #9270

Changeset: 6c861ad2cb6363b778cb716f5ad481f61be2a701

comment:5 Changed 6 years ago by Martyn Gigg

Provide menu option to clear current script variables

Refs #9270

Changeset: 013ee3ecbe57d4b6dede0638b917fd927a478750

comment:6 Changed 6 years ago by Martyn Gigg

  • Status changed from inprogress to verify
  • Resolution set to fixed

Branch: feature/9270_clear_script_dict_exec_all

Tester: To test that the variables are cleared when "Execute all" is triggered, do the following:

  • Open script window and type
    x = 1
    y = 2
    print x
    print y
    
  • Run "Execute All" and the values of x and y should be printed to the output box.
  • Comment out the y=2 line and then run "Execute All". There should now be an error that y has not been defined.

Now try a similar thing using the new option Execute->Clear Variables:

  • in the script above put back in the line y=2 and execute all to redefine y
  • click the "Execute->Clear Variables" menu option
  • highlight just the single line print y and click "Execute->Execute Selection"
  • there should be a similar error about y being undefined.

comment:7 Changed 6 years ago by Arturs Bekasovs

  • Status changed from verify to verifying
  • Tester set to Arturs Bekasovs

comment:8 Changed 6 years ago by Arturs Bekasovs

The changes do what is described: saved info is cleared when running the whole script, not cleared if running only a part of it, and cleared when using the new menu option. I've tried it with both variables (as per testing description) and imports. Works OK with multiple scripts open - variables are cleared in the current tab only. The code is understandable and looks neat.

Last edited 6 years ago by Arturs Bekasovs (previous) (diff)

comment:9 Changed 6 years ago by Arturs Bekasovs

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/9270_clear_script_dict_exec_all'

Full changeset: c94ee7117d605b95e252de8c08d43980115ec64e

comment:10 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10113

Note: See TracTickets for help on using tickets.