Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
582c67c3
Commit
582c67c3
authored
11 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
widgets_list bugfix - wrong variable name; comments in properties
parent
ec0e742b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tkprop/properties.py
+24
-19
24 additions, 19 deletions
tkprop/properties.py
tkprop/widgets_list.py
+1
-1
1 addition, 1 deletion
tkprop/widgets_list.py
with
25 additions
and
20 deletions
tkprop/properties.py
+
24
−
19
View file @
582c67c3
...
...
@@ -19,9 +19,8 @@
# myPropObj = PropObj()
#
#
# #
a
ccess the property value as normal:
# #
A
ccess the property value as
a
normal
attribute
:
# myPropObj.myProperty = True
#
# myPropObj.myProperty
#
# # >>> True
...
...
@@ -33,26 +32,28 @@
# # >>> <tkprops.tkprop.Boolean at 0x1045e2710>
#
#
# # access the underlying Tkinter control variable:
# # access the underlying Tkinter control variable
# # (there are caveats for List properties):
# myPropObj.getTkVar('myProperty')
#
# # >>> <tkinter.BooleanVar instance at 0x1047ef518>
#
#
# # Receive notification of property value changes
# def myPropertyChanged(instance,
propN
ame,
newV
alue):
# print('New value for {}: {}'.format(
prop
name,
newV
alue)
# def myPropertyChanged(instance,
n
ame,
v
alue):
# print('New value for {}: {}'.format(name,
v
alue)
)
#
# PropObj.myProperty.addListener(
# myPropObj, 'myListener', myPropertyChanged)
#
# myPropObj.myProperty = False
#
# # >>> New value for myProperty: False
#
#
# # Remove a previously added listener
# PropObj.myProperty.removeListener(myPropObj, 'myListener')
#
#
#
#
#
# Lots of the code in this file is probably very confusing. First
# of all, you will need to understand python descriptors.
...
...
@@ -150,8 +151,10 @@ class PropertyBase(object):
PropertyBase object as a property, a _TkVarProxy instance
is created and attached as an attribute of the parent.
Subclasses should call this superclass constructor,
passing it the tkvartype and default value, and an optional
custom validation function.
passing it the tkVarType and default value, and an optional
custom validation function specified by the application
code. Built in validation should be specified by overriding
the validate method.
"""
self
.
label
=
None
self
.
tkVarType
=
tkVarType
...
...
@@ -643,15 +646,16 @@ class FilePath(String):
class
_ListWrapper
(
object
):
"""
Used by the List property type, defined below. An object which
acts like a list, but for which items are embedded in an
appropriate Tkinter variable, a minimum/maximum list length may
be enforced, and value/type constraints enforced on the values
added to it. Not all list operations are supported.
acts like a list, but for which items are embedded in a
_TkVarProxy object, minimum/maximum list length may be enforced,
and value/type constraints enforced on the values added to it.
Not all list operations are supported.
A _TkVarProxy object is created for each item that is added to
the list. When a list value is changed, instead of a new
variable being created, the value of the existing variable
is changed. References to
every Tk variable in the list
may
is changed. References to
the list of _TkVarProxy objects
may
be accessed via the _tkVars attribute of the _ListWrapper
object.
"""
...
...
@@ -700,10 +704,11 @@ class _ListWrapper(object):
def
tkVar
(
self
):
"""
There is a bit of trickery going on here. The HasProperties
class thinks that all properties are represented by a _TkVarProxy
object, which encapsulates a Tkinter control variable, which in
turn controls the property value. The Tkinter control variable
is accessible via the
'
tkVar
'
attribute of the _TkVarProxy class.
class thinks that all properties are represented by a single
_TkVarProxy object, which encapsulates a Tkinter control
variable, which in turn controls the property value. The
Tkinter control variable is accessible via the
'
tkVar
'
attribute of the _TkVarProxy class.
However, this is not possible for List properties, because a single
List property has multiple values, and is thus represented by a
...
...
This diff is collapsed.
Click to expand it.
tkprop/widgets_list.py
+
1
−
1
View file @
582c67c3
...
...
@@ -32,7 +32,7 @@ def _pasteDataDialog(parent, listProp, propObj):
- propObj: The tkprop.HasProperties object which owns listProp.
"""
listObj
=
propObj
.
getTkVar
(
list
Obj
.
label
)
listObj
=
propObj
.
getTkVar
(
list
Prop
.
label
)
window
=
tk
.
Toplevel
()
frame
=
ttk
.
Frame
(
window
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment