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

Reimplement pausing calling function to use `with` #206

Closed
jarvisteach opened this Issue Aug 9, 2017 · 5 comments

Comments

Projects
None yet
1 participant
@jarvisteach
Owner

jarvisteach commented Aug 9, 2017

Previously a class was implemented PauseLogger to allow easy pausing of logging, when certain events happen.

This same system could be used to pause event propagation.

In the OptionBox, for example, we have the following code:

if not callFunction and hasattr(box, 'cmd'):
    box.var.trace_vdelete('w', box.cmd_id)

# then do some stuff

if not callFunction and hasattr(box, 'cmd'):
    box.cmd_id = box.var.trace('w', box.cmd)

Similar code is also used with: scales, RBs, Entries and should be elsewhere.

This could be shortened to:

with PausePropagation(callFunction, widget):
    # then do some stuff

And the class could handle the rest...

Should be implemented on:

  • CheckBox - not required, no trace
  • Scale
  • OptionBox
  • Properties - not required, no trace
  • SpinBox - not required, no trace
  • RadioButton
  • ListBox - not required, no trace
  • DatePicker - not required, calls OptionBox directly
  • TextArea - not required, has a trace on modified, which checks the callFunction attribute
  • Entry

@jarvisteach jarvisteach added this to the 0.09 milestone Aug 9, 2017

@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach
Owner

jarvisteach commented Aug 17, 2017

jarvisteach added a commit that referenced this issue Aug 17, 2017

jarvisteach added a commit that referenced this issue Aug 17, 2017

Example of PausePropagation #206
First example of PausingPropagation working

Renamed to PauseCallFunction
@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 17, 2017

Owner

Implementation proven to work, however there are different use cases.

There are 3 relevant variables:

  • a trace_object - the thing we are tracing, often a variable
  • a trace_id - a link to the trace
  • a cmd - the function that gets called by the trace

Some widgets this works fine but others don't have a variable, and instead are traced directly. Need to change slightly...

Owner

jarvisteach commented Aug 17, 2017

Implementation proven to work, however there are different use cases.

There are 3 relevant variables:

  • a trace_object - the thing we are tracing, often a variable
  • a trace_id - a link to the trace
  • a cmd - the function that gets called by the trace

Some widgets this works fine but others don't have a variable, and instead are traced directly. Need to change slightly...

jarvisteach added a commit that referenced this issue Aug 20, 2017

Updated PauseCallFunction #206
PauseCallFunction now has a boolean parameter whether to use the widget's variable or the widget.

This is part of work on #132 - getting tickOptionBoxes sorted
@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 20, 2017

Owner

Class now looks like:

PauseCallFunction(callFunction, widget, useVar=True)

By default (when useVar is True):

  • trace is added/delete on a var attribute of widget.
  • trace_id is stored as an attribute (cmd_id) of widget.
  • and the trace function is stored as an attribute (cmd) of widget.

If useVar is set as False:

  • Then the trace is added/removed to the widget directly - no var
  • The other two stay the same.
Owner

jarvisteach commented Aug 20, 2017

Class now looks like:

PauseCallFunction(callFunction, widget, useVar=True)

By default (when useVar is True):

  • trace is added/delete on a var attribute of widget.
  • trace_id is stored as an attribute (cmd_id) of widget.
  • and the trace function is stored as an attribute (cmd) of widget.

If useVar is set as False:

  • Then the trace is added/removed to the widget directly - no var
  • The other two stay the same.

jarvisteach added a commit that referenced this issue Aug 20, 2017

PCF - OB, RB #206
Added PauseCallFunction to OB & RB
Not necessary on TB

jarvisteach added a commit that referenced this issue Aug 20, 2017

@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 20, 2017

Owner

NB. Entries could use a bunch of PauseCallFunction for all the limits - the deafultValue has to bypass all the rules (lower, upper, length, auto-complete, numeric, secret) - might be able to simplify all of this??

Will raise new change request.

Owner

jarvisteach commented Aug 20, 2017

NB. Entries could use a bunch of PauseCallFunction for all the limits - the deafultValue has to bypass all the rules (lower, upper, length, auto-complete, numeric, secret) - might be able to simplify all of this??

Will raise new change request.

@jarvisteach jarvisteach modified the milestones: 0.08, 0.09 Aug 20, 2017

jarvisteach added a commit that referenced this issue Aug 20, 2017

@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 20, 2017

Owner

All done - although not used in that many places :(

Owner

jarvisteach commented Aug 20, 2017

All done - although not used in that many places :(

jarvisteach added a commit that referenced this issue Aug 20, 2017

jarvisteach added a commit that referenced this issue Aug 25, 2017

Reverted cmd/cmd_id references
Changed back to previous style to keep consistent - #226 #206 #220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment