[FAQTS] Python Knowledge Base Update -- August 10th, 2000

Fiona Czuczman fiona at sitegnome.com
Thu Aug 10 06:05:09 EDT 2000


Hi Guys,

The latest entries into http://python.faqts.com

cheers,

Fiona


## Unanswered Questions ########################################


-------------------------------------------------------------
In tkinter, how do you change a widget's parent?
http://www.faqts.com/knowledge-base/view.phtml/aid/5245
-------------------------------------------------------------
keith murphy, Fiona Czuczman



## New Entries #################################################


-------------------------------------------------------------
Does anyone know of any wxpython tutorial / good medium sized program to learn from?
http://www.faqts.com/knowledge-base/view.phtml/aid/5277
-------------------------------------------------------------
Fiona Czuczman
Robin Dunn, David Bolen

There is the beginings of one here: http://wxpython.org/tutorial.html.

The demo distributed with wxPython is meant to be a teaching tool
although it needs some work to make it more newbie friendly...

---------

For me, what I've found best in my approach towards picking up
wxPython was to have four sources of information available:

1. wxPython demo (in the 'demo' directory of wxPython)
2. wxWindows help documentation (in the 'docs' directory of wxPython)
3. wxPython installed modules (in the main and lib wxPython directory)
4. wxWindows/wxPython source. (retrieve from the wxWindows or wxPython 
site)


1. The demo is by far the easiest to start with since it's chock full
of code that you can interactively see run and then "borrow" the
actual code, either from the demo program's listing pane or from the
filesystem.  You can go quite a long way just depending on the demo -
you may not get every tiny little thing the way you want but it should
be really easy to get a functioning application.  Once you start
getting down the nitty gritty and having other questions, I find the
other sources to be the most useful in the order listed.

2. Although there are times when it can be ambiguous with respect to
wxPython (not quite everything that needs a wxPython note has one) or
even slightly out of whack with wxWindows itself, the wxWindows
documentation is really quite good, and it also includes some general
overviews.  The information is for the most part, directly
translatable to wxPython.

3. When in doubt about how wxPython wrapped something from wxWindows
(and it's not used in a demo the way I want to use it), I start with
the wxPython .py modules - looking through them can verify which
methods are wrapped and available (and I found particularly helpful
with the new grid class which isn't documented elsewhere yet).
However, at some point this doesn't help fully since the wrapper
doesn't show you precise parameters for all methods, just a generic
SWIG interface.  So then you go to...

4. The source is the final arbiter. :-) First, I'll look at the SWIG
interface files for wxPython which will let me know precisely what is
wrapped and how.  If something there is still unclear, I'll revert
back to the wxWindows source and see what actually happens for a class
or method (although this requires understanding C++ to follow fully).
And within the wxWindows source, there are also other direct wxWindows
samples that (again, requiring C++ knowledge) can provide some further
samples of operating code.

The vast majority of learning I did with (1) and (2) - I've only had
to delve into (3) and (4) occasionally, but it was really nice to have
them around when I needed to.


-------------------------------------------------------------
How can I generate a string with 42 zeros, not the ASCII value but the REAL thing - (0x00)?
http://www.faqts.com/knowledge-base/view.phtml/aid/5278
-------------------------------------------------------------
Fiona Czuczman
Jerome Chan, Thomas Gagne

zero_string = chr(0) * 42

also

'\000' * 42

and

struct.pack('42x')


## Edited Entries ##############################################


-------------------------------------------------------------
I wonder if there is a way for Python to read directly the user input of a HTML form?
http://www.faqts.com/knowledge-base/view.phtml/aid/3112
-------------------------------------------------------------
Fiona Czuczman
Graham Bleach,Richard Chamberlain

You can use the cgi module.

There is an example of exactly that at:

http://www.devshed.com/Server_Side/Python/CGI/page4.html

You should probably read the whole article:

http://www.devshed.com/Server_Side/Python/CGI/

A good place to start for these topics:

http://www.python.org/topics/web/basic-cgi.html

Specifically cgi.FieldStorage(). This returns a dictionary of values 
that have been passed by a form.


-------------------------------------------------------------
Can I script or access the internal of (X)Emacs with Python?
http://www.faqts.com/knowledge-base/view.phtml/aid/5254
-------------------------------------------------------------
Shae Erisson, Alastair Burt


If this question means "Can I use Python instead of Emacs Lisp to add
extra modules to Emacs?", I am afraid you are out of luck.

If this question means "Can a running Python process control a running 
Emacs process?", then you probably want to use gnuserv.  This comes
standard with XEmacs. I do not know about the other Emacs.  You need to
get (X)Emacs to call the Elisp function "gnuserv-start", and then access
this process through the "gnuclient" program.  Here is an example:

 $ xemacs -f gnuserv-start &
 [1] 15069
 $ python
 Python 1.5.2 (#4, Feb  3 2000, 16:21:22)  [GCC 2.8.1] on sunos5
 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 >>> import commands
 >>> commands.getoutput('gnuclient -batch -eval "(+ 1 1)"')
 '2'







More information about the Python-list mailing list