[FAQTS] Python Knowledge Base Update -- July 18th, 2000

Fiona Czuczman fiona at sitegnome.com
Tue Jul 18 04:25:18 EDT 2000


Hi Guys,

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

cheers,

Fiona Czuczman


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


-------------------------------------------------------------
Can a class have two __init__ functions with different argument lists?
http://www.faqts.com/knowledge-base/view.phtml/aid/4799
-------------------------------------------------------------
Mark Tomko



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


-------------------------------------------------------------
Searching an example on how to use configparser in python?
http://www.faqts.com/knowledge-base/view.phtml/aid/4827
-------------------------------------------------------------
Fiona Czuczman
Olmy

assuming you have a config file called test.conf and it contains the 
following:

[DEFAULT]

name = pythontest
path = /tmp/test


then you should be able to use the following quickie test script:

from ConfigParser import *

configdict = ConfigParser()
configdict.read('test.conf')

print configdict.defaults().keys()
print configdict.defaults()['path']

path = configdict.defaults()['path']

print path


that should give you a quick idea of how to load your config file 
in ConfigParser's dictionary format.

See the following URL for the reference documentation on what else 
you can do with ConfigParser:

http://www.python.org/doc/current/lib/module-ConfigParser.html

Pay special attention on how to handle RFC822 sections and how to handle 
the "%" expansions.


-------------------------------------------------------------
Where can I get the source for all of the built-in methods, types, etc.?
http://www.faqts.com/knowledge-base/view.phtml/aid/4828
-------------------------------------------------------------
Fiona Czuczman
Alex

Check out this link:


http://www.python.org/download/download_source.html


-------------------------------------------------------------
Working with the new Build 132 of Pythonwin the German Umlauts are not handled properly in the editor windows.  How can we fix this?
http://www.faqts.com/knowledge-base/view.phtml/aid/4832
-------------------------------------------------------------
Fiona Czuczman
Neil Hodgson

132 defaults to using Unicode for editing Python source code and the
interactive window. To stop this, open 
Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and 
comment out the two lines under "# Enable Unicode if we can". Save the 
file, shut down Pythonwin and restart it and see if this fixes the 
problem.


-------------------------------------------------------------
Tthe ^-key kills build 132 immediately, when using the German keyboard layout. How can we stop that?
http://www.faqts.com/knowledge-base/view.phtml/aid/4833
-------------------------------------------------------------
Fiona Czuczman
Neil Hodgson

This is a known problem. It occurs inside the line

   key = win32ui.TranslateVirtualKey(key)

   found in fire_key_event in Pythonwin\pywin\scintilla\bindings.py.

Mark is aware of the problem in the win32ui code, but you might want to 
try this short workaround while waiting for a fixed PythonWin. Just 
before the "if event is None:" line inside fire_key_event insert this 
code.

  if key == 220:
   return 1

This avoids calling win32ui.TranslateVirtualKey for the "^" key. More
tests may be needed for other accent characters or other locales.


-------------------------------------------------------------
Is there a way to position child widgets on a TopLevel widget using absolute coordinates instead of using pack, place or grid?
http://www.faqts.com/knowledge-base/view.phtml/aid/4834
-------------------------------------------------------------
Fiona Czuczman
richard_chamberlain

You can do absolute positioning with place:

from Tkinter import *
root=Tk()
Label(root,text="He's not the messiah,").place(x=5,y=5)
Label(root,text="he's a very naughty boy.").place(x=35,y=70)
root.mainloop()

Not highly recommended though!


-------------------------------------------------------------
Installing PyOpenGL on Linux
http://www.faqts.com/knowledge-base/view.phtml/aid/4835
-------------------------------------------------------------
Fiona Czuczman
Robin Humble, Stephen R. Figgins

Installing PyOpenGL on Linux is not easy right now.  I managed to do it,
but had to alter some of the source.  I was about to write up how I did
it when I found Robin Humble had done the same thing, and posted it to
the PyOpenGL egroup: 

  http://wxwindows.org/pipermail/wxpython-users/2000-April/001922.html

Here is the text of his post:
=====================================================================  
Hi,
First post...
These are the steps I went through to get pyOpenGL from CVS (May30)
working with RedHat 6.2. I think it'd be similar for RH6.1.
Some of these changes should probably go into CVS...

* install python-numpy-15.3-1.i386.rpm from 
  http://download.sourceforge.net/numpy/python-numpy-15.3-1.i386.rpm

* grab pyOpenGL from CVS using the instructions on
  http://www.pythonpros.com/cvs.html

* edit Setup.in to be all -lGL -lGLU (not MesaGL) and to be link
  paths of -L/usr/X11R6/bin
  - this'd be fine as a spec file patch... don't worry about CVS

* edit src/Togl-1.5/togl.c at ~line 127 to add a 8.0.5 version choice
  which is the same as the 8.0.4 version
  - probably should be in CVS as it appears to work with tk/tcl 8.0.5

* run python BUILD.py
* run python install.py -v

* edit /usr/lib/tk8.0/Togl/pkgIndex.tcl to be .so not .dll
  - there should be an OS dependant 'pkgIndex.tcl' in the support/
    directory that 'install.py' chooses depending upon whether you're 
    running Unix or Windows. Obviously .dll makes no sense under
    Unix/Linux.

* move /usr/lib/tk8.0/Togl/togl.so to be Togl.so
  - maybe if I knew what the syntax of the 'pkgIndex.tcl' file was then
    this wouldn't be necessary as 'togl.so' should be ok? Not sure...

I also have most of the demos from www.python.de working if anyone is
interested. The RawOpengl one being the exception.
I couldn't find any sensible demos from the cvs version of pyOpenGL.
Maybe I don't know the right place to look?

Please let me know if you'd like patches for any of these things and
I'll do my best to help. If the CVS gets updated then I'm happy to
contribute a .spec file and create a source and binary i386 rpm (and a
download site) if anyone is interested. Possibly also an Alpha/Linux
binary rpm.

I'm impressed by the speed and simplicity of pyOpenGL so far! About
100k+ points per frame animating smoothly and happily (software only
Mesa with Athlon700/K7V/G400Max)...

===================================================================== 

Since reading this, I found another person who says they solved some of
the MesaGL library problems by installing the Mesa 3.0 RPM from Robin 
Dunn's wxPython site:

  http://alldunn.com/wxPython/dist/others/


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


-------------------------------------------------------------
How do I get IDLE to run a script on startup?
http://www.faqts.com/knowledge-base/view.phtml/aid/3241
-------------------------------------------------------------
Fiona Czuczman
Shae Erisson

Problem:

I've created a script called $IDLESTARTUP.py in the IDLE directory, and 
I'm running idle.pyw with the -s switch, but it doesn't appear to be 
working.  (Running IDLE 0.5 on Win98.)

Solution:

$IDLESTARTUP actually means "read the value of the environment variable
IDLESTARTUP"
That means if you add a line in your autoexec.bat that says:
SET IDLESTARTUP="C:\Program Files\Python\Tools\idle\autoidle.py"

Then the -s switch will work (as long as you have a file name
autoidle.py in the correct path that's a python file that is :)

You can of course change the value of that variable to start with any
file you prefer. For shell variables, you don't need to surround them
with double quotes if there aren't any spaces in the path you're giving
it.
ex:
SET IDLESTARTUP=C:\Python\Tools\idle\idlesetup.py
that will work fine since there aren't any spaces (like "Program Files")
in the directory specification.







More information about the Python-list mailing list