Kenneth McDonald | 23 Mar 2004 02:04
Picon
Favicon

More thoughts on Tkinter documentation

Here are two more ideas for how to proceed with Tkinter documentation.

1) Is it possible to set up some sort of "structured wiki", where
	a) Some people can set up documentation structure,
	and others can add to it.

	b) Anyone can go in and write documentation in a section,
	and the "owner" of the section can then integrate (or discard)
	what has been contributed.

For me, this would work well. If I needed to know something,
go look at the online document. If my answer is there, great.
If my answer isn't there, I have to go and figure it out myself--
and having done that, it isn't much more time to go back and
type in what I've found.

2) I'm still a big fan of inline documentation. However, I don't
really like docstrings because they don't provide enough
structure or analytical power, especially for a fairly complex
interface like Tkinter. I think it would be rather cool to define
a more structured form of inline documentation, eg. a __doct__
special field (combination of doc and dict) field, where, given a 
function

def f(foo, bar):
	....

The doct object for the function could be something like:

__doct__ = dict(
(Continue reading)

Cameron Laird | 23 Mar 2004 02:48

Re: More thoughts on Tkinter documentation

> From tkinter-discuss-bounces <at> python.org Mon Mar 22 20:16:13 2004
> 		.
> 		.
> 		.
> Here are two more ideas for how to proceed with Tkinter documentation.

> 1) Is it possible to set up some sort of "structured wiki", where
> 	a) Some people can set up documentation structure,
> 	and others can add to it.

> 	b) Anyone can go in and write documentation in a section,
> 	and the "owner" of the section can then integrate (or discard)
> 	what has been contributed.

> For me, this would work well. If I needed to know something,
> go look at the online document. If my answer is there, great.
> If my answer isn't there, I have to go and figure it out myself--
> and having done that, it isn't much more time to go back and
> type in what I've found.
> 		.
> 		.
> 		.
> Any thoughts on the above? I can't do much about (1) myself,
> but if I receive any positive feedback about (2), I'll put
> together a couple of docts for a bit of Tkinter stuff, and post
> them to see if people think its worth continuing.
> 		.
> 		.
> 		.
I think you can.  Just put stuff in the Wiki right now, tonight,
(Continue reading)

Jason Harper | 23 Mar 2004 10:05
Picon
Favicon

Python->Tcl lists

Does Tkinter provide any way of properly converting a Python list to a
Tcl list?

Specifically, I am trying to insert text into a Text widget with
multiple tags, which is supposedly allowed by passing a list of tag
names.  However, passing a Python list doesn't work - as far as I can
tell, the list just gets converted with str() and then split on
whitespace!  The results (as verified with .tag_names()) is a mishmash
of word fragments, including commas, quote marks, and brackets that
could have only come from the stringification of the list: no such
characters were actually part of the tags in the list.
	Jason Harper
Jeff Epler | 23 Mar 2004 14:14
Favicon

Re: Python->Tcl lists

Python tuples, including nested tuples, are converted to Tcl lists.
Lists are just converted to strings.

>>> import Tkinter
>>> tk = Tkinter.Tk().tk
>>> tk.call("list", [1, "a b", 3, "{"])   # A list is just converted
"\\[1,\\ 'a\\ b',\\ 3,\\ '\\{'\\]"        # as by str()
>>> tk.call("list", (1, "a b", 3, "{"))   # A tuple is converted
'{1 {a b} 3 \\{}'                         # to a tcl list
>>> tk.call("list", (1, (2, 3, "a b"), "c d")) # Nested example
'{1 {2 3 {a b}} {c d}}'
>>> tk.call("list", 1, "a b", 3, "{")     # Positional args are quoted
'1 {a b} 3 \\{'                           # as needed

So where you're trying to do
    text.insert(0.0, "blah", [other, args, here])
you should try
    text.insert(0.0, "blah", tuple([other, args, here]))
or 
    text.insert(0.0, "blah", *[other, args, here])
or
    text.insert(0.0, "blah", other, args, here)

I just did the following and got "what I expected":
>>> import Tkinter
>>> t = Tkinter.Text()
>>> t.tag_configure("red", background="red")
>>> t.tag_configure("blue", background="blue")
>>> t.pack()
>>> t.insert(0.0, "blah", "red", " ", "", "bleep", "blue")
(Continue reading)

Kenneth McDonald | 23 Mar 2004 20:38
Picon
Favicon

(no subject)

 From previous message:
---------------------------------------------
So where you're trying to do
     text.insert(0.0, "blah", [other, args, here])
you should try
     text.insert(0.0, "blah", tuple([other, args, here]))
or
     text.insert(0.0, "blah", *[other, args, here])
or
     text.insert(0.0, "blah", other, args, here)

-----------------------------------------------

And to be a little pickier, that should probably
be something like:

text.insert("1.0", ...)

as Text indexes of the n.n form are (a) still strings,
and (b) count lines from 1, not from 0. "0.0" will
probably work, but if it does, it will refer to the same
location as "1.0"

However, I'm surprised from the above that

     text.insert(0.0, "blah", tuple([other, args, here]))

would work. Why wouldn't that have the same
problem as

(Continue reading)

Cameron Laird | 23 Mar 2004 20:46

Gmane picked us up.

The TkinterDiscuss Wiki page has a pertinent hyperlink.
Kenneth McDonald | 23 Mar 2004 20:54
Picon
Favicon

Tools for summarizing a module?

Before I start any documentation effort on Tkinter, I'd like to get
a good idea of what's in there right now. Is there a good tool
that will go through a module, and print out, in summary form,
its functions, classes, methods, etc., with docstrings if present?
If not, I'll write my own, but why waste effort if this has already
been done?

Thanks,
Ken
Stewart Midwinter | 23 Mar 2004 22:16

Re: Tools for summarizing a module?

Ken, not sure if this is exactly what you need, but Pydoc is a very simple tool 
to use.  It will generate a series of HTML pages, one for each Python script in 
your folder tree. All you need to do is place your quoted doc strings as shown 
in the attached example file.   then, to view the documentation, you run pydoc 
in viewer mode and it launches a browser to show the pages.

cheers
-- 
Stewart Midwinter
Calgary, Alberta
stewart 'at' midwinter 'dot' ca

Quoting Kenneth McDonald <kmmcdonald <at> wisc.edu>:

> Before I start any documentation effort on Tkinter, I'd like to get
> a good idea of what's in there right now. Is there a good tool
> that will go through a module, and print out, in summary form,
> its functions, classes, methods, etc., with docstrings if present?
> If not, I'll write my own, but why waste effort if this has already
> been done?
#!/usr/bin/env python
# -*- coding: Latin-1 -*-
# =============================================================================c+
# company name and address
# Calgary, Alberta
# Canada  T2P 2V7
# Voice: 
# Web:   
(Continue reading)

Kenneth McDonald | 25 Mar 2004 00:40
Picon
Favicon

Inserting a unicode zero-width nonbreaking space into a Text widget, from Tkinter, on a Mac

As the subject says, I am attempting to insert a particular unicode 
character
(\ufeff) into a Text widget, from Python. This is not quite working 
correctly,
and I'm not sure if the problem is between Python and Tcl, or is a 
problem of
OS X not properly knowing the character.

This character is supposed to be a 0-width space, and using Python's
unicodedata.name function confirms that feff is in fact the proper 
unicode
sequence.  The character is construction using a one-character python
string:

	zws = u"\ufeff"

And then passed to Text's insert command. Unfortunately, what shows
up on screen is a complex (perhaps Chinese) asian ideograph.
"Python in a Nutshell" indicates that all communication between
Tkinter and Tk is in unicode, so I had hoped this would transfer
correctly.

Not sure if I need to do some conversion or not...could there be
a conflict between a straight Unicode (16-bit) representation
and a UTF-8 representation? Or do I need to do an OS setting
to make sure the OS and the internal representation are on
the same wavelength?

Thanks,
Ken
(Continue reading)

Stewart Midwinter | 25 Mar 2004 02:11

Re: Inserting a unicode zero-width nonbreaking space into a Text widget

A zero-width space?  Is that an oxymoron like "military intelligence"?  I'm
curious, what would be the usual application for such a beast?

--

-- 
Stewart Midwinter
Calgary, Alberta
stewart 'at' midwinter 'dot' ca

Quoting Kenneth McDonald <kmmcdonald <at> wisc.edu>:

> This character is supposed to be a 0-width space, ...

Gmane