[issue20636] Better repr for tkinter widgets

2014-04-13 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-04-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 66770f126c71 by Serhiy Storchaka in branch 'default':
Issue #20636: Improved the repr of Tkinter widgets.
http://hg.python.org/cpython/rev/66770f126c71

--
nosy: +python-dev

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-03-20 Thread Terry J. Reedy

Terry J. Reedy added the comment:

After looking more at testing entire (Idle) dialogs and windows for sanity, I 
like the idea even more. A person can check that everything that is present 
looks ok, but code is at least as good as using a checklist to verify that what 
is present is exactly what should be present. For this, widgets should have 
meaningful and predictable names. Once widgets are given names, they should be 
used in the representation. The proposed

>>> top.winfo_children()
[>> top.winfo_children()
[]


As for Ezio's question: The new method is defined in class tkinter.Misc and 
only applies to instances of subclasses thereof -- BaseWidget, Widget, etc, in 
tkinter.__init__ and ttk.Widget. I suppose other code might subclass something, 
but as far as I know, Idle classes 'have a' widget rather than 'being a' 
widget. But if Misc or a subclass could be sensibly subclassed in C code, you 
could, to be safe, change "top.__class__.__module__" to "getattr(top.__class__, 
'__module__', 'module'). I believe 'self._w' is safe as an object without ._w 
is not a tk widget.

--

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-03-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Are there any questions or objections?

--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-02-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> > 
> 
> Not knowing the internal of tkinter, this seems somewhat confusing.
> Is that an "anonymous name/id"?

If the name parameter is not specified, repr(id(self)) is used. Here is a 
button with id() == 3066782348, its parent has id() == 3070343372 and its 
grandparent is root. str() for this button returns full name 
".3070343372.3066782348".

> > 
> 
> This already looks more useful.  How is that determined?  Why the "first"
> object is missing (i.e. .panel seems to be an attribute of a missing
> object)?

Tk widgets are organized in hierarchical structure and names look similar to 
file system names. "." is the root, ".frame" is a frame in the root, 
".frame.b1" is a button in frame ".frame".

> Regarding the patch, are you sure that .__class__.__module__ is always
> available?  I seem to remember that it might be missing in some cases, e.g.
> modules written in C (but I might be confusing it with something else like
> __file__).

Yes, for example __module__ is absent in _tkinter.TkappType. But I think that 
every Python implemented class has __module__.

--

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-02-23 Thread Ezio Melotti

Ezio Melotti added the comment:

> 

Not knowing the internal of tkinter, this seems somewhat confusing.
Is that an "anonymous name/id"?

> 

This already looks more useful.  How is that determined?  Why the "first" 
object is missing (i.e. .panel seems to be an attribute of a missing object)?


Regarding the patch, are you sure that .__class__.__module__ is always 
available?  I seem to remember that it might be missing in some cases, e.g. 
modules written in C (but I might be confusing it with something else like 
__file__).

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-02-21 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I like this. It would make naming widgets more useful. I checked one Idle 
dialog and nothing is named. I suspect this is typical.

The proposed change would break a doctest that follows the fix in the doctest 
manual.
---
>>> C()   # the default repr() for instances embeds an address
<__main__.C instance at 0x00AC18F0>

The ELLIPSIS directive gives a nice approach for the last example:
>>>

>>> C() #doctest: +ELLIPSIS
<__main__.C instance at 0x...>
---
I think the recommendation should better be

<__main__.C instance ...>

except that 'instance' is now 'object' -- and *that* change must have broken 
much more that this one would.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue20636] Better repr for tkinter widgets

2014-02-15 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Here is a patch which adds more helpful repr for Tkinter widgets. Was



Becomes:



or (if you assigned names to widgets)



This is very helpful for debugging.

--
components: Tkinter
files: tkinter_misc_repr.patch
keywords: patch
messages: 211269
nosy: gpolo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Better repr for tkinter widgets
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file34089/tkinter_misc_repr.patch

___
Python tracker 

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