[FAQTS] Python Knowledge Base Update -- July 22nd, 2000

Fiona Czuczman fiona at sitegnome.com
Sat Jul 22 23:34:38 EDT 2000


Hello List,

Here are the latest entries into http://python.faqts.com

best regards,

Fiona Czuczman

Including:

- Is there a way to make a text box uneditable by the user, but 
insertable ( insert(END, 'schweet') ) by the application?
- I'm looking for an ODBC client package to Informix and SQL*Server 
which API is identical in Windows and Linux.
- Any pointers on using Python with CORBA?
- Anyone know how to use the font measure() thing in tkinter?
- Are there any current SSL libraries for Python?
- Why is my pipe i/o thread blocking the other threads? Any answers?
- I want one thread to wait for one or more other threads to terminate.
- Where can I find some example python/tkinter code? Some examples of 
how to use all those widgets would be useful.
- How can I change the text on a label? When I use the 
variabletext=whatever thing, the label wont show up.
- Is there a Python MySQL module for use under Windows?
- Removing null items from a list
- Is there any way I can prevent pythonwin(scintilla) from reading the 
method names of a specific class


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


-------------------------------------------------------------
Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status?
http://www.faqts.com/knowledge-base/view.phtml/aid/4922
-------------------------------------------------------------
Loren Poulsen



-------------------------------------------------------------
Can I run a script in an already running interpreter to hook a gui to a server process?
http://www.faqts.com/knowledge-base/view.phtml/aid/4761
-------------------------------------------------------------
Slimy, Fiona Czuczman



-------------------------------------------------------------
Can I make something like jtable with tkinter?
http://www.faqts.com/knowledge-base/view.phtml/aid/4019
-------------------------------------------------------------
udo apolloner, Fiona Czuczman



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


-------------------------------------------------------------
Is there a way to make a text box uneditable by the user, but insertable ( insert(END, 'schweet') ) by the application?
http://www.faqts.com/knowledge-base/view.phtml/aid/4927
-------------------------------------------------------------
Fiona Czuczman
richard_chamberlain

There may be a better way of doing it...

from Tkinter import *
root=Tk()
text=Text(root,width=50,height=50)
text.pack()
def intercept(event):
    return 'break'
text.bind('<Key>',intercept)
text.insert(END,'Sweet ;-)')
root.mainloop()

Here I bind a <Key> event to the intercept function - where I return 
'break' to stop the event propagating, so basically it's disabled. To 
undisable you'd just need to unbind that event.


-------------------------------------------------------------
I'm looking for an ODBC client package to Informix and SQL*Server which API is identical in Windows and Linux.
http://www.faqts.com/knowledge-base/view.phtml/aid/4929
-------------------------------------------------------------
Fiona Czuczman
Matthias Huening

Try Marc Lemburg's mxODBC:

http://starship.python.net/crew/lemburg/


-------------------------------------------------------------
Any pointers on using Python with CORBA?
http://www.faqts.com/knowledge-base/view.phtml/aid/4930
-------------------------------------------------------------
Fiona Czuczman
Martin von Loewis

Sure. There is a OMG-adopted language mapping, at

http://cgi.omg.org/cgi-bin/doc?ptc/00-04-08.pdf

There is a number of implementations of that mapping as well. In order
of appearance:

ILU:          ftp://ftp.parc.xerox.com/pub/ilu/ilu.html
Fnorb:        http://www.fnorb.com
omniORBpy:    http://www.uk.research.att.com/omniORB/omniORBpy/
orbit-python: http://sourceforge.net/project/?group_id=3561
[They look like they are ordered by increasing name length :-]

These implementations differ in ease-of-installation, degree of
conformance to the mapping spec (or to CORBA Core), additional
features offered, performance, portability, and so on.

Discussion of CORBA and Python typically takes place on the DO SIG,

http://www.python.org/sigs/do-sig/


-------------------------------------------------------------
Anyone know how to use the font measure() thing in tkinter?
http://www.faqts.com/knowledge-base/view.phtml/aid/4931
-------------------------------------------------------------
Fiona Czuczman
Matthew Dixon Cowles

>>> import Tkinter
>>> foo=Tkinter.Toplevel()
>>> import tkFont
>>> f=tkFont.Font(family="7x13")
>>> f.measure("wibble")
42

The Toplevel() call wouldn't be necessary in your program since you'd
have already called mainloop().


-------------------------------------------------------------
Are there any current SSL libraries for Python?
http://www.faqts.com/knowledge-base/view.phtml/aid/4932
-------------------------------------------------------------
Fiona Czuczman
Michael Ströder, pehr anderson

M2Crypto found on http://www.post1.com/home/ngps/m2/

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

We had this same issue. 
To solve it, we found that we could get what we needed by using the 
command-line options available in the openssl package. If your problem 
is more complicated than ours, you may be interested in investing more 
time than us.

To do what we did, install openssl-0.9.5a-1 from  http://www.openssl.org 
Binary RPMS are available from the http://openssh.com project
ftp://ftp1.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/rpm/
"man openssl" should tell you how to work openssl and you can run it 
from python with something like:
page = os.popen("echo %s | openssl" % cmds).read()
I don't remember exactly what we did so try your own thing.

Word on the street is that you should look in the prereleases of python 
1.6 (renamed 2.0) for the "right" long-term solution. I've downloaded 
the CVS and it looks like you will have to uncomment a couple of lines 
in:

python/dist/src/Modules/Setup.in


Here is the relevant section:

# Socket module compiled with SSL support; you must edit the SSL
variable:
#SSL=/usr/local/ssl
#socket socketmodule.c \
#       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#       -L$(SSL)/lib -lssl -lcrypto

# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
#crypt cryptmodule.c # -lcrypt  # crypt(3); needs -lcrypt on some
systems


-------------------------------------------------------------
Why is my pipe i/o thread blocking the other threads? Any answers?
http://www.faqts.com/knowledge-base/view.phtml/aid/4933
-------------------------------------------------------------
Fiona Czuczman
Richard Brodie

There is a global lock within Python, protecting its internals. When you
call out from a Python to a C extension method in a thread, the thread
holds the lock.

For maximum parallelism, and particularly if you're doing blocking I/O
in a thread, you need to release and reaquire the lock.

See: http://www.python.org/doc/current/api/threads.html for details.


-------------------------------------------------------------
I want one thread to wait for one or more other threads to terminate.
http://www.faqts.com/knowledge-base/view.phtml/aid/4934
-------------------------------------------------------------
Fiona Czuczman
Dale Burnett, Aahz Maruch

On windows you can use the Win32 functions WaitforSingleObject, SetEvent
and CreateEvent.  If you cant or dont want to use the win32 functions,
then check out the Event Objects in the threading module.

-----------

If you're waiting for one thread, that's reasonably easy.  If you're
waiting for all of a group of threads, use a semaphore.  But if you're
waiting for any one of a group of threads, that's a bit more tricky.
I'd suggest waiting on a queue, where the threads dump their data into
the queue.


-------------------------------------------------------------
Where can I find some example python/tkinter code? Some examples of how to use all those widgets would be useful.
http://www.faqts.com/knowledge-base/view.phtml/aid/4935
-------------------------------------------------------------
Fiona Czuczman
richard_chamberlain, Keith Murphy, Charles G Waldman

Have a look at John Grayson's manning site 
(http://www.manning.com/grayson) you 
can download the source from his book including code that demonstrates 
each widget.

I really would recommend a copy as it's an excellent book.

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

I would say that the best reference I've found for tkinter is Fredrik
Lundh's 'an introduction to tkinter'

http://www.pythonware.com/library.htm

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

How about in the Python source distribution in the directory
Demo/tkinter?


-------------------------------------------------------------
How can I change the text on a label? When I use the variabletext=whatever thing, the label wont show up.
http://www.faqts.com/knowledge-base/view.phtml/aid/4936
-------------------------------------------------------------
Fiona Czuczman
richard_chamberlain, Charles G Waldman

from Tkinter import *
root=Tk()
myString=StringVar()
Label(root,textvariable=myString).pack()
myString.set("Well, eh, how about a little red Leicester.")
def changeLabel():
    myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ")
Button(root,text='Click Me',command=changeLabel).pack()
root.mainloop()

I presume where you're going wrong is you are not creating an instance 
of StringVar and setting (or getting) the variable through that.

----

See http://www.secretlabs.com/library/tkinter/introduction/index.htm
for lots of useful tkinter information.


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


-------------------------------------------------------------
Is there a Python MySQL module for use under Windows?
http://www.faqts.com/knowledge-base/view.phtml/aid/4188
-------------------------------------------------------------
Fiona Czuczman
Stefan Franke,Steve Cook

Check out

  ZMySQLDA-1.2.0.tar.gz

on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some 
Windows patches already applied. I run it sucessfully with the lately 
GPLed MySQL-2.23.19 on Win98.

All you need to do is to edit Setup.in, adjust the paths to your local 
MySQL installation, and run compile.py.

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

Go here http://www.mysql.com/downloads/mysql-3.23.html

You can download the official Win9x/NT install package.  MySQL 3.23 is 
now under the GPL so you can get it for windows without paying for it, 
like you have to for 3.22


-------------------------------------------------------------
Removing null items from a list
Why not just loop through the list, test for false, and if false remove from the list?
http://www.faqts.com/knowledge-base/view.phtml/aid/4522
-------------------------------------------------------------
Nathan Wallace, Fiona Czuczman, Bill Anderson
Hans Nowak, Snippet 334, Andrew M. Kuchling

"""
Packages: basic_datatypes.lists
"""

"""
> So I've got a very simple desire: to remove all false (I.E. None, 0, '',
> []) items from a list.

The filter() built-in function, when not passed a specific function,
does exactly this:
"""

print filter(None, [ 1,2,0, None, [], '12', '' ])
# [1, 2, '12']

"""
filter(F, seq) returns all the elements of the sequence 'seq', for
which the function F returns true: for example, the following code 
takes all the strings of even length:
"""

print filter(lambda s: len(s) % 2 == 0, ['a', 'ab', '', 'abcd'])
# ['ab', '', 'abcd']

"""
If F is None, then filter() simply returns those elements that Python
treats as true.
"""


-------------------------------------------------------------
Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class
http://www.faqts.com/knowledge-base/view.phtml/aid/4734
-------------------------------------------------------------
Nils Otto Johansen, Fiona Czuczman
Mark Hammond

NO.







More information about the Python-list mailing list