[issue27388] IDLE configdialog: reduce multiple references to Var names

2020-06-07 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions: +Python 3.10 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2017-06-21 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
pull_requests:  -2354

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2017-06-21 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I moved PR 2307 to a new issue, #30728 Modernize configdialog. My comment that 
internal Var names "can lowercased (PEP8) and otherwised changed" was 
anticipating such an issue.  The point for this issue was to contrast Var names 
with the cross-version config names that we must not change.

I don't expect anyone else to fully understand this without a couple of hours 
of code study.

Once #22115 was merged, I could have gone ahead.  Since I did not, I should now 
wait for at least part of PR 2307 and #30728 since the patch for this would 
break parts of the existing new patch.  I could work on a new test though.

--
dependencies: +Add new methods to trace Tkinter variables

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2017-06-20 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Created a pull request for this - "The varnames, like method names, are 
internal to configdialog and can lowercased (PEP8) and otherwised changed."

--
nosy: +csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2017-06-20 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +2354

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2017-06-19 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
components: +IDLE

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27388] IDLE configdialog: reduce multiple references to Var names

2016-06-25 Thread Terry J. Reedy

New submission from Terry J. Reedy:

ConfigDialog uses nearl 20 tkinter Vars, and I expect to add more.  The name of 
each appears in at least 6 places.

In one of 'create tab frame' methods:
1. create the Var
2. use the Var with at least 1 tk widget
In AttachVarCallbacks method:
3, 4. attach trace with callback with derived name
  self.varname.trace_add('write', self.VarChanged_varname)
In remove_var_callbacks method (with delete call already factored out):
5. include Var in for loop tuple, to remove callback with
  "var.trace_remove('write', var.trace_info()[0][1])"
In callback definition:
6. def VarChanged_varname

The above uses the new trace method names that will be introduced in #22115, 
which I expect will be applied first.  (I might also replace
'VarChanged_' with 'var_changed_' or something shorter, but this is not 
relevant here.)

I propose to consolidate 1, 3, & 4 by replacing AttachVarCallbacks with

def add_traced_var(varname):
"""Create var; bind to varname, append to list, and trace with callback.

varname must match use in caller and callback def.
"""
var = tk.StringVar(self.root)
setattr(self, varname, var)
self.vars.append(var)
cbsuffix = 'font' if varname.startswith('font') else varname
var.trace_add('write', self.getattr('VarChanged_' + cbsuffix))

The cbsuffix local takes care of the complication that the 3 'fontWxyz' vars 
need the same callback.  In any Var are not StringVars, add vartype parameter.

Each tab frame creation method would call add_traced_var within a varname loop. 
 The current varname tuple for 5. would be replaced with self.vars, which 
should then be cleared.  This will leave 3 name occurrences that must match 
instead of 6.

---
I believe 1-6 is complete.  Varnames are translated to config item names within 
the callbacks, so do not have to match.  For instance,

def VarChanged_spaceNum(self, *params):
value = self.spaceNum.get()
self.AddChangedItem('main', 'Indent', 'num-spaces', value)

translated 'spaceNum' to 'num-spaces'.  On the other hand, I an not sure why 
the difference.  For back compatibility, config names are fixed.  The varnames, 
like method names, are internal to configdialog and can lowercased (PEP8) and 
otherwised changed.
---

For testing, I will embed the add and delete methods in a dummy class with a 
couple of dummy callbacks.  Then add, introspect, delete, and introspect again.

--
assignee: terry.reedy
messages: 269271
nosy: terry.reedy
priority: normal
severity: normal
stage: test needed
status: open
title: IDLE configdialog: reduce multiple references to Var names
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com