Re: generating a tree-like structure

2007-05-31 Thread kyosohma
On May 31, 12:44 pm, Thorsten Kampe <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This is a fairly general question: is there some kind of module or
> framework that allows building a tree like structure from certain kind
> of data?
>
> To be specific: I have a program that dumps the content of a LDAP
> directory including all properties and values and groups the result
> from the LDAP search by objClass.
>
> Now I was thinking: would it be possible to generate from the totally
> unordered output that the LDAP server gives me, a tree like
> representation that displays the hierarchy (omitting the values or
> even properties if necessary)?
>
> It should be a textual representation of what you see in GUI programs
> like "LDAP Administrator" but the output should be represented like
> the "tree" program in Linux or Windows "tree.com".
>
> Any ideas appreciated...
>
> Thorsten

I think you might be able to use ElementTree. The website for the
module claims it can be used for hierarchical data structures:
http://effbot.org/zone/element-index.htm

Did you look at any of the Python LDAP tools? They might be useful
too. See some of the links below:
http://linuxjournal.com/article/6988
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303336

Hopefully they'll give some guidance. I've not used LDAP myself as of
yet.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


MoinMoin configuration

2007-06-03 Thread kyosohma
Hi,

I am working on a new site about Python to help document some of the
modules that don't have much for documentation. Anyway, I chose to use
MoinMoin because it has very easy-to-use code display with line
numbers that toggle on and off.

The question I have is how do I configure MoinMoin to force users to
login before making changes and still allow the user to choose if he/
she wants to sign the edit or not? It looks like Python.org has that
kind of thing in place.

I have read through the ACL instructions on MoinMoin's site, but I
don't understand how to make it work. See 
http://moinmoin.wikiwikiweb.de/HelpOnAccessControlLists

To me it seems to be saying that you have to create a page before you
can set the ACL for it. I don't want a bunch of pages where some have
ACL's and some don't.

If you can clear up my confusion, that would be great. Thanks!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: excel library without COM

2007-06-03 Thread kyosohma
On Jun 3, 7:59 pm, james_027 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> is there any library to help me write excel files without using win
> com? because i'll be working on linux platform. At the same time I
> could want to perform some formatting, merging of cells. adding sheets
> and etc ...
>
> Thanks
> james

I'm not aware of any modules. However, this thread is on the same
topic and it mentions using html or txt files as possibilities:

http://mail.python.org/pipermail/python-list/2002-April/138748.html

I would also think that you could write some kind of custom XML parser/
creator that you could use to create the Excel sheet's structure and
then interface with COM later.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using pyTTS with other languages.

2007-06-04 Thread kyosohma
On Jun 4, 8:17 am, simon kagwe <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to create a TTS program for a local (Kenyan) language. I have
> installed pyTTS on my computer and it works perfectly with English sentences.
> However, my language is very different from English (sylabbles, pronounciation
> etc.) How can I go about having a TTS program that correctly speaks my 
> language?
> Can pyTTS do this?
>
> I need all the help I can get.
>
> Regards,
> Simon.

Hi Simon,

I am pretty sure pyTTS can do this. It has a method to tell it how to
pronounce words. See the following article:

http://www.cs.unc.edu/~parente/tech/tr02.shtml

It describes how to use mis-spelled words to force correct
pronunciation as well as how to do it with XML.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Who uses Python?

2007-06-04 Thread kyosohma
On Jun 4, 2:37 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> I mean other than sysadmins, programmers, and web-site developers?
>
> I have heard of some DBAs who use a lot of python.
>
> I suppose some scientists. I think python is used in bioinformatics. I
> think some math and physics people use python.
>
> I suppose some people use python to learn "programming" in general.
> Python would do well as a teaching language.
>
> I would think that python would be a good language for data analysis.
>
> Anything else? Finance? Web-analytics? SEO? Digital art?

We use it for login scripts, locking down PCs, automating backups,
GIS, and more.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get_traceback

2007-06-04 Thread kyosohma
On Jun 4, 12:23 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> Is there a function or idoim for returning an exception/traceback
> rather than just printing it to stdout?  I'm running a deamon where
> stdout is going to /dev/null, and I'm not even watching it..until
> now.  All the functions I found in traceback and sys seemed only to
> print the error rather than just returning it, so I resorted to this:
>
> def get_traceback():
> import traceback, tempfile
> stdout = sys.stdout
>
> f = tempfile.TemporaryFile(mode='w+')
> sys.stdout = f
>
> traceback.print_tb(sys.exc_info()[2])
> error = f.read()
> f.close()
>
> sys.stdout = stdout
> return error
>
> Whats the right function?!?  Thanks.
>
> ~Sean

I use the traceback module as you do and I usually have it email the
traceback to me if there's an error. You could also have the script
redirect stdout to a file object.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython splitwindow with interpreter on bottom

2007-06-04 Thread kyosohma
On Jun 4, 9:57 am, chewie54 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Does anyone know of an example of wxPython source code that shows how
> to put a python shell (interpreter) in a bottom window with a
> graphical application in the top window?
>
> Thanks,

There's the pyCrust/pyShell examples in the wxPython demo. They are
quite similar to what you want, I think.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginning Python

2007-06-05 Thread kyosohma
On Jun 5, 9:29 am, abhiee <[EMAIL PROTECTED]> wrote:
> Hello , I have just begun learning python...and I'm loving it...Just
> wanted to ask you that how much time would it take me to learn python
> completely and which languages should i learn alongwith python to be a
> good professional programmer?...Now i only know C
> thanx in advance!

I think a more accurate question would be "how long does it take to
learn python so I don't have to look stuff up constantly". Knowing any
language completely is nigh impossible unless you designed it
yourself. However, I must say that learning Python so that you can
just start programming well without always going for help is quite
easy. I would think it would take 1-3 months depending on your ability
to suck in information and the amount of time you actually program.

As I understand it, the top languages are still Java and C++, with
COBOL being a major player in insurance/business environments. I would
recommend pretty much any web language as more and more is heading
towards the online world. Thus, Java/Javascript, PHP, Perl, CSS, CGI,
etc are good to know.

Check out this interesting graph on computer language trends:
http://www.cs.berkeley.edu/~flab/languages.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generating a wm5 executable

2007-06-06 Thread kyosohma
On Jun 6, 1:19 pm, Marco <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm quite a newbee on Python and have started developing apps on
> PythonCE.
>
> My .pyc files are running fine under windows mobile 5 but I'm a bit
> stuck on how to generate single file executable packages under such
> platform, nor I've found a lot of reference about it - seems to be
> quite a niche.
>
> Can I run py2exe runs under wm5?
>
> Any other suggestion?
>
> Thanks in advance
>
> Marco

I know some Python people use Inno Setup for packaging an executable
and I think that would work with Windows Mobile. They seem to be using
a mix of py2exe and Inno in some cases. Here's some links I found on
the topic:

http://mail.python.org/pipermail/patches/2003-October/013672.html
http://www.thescripts.com/forum/thread30814.html
http://www.thescripts.com/forum/thread26910.html
http://innoconda.berlios.de/

Something to ponder and/or glean ideas from.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - Force toplevel window to stay on top of Tk() window

2007-06-08 Thread kyosohma
On Jun 8, 11:48 am, [EMAIL PROTECTED] wrote:
> Hi,
> I have a Tk() window "base_win = Tk()" with multiple frames on it
> having a combination of widgets. If I click on say a button widget
> which launches a new top level window "new_win = TopLevel()", I was
> looking for a way for this "new_win" to always stay on top of
> "base_win" till I close "new_win", as a result also not allowing any
> selections to be made in the "base_win" .
> Thanks
> Rahul

You need to research showing modal dialogs. This link looks promising:

http://mail.python.org/pipermail/tkinter-discuss/2005-March/000371.html

This one from Lundh's site has better explanations on dialog's in
general:

http://effbot.org/tkinterbook/tkinter-dialog-windows.htm


Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obtaining hte currently running script under windows

2007-06-08 Thread kyosohma
On Jun 8, 8:45 am, Sean Farrow <[EMAIL PROTECTED]> wrote:
> Hi:
> Is there any way to obtain the full path to the currently running script
> under win32?
> I am using the pythonw.exe file is that helps.
> Sean.

Check out Google! I found the following link by typing "python os cwd"

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474083

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Repository - file scanner

2007-06-09 Thread kyosohma
On Jun 8, 2:33 pm, HMS Surprise <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> Could someone point my muddled head at a/the python repository. I know
> that one exists but cannot find it again. In particular I am looking
> for a standalone search tool that given a path searches files for a
> text string.
>
> Thanks,
>
> jvh

Are you looking for

A.) a Python script to search for file names that match a given text
string?
B.) a script to search for a given text string within a text file?
C.) a Python repository, as in the SVN/CVS area?



Here's a couple scripts for finding files given a path:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52224
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189973

And here's an interesting article on creating a Python "Find" utility:
http://www.python.org/search/hypermail/python-1994q2/0116.html

This link has a chapter from "Learning Python" by O'Reilly that talks
about looking for words within files:
http://www.oreilly.com/catalog/lpython/chapter/ch09.html

The "repository" is here: http://svn.python.org/

Enjoy!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Repository - file scanner

2007-06-09 Thread kyosohma
On Jun 8, 2:33 pm, HMS Surprise <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> Could someone point my muddled head at a/the python repository. I know
> that one exists but cannot find it again. In particular I am looking
> for a standalone search tool that given a path searches files for a
> text string.
>
> Thanks,
>
> jvh

Search for text in a file, from O'Reilly's "Learning Python" book:
http://www.oreilly.com/catalog/lpython/chapter/ch09.html

Search for files given a path (or paths) and some text to search for:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52224
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189973
http://www.python.org/search/hypermail/python-1994q2/0116.html

The Python repository (I think): http://svn.python.org/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Needed: FTP Upload Directory Tree script

2007-06-10 Thread kyosohma
On Jun 10, 3:01 am, IanC <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Does anyone know of a function or script to upload an entire
> subdirectory tree from a local file space to an FTP server?
>
> The Python distribution comes with "ftpmirror.py", which performs
> a mirror download of a directory tree, but I need the "Upload"
> version of this.
>
> Thanks for any hints
> --
> -- Ian -- [EMAIL PROTECTED]  ---

Here's some links that should give you some pointers:

http://zephyrfalcon.org/weblog/arch_d7_2003_06_28.html#e262
http://www.example-code.com/python/python-ftp-upload.asp
http://www.thescripts.com/forum/thread22534.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Repository - file scanner

2007-06-10 Thread kyosohma
On Jun 9, 12:38 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Sat, 09 Jun 2007 12:30:49 -0300, <[EMAIL PROTECTED]> escribió:
>
> > On Jun 8, 2:33 pm, HMS Surprise <[EMAIL PROTECTED]> wrote:
> >> Could someone point my muddled head at a/the python repository. I know
> >> that one exists but cannot find it again. In particular I am looking
> >> for a standalone search tool that given a path searches files for a
> >> text string.
>
> > Are you looking for
>
> > A.) a Python script to search for file names that match a given text
> > string?
> > B.) a script to search for a given text string within a text file?
> > C.) a Python repository, as in the SVN/CVS area?
>
> D.) The Python Package Index perhaps?http://www.python.org/pypi
>
> --
> Gabriel Genellina

Sorry about the dual post...google groups was acting very weird for me
yesterday.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pasting an image from clipboard in Tkinter?

2007-06-11 Thread kyosohma
On Jun 11, 7:23 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote:
> As many might know, windows allows to copy an image into the clipboard
> by pressing the "Print Screen" button on the keyboard. Is it possible
> to paste such an image from the clipboard into a "Text" widget in
> Tkinter? Here is my first attempt with just trying to print out the
> image data:
>
> -
> def pasteImg(tgt):
>global clipboardEnabled
>if not clipboardEnabled: return
>
>win32clipboard.OpenClipboard(0)
>print win32clipboard.GetClipboardData()
>win32clipboard.CloseClipboard()
> -
>
> This works fine with selecting text, but comes up with the following
> error when trying to paste an image:
>
> -
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> return self.func(*args)
>   File "X:\development\testing\tkwiki\tkwiki.py", line 52, in 
> Button( root, command=lambda: pasteImg(txt) ).pack()
>   File "X:\development\testing\tkwiki\tkwiki.py", line 38, in pasteImg
> print win32clipboard.GetClipboardData()
> TypeError: Specified clipboard format is not available
> -
>
> Obviously the clipboard does not know about that format. Does that
> mean I have to wait until it's implemented or are there other ways to
> access the image data?


I don't think you can paste to a text widget, but I could be mistaken.
This link talks about pasting an image into a window, but I don't
think it's really what you want...however, it might give you some
ideas:

http://effbot.org/zone/wck-3.htm  (see the "Drawing Images" section)

This link also talks about some of the same things:
http://www.wadsworth.org/spider_doc/spider/docs/python/spipylib/tkinter.html

If I understand them correctly, it sounds like you could possibly
catch the the paste operation and convert the image to a TkImage and
then paste it. I think that since it is in the clipboard, then it is a
file object and this may work. I just don't know how you intercept a
paste.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Help!!!

2007-06-11 Thread kyosohma
On Jun 11, 3:39 am, Elfine Peterson Tjio <[EMAIL PROTECTED]> wrote:
> I'm trying to make a program that reads Fasta file and print it out. I used 
> the SeqIO module and the results is:
>
> 'ATGGTCATSingleAlphabet()'
>
> For this purpose, should I use SeqIO or Fasta?
>
> for example:
>
> from Bio import SeqIO
>
> or
>
> from Bio import Fasta
>
> I want it to print every letter. Can anyone point me to the right direction. 
> The newest biopython tutorial or book recommendation will be appreciated, too.

As I understand it, a "Fasta" file is a text file, correct? If so,
this should be trivial with Python.

I created a file with the following data from 
http://en.wikipedia.org/wiki/Fasta_format:

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

Then I did the following to read it:

>>> fil = open(r'c:\test\fasta.txt')
>>> for f in fil.readlines():
if '>' in f:
print f
else:
for letter in f:
print letter

That seemed to work for me. You probably don't want to print the first
line, but that's easily fixed.

Hope that helps.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx.grid 2.6.1.0 events

2007-06-11 Thread kyosohma
On Jun 11, 9:04 am, DarkBlue <[EMAIL PROTECTED]> wrote:
> Hello
>
> pythoncard
> wx 2.6.1
> python 2.4.x
> kinterbasdb
> firebird
>
> I have a wx.grid filled with data from a database
> one of the fields is a blob field with text data, which
> I want to display in some adjacent text control when I scroll
> through the grid.
>
> The question is which wx.EVT_XXX do I need
> to use and how to 'connect ' the wx.grid to my TextArea
> control ,so that the correct data gets displayed after
> any row change?
>
> Thanks for any hints.
>
> Db

Upon skimming the grid controls event types in the wxPython in Action
book, it looks like you could catch the wx.grid.EVT_GRID_SELECT_CELL
event. Then use the GetCellValue method to grab the selected cell's
contents and then write that to your TextCtrl.

If that doesn't work, please post the issue to the wxPython user's
group here: http://wxpython.org/maillist.php

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pasting an image from clipboard in Tkinter?

2007-06-11 Thread kyosohma
On Jun 11, 9:07 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote:
> On Jun 11, 3:47 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On Jun 11, 7:23 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote:
>
> > > As many might know, windows allows to copy an image into the clipboard
> > > by pressing the "Print Screen" button on the keyboard. Is it possible
> > > to paste such an image from the clipboard into a "Text" widget in
> > > Tkinter? Here is my first attempt with just trying to print out the
> > > image data:
>
> > > -
> > > def pasteImg(tgt):
> > >global clipboardEnabled
> > >if not clipboardEnabled: return
>
> > >win32clipboard.OpenClipboard(0)
> > >print win32clipboard.GetClipboardData()
> > >win32clipboard.CloseClipboard()
> > > -
>
> > > This works fine with selecting text, but comes up with the following
> > > error when trying to paste an image:
>
> > > -
> > > Exception in Tkinter callback
> > > Traceback (most recent call last):
> > >   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
> > > return self.func(*args)
> > >   File "X:\development\testing\tkwiki\tkwiki.py", line 52, in 
> > > Button( root, command=lambda: pasteImg(txt) ).pack()
> > >   File "X:\development\testing\tkwiki\tkwiki.py", line 38, in pasteImg
> > > print win32clipboard.GetClipboardData()
> > > TypeError: Specified clipboard format is not available
> > > -
>
> > > Obviously the clipboard does not know about that format. Does that
> > > mean I have to wait until it's implemented or are there other ways to
> > > access the image data?
>
> > I don't think you can paste to a text widget, but I could be mistaken.
> > This link talks about pasting an image into a window, but I don't
> > think it's really what you want...however, it might give you some
> > ideas:
>
> >http://effbot.org/zone/wck-3.htm(see the "Drawing Images" section)
>
> > This link also talks about some of the same 
> > things:http://www.wadsworth.org/spider_doc/spider/docs/python/spipylib/tkint...
>
> > If I understand them correctly, it sounds like you could possibly
> > catch the the paste operation and convert the image to a TkImage and
> > then paste it. I think that since it is in the clipboard, then it is a
> > file object and this may work. I just don't know how you intercept a
> > paste.
>
> > Mike
>
> Unfortunately, when they talk about "pasting" they talk about a PIL
> method called paste, which (if I understood correctly) deals with
> blitting one image onto another. Not "pasting" as in copy/paste from
> clipboard.

I don't do much with images as of yet, but from what I've read, it
seems that blitting is a common method. Here's a fairly interesting
article on the process using wxPython (sorry...I wasn't finding
anything under Tkinter):

http://wiki.wxpython.org/index.cgi/WorkingWithImages

It might give some ideas.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: with as a reserved word

2007-06-11 Thread kyosohma
On Jun 11, 10:03 am, BBands <[EMAIL PROTECTED]> wrote:
> I gather that 'with' is on its way to becoming a reserved word. Is
> this something that will break?
>
> import Gnuplot
> gp = Gnuplot.Gnuplot(debug=1)
> data = Gnuplot.Data([1,2,3,4,3,2,3,4,3,2,1], with='linespoints')
> gp.plot(data)
>
> >>> :3: Warning: 'with' will become a reserved keyword in Python 2.6
>
> http://www.gnuplot.info/http://gnuplot-py.sourceforge.net/
>
> This was run by PyScripter 1.8.7.1 with Python 2.5.
>
>  jab

Looks that way since you can assign anything to 'for' or 'if' or other
reserved words.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing global namespace from module

2007-06-11 Thread kyosohma
On Jun 11, 11:02 am, reubendb <[EMAIL PROTECTED]> wrote:
> Hello,
> I am new to Python. I have the following question / problem.
> I have a visualization software with command-line interface (CLI),
> which essentially is a Python (v. 2.5) interpreter with functions
> added to the global namespace. I would like to keep my own functions
> in a separate module and then import that module to the main script
> (that will be executed using the CLI interpreter). The problem is, I
> cannot access the functions in the global namespace of the main script
> from my module. Is there anyway to do that ?
>
> Here is an example of what I meant. The function AddPlot() and
> DrawPlots() are added to the global namespace by the software CLI. If
> I do this:
>
> mainscript.py:
> ---
> AddPlot("scatter", "coordinate")
> # set other things here
> DrawPlots()
>
> it works fine. But I want to be able to do this:
>
> myModule.py:
> --
> def defaultScatterPlot():
>   AddPlot("scatter", "coordinate")
>   #do other things
>   DrawPlots()
>
> and then in mainscript.py:
> ---
> import myModule
> myModule.defaultScatterPlot()
>
> This won't work because myModule.py doesnot have access to AddPlot().
> How do I do something like this ?
>
> Thank you in advance for any help.
> RDB

I think you're doing it backwards. If you want access to AddPlot, then
you should import mainscript into that module instead of the other way
around. When I have common methods I want to call from different
scripts, I put those methods/functions into their own module/file.
Then I just import the module and call whatever script I need.



commonMods.py
-
AddPlot(*args, *kwargs):
# Do something
DrawPlots(*args, *kwargs):
# Do something
-


mainProgram.py

from commonMods import AddPlot
AddPlot("scatter", "coordinate")
# etc etc
-

myModule.py

from commonMods import AddPlot
AddPlot("scatter", "coordinate")
# etc etc
-



Hope that helps.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel file interface for Python 2.3?

2007-06-12 Thread kyosohma
On Jun 12, 8:01 am, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
> I'm in need of a module that will let me create Excel workbooks from within
> Python.  Something like PyExcelerator, but it needs to work with Python 2.3.
> (A third-party limitation that I have no control over.)  Can anyone point me
> to what I need?  All my searches keep leading back to PyExcelerator.
>
> --
> -Bill Hamilton

You can also use COM if you're on Windows, via PyWin32. Hammond's book
talks about it a little here: 
http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html

I also saw some information about this in Core Python Programming by
Chun.

Example code follows:



import win32com.client as win32
def excel():
app = 'Excel'
xl = win32.gencache.EnsureDispatch('%s.Application' % app)
ss = xl.Workbooks.Add()
sh = ss.ActiveSheet
xl.Visible = True
sleep(1)

sh.Cells(1,1).Value = 'Python-to-%s Demo' % app
sleep(1)
for i in RANGE:
sh.Cells(i,1).Value = 'Line %d' % i
sleep(1)
sh.Cells(i+2,1).Value = "Th-th-th-that's all folks!"


ss.Close(False)
xl.Application.Quit()



Admittedly, COM is kind of confusing. But it's there if you need it.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel file interface for Python 2.3?

2007-06-12 Thread kyosohma
On Jun 12, 8:38 am, [EMAIL PROTECTED] wrote:
> On Jun 12, 8:01 am, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
>
> > I'm in need of a module that will let me create Excel workbooks from within
> > Python.  Something like PyExcelerator, but it needs to work with Python 2.3.
> > (A third-party limitation that I have no control over.)  Can anyone point me
> > to what I need?  All my searches keep leading back to PyExcelerator.
>
> > --
> > -Bill Hamilton
>
> You can also use COM if you're on Windows, via PyWin32. Hammond's book
> talks about it a little 
> here:http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html
>
> I also saw some information about this in Core Python Programming by
> Chun.
>
> Example code follows:
>
> 
>
> import win32com.client as win32
> def excel():
> app = 'Excel'
> xl = win32.gencache.EnsureDispatch('%s.Application' % app)
> ss = xl.Workbooks.Add()
> sh = ss.ActiveSheet
> xl.Visible = True
> sleep(1)
>
> sh.Cells(1,1).Value = 'Python-to-%s Demo' % app
> sleep(1)
> for i in RANGE:
> sh.Cells(i,1).Value = 'Line %d' % i
> sleep(1)
> sh.Cells(i+2,1).Value = "Th-th-th-that's all folks!"
>
> ss.Close(False)
> xl.Application.Quit()
>
> 
>
> Admittedly, COM is kind of confusing. But it's there if you need it.
>
> Mike

Oops...forgot that to mention that I import the sleep function from
the time module in the above code. Sorry about that.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file open default location

2007-06-12 Thread kyosohma
On Jun 12, 8:42 am, "T. Crane" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How is the default path chosen in this instance:
>
> myFile = file('test.txt','w')
>
> Here I'm opening/creating a file but I have not specified the exact path, so
> how does Python determine where to 'put' this file?  More to the point, how
> do I change what the default path is?  Right now it's a networked drive that
> should not be getting my Python clutter.
>
> Interestingly, this network drive is also where I can find my _ipython
> folder from my ipython install as well as my .matplotlib folder.  Can anyone
> tell me how to change where these folders and files go by default?
>
> thanks for any help,
> trevis

When you don't specify where you want to save a file, it saves the
file to the directory the script itself is run from. As far as I know,
you have to specify where you want the file saved if you don't want it
with the script.py

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert String to Int and Arithmetic

2007-06-12 Thread kyosohma
On Jun 12, 9:32 am, tereglow <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am a complete newbie to Python and am accustomed to coding in PHP/
> Perl/Shell.  I am trying to do the following:
>
> I have a string:
>
> cpuSpeed = 'Speed: 10'
>
> What I would like to do is extract the '10' from the string,
> and divide that by 1000 twice to get the speed of a processor in MHz.
>
> My understanding is that I need to 'import re' and then use re.split
> to get the first part done.  The second part confuses me because I'm
> unable to convert the '10' to an integer to run division
> against it.
>
> Basically, I want to come out with 1000 for the above string.  Any
> help would be appreciated.
> Tom

You don't need to use the "re" module. I'd just do something like
this:

>>> temp = cpuSpeed.split(' ')
>>> temp
['Speed:', '10']
# grab the 2nd element from the list and cast it as an integer
>>> cpuSpeed = int(temp [1])
>>> cpuSpeed = (cpuSpeed / 1000) / 1000
>>> cpuSpeed
1000

Basically, you just use the split command and cast it as an integer
using the reserved word "int".

Then you can divide it twice.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file open default location

2007-06-12 Thread kyosohma
On Jun 12, 9:09 am, "Richard Brodie" <[EMAIL PROTECTED]> wrote:
> "T. Crane" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
>
> > As an aside, I forgot to mention above that I'm using Windows XP.  Any 
> > other ideas or
> > possible reasons that it would not choose my script location as the default 
> > location to
> > save something?
>
> If you open a DOS window and run Python from there, it will write the files
> in whatever directory you were in when you typed the command.
>
> If you are running Python directly from Windows, or from an IDE, it's up
> to the OS or the IDE to decide what your default directory is. Often it
> will be the home directory from your user profile.

Oops. My bad. I didn't know that the IDE behaved differently than the
DOS window.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Forgetting an import

2007-06-12 Thread kyosohma
On Jun 12, 11:36 am, HMS Surprise <[EMAIL PROTECTED]> wrote:
> I imported a set of functions from a file I wrote to interpreter
> shell:
>
> from myFile import *
>
> Now if I change functions in this file how can I make python forget it
> so I can force a fresh import?
>
> thanx,
>
> jh

If you did an import FunctionName, then you could use the "reload"
built-in. Otherwise, I think you'll just have to restart the shell.


import FunctionName
# do something
# reload FunctionName after editing it
reload(FunctionName)


Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a question about unicode in python

2007-06-12 Thread kyosohma
On Jun 12, 12:29 pm, "Evan Klitzke" <[EMAIL PROTECTED]> wrote:
> On 6/12/07, hzqij <[EMAIL PROTECTED]> wrote:
>
> > i have a python source code test.py
>
> > # -*- coding: UTF-8 -*-
>
> As Marc pointed out, you should test the actual file encoding of the
> program to check that it is, in fact, UTF-8 encoded. If you're on a
> Unix/Linux system you should be able to test for a UTF-8 encoded file
> using the "file" command, e.g.
>
> [EMAIL PROTECTED] ~ $ file ~/uni.py
> /home/evan/uni.py: UTF-8 Unicode text
>
> --
> Evan Klitzke <[EMAIL PROTECTED]>

If you're using IDLE to edit the source with, you can set IDLE to
encode in utf8 by going to Options, Configure IDLE, General Tab, and
change the Default Source Encoding to utf-8.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread kyosohma
On Jun 14, 4:02 pm, "Talbot Katz" <[EMAIL PROTECTED]> wrote:
> Greetings Pythoners!
>
> I hope you'll indulge an ignorant outsider.  I work at a financial software
> firm, and the tool I currently use for my research is R, a software
> environment for statistical computing and graphics.  R is designed with
> matrix manipulation in mind, and it's very easy to do regression and time
> series modeling, and to plot the results and test hypotheses.  The kinds of
> functionality we rely on the most are standard and robust versions of
> regression and principal component / factor analysis, bayesian methods such
> as Gibbs sampling and shrinkage, and optimization by linear, quadratic,
> newtonian / nonlinear, and genetic programming; frequently used graphics
> include QQ plots and histograms.  In R, these procedures are all available
> as functions (some of them are in auxiliary libraries that don't come with
> the standard distribution, but are easily downloaded from a central
> repository).
>
> For a variety of reasons, the research group is considering adopting Python.
>   Naturally, I am curious about the mathematical, statistical, and graphical
> functionality available in Python.  Do any of you out there use Python in
> financial research, or other intense mathematical/statistical computation?
> Can you compare working in Python with working in a package like R or S-Plus
> or Matlab, etc.?  Which of the procedures I mentioned above are available in
> Python?  I appreciate any insight you can provide.  Thanks!
>
> --  TMK  --
> 212-460-5430home
> 917-656-5351cell

I'd look at following modules:

matplotlib - http://matplotlib.sourceforge.net/
numpy - http://numpy.scipy.org/

Finally, this website lists other resources: 
http://www.astro.cornell.edu/staff/loredo/statpy/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Custom wxPython Widget

2007-06-18 Thread kyosohma
On Jun 15, 10:24 pm, Jens Thiede <[EMAIL PROTECTED]> wrote:
> What is the best source code to read? Any tips; suggestions?
>
> Thanks in advance
> Jens Thiede

I would recommend reading the wxPython demo source code. Also, this
website has some custom widgets written in "pure wxPython", some of
which are in the demo: http://xoomer.alice.it/infinity77/eng/freeware.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Controlling Firefox with Python

2007-06-19 Thread kyosohma
Hi,

I would like to be able to control Firefox through Python. I see
there's pyWinAuto, which might work if they had good documentation.
I've also messed with win32 modules, but I don't think Firefox will
work with those too nicely since it isn't a COM-based program.

I've also found some Python Firefox XUL scripting information that is
at least 2 years old and also not documented well. I really need to be
able to cycle through the tabs that are open in a current Firefox
session and search for a specifically labeled tab.

Any ideas on how to do this would be appreciated. I am using Windows
XP with Python 2.4. Thanks!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython: Redirect the stdout to a textctrl

2007-06-19 Thread kyosohma
On Jun 19, 3:16 pm, Alejandro <[EMAIL PROTECTED]> wrote:
> Hi:
>
> I want to redirect stdout to a textctrl I have. From what I read in
> the wxpython documentation, I can use the wxLogTextCtrl class to do
> this. I am doing the following:
>
> class MyGui(gui.MyFrame):  #gui.MyFrame generated by wxGlade
> def __init__(self, *args, **kwds):
> gui.MyFrame.__init__(self, *args, **kwds)
> # ... code removed ...
> wx.Log_SetActiveTarget(wx.LogTextCtrl(self.text_ctrl_2))
> print 'foo' #to test the redirection
>
> if __name__ == "__main__":
> app = wx.App(redirect=wx.LogTextCtrl)
> wx.InitAllImageHandlers()
> gui = MyGui(None, -1, "")
> app.SetTopWindow(gui)
> gui.Show()
> app.MainLoop()
>
> However, the output instead of going to my textctrl, goes to a new
> window named "xwPython: stdout/stderr".
>
> What am I missing?

Give this a try:



class XPinst(wx.App):
def __init__(self, redirect=False, filename=None):
wx.App.__init__(self, redirect, filename)

def OnInit(self):
self.frame = wx.Frame(None, -1, title='Redirect Test',
size=(620,450),
  style=wx.STAY_ON_TOP|
wx.DEFAULT_FRAME_STYLE)

panel = wx.Panel(self.frame, -1)

self.log = wx.TextCtrl(panel, -1, size=(500,400),
  style = wx.TE_MULTILINE|wx.TE_READONLY|
wx.HSCROLL)
redir=RedirectText(self.log)
sys.stdout=redir
print 'test'

self.frame.Show()
return True

class RedirectText:
def __init__(self,aWxTextCtrl):
self.out=aWxTextCtrl

def write(self,string):
self.out.WriteText(string)



Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling Firefox with Python

2007-06-20 Thread kyosohma
On Jun 19, 4:35 pm, "Méta-MCI" <[EMAIL PROTECTED]>
wrote:
> Hi!
>
> See Mozlab:  http://dev.hyperstruct.net/mozlab
>
> and give a report, please.
> Thank you in advance.
>
> Michel Claveau

There seems to be some kind of weird bug with the current version of
MozLab. When I use telnet on my Windows XP box, it tries to evaluate
every character I type, which only results in lots of syntax errors. I
tried Putty in raw mode, and it works, but not well. Each line doesn't
get output to the far left. Instead, each line is dropped down one
line and tabbed over so it's one character ahead of the previous line.

I assume you think I can use Python to telnet to a running MozLab to
execute my commands? I will need to be able to do this to all the
users on a network and installing extensions on everyone's PC will be
somewhat difficult.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: wxPython - embed separate script in panel?

2007-06-20 Thread kyosohma
On Jun 19, 7:28 pm, [EMAIL PROTECTED] wrote:
> This is a wxPython question.. the wxPython group is pretty much
> inactive.
>
> I have an MDI parent frame and child frame set up. In the child frame,
> I want to use part of the frame to display the output from a .py that
> is mainly matplotlib (a graph) in a section of the frame. How can I
> get it to automatically run that script and place the resultant graph
> in a panel?
>
> Thanks

I'm not sure what you're talking about. I get a digest email from the
wxPython user's group at least twice a day. Try going here and posting
to it:

http://www.wxpython.org/maillist.php

Are you signed up to the dev group or something?

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python website

2007-06-20 Thread kyosohma
On Jun 20, 9:22 am, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> what are you list of favorite python website (news, articles,
> tutorials)?
>
> cheers,
> james


wxPython.org (and the wxPython wiki)
Python.org
ActiveState - http://aspn.activestate.com/ASPN/Python/Cookbook/
Charming python series - http://www.ibm.com/developerworks/library/l-pycon.html
http://gnosis.cx/publish/tech_index_cp.html
Devshed - http://www.devshed.com/c/b/Python/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list



Re: Controlling Firefox with Python

2007-06-20 Thread kyosohma
On Jun 20, 9:05 am, [EMAIL PROTECTED] wrote:
> On Jun 19, 4:35 pm, "Méta-MCI" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi!
>
> > See Mozlab:  http://dev.hyperstruct.net/mozlab
>
> > and give a report, please.
> > Thank you in advance.
>
> > Michel Claveau
>
> There seems to be some kind of weird bug with the current version of
> MozLab. When I use telnet on my Windows XP box, it tries to evaluate
> every character I type, which only results in lots of syntax errors. I
> tried Putty in raw mode, and it works, but not well. Each line doesn't
> get output to the far left. Instead, each line is dropped down one
> line and tabbed over so it's one character ahead of the previous line.
>
> I assume you think I can use Python to telnet to a running MozLab to
> execute my commands? I will need to be able to do this to all the
> users on a network and installing extensions on everyone's PC will be
> somewhat difficult.
>
> Mike

UPDATE: I can do tab traversal in Firefox using the sendkeys method. I
just need a way to read the label on the current tab or the title of
the Firefox window.

Any ideas?

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: visual gui ides for python/jythpn

2007-06-20 Thread kyosohma
On Jun 20, 1:16 pm, kromakey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Are there any free visual GUI IDE's available for python/jython, which
> have a drag and drop form designer similar to Visual Studio or
> Delphi ?
>
> Cheers
> kromakey

I think Boa Contructor and wxGlade do that for the wxPython GUI
toolkit:

http://boa-constructor.sourceforge.net/
http://wxglade.sourceforge.net/

XRCed kind of does this as well: http://xrced.sourceforge.net/

Dabo: http://dabodev.com

wxGlade and XRCed are included in SPE - http://pythonide.blogspot.com/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython: Redirect the stdout to a textctrl

2007-06-20 Thread kyosohma
On Jun 20, 4:03 pm, Alejandro <[EMAIL PROTECTED]> wrote:
> On Jun 19, 5:07 pm, [EMAIL PROTECTED] wrote:> Give this a try:
>
> > 
>
>  [good piece of code]
>
> > 
>
> It worked like a charm! Thanks.
>
> I still don't understand why my initial aproach didn't work as
> expected.
>
> Regards,
> Alejandro.

Alejandro,

Yeah, I'm not sure what the deal is with your code. But I've never
used the LogTextCtrl widget. You might ask why it doesn't work
directly by posting to the wxPython user's group here:
http://www.wxpython.org/maillist.php

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyosohma
On Jun 21, 10:10 am, Duncan Booth <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] wrote:
> > I have many users using two different versions of python, 2.4 and
> > 2.5.  I am running Python scripts on their computers programmatically,
> > but I can't run it with the full path because they have different
> > versions installed.  I need to run it like 'python {script name}'.  So
> > I need to add Python to the path.  How do I do this permanently
> > without going to each computer and setting it through the GUI?  I
> > tried creating a Windows batch script using setx, but the user had to
> > be an administrator.
>
> > Or is there any other way I can run whatever version of Python happens
> > to be installed with a single command?  Anyone have any ideas?  Such a
> > simple issue, there must be a simple solution. (of course, this is
> > Windows).
>
> Assuming they have Python installed normally there will be file
> associations set up for .py and .pyw, so all you need to do to type in
> the script name: Python itself does not need to be in the path.
> N.B. You do need to include the .py extension unless you can arrange to
> edit the PATHEXT environment variable.
>
> e.g.
>
> C:\Temp>type t.py
> import sys
> print sys.version
>
> C:\Temp>t.py
> 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
>
> C:\Temp>assoc .py
> .py=Python.File
>
> C:\Temp>ftype Python.File
> Python.File="C:\Python25\python.exe" "%1" %*

If your users aren't programmers, then why not just run Python over
the network? That's what we do at my place of employment. The only
machines that have Python actually installed are development machines.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyosohma
On Jun 21, 10:30 am, [EMAIL PROTECTED] wrote:
> On Jun 21, 11:22 am, [EMAIL PROTECTED] wrote:
>
>
>
> > If your users aren't programmers, then why not just run Python over
> > the network? That's what we do at my place of employment. The only
> > machines that have Python actually installed are development machines.
>
> > Mike
>
> Mike,
>
> I place the scripts on the server, but hadn't thought of placing an
> entire Python installation on the server.  I just tried it and it
> seems to work.  It shouldn't cause any problems?  That might actually
> work out really well too.  Thanks for the suggestion.

We've been running python scripts over the network for more than a
year. The only issues I can think of is that at first it didn't always
find that weird Python dll file, but once we got that on the server,
that problem went away too.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding Python to the path in Windows

2007-06-21 Thread kyosohma
On Jun 21, 10:45 am, [EMAIL PROTECTED] wrote:
> On Jun 21, 10:30 am, [EMAIL PROTECTED] wrote:
>
>
>
> > On Jun 21, 11:22 am, [EMAIL PROTECTED] wrote:
>
> > > If your users aren't programmers, then why not just run Python over
> > > the network? That's what we do at my place of employment. The only
> > > machines that have Python actually installed are development machines.
>
> > > Mike
>
> > Mike,
>
> > I place the scripts on the server, but hadn't thought of placing an
> > entire Python installation on the server.  I just tried it and it
> > seems to work.  It shouldn't cause any problems?  That might actually
> > work out really well too.  Thanks for the suggestion.
>
> We've been running python scripts over the network for more than a
> year. The only issues I can think of is that at first it didn't always
> find that weird Python dll file, but once we got that on the server,
> that problem went away too.
>
> Mike

I should probably mention that if you have some complicated GUI's,
they will probably load slowly over the network. And I did notice that
scripts using WMI and pyWin32 modules can be slower than they ought to
be. Just something to keep in mind if you have a slow connection. We
have a T1 out to a remote location and it's caused some minor issues
using anything of that nature.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rsync module?

2007-06-22 Thread kyosohma
On Jun 21, 7:40 pm, "Evan Klitzke" <[EMAIL PROTECTED]> wrote:
> Are there any python modules for accessing rsync from python? I would
> like to be able to rsync files from a python script to a remote server
> running an rsync daemon. I'm well aware that I can invoke rsync using
> subprocess, os.system, etc., but I am curious if there is a way to do
> it directly.
>
> --
> Evan Klitzke <[EMAIL PROTECTED]>

I found the following doing a quick Google search:

http://www.vdesmedt.com/~vds2212/rsync.html
http://freshmeat.net/projects/pysync/
http://www.nongnu.org/rdiff-backup/

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WX call a pywx program from a program, and return values

2007-06-24 Thread kyosohma
On Jun 24, 10:02 am, Marcpp <[EMAIL PROTECTED]> wrote:
> I need to call a pywx program(1) from an wxpy program(2) and return a
> value to program(2).
> Any example to do it?

Yup. See links below:

http://mail.python.org/pipermail/tutor/2005-May/038648.html
http://www-pcmdi.llnl.gov/software-portal/cdat/tips_and_tricks/python_tips/passing_arguments.html
http://aspn.activestate.com/ASPN/Mail/Message/wxPython-users/3508008

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing sound volume

2007-06-24 Thread kyosohma
On Jun 23, 7:47 am, simon kagwe <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am playing sounds using the winsound module. Is there a way I can change the
> volume?

The docs don't mention anything about controlling the volume, so I
doubt it's possible with winsound. However, I found this in the
archives:

http://mail.python.org/pipermail/edu-sig/2001-December/001899.html

It's some kind of wrapper for Snack that allows you to mess with the
volume. This site talks about Snack, winsound and another module:

http://www.zak.co.il/gpl/misc/eng/pythonsound.html

And finally a way that might work using ctypes:

http://mail.python.org/pipermail/python-win32/2006-March/004436.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which XML?

2007-06-24 Thread kyosohma
On Jun 24, 7:04 pm, Bruno Barberi Gnecco
<[EMAIL PROTECTED]> wrote:
> I've found a lot of XML libraries for Python. Any advices on which
> one to use (or *not* to use)? My requirements are: support for XPath,
> stability (a must, segfaults are not an option), with DOM API and good
> performance desirable.
>
> Thanks for any advice.
>
> --
> Bruno Barberi Gnecco 

I use the minidom module for most of my XML work, but I don't think it
has much in the way of XPath. I think lxml might work better for that
sort of thing and I think it's part of ElementTree:

http://codespeak.net/lxml/dev/objectify.html

This guy kind of reviews the major XML modules:

http://www.oreillynet.com/onlamp/blog/2005/01/code_respecting_xpath_xml_pyth.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which XML?

2007-06-25 Thread kyosohma
On Jun 25, 3:47 am, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Jun 24, 7:04 pm, Bruno Barberi Gnecco
> > <[EMAIL PROTECTED]> wrote:
> >> I've found a lot of XML libraries for Python. Any advices on which
> >> one to use (or *not* to use)? My requirements are: support for XPath,
> >> stability (a must, segfaults are not an option), with DOM API and good
> >> performance desirable.
>
> > I use the minidom module for most of my XML work, but I don't think it
> > has much in the way of XPath. I think lxml might work better for that
> > sort of thing and I think it's part of ElementTree:
>
> >http://codespeak.net/lxml/dev/objectify.html
>
> lxml is not part of ElementTree (only mostly compatible), but it's a must if
> you want to have a simple API *and* XPath *and* good performance.
>
> http://codespeak.net/lxml/
>
> The API is not W3C-DOM compatible, but that's rather a plus IMHO.
>
> Stefan

Oops, sorry about the mis-information. I mis-read 
http://effbot.org/zone/element-index.htm

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Capturing and sending keys {Esperanto}

2007-06-25 Thread kyosohma
On Jun 25, 8:26 am, AJK <[EMAIL PROTECTED]> wrote:
> Hello there!
>
> I've been googleing yet, and suppose it's hopeless to try, but better ask 
> it...
>
> I want to write a program which turns Cx to Ĉ, cx to ĉ et al WHILE
> TYPING. (i.e. converting Esperanto x-system to real hats, for those
> who know about this.) Therefore I though will need to capture the last
> 2 typed characters (from any application), send a double backspace and
> after that send the correct letters (back to the same application)...
>
> However, it seems inpossible to capture those letters, and maybe to
> send them too...
>
> Or am I wrong?
>
> Greetings,
>
> LaPingvino
>
> (project:http://code.google.com/p/iksilo/- SVN Repository is free
> viewable, project is GPL)
>
> --
> Ĉar Dio tiel amis la mondon, ke Li donis Sian solenaskitan Filon, por
> ke ĉiu, kiu fidas al li, ne pereu, sed havu eternan vivon.
> -Johano 3:16, La sankta Biblio-
>
> Ĝoju ĉiam, preĝu senĉese, pri ĉio donu dankon.
> -1 Tesalonikanoj 5:16-18a, La sankta Biblio-

I've never done this before, but theoretically, you should be able to
have a separate process monitor what you're typing and maybe do edits
in real time. At least, I assume that that is how MS Word works. I
have messed a little with sendkeys though. Here's the examples I found
on the net:

http://mail.python.org/pipermail/python-list/1999-May/003244.html
http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp

The msdn one is just the MS docs for Sendkeys.

One other alternative would be to type it all out and then run a
script to parse your document and basically just do a search and
replace.

Hopefully that helps your out a little at least.

Mike


-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Capturing and sending keys {Esperanto}

2007-06-25 Thread kyosohma
On Jun 25, 8:26 am, AJK <[EMAIL PROTECTED]> wrote:
> Hello there!
>
> I've been googleing yet, and suppose it's hopeless to try, but better ask 
> it...
>
> I want to write a program which turns Cx to Ĉ, cx to ĉ et al WHILE
> TYPING. (i.e. converting Esperanto x-system to real hats, for those
> who know about this.) Therefore I though will need to capture the last
> 2 typed characters (from any application), send a double backspace and
> after that send the correct letters (back to the same application)...
>
> However, it seems inpossible to capture those letters, and maybe to
> send them too...
>
> Or am I wrong?
>
> Greetings,
>
> LaPingvino
>
> (project:http://code.google.com/p/iksilo/- SVN Repository is free
> viewable, project is GPL)
>
> --
> Ĉar Dio tiel amis la mondon, ke Li donis Sian solenaskitan Filon, por
> ke ĉiu, kiu fidas al li, ne pereu, sed havu eternan vivon.
> -Johano 3:16, La sankta Biblio-
>
> Ĝoju ĉiam, preĝu senĉese, pri ĉio donu dankon.
> -1 Tesalonikanoj 5:16-18a, La sankta Biblio-

I just thought of something. Look for real time spell checkers! I
found this one: http://ponderer.org/cvs/index.pl/javascript/spell.py

Even if you can't find one in Python, you can probably translate to
the snake.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to save initial configuration? (program installation)

2007-06-25 Thread kyosohma
On Jun 25, 10:02 am, Jason Zapman II <[EMAIL PROTECTED]> wrote:
> I've written a program.  To install this program, I'm going to need to
> initialize some stuff for the users environment, specifically the name/
> location of an internal state file.
>
> Currently, I'm hard coding the location of this file, but that's in-
> elegant.  What I'd like to do is just ask the user, with a suggested
> default.
>
> My question is how do I save this answer?  It's kind of a chicken-and-
> egg problem.
>
> The only solution I've thought of is to write something that's self
> modifying, but that's ugly (go in, grep for this variable
> initialization, re-write that line with the new value, quit).  Is
> there a better way to do this?  There almost has to be...
>
> If not, are there some 'best practices' on how to do the self-
> modification?
>
> Thanks for any help;
> Jason

I would think you could pop-up some dialog when the program is first
run to ask where they want the file to be. On the first run though,
you can just have the config file located in the current working
directory with the script file itself. Then just move it or save a new
copy to the new location and delete the original.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to save initial configuration? (program installation)

2007-06-25 Thread kyosohma
On Jun 25, 10:58 am, Jason Zapman II <[EMAIL PROTECTED]> wrote:
> On Jun 25, 11:37 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > The traditional choices are the registry for Windows, and the /etc
> > subtree for the various, almost uncountable, flavors of Unix and
> > nixalikes. You're right, it's much more difficult per-system than
> > per-user, since there are so many conventions.
>
> I forgot to mention that this is for Unix environments, so the
> registry isn't an option, unfortunately (never thought I'd say
> that... ;-) ).
>
> Is there anything in the distutils.* stuff that would be useful?  This
> isn't going to be a python package (it's a standalone program).
>
> --Jason

Well, I don't know what your user file does, but couldn't you create
a .ini type file to hold the user's choice for the other file's
location and save the ini to the current working directory?

Something like this:


usersChosenPath = /usr/Path/to/Config


Kind of redundant, but I would think it would still work.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing sound volume

2007-06-25 Thread kyosohma
On Jun 25, 7:48 am, simon kagwe <[EMAIL PROTECTED]> wrote:
> > And finally a way that might work using ctypes:
>
> >http://mail.python.org/pipermail/python-win32/2006-March/004436.html
>
> > Mike
>
> Hi,
>
> Thanks for your reply.
>
> I had already read about the Snack, but I can't use it since my program uses
> wxPython for the GUI and Snack requires tk. The best option was the ctypes
> method you told me about. I used the code in the sample, but I am getting the
> following error:
>
> exceptions.WindowsError Error 11 while setting volume
>
> The author of the code claims it works. What could be causing the above error?
>
> [ I am using Python 2.4.4 and ctypes 1.0.1 ]
>
> Regards,
> Simon

I'm not sure what the deal is. I just tested that script on my
workstation and it works fine for me. I think I have the latest
ctypes, but I can't figure out how to get the version number off of it
to be sure. I am running Python 2.4.3 on Windows XP SP2 though.

You might try that pygames idea. I've never tried it, but you'd think
that would work.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen and a long running process in a wx.python application

2007-06-26 Thread kyosohma
On Jun 26, 10:16 am, Doru Moisa <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How can I capture the output of a long runnning process which I open
> with popen() ?
> I tried reading line by line, char by char, but the result always
> comes when the process finishes.
> (I am trying to make a wx.python program that opens some "make ..."
> with popen). How can I receive the output of the program immediatly,
> so that I can show a progressbar  in my application ?
> I always get the program's output after it finished executing.
> Is this the right place, or should I post this to wx.python ?
>
> Thank you in advance.

When talking about anything advanced with wxPython, you usually want
to submit it to the wxPython user's group. Lots of advanced users
(including the author of wxPython) answer questions there.

I would recommend looking at the following link as this will probably
be one of the first suggestions:
http://wiki.wxpython.org/index.cgi/LongRunningTasks?highlight=%28task%29%7C%28longrunning%29

wxPython mailing list: http://www.wxpython.org/maillist.php

I used a variation of one of the threading example in the
LongRunningTasks page to send output to a text widget, through stdout
redirection.

Good luck!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen() problem

2007-06-26 Thread kyosohma
On Jun 26, 3:38 pm, 7stud <[EMAIL PROTECTED]> wrote:
> I have this program:
>
> mytest.py
> --
> myinput = raw_input("Enter input: ")
>
> if myinput == "hello":
> print "goodbye"
> --
>
> and I want to execute it using subprocess.Popen().  I tried the
> following but it just hangs:
>
> ---
> import subprocess
>
> f = open("/Users/me/2testing/dir1/aaa.txt", "w")
> my_path = "/Users/me/2testing/"
> my_file = "mytest.py"
>
> p = subprocess.Popen(["python", "mytest.py"], stdin=subprocess.PIPE,
> stdout = f,
> stderr = f,
> cwd = my_path
> )
>
> f.close()
>
> p.stdin.write("hello")
> p.wait()
>
> f.open("/Users/me/2testing/dir1/aaa.txt")
> print f.read()
> 

Never tried this, but I think you need to use the communicate method
detailed here:

http://docs.python.org/dev/lib/node537.html

If that doesn't work, you might look into using the threading module
and its methods. Or there could be a flush command that I can't
find...

Mike


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Evolution of a pythonistas!

2007-06-28 Thread kyosohma
On Jun 28, 8:02 am, "Sells, Fred" <[EMAIL PROTECTED]> wrote:
> concur 100%.  You can breeze through the fist half of the online tutorial in
> a about 2 cups of coffee but you don't know what you don't know until you
> try to do something real.
>
> Even with 20 years of working with Python, I find goodies in the cookbook
> for each new project.
>
> Get a python aware editor.  I use Eclipse+PyDev for big jobs, but still use
> Emacs with python-mode for quickies.  Although I would never recommend Emacs
> to someone who does not already know how to use it.  IDLE is ok, for
> beginning but I find it distracting.  Eclipse can be intimidating at first,
> but if you go through the PyDev howto's, You'll learn all you need.
>
> Forget about typing stuff interactively, It is better to work in a file so
> you can see your work evolve.
>
> Finally, I have never had a project in the last 5 years that someone hasn't
> already done.  Google is your friend.  Many of the hits are misleading or
> too much code to fit what I need, but I often find a snippet that I can use.
>
> > -Original Message-

Wow Fred! You're awesome! How did you get 20 years in of Python when
it was created in 1991? Still, I think you're right. Most of the time,
I can find what I need because it's already done. I've only been
programming for just over a year and I learn something new almost
every day. And yes, the best way to learn is by "just coding".

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob question How do I run a Python script.

2007-06-28 Thread kyosohma
On Jun 28, 12:17 pm, CarlP <[EMAIL PROTECTED]> wrote:
> How do I run a Python script. I have one that gmail loader needs to
> run on my email box. Here's the script
>
> http://www.marklyon.org/gmail/cleanmbox.py
>
> I can't seem to find what I need to run it. I installed python, run
> the interpreter and the script , but all it will do is say invalid
> syntax.
>
> Thanks

Please post the traceback too. That will aid in helping you.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help Needed in WxPython

2007-06-29 Thread kyosohma
On Jun 29, 7:50 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> senthil arasu wrote:
> > Hi,
> > Currently Iam integrating GUI Framework in Python.
> > As per design design,I need to use tab buttons to launch different HTML
> > pages in same frame(without launching seperate window ). I have already
> > tried with webbrowser class & WxPython GUI kit. Iam unable to get the
> > expected result.
>
> > I am wanted to be clear..!whether python supports my design or i need to
> > go for some other option
>
> > I need somebody to help me.
>
> > thanks
>
> Could you use the webbrowser module to control presentation of HTML pages?
>
> regards
>   Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenweb  http://del.icio.us/steve.holden
> --- Asciimercial --
> Get on the web: Blog, lens and tag the Internet
> Many services currently offer free registration
> --- Thank You for Reading -

senthil arasu,

If you're on Windows, you can use wxPython's
wx.lib.iewin.IEHtmlWindow, which wraps Internet Explorer somehow using
ActiveX. I've heard that some of the people in the wxPython user's
group are working on a more generic WebKit, but I don't think it's
done yet. Other than that, the only other module wxPython provides
that I'm aware of is wx.HtmlWindow which is pretty limited.

If the IEHtmlWindow doesn't work for you, then you're probably better
off using webbrowser to open the native browser with the specified
page from within Python/wxPython.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: win32event.WaitForInputIdle() returns too soon

2007-06-29 Thread kyosohma
On Jun 29, 3:03 pm, "Hans" <[EMAIL PROTECTED]> wrote:
> "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in berichtnews:[EMAIL 
> PROTECTED]
>
>
>
> > En Thu, 28 Jun 2007 19:15:40 -0300, Hans <[EMAIL PROTECTED]> escribió:
>
> >> I'm sending keyboard and mouse events to a seperate windows application.
> >> I use win32event.WaitForInputIdle() before calling e.g.
> >> win32api.keybd_event()
> >> However it seems that WaitForInputIdle() returns too soon because some
> >> of my
> >> events get lost. Now I'v created my own  WaitForInputIdle() which calls
>
> > From the Microsoft docs for WaitForInputIdle: "The WaitForInputIdle
> > function only works with GUI applications. If a console application calls
> > the function, it returns immediately, with no wait."
> > A typical Python script is a console application.
>
> > --
> > Gabriel Genellina
>
> It would explain my problem.
> Perhaps I could create a small windows application as interface..
> I have to think about it ( and wait, as I currently don't have access to
> visual C++, nor the MS documentation)
>
> Thanks,
> Hans

Who says you have to create it with Visual C++? You could use Tkinter
or wxPython. Both are pretty easy to pick up and can look professional
with a little work.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Python + Google Calendar API issue

2007-06-30 Thread kyosohma
Hi,

I was trying to hook into Google Calendar today using their gdata
module for Python, but I can't seem to get Python to work with it.
When I run the setup.py from the command line, I get the following:

Traceback (most recent call last):
  File "J:\Python\Lib\site-packages\gdata\setup.py", line 39, in ?
package_dir = {'gdata':'src/gdata', 'atom':'src/atom'}
  File "J:\Python\lib\distutils\core.py", line 137, in setup
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" %
msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
[cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied


I tried using some different commands, like --verbose, but it would
just give me the same traceback. I also tried manually copying all the
files into my site-packages directory (as you can see from the
traceback) in hopes that it might work without running the setup.py
file.

Does anyone have any ideas? I don't usually have any problem getting
these things to work. I am using Python 2.4.3 on Windows XP Pro SP2.

Thanks a lot!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python + Google Calendar API issue

2007-07-01 Thread kyosohma
On Jul 1, 7:15 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] schrieb:
>
>
>
> > Hi,
>
> > I was trying to hook into Google Calendar today using their gdata
> > module for Python, but I can't seem to get Python to work with it.
> > When I run the setup.py from the command line, I get the following:
>
> > Traceback (most recent call last):
> >   File "J:\Python\Lib\site-packages\gdata\setup.py", line 39, in ?
> > package_dir = {'gdata':'src/gdata', 'atom':'src/atom'}
> >   File "J:\Python\lib\distutils\core.py", line 137, in setup
> > raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" %
> > msg
> > SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
> > [cmd2_opts] ...]
> >or: setup.py --help [cmd1 cmd2 ...]
> >or: setup.py --help-commands
> >or: setup.py cmd --help
>
> > error: no commands supplied
>
> > I tried using some different commands, like --verbose, but it would
> > just give me the same traceback. I also tried manually copying all the
> > files into my site-packages directory (as you can see from the
> > traceback) in hopes that it might work without running the setup.py
> > file.
>
> > Does anyone have any ideas? I don't usually have any problem getting
> > these things to work. I am using Python 2.4.3 on Windows XP Pro SP2.
>
> Did you supply an install command:
>
> python setup.py install
>
> --verbose is no command.
>
> Diez

Oops. When I typed  it gave me lots of info, but I guess I mis-
read it. Turns out you were quite right and that all I needed was the
"install" command.

Thanks a lot!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need help with win32com

2007-07-02 Thread kyosohma
On Jul 2, 11:38 am, Thomas <[EMAIL PROTECTED]> wrote:
> I want to be able to access an excel file and extract the code from
> the macro that is in the file.  How can I do this?
>
> --
> ~Thomas~

You should be able to use PythonWin and the makepy utility to get
handles to the Excel object. See the following article:

http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html

I also found an article on how to use Python as the scripting language
in Excel:

http://www.velocityreviews.com/forums/t319222-re-python-in-excel.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is wrong with that r"\"

2007-07-03 Thread kyosohma
On Jul 3, 7:15 am, alf <[EMAIL PROTECTED]> wrote:
> question without words:
>
>  >>> r"\"
>File "", line 1
>  r"\"
> ^
> SyntaxError: EOL while scanning single-quoted string
>  >>> r"\ "
> '\\ '

One slash escapes the following character, so the proper way of
writing it is either

r"\\" or r"\""

See http://docs.python.org/ref/strings.html for more information.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is wrong with that r"\"

2007-07-03 Thread kyosohma
On Jul 3, 8:25 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Tue, 03 Jul 2007 06:16:43 -0700, [EMAIL PROTECTED] wrote:
> >On Jul 3, 7:15 am, alf <[EMAIL PROTECTED]> wrote:
> >> question without words:
>
> >>  >>> r"\"
> >>File "", line 1
> >>  r"\"
> >> ^
> >> SyntaxError: EOL while scanning single-quoted string
> >>  >>> r"\ "
> >> '\\ '
>
> >One slash escapes the following character, so the proper way of
> >writing it is either
>
> >r"\\" or r"\""
>
> >Seehttp://docs.python.org/ref/strings.htmlfor more information.
>
> I wonder if the OP was asking how to spell the one-length string \?
> In that case, the answer is that it can't be done using raw strings,
> but "\\" does it.  Backslash escapes aren't interpreted in raw strings,
> but you still can't end a raw string with a backslash.
>
> Jean-Paul

Very true...sometimes I need to read these weird posts 2 or 3 times.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Cannot convert from the charset 'latin-1'

2007-07-03 Thread kyosohma
On Jul 3, 11:16 am, Helmut Jarausch <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to teach  "dugui.py" (a tiny GUI for restructuredtext written in
> wxPython) to accept files in isolatin-1 encoding.  It displays e.g. German
> umlauts correctly but then I get a popup window saying
> Python Error
> Cannot convert from the charset 'latin-1'!
>
> How can I find out where this did come from. Running it under pdb
> isn't helpful either.
>
> Many thanks for a hint,
>
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany

Probably your best bet is to post wxPython specific questions to the
wxPython user's group: http://www.wxpython.org/maillist.php

But I did a little Google-fu and found this for you:

http://wiki.wxpython.org/index.cgi/UnicodeBuild

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Restarting a Python Application

2007-07-03 Thread kyosohma
Hi,

I packaged up an application I am developing into an executable. In
the application, it has user configurable options. I would like a way
to restart the application so that the new options the user chooses
can be applied. Firefox can restart itself. Does anyone know how to
accomplish this in Python?

Here is what I tried:



exePath = os.path.join(os.getcwd(), 'myprogram.exe')
subprocess.Popen(exePath)
sys.exit()



This didn't work. It closed the program, but another instance did not
appear.

Tips would be appreciated.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can i change an Object type ?

2007-07-04 Thread kyosohma
On Jul 4, 12:40 am, Tim Roberts <[EMAIL PROTECTED]> wrote:
> KuhlmannSascha <[EMAIL PROTECTED]> wrote:
>
> >i tried now for several hours to read through a win32com API to access
> >Itunes and read out myplaylists.
>
> >First of all the Code:
> >...
> >The current Logic is to access first Itunes and then a Playlist
> >Collection.
> >This Playlist collection returns different kind of objects for
> >Playlists.
> >I am focussing on the Playlists of the object UserPlaylist.
> >(CodeLine:   if curPlaylist.Kind == 2:)
> >After that i should be sure to have a UserPlaylist, but Python stops
> >with an exception that the requested Attribute "Smart"  is not
> >available
> >Error MEssage:
> >AttributeError: ' >instance at 0x30216960>' object has no attribute 'Smart'
>
> Smart is part of IITUserPlaylist, not IITPlaylist.  You need to call
> curPlaylist.QueryInterface to get the IITUserPlaylist, but that means
> you'll need to know the GUID for IITUserPlaylist.  Perhaps Google will
> help.
> --
> Tim Roberts, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.

These look like they could give you some pointers too:

http://www.brunningonline.net/simon/blog/archives/001627.html
http://lazycat.org/backburner.html
http://mail.python.org/pipermail/python-win32/2007-February/005506.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python work with QuickBooks SDK?

2007-07-04 Thread kyosohma
On Jul 4, 1:51 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> My guess is that it would, but I can find no mention of python in the
> intuit developers site. I  can find some references to PHP and Perl,
> but no Python.
>
> I looks to me like Intuit develops have a strong preference for visual-
> basic, then c/c++, then delphi.
>
> I find it just a little bit surprising, since Python does work
> with .Net and all.

I'm not seeing a Python wrapper for the SDK, but it looks like you can
access it with COM. This thread talks a little about doing just that:

http://mail.python.org/pipermail/python-win32/2004-May/001990.html

To learn more about Python and how to work with COM, check this site
out:

http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html

I hope that helps you out.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WXPYTHON push button call a frame

2007-07-05 Thread kyosohma
On Jul 5, 9:04 am, Marcpp <[EMAIL PROTECTED]> wrote:
> On 5 jul, 14:51, Steve Holden <[EMAIL PROTECTED]> wrote:
>
>
>
> > Marcpp wrote:
> > > Hi I need to call a widget from a button in WXPYTHON. I've tried to
> > > this from a function like this, but when push the button, the program
> > > opens a window and do error.
> > > Any idea?
>
> > Well, one *really* good idea would be to copy the error message and
> > paste it into your message. The readers of this list have amazing
> > psychic powers, but you can always help improve the answer quality by
> > providing relevant information.
>
> > > .
> > > def DialogRRHH(self,event):
> > > prog = wx.PySimpleApp(0)
> > > wx.InitAllImageHandlers()
> > > DialogRRHH = MTRRHH(None, -1, "")
> > > prog.SetTopWindow(DialogRRHH)
> > > DialogRRHH.Show()
> > > prog.MainLoop()
>
> > > class MTRRHH(wx.Frame):
> > > ...
> > > if __name__ == "__main__":
> > > app = wx.PySimpleApp(0)
> > > wx.InitAllImageHandlers()
> > > tasques = tasques(None, -1, "")
> > > app.SetTopWindow(tasques)
> > > tasques.Show()
> > > app.MainLoop()
>
> > Unfortunately your code extracts don't tell us what's going wrong, only
> > how the program is constructed. While that *is* useful information, by
> > itself it only paints half the picture.
>
> > regards
> >   Steve
> > --
> > Steve Holden+1 571 484 6266   +1 800 494 3119
> > Holden Web LLC/Ltd  http://www.holdenweb.com
> > Skype: holdenweb  http://del.icio.us/steve.holden
> > --- Asciimercial --
> > Get on the web: Blog, lens and tag the Internet
> > Many services currently offer free registration
> > --- Thank You for Reading -
>
> Hi, the problem is No Error message, but the program continues running
> after I closed it (by the X).

When I open a custom frame from one of my applications, I do something
like this:




def BtnEventHandler(self, event):
frame = myFrame()
frame.Show()






class myFrame(wx.Frame):
def __init__(self, filename=None):
wx.Frame.__init__(self, None, -1, 'Whatever', size=(570,295))
# you can set the OnTop style here
# lots of other code...

def OnClose(self, event):
# Close the frame
self.Close()



If you have additional problems, try mailing the wxPython group, which
you can find here: www.wxpython.org

Mike



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Restarting a Python Application

2007-07-06 Thread kyosohma
On Jul 3, 5:00 pm, Matimus <[EMAIL PROTECTED]> wrote:
> On Jul 3, 2:27 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi,
>
> > I packaged up an application I am developing into an executable. In
> > the application, it has user configurable options. I would like a way
> > to restart the application so that the new options the user chooses
> > can be applied. Firefox can restart itself. Does anyone know how to
> > accomplish this in Python?
>
> > Here is what I tried:
>
> > 
>
> > exePath = os.path.join(os.getcwd(), 'myprogram.exe')
> > subprocess.Popen(exePath)
> > sys.exit()
>
> > 
>
> > This didn't work. It closed the program, but another instance did not
> > appear.
>
> > Tips would be appreciated.
>
> > Mike
>
> You could package your program into a function or class and just
> restart that.
>
> [code]
> # global flag for restart.
> do_restart = False
>
> def main(args=None):
> # program code
> # set do_restart and return to restart
>
> if __name__ == "__main__":
> retval = main()
> while do_restart:
> retval = main()
> sys.exit(retval)
>
> [/code]

Actually I am using wxPython for a GUI front-end. Thus, it is already
in a class. I am not sure how to apply your idea to a program that is
already running in an infinite event loop.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tool for finding external dependencies

2007-07-09 Thread kyosohma
On Jul 8, 8:39 pm, Rob Cakebread <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I need to find external dependencies for modules (not Python standard
> library imports).
>
> Currently I use pylint and manually scan the output, which is very
> nice, or use pylint's --ext-import-graph option to create a .dot file
> and extract the info from it, but either way can take a very long
> time.
>
> I'm aware of Python's modulefinder.py, but it doesn't find external
> dependencies (or at least I don't know how to make it do them).
>
> Thanks,
> Rob

Recently I ran into some debugging issues and the freeware app
"Dependency Walker" was suggested to me. I still haven't used it much
since I only got it last Friday, but it looks promising:
http://www.dependencywalker.com

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython - ListCtrl ColumnSorterMixin sometimes works sometimes doesn't!

2007-07-09 Thread kyosohma
On Jul 7, 7:55 am, Steve Senior <[EMAIL PROTECTED]> wrote:
> Hi,
>
> My application has a tree control in which a user can select a filter.
> This filter is then applied to the results and the results are
> constructed in the ListControl (report style) widget.
>
> This all works fine.
>
> Recently I added the wx.lib.mixins.listctrl.ColumnSorterMixin mixin to
> the ListCtrl widget.
>
> Now here is the problem. On some of the filters you can sort all of the
> columns both ascending and descending - i.e. if you click a column once
> it will sort properly, then if you click the column again it will
> happily reverse the sort.
>
> On some of the filters you can only sort the column once. Repeated
> clicks do not reverse the sort order. I added some print statments to
> the listctrl.py to see what was happening here and it appears that when
> you click the column for the second time, it actually sorts it twice
> which means that the display doesn't change!
>
> This is really perplexing me, I've exhausted all of my options and need
> some help please.
>
> Many Thanks,
> Steve.

It sounds a lot like your program is firing an event twice. What event
are you using to capture the mouse-click? You are much better off
posting wxPython specific questions to the wxPython user's list:
http://www.wxpython.org/maillist.php

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tool for finding external dependencies

2007-07-09 Thread kyosohma
On Jul 9, 9:27 am, Rob Cakebread <[EMAIL PROTECTED]> wrote:
> On Jul 9, 7:17 am, [EMAIL PROTECTED] wrote:
>
>
>
> > Recently I ran into some debugging issues and the freeware app
> > "Dependency Walker" was suggested to me. I still haven't used it much
> > since I only got it last Friday, but it looks 
> > promising:http://www.dependencywalker.com
>
> > Mike
>
> Thanks Mike, but I'm just trying to determine Python imports, like:
>
> $ pylint g_pypi
>
> [snip lots of other tests which take a lonng time]
>
> External dependencies
> -
> ::
>
> configobj (g_pypi.config)
> portage (g_pypi.enamer,g_pypi.portage_utils,g_pypi.cli)
> pkg_resources (g_pypi.cli,g_pypi.ebuild)
> yolk
>   \-pypi (g_pypi.cli)
>   \-setuptools_support (g_pypi.cli)
>   \-yolklib (g_pypi.cli)
> gentoolkit (g_pypi.portage_utils)
> pygments (g_pypi.ebuild)
>   \-lexers (g_pypi.ebuild)
>   \-formatters (g_pypi.ebuild)
> Cheetah
>   \-Template (g_pypi.ebuild)

Hmmm...I also use GUI2Exe, which may help you too. It'll list "missing
modules" and binary dependencies. It's basically a GUI interface to
py2exe:

http://xoomer.alice.it/infinity77/eng/GUI2Exe.html


This looks interesting, but I've never used it:

http://www.tarind.com/depgraph.html


Finally, here's some more info on modulefinder:

http://svn.python.org/projects/python/trunk/Lib/modulefinder.py

Looks like you run modulefinder like this:



mod = modulefinder.ModuleFinder()
mod.run_script(path/to/python_script.py)
mod.report()



Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: no python install

2007-07-09 Thread kyosohma
On Jul 9, 10:26 am, Beethon <[EMAIL PROTECTED]> wrote:
> my computer has no puthon installed
> i downloaded some sofware that are shiped with .py files
> please explain how the programs become workable ?
>
> thanks

Check the softwares' website(s) to see what the dependencies are and
download them. You can download Python at www.python.org.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


ImportError: MemoryLoadLibrary failed loading

2007-07-09 Thread kyosohma
Hi,

Recently I began my journey into creating executables. I am using
Andrea
Gavana's cool GUI2EXE program which works very well and that is a GUI
for
py2ece. I am also using Inno Setup to create a script/executable.
Anyway,
today I am putting the program to the test with some volunteer testers
and
I've hit a wall. On the first tester's PC the program installed
beautifully and runs great. The next tester's PC, the program failed
to
run complaining that MSVCR71.dll didn't exist. I copied that file on
there and now I get the following traceback written to my exe's log
file:

Traceback (most recent call last):
File "reminder.py", line 23, in ?
File "zipextimporter.pyo", line 78, in load_module
File "wx\__init__.pyo", line 45, in ?
File "zipextimporter.pyo", line 78, in load_module
File "wx\_core.pyo", line 4, in ?
File "zipextimporter.pyo", line 91, in load_module
ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd

I see other user's have this issue too sometimes and they talk a lot
about
a "gdiplus.dll" file. My user's PC has that file in 4 places on her
computer and my development PC has it in 6 places. Does either DLL
have to
be in a specific location for the executable to find it? Is this
something
else entirely? I tried sticking the gdiplus.dll file in the directory
my
executable runs from too, but that didn't work either.

I have posted this to the wxPython's group and the py2exe group, but
the latter doesn't have much activity and the wxPython suggestions
didn't work.

Thanks a lot!


Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing python apps

2007-07-09 Thread kyosohma
On Jul 9, 2:59 pm, Robert Dailey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm creating a set of command-line tools using Python. These tools
> manage resources for a game I'm working on. However, many people that
> will be using these tools will not want to install Python on their
> machines. This would be a very tedious process (for first time users
> of my tools).
>
> Ideally, I would like for someone to be able to use my tools without
> having to install Python. For example, if I could put python.exe in a
> hidden folder somewhere in my tools directory, and make a batch file
> that they run to start the tool, python could be executed from a
> relative path in my tools directory. Is this possible? What is an
> ideal way of distributing python apps? I would prefer a transparent
> and user-friendly approach.
>
> Thanks for any tips.

The typical approach is using py2exe:

http://www.py2exe.org/


I use it in conjunction with Inno Setup.

http://www.jrsoftware.org/isinfo.php


GUI2Exe is a GUI interface to py2exe:

http://xoomer.alice.it/infinity77/eng/GUI2Exe.html

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dealing with nested xml within nested xml within......

2007-07-09 Thread kyosohma
On Jul 9, 3:03 pm, Ultrus <[EMAIL PROTECTED]> wrote:
> Hello all,
> I don't need specific examples, but I'm trying to wrap my head around
> parsing xml within xml and even further, not limiting how far someone
> will nest xml. I'm already making great use of BeautifulSoup's
> BeautifulStoneSoup to parse xml, but what do I do if I come across
> something like this?
>
> 
>This is a random response (once parsed)
>
>   
>  This is a random response within a random response
>  
> 
>This is a random response within a random response,
> within another random response
>Like above, this is another random response.
> 
>  
>   
>
> 
>
> Not knowing how far one will nest random responses, how would one
> manage digging into xml like this? Right now I'm thinking about not
> even going there. I would presently write scripts that would parse 3
> or so levels deep, but no further. :P It would make an interesting
> project, like an interactive adventure story.

You'd probably write a function that called itself to parse something
like this. Unfortunately, I am not a recursion expert. You can read up
on it though:

http://www.freenetpages.co.uk/hp/alan.gauld/tutrecur.htm
http://pythonjournal.cognizor.com/pyj2.2/RecursionByAJChung.html

I haven't used Beautiful Soup, but I think you can use lxml or
ElementTree to get a tree object of the XML and then just iterate over
the tree.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding Matplotlib in wxpython wx.Panel problem

2007-07-11 Thread kyosohma
On Jul 10, 2:09 pm, abakshi11 <[EMAIL PROTECTED]> wrote:
> I was wondering if you ever got to create a small GUI program that did plots
> using Matplotlib
> I am gettin an error where its saying "WXagg's accelerator requires the
> wxPython headers-the wxpython header files can not be located in any of the
> standard include directories reported by 'wx-config --cppflags'
> Do you think you can help?
>
>
>
> Soren-3 wrote:
>
> > Hi,
>
> > I'm trying to create a small GUI program where I can do plots using
> > Matplotlib. I've been trying to borrow code from the examples at the
> > matplotlib website, but I can't get it to work.
>
> > I want to be able to create a wx.Panel that contains an axis for
> > plotting. Around it i want other panels containing various settings,
> > buttons etc. to control the plot. So far I can't even get the program
> > to actually show a plot in a panel.
>
> > Does anyone here have experience in making a wxpython GUI with
> > matplotlib?
>
> > Any help would be appreciated!
>
> > Thanks,
> > Soren
>
> > My code shows a frame, and I'm trying to set up two panels.. one with
> > a plot and one with a button.. The plotpanel is just a little square
> > in the corner when I run it.. ???
>
> > My code is as follows:
>
> > import wx
> > import pylab
> > from matplotlib.numerix import arange, sin, cos, pi
> > import matplotlib
>
> > matplotlib.use('WXAgg')
> > from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
> > from matplotlib.backends.backend_wx import NavigationToolbar2Wx
> > from matplotlib.figure import Figure
> > matplotlib.interactive(False)
>
> > class App(wx.App):
>
> > def OnInit(self):
> > self.frame = MainFrame("Autoplotter", (50,60), (700,700))
> > self.frame.Show()
>
> > return True
>
> > class MainFrame(wx.Frame):
>
> > def __init__(self, title, pos, size):
> > wx.Frame.__init__(self, None, -1, title, pos, size)
>
> > pPanel = PlotPanel(self, -1)# Plot panel
>
> > bPanel = ButtonPanel(self, 100,500, (200,100))# button
> > panel
>
> > sizer = wx.BoxSizer(wx.VERTICAL)
>
> > sizer.Add(pPanel,0)
> > sizer.Add(bPanel,0)
>
> > self.SetSizer(sizer)
>
> > class ButtonPanel(wx.Panel):
>
> > def __init__(self, Parent, xPos, yPos, insize):
>
> > pos = (xPos, yPos)
> > wx.Panel.__init__(self, Parent, -1, pos, style =
> > wx.RAISED_BORDER, size = insize)
>
> > button = wx.Button(self, -1, 'HELLO!!', (10,10), (150,50))
>
> > class NoRepaintCanvas(FigureCanvasWxAgg):
> > """We subclass FigureCanvasWxAgg, overriding the _onPaint method,
> > so that
> > the draw method is only called for the first two paint events.
> > After that,
> > the canvas will only be redrawn when it is resized.
> > """
> > def __init__(self, *args, **kwargs):
> > FigureCanvasWxAgg.__init__(self, *args, **kwargs)
> > self._drawn = 0
>
> > def _onPaint(self, evt):
> > """
> > Called when wxPaintEvt is generated
> > """
> > if not self._isRealized:
> > self.realize()
>
> > if self._drawn < 2:
> > self.draw(repaint = False)
> > self._drawn += 1
>
> > self.gui_repaint(drawDC=wx.PaintDC(self))
>
> > class PlotPanel(wx.Panel):
>
> > def __init__(self, parent, id = -1, color = None,\
> >  dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE,
> > **kwargs):
>
> > wx.Panel.__init__(self, parent, id = id, style = style,
> > **kwargs)
>
> > self.figure = Figure(None, dpi)
> > self.canvas = NoRepaintCanvas(self, -1, self.figure)
> > self._resizeflag = True
>
> > self.Bind(wx.EVT_IDLE, self._onIdle)
> > self.Bind(wx.EVT_SIZE, self._onSize)
>
> > self._SetSize()
>
> > def draw(self):   # just draw something!
> > if not hasattr(self, 'subplot'):
> > self.subplot = self.figure.add_subplot(111)
> > theta = arange(0, 45*2*pi, 0.02)
> > rad = (0.8*theta/(2*pi)+1)
> > r = rad*(8 + sin(theta*7+rad/1.8))
> > x = r*cos(theta)
> > y = r*sin(theta)
> > #Now draw it
> > self.subplot.plot(x,y, '-r')
>
> > def _onSize(self, event):
> > self._resizeflag = True
>
> > def _onIdle(self, evt):
> >  if self._resizeflag:
> >  self._resizeflag = False
> >  self._SetSize()
> >  self.draw()
>
> > def _SetSize(self, pixels = None):
> > """
> > This method can be called to force the Plot to be a desired
> > size, which defaults to
> > the ClientSize of the panel
> > """
> > if not pixels:
> > pixels = self.GetClientSize()
> > self.canvas.SetSize(pixels)
> > self.figure.set_figsize_inches(pixels[0]/
> > self.figure.get_dpi(),
> > pixels[1]/self.figure.get_

Re: ImportError: MemoryLoadLibrary failed loading

2007-07-11 Thread kyosohma
On Jul 9, 12:47 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> Recently I began my journey into creating executables. I am using
> Andrea
> Gavana's cool GUI2EXE program which works very well and that is a GUI
> for
> py2ece. I am also using Inno Setup to create a script/executable.
> Anyway,
> today I am putting the program to the test with some volunteer testers
> and
> I've hit a wall. On the first tester's PC the program installed
> beautifully and runs great. The next tester's PC, the program failed
> to
> run complaining that MSVCR71.dll didn't exist. I copied that file on
> there and now I get the following traceback written to my exe's log
> file:
>
> Traceback (most recent call last):
> File "reminder.py", line 23, in ?
> File "zipextimporter.pyo", line 78, in load_module
> File "wx\__init__.pyo", line 45, in ?
> File "zipextimporter.pyo", line 78, in load_module
> File "wx\_core.pyo", line 4, in ?
> File "zipextimporter.pyo", line 91, in load_module
> ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd
>
> I see other user's have this issue too sometimes and they talk a lot
> about
> a "gdiplus.dll" file. My user's PC has that file in 4 places on her
> computer and my development PC has it in 6 places. Does either DLL
> have to
> be in a specific location for the executable to find it? Is this
> something
> else entirely? I tried sticking the gdiplus.dll file in the directory
> my
> executable runs from too, but that didn't work either.
>
> I have posted this to the wxPython's group and the py2exe group, but
> the latter doesn't have much activity and the wxPython suggestions
> didn't work.
>
> Thanks a lot!
>
> Mike

I figured this out, not that anyone probably cares. It seems the
program was looking for MSVCP71.dll, but I (alas) included the
MSVCR71.dll instead. If I include the correct file, it works. For all
the newbs out there, spelling makes a difference!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lists in classes

2007-07-12 Thread kyosohma
On Jul 12, 10:23 am, Jeremy  Lynch <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Learning python from a c++ background. Very confused about this:
>
> 
> class jeremy:
> list=[]
> def additem(self):
> self.list.append("hi")
> return
>
> temp = jeremy()
> temp.additem()
> temp.additem()
> print temp.list
>
> temp2 = jeremy()
> print temp2.list
> ==
> The output gives:
> ['hi','hi']
> ['hi','hi']
>
> Why does adding items to one instance produce items in a separate
> instance? Doesn't each instance of jeremy have its' own "list"?
>
> Many thanks for clearing up this newbie confusion.
>
> Jeremy.

The reason it works like that is that your variable "list" isn't an
instance variable per se. Instead, you should have it like this:



class jeremy:
def __init__(self):
self.lst=[]
def additem(self):
self.lst.append("hi")
return



Now it works as expected. It's some kind of scope issue, but I can't
explain it adequately.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx.App console window [Windows]

2007-07-12 Thread kyosohma
On Jul 12, 3:44 pm, [EMAIL PROTECTED] wrote:
> Hi All,
>
> I'm looking for a way to  hide console window created by wx.App class.
>
> examplary code below:
>
> import wx
>
> class Gui(wx.App):
> def __init__(self, *pargs, **kwargs):
> wx.App.__init__(self, *pargs, **kwargs)
>
> if __name__ == "__main__":
> app = Gui()
> app.MainLoop()
>
> produces a blank console window (than dies).
>
> What shall I do to make wx.App run without raising console window?
>
> thanks in advance

Save the file as a *.pyw. And I would recommend adding the following 2
lines to your __init__ :



frame = wx.Frame(None, wx.ID_ANY, title='My Title')
frame.Show()



Maybe even stick in a panel object for that matter.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx.App console window [Windows]

2007-07-12 Thread kyosohma
On Jul 12, 5:55 pm, [EMAIL PROTECTED] wrote:
> On 13 Lip, 00:28, [EMAIL PROTECTED] wrote:
>
>
>
> > On Jul 12, 3:44 pm, [EMAIL PROTECTED] wrote:
>
> > > Hi All,
>
> > > I'm looking for a way to  hide console window created by wx.App class.
>
> > > examplary code below:
>
> > > import wx
>
> > > class Gui(wx.App):
> > > def __init__(self, *pargs, **kwargs):
> > > wx.App.__init__(self, *pargs, **kwargs)
>
> > > if __name__ == "__main__":
> > > app = Gui()
> > > app.MainLoop()
>
> > > produces a blank console window (than dies).
>
> > > What shall I do to make wx.App run without raising console window?
>
> > > thanks in advance
>
> > Save the file as a *.pyw. And I would recommend adding the following 2
> > lines to your __init__ :
>
> > 
>
> > frame = wx.Frame(None, wx.ID_ANY, title='My Title')
> > frame.Show()
>
> > 
>
> > Maybe even stick in a panel object for that matter.
>
> > Mike
>
> Thank you Mike, *.pyw made the first part of the trick just perfectly.
> Thanks to your answer I was able to ask google proper question
> concerning second part. Below (for possible future readers) I attach
> solution I found:
>
> People looking for possibility of running wx.App no console version
> after py2exe compilation:
> in setup script change 'console = ['foo.py']' for 'windows = ['foo.py']

I like the GUI interface to py2exe that I found here:
http://xoomer.alice.it/infinity77/eng/GUI2Exe.html

Quite handy.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scripts into wxPython

2007-07-13 Thread kyosohma
On Jul 13, 7:39 am, justme <[EMAIL PROTECTED]> wrote:
> Hello
>
> I've been happily scripting away for the last few years (Matlab, now
> Python) and all has been fine. Now I find myself scripting up code for
> clients, but they all want a nice GUI. I've had a tinker with wxPython
> and it all seems standard enough but I was wondering if anyone has any
> comments about how easy it is to shoehorn some fairly complex scripts
> into a GUI so that non-scripters can use the code. I assume I'll need
> to recode up all the input outputs?
>
> Any thoughts, or should I have started GUI programming right at the
> outset!
>
> Cheers

Yup! To get the inputs, you'll have to redo them in wxPython. But it's
not a big deal. If you're outputs are print statements than you can
just redirect stdout to a textctrl in wxPython and you won't need to
do too much there. Most of the backend complex stuff won't need any
changing or very little as long as it was written in a refactored /
stand-alone fashion.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help reading cookie values

2007-07-13 Thread kyosohma
On Jul 13, 3:08 pm, Sean <[EMAIL PROTECTED]> wrote:
> I am trying to read a cookie I set but I am not sure if I really set
> it correctly or I am not reading it correctly.  I was given the
> following instructions to set the cookie.  It appears to be working
> because in Firefox browser I see the cookie listed for my domain
>
> > you set a cookie in a pythonscript like:
> > context.REQUEST.RESPONSE.setCookie('cookie_name', 'some value',
> > expires=(DateTime() + 365).toZone('GMT').rfc822(), path='/')
>
>  I have been searching everywhere to find information on reading the
> cookie value that I set.  I used the following code I found which
> returns 'no cookiez' in spite of the fact that I see the cookie in my
> browser's cookie listing.  I must be doing something wrong in the way
> I am testing for its existence
>
> import Cookie
> import os
> thiscookie = Cookie.SimpleCookie()
>
> if 'HTTP_COOKIE' in os.environ:
> #if os.environ.has_key('HTTP_COOKIE'): I tried this way also
>
> thiscookie.load(os.environ['HTTP_COOKIE'])
>
> a_code = thiscookie['my_cookie'].value
>
> return a_code
>
> else:
>
> return 'no cookiez'

This site looks like it has some good information on Cookie handling
(see "cookielib and ClientCookie Example" section:
http://www.voidspace.org.uk/python/recipebook.shtml

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access Denied while trying to delete file from python script

2007-07-14 Thread kyosohma
On Jul 14, 3:39 am, "Viewer T." <[EMAIL PROTECTED]> wrote:
> I am trying to write a script that deletes certain files based on
> certain criteria.
>
> What I am trying to do is to automate the process of deleting certain
> malware files that disguise themselves as system files and hidden
> files. When I use os.remove() after importing the os module is raises
> a Windows Error: Access denied probably because the files have
> disguised themselves as system files. Is there anway to get adequate
> privileges under windows to be able to delete system files from within
> a python script. I know it is probably a windows security feature but
> is there anyway to gain such privileges.

You'll need to use the PyWin32 package (AKA win32all). There's a
win32security module. These links might help:

http://mail.python.org/pipermail/python-list/2006-February/367441.html
http://www.thescripts.com/forum/thread28850.html
http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/pywin32/Windows_NT_Files_.2d.2d_Locking.html

Sometimes you can beat windows over the head using its own delete
commands:

os.system('DEL /F /S /Q "%s"' % item)
os.system(r'RD /S /Q "%s"' % item)

I know there's a cookbook recipe on it, but I can't seem to find it
right now. Hopefully this will help you some though.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting text inside the HTML tag

2007-07-14 Thread kyosohma
On Jul 14, 12:47 pm, Nikola Skoric <[EMAIL PROTECTED]> wrote:
> I'm using sgmllib.SGMLParser to parse HTML. I have successfuly parsed start
> tags by implementing start_something method. But, now I have to fetch the
> string inside the start tag and end tag too. I have been reading through
> SGMLParser documentation, but just can't figure that out... can somebody
> help? :-)
>
> --
> "Now the storm has passed over me
> I'm left to drift on a dead calm sea
> And watch her forever through the cracks in the beams
> Nailed across the doorways of the bedrooms of my dreams"

Oi! Try Beautiful Soup instead. That seems to be the defacto HTML
parser for Python:

http://www.crummy.com/software/BeautifulSoup/

You might find the minidom or lxml modules to your liking as well.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Technology solutions for Ruby?

2007-07-16 Thread kyosohma
On Jul 16, 1:46 pm, vasudevram <[EMAIL PROTECTED]> wrote:
> On Jul 16, 10:25 pm, vasudevram <[EMAIL PROTECTED]> wrote:
>
>
>
> > [ Though the OP posted his message to comp.lang.ruby, I'm cross-
> > posting it to comp.lang.python, since he mentions Python as a possible
> > alternative he's looking at, and also because I've recommended Python
> > for his stated needs. Also, interested to see what other Pythonistas
> > have to say in response to my reply.
> >  - Vasudev]
>
> > > On Jul 16, 2007, at 2:21 AM, Michael Reiland wrote:
> > > At the heart of the issue is the fact that I refuse to use Java for this
>
> > project, I prefer not to use .Net because of the portability issues,
> > and
> > I'd like to get away from C++ for obvious reasons.
>
> > > To me this means Ruby, Python, or, as mentioned above, Perl.  If anyone
>
> > can tell me of a way to meet the above requirements in either Python
> > or
> > Perl, I'm all ears (I just prefer Ruby).
>
> > Yes, I think it would be really great for the Ruby community and for
> > the growth of the language if wxRuby was more mature as a GUI toolkit.
> > (Not knocking the wxRuby developers at all, its great that they've
> > even done what they have - I know that creating other language (like
> > Ruby) bindings to a C++ lib is a non-trivial task).
>
> > My suggestion: Python + wxPython + Python DBI + (Py2Exe + InnoSetup)
> > *might* meet all your needs. (As with any decision about what software
> > technologies to use, you'll have to evaluate the suggested options to
> > see if they fit your needs.)
>
> > Note: I've used and like both Ruby and Python (saying this after using
> > many, though not all, language features and libraries of both
> > languages), and am not trying to discourage you from using Ruby for
> > your needs; its just that, based on your needs as described, it looks
> > to me as if Python meets them better than Ruby at present:
>
> > > 1. GUI - Native Look and Feel.  According to wxRuby the bindings aren't
>
> > mature enough for production use.  Does anyone have any experience
> > with
> > this and/or can you offer alternatives that provide a native look and
> > feel (I
>
> > I don't know enough about wxRuby to comment.
>
> > wxPython has this (Native Look and Feel), I think (used it some, a
> > while ago), not 100% sure, you can check on the site  - 
> > http:/www.wxpython.org
> >  - to make sure. The site does say that it is cross-platform:
>
> > "wxPython is a cross-platform toolkit. This means that the same
> > program will run on multiple platforms without modification. Currently
> > supported platforms are 32-bit Microsoft Windows, most Unix or unix-
> > like systems, and Macintosh OS X.
> > "
>
> > but that doesn't necessarily mean that it will have native look and
> > feel on all supported platforms. (The two are not the same thing.)
> > That's why you will need to check.
>
> > wxPython pros: Its fairly easy to learn, at least for simple GUI apps
> > (e.g. a few widgets / controls and a file dialog or two). I was able
> > to build these simple ones - see the code, article and screenshots
> > available here (or from links from here):
>
> >http://www.packtpub.com/article/Using_xtopdf
>
> > - in quite a short time, starting from zero knowledge of wxPython (I
> > did know some Python from before), just by looking at the sample apps,
> > and some reading of the docs.
>
> > See the quotes about wxPython:http://www.wxpython.org/quotes.php
>
> > >2. Databases - contemplating using ActiveRecord, but I would like to use
>
> > ODBC to support multiple types of DB's in a uniform way (if you know
> > of
> > alternatives to ODBC or ActiveRecord, please let me know).
>
> > I think, but again, not sure, that Python DBI + appropriate database
> > drivers, may meet this need. Basically Python DBI is similar to ODBC
> > (roughly), and to Perl DBI + DBD, as I understand. There's also ODBC
> > support in the Win32 extensions package for Python - IIRC, Google for
> > 'win32all' to get it. Its also available as a link from the Python for
> > Win32 MSI installer on python.org.
> > I've used Python ODBC some, it works and is easy to use.
> > See this for a simple example:
>
> >http://jugad.livejournal.com/2006/07/07/
>
> > (See the second post at that page, titled "Publishing ODBC database
> > content as PDF
> > ". The code shown in the post is not indented as per proper the Python
> > syntax (LiveJournal messed up the indentation), sorry about that, but
> > its trivial to correct if you know Python indenting rules). Also read
> > the Python ODBC docs and examples, of course.
>
> > >3. Binary - Are there any utilities for compiling Ruby into a binary
>
> > executable?  The issue is twofold, speed, and not handing the
> > customer
> > the source :)
>
> > For Python, there is py2exe (for Windows only). I used py2exe recently
> > and it works well enough for the simple cases that I tried. (I tried
> > building EXEs for a simple Python hello-world program, and for a
> > 

Re: wxPython, searching, and threads

2007-07-19 Thread kyosohma
On Jul 18, 11:38 am, Benjamin <[EMAIL PROTECTED]> wrote:
> Hello! I am writing a search engine with wxPython as the GUI. As the
> search thread returns items, it adds them to a Queue which is picked
> up by the main GUI thread calling itself recursively with
> wx.CallAfter. These are then added to a ListCtrl. This works fine for
> small searches, but with larger and longer searchs the GUI is clogged
> and won't respond. I suspect (I may be wrong) that there are so many
> results being sent to the ListCtrl that the event loop doesn't have
> time to respond to events. I've tried buffering the results before
> sending them to the GIU, but that doesn't help at all. Please advise.

The standard wxPython user's group reply to a question like this is,
check out http://wiki.wxpython.org/LongRunningTasks. I've used a
variation of what's on this page to create a fairly complex installer
than keeps a textctrl updated with its progress. Since the installer
runs for almost an hour, I think this method works great.

Admittedly, you work with threads, which is intimidating to some
degree and if you use WMI, then you'll need to use some special
commands to make it work in a thread.

The wxPython mailing list is here: http://www.wxpython.org/maillist.php

Hope that helps.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Posted messages not appearing in this group

2007-07-19 Thread kyosohma
On Jul 18, 5:50 am, Alex Popescu <[EMAIL PROTECTED]>
wrote:
> Sanjay  gmail.com> writes:
>
>
>
> > Hi All,
>
> > I tried posting in this group twice since last week, but the messages
> > did not appear in the forum. Don't know why. Trying this message
> > again...
>
> > Sanjay
>
> Something similar seemed to happen to me too, but when checking with gmane 
> I've
> noticed that all my posts got in (and now I am trying to figure out how can I
> apologize for multiple posts :-) ).
>
> bests,
> ./alex
> --
> .w( the_mindstorm )p.

If you use google groups to post, then it's something to do with
Google. It seems to be having some serious issues this week. And I've
had it not post my posts before even though it ended up on gmane.
Google seems to forward the message, but it does a lousy job updating
itself of late.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Real-time Update

2007-07-19 Thread kyosohma
On Jul 18, 3:24 am, ReTrY <[EMAIL PROTECTED]> wrote:
> I'm writing a program with Tkinter GUI, When the program is running it
> need to be updated every five seconds (data comes from internet). How
> should I do that ? How to make a function in main loop ?

I'm pretty sure the book "Programming Python 3rd Ed." by Lutz covers
this stuff in detail. I think it mentions using threads for this sort
of thing. The wxPython wiki has a good example that I think you could
adapt for Tkinter. Just use the threading code and wrap it in your
Tkinter code and I think you'll be good to go. Here's the link:
http://www.wxpython.org/maillist.php

Good luck,

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Real-time Update

2007-07-19 Thread kyosohma
On Jul 18, 4:43 pm, [EMAIL PROTECTED] (Aahz) wrote:
> In article <[EMAIL PROTECTED]>,
>
> ReTrY  <[EMAIL PROTECTED]> wrote:
>
> >I'm writing a program with Tkinter GUI, When the program is running it
> >need to be updated every five seconds (data comes from internet). How
> >should I do that ? How to make a function in main loop ?
>
> See the Tkinter example from my threads tutorial on my website.
> --
> Aahz ([EMAIL PROTECTED])   <*>http://www.pythoncraft.com/
>
> I support the RKAB

There's also a good example on the wxPython wiki dealing with threads
that you should be able to adapt to Tkinter.

http://wiki.wxpython.org/LongRunningTasks

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython, searching, and threads

2007-07-19 Thread kyosohma
On Jul 18, 3:15 pm, Benjamin <[EMAIL PROTECTED]> wrote:
> Hello! I am writing a search engine with wxPython as the GUI. As the
> search thread returns items, it adds them to a Queue which is picked
> up by the main GUI thread calling itself recursively with
> wx.CallAfter. These are then added to a ListCtrl. This works fine for
> small searches, but with larger and longer searchs the GUI is clogged
> and won't respond. I suspect (I may be wrong) that there are so many
> results being sent to the ListCtrl that the event loop doesn't have
> time to respond to events. I've tried buffering the results before
> sending them to the GIU, but that doesn't help at all. Please advise.

I think what you need to look at is http://wiki.wxpython.org/LongRunningTasks

That's what the people on the wxPython list usually recommend when
doing what you're doing. I've used the techniques there and they work
great!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Python MAPI

2007-07-20 Thread kyosohma
Hi,

I've been googling all over and can't find any good answers about this
problem. I would like to create some kind of MAPI interface with
Python such that when I open Microsoft Word (or another Office
program) and click File, Send To, Mail Recipient it opens a program I
wrote in Python and uses it to send the email rather than Outlook.

The closest I've come is finding the registry key HKLM\Software\Clients
\Mail which seems to control the default email client. I did figure
out how to redirect mailto directives on websites to my program
successfully, but this is a whole 'nother ballgame.

Any suggestions are welcome. I am considering writing some VBA hooks
in Office Apps in question, but would prefer to avoid that.

Thanks!

Mike

P.S. Currently using Python 2.4, wxPython 2.8.3 (for GUI) on Windows
XP Pro.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python MAPI

2007-07-20 Thread kyosohma
On Jul 20, 1:48 pm, vasudevram <[EMAIL PROTECTED]> wrote:
> On Jul 20, 10:57 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi,
>
> > I've been googling all over and can't find any good answers about this
> > problem. I would like to create some kind of MAPI interface with
> > Python such that when I open Microsoft Word (or another Office
> > program) and click File, Send To, Mail Recipient it opens a program I
> > wrote in Python and uses it to send the email rather than Outlook.
>
> > The closest I've come is finding the registry key HKLM\Software\Clients
> > \Mail which seems to control the default email client. I did figure
> > out how to redirect mailto directives on websites to my program
> > successfully, but this is a whole 'nother ballgame.
>
> > Any suggestions are welcome. I am considering writing some VBA hooks
> > in Office Apps in question, but would prefer to avoid that.
>
> > Thanks!
>
> > Mike
>
> > P.S. Currently using Python 2.4, wxPython 2.8.3 (for GUI) on Windows
> > XP Pro.
>
> Hi,
>
> 1: I don't know much about Windows APIs, but am currently reading the
> "Windows Internals" book. Got this idea from it:
>
> Go tohttp://www.microsoft.com/technet/sysinternals/default.mspx
> and check out the SysInternals utilities there. The book says that you
> can use some of them to "spy" on what an app is doing - what registry
> keys it is reading/writing, lots of other OS-level calls it makes as
> it runs. Digging around and using some of these utilities to check out
> what an Office app does when you use it to send mail, might help you
> figure out a way to do what you want.
>
> 2. Try looking for registry entries specific to Office Apps, and look
> under those subtrees for likely email-related entries to modify (if
> you haven't tried that already). I guess you already know that
> fiddling with the registry can be risky and can crash your system, so
> take backups, etc.
>
> Using COM via Python may also help - again, some digging required. You
> probably already have the PyWin32 Python extensions for Windows COM
> (earlier called win32all - seehttp://wiki.python.org/moin/Win32All) -
> if not, its available here:
>
> http://www.python.org/download/releases/2.4.4/
> (scroll down the page for the link)
>
> Vasudev Ramwww.dancingbison.com
> jugad.livejournal.com
> sourceforge.net/projects/xtopdf

Thanks for the ideas...I am already monitoring the registry to see
what happens when I switch between two email clients. In this case, I
am switching between Outlook 2003 and Thunderbird 2. The pertinent
registry files are as follows:

# changes which email client to use
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]

# obviously changes the .eml file association
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.eml]

# haven't the fogiest idea what this does, if anything
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{29F458BE-8866-11D5-
A3DD-00B0D0F3BAA7}]

# change mailto functionality
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\DefaultIcon]
@="C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe,0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command]
@="\"C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe\" -osint -
compose \"%1\""

I assume you're referring to "Process Monitor", which is a really cool
tool. Maybe it'll help, but I usually can't get it to filter out
enough of the noise to make the output useful. I'll give it a go
nonethless.

I am running all my tests in a VM, so I really don't care if the
registry gets hosed at this point.

Thanks again,

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python MAPI

2007-07-20 Thread kyosohma

>
> If Process Monitor has an option to save its output as text files /
> CSV files (some of the other SysInternals tools do), you might want to
> try using (a Windows version) of grep or awk to filter out the
> noise ..
>
> Vasudev

Well, I ran Process Monitor with some filters enabled to only watch
Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?

Explorer.exe and outlook express do thousands of the registry calls
and the paths they manipulate vary wildly. Oh well, I'll be off the
clock in about 15 minutes so it can wait until Monday.

Thanks for your help. I'll post if I figure out anything...hopefully
you'll do the same.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Images in Tkinter

2007-07-20 Thread kyosohma
On Jul 20, 11:37 am, "Viewer T." <[EMAIL PROTECTED]> wrote:
> I wrote a class in which I have to use Tkinter images. When I create
> an image object in the class and reference it with the image attribute
> of label within the class, it does not dhow the image. It just shows a
> blank label that conforms to the size of the image. My images is a GIF
> image.
>
> My code takes the form:
> class Login:
>  def __init__(self):
>   create image object and other things necessary for class
> initialisation
>   self.make_widgets
>  def make_widgets(self):
>   Then I create my widgets
>
> Then, I instantiate the login class.
>
> I use Python 2.5. Does anyone have any idea why my imae does not
> diplay itself? I have tried using the image before outside a class and
> it works! Also, I tried creating the image object outside class but it
> gives a runtime error saying it is too early to create an image
> object. Please help!

This might be the problem: 
http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: win32com ppt embedded object numbers reverting back to original numbers

2007-07-20 Thread kyosohma
On Jul 19, 4:33 pm, Lance Hoffmeyer <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I have a script that takes numbers from XL and inserts them into an embedded
> MSGRAPH dataset in PPT.  The problem is that when I reopen the modified 
> document
> that has been saved as a new filename and activate the embedded datasheet the
> new numbers that were inserted disappear and the old, original numbers come 
> back?
>
> I thought that adding these lines and resetting these variables was supposed 
> to prevent
> this from happening?
>
> del oGraph
> del PWB
> del oHEADER
> del oVALUE
>
> Anyone had experience with this and know what I need to do to keep the 
> embedded datasheet
> from reverting back to it's original numbers after modification?
>
> Thanks in advance,
>
> Lance
>
> #
> #
> # ADD THIS INTO A MODULE IN PPT TO OBTAIN THE PROG ID OF A SLIDE
> #Sub test()
> #MsgBox "The Slide ID of the current slide is:" & _
> #   ActiveWindow.View.Slide.SlideID
> #End Sub
> #
> def attributesbyID(row,base,slideID,spreadsheet):
> sh = wb.Worksheets (spreadsheet)
> sh.Select()
> LIST = xlparams(row, base)
>  POWERPOINT SECTION ##
> for shape in WB.Slides.FindBySlideID(slideID).Shapes:
> if (shape.Type== 7):
> for oXLROW,oXLBASE,oXLLASTCOL,oPPTCELL,oPPTHEADERCELL 
> in LIST:
> oVALUE = sh.Cells(oXLROW,oXLLASTCOL).Value
> oHEADER = sh.Cells(base-1,oXLLASTCOL).Value  
> + " (n="  +  str(int(sh.Cells(oXLBASE,oXLLASTCOL).Value))  + ")"
> PWB = 
> WB.Slides.FindBySlideID(slideID).Shapes(shape.Name)
> oGraph = PWB.OLEFormat.Object
> 
> oGraph.Application.datasheet.Range(oPPTCELL).Value = oVALUE
> 
> oGraph.Application.datasheet.Range(oPPTHEADERCELL).Value = oHEADER
> oGraph.Application.datasheet.Font.Bold=False
> del oGraph
> del PWB
> del oHEADER
> del oVALUE
> ###
> #
> #
> #
>
> def xlparams(row, base):
> lastcol=LASTCOL
> ### EXCEL SECTION TO GET NUMBERS #
> 
> thelist=((row,base,lastcol,"A13","013"),(row,base,lastcol-1,"A14","014"),(row,base,lastcol-2,"A15","015"),(row,base,lastcol-3,"A16","016"),
>   
> (row+20,base+20,lastcol,"A9","09"),(row+20,base+20,lastcol-1,"A10","010"),(row+20,base+20,lastcol-2,"A11","011"),(row+20,base+20,lastcol-3,"A12","012"),
>   
> (row+40,base+40,lastcol,"A5","05"),(row+40,base+40,lastcol-1,"A6","06" ), 
> (row+40,base+40,lastcol-2,"A7","07" ), (row+40,base+40,lastcol-3,"A8","08" ),
>   
> (row+60,base+60,lastcol,"A1","01"),(row+60,base+60,lastcol-1,"A2","02" ), 
> (row+60,base+60,lastcol-2,"A3","03" ), (row+60,base+60,lastcol-3,"A4","04" ))
> ##
> return thelist
>
> ## attribute(ROW NUMBER, BASE ROW NUMBER, SLIDE NUMBER)
> attributesbyID(14,12,839,"Attributes(116-144)") # This medication has a 
> convenient dosing frequency

I've never done this with Python, but it sounds like your inserting a
linked table rather than a copy of the dataset as an Excel worksheet.
Try doing the insert manually to see which way keeps the data the way
you want, then you'll probably gain insight into what you need to do
in Python.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter canvas

2007-04-18 Thread kyosohma
On Apr 18, 3:43 pm, Gigs_ <[EMAIL PROTECTED]> wrote:
> how to write text on canvas. i know that i need to use canvas.create_text, but
> how to write text than when i create_text?
> or how to access object ID in canvas and change some options?
>
> thanks in advance!

All you need to do is canvas.create_text(x, y, text='Hello World')
where x and y are coordinates on the canvas. You can also add fg and/
or bg to set foreground and background colors, respectively.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using tkinter to display html

2007-04-19 Thread kyosohma
On Apr 19, 6:29 am, "Stephen M. Gava" <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> I prefer using tkinter to wxpython (so sue me :) and i need to display a
> lot of html in a particular app. does anyone know if one of the existing
> add on tk html widgets have been wrapped for tkinter already?
>
> TIA for any reply,
> Stephen

The following thread has various ideas in it:
http://mail.python.org/pipermail/python-list/2001-October/107989.html

I know wxpython has widgets specifically made to display html or even
wrap Internet Explorer, ActiveX and more.

Good luck!

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter canvas

2007-04-19 Thread kyosohma
On Apr 19, 7:24 am, Gigs_ <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Apr 18, 3:43 pm, Gigs_ <[EMAIL PROTECTED]> wrote:
> >> how to write text on canvas. i know that i need to use canvas.create_text, 
> >> but
> >> how to write text than when i create_text?
> >> or how to access object ID in canvas and change some options?
>
> >> thanks in advance!
>
> > All you need to do is canvas.create_text(x, y, text='Hello World')
> > where x and y are coordinates on the canvas. You can also add fg and/
> > or bg to set foreground and background colors, respectively.
>
> > Mike
>
> but is there any option to bind event?
> when i create text i want to write in text box on canvas so i think that i 
> need
> to bind event

I'm not sure what you mean. Do you want to type your text into a
textbox and as you type, you want it displayed on the canvas itself as
well? If that is the case, then yes, you'll need to bind an event. If
you just want to type text in a textbox that is on a canvas, the
textbox widget takes care of everything and binding an event is
unnecessary.

Here is some info on events:

http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm
http://www.builderau.com.au/program/print.htm?TYPE=story&AT=339272995-339024614t-32000c
http://www.bembry.org/technology/python/notes/tkinter_3.php

Hope that points you in the right direction.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Relative import problem

2007-04-19 Thread kyosohma
On Apr 19, 11:54 am, "Jorgen Bodde" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I want to structure my app so that I have two dirs like;
>
> obj/{object files}
>
> gui/{gui files}
>
> Here comes the catch. From the GUI dir, I would like to access the obj
> submodule path. I need to go one dir back.. I read there was something
> like from .. import x in python 2.5 so that I could access my obj dir
> from a lower level, but I have problems getting this to work.
>
> Example;
>
> In the main dir I have;
>
> main.py:
> 
> import gui
>
> gui.gui.startme()
> 
>
> In the obj dir I have;
>
> obj/obj.py
> -
>
> def start():
> print 'Started OBJ'
> -
>
> In the GUI dir I have
>
> gui/gui.py
> -
> from .. import obj
>
> def start():
> obj.obj.start()
> -
>
> This does not work. It gives me;
>
> D:\personal\src\GuitarPortfolio\tmp>python start.py
> Traceback (most recent call last):
>   File "start.py", line 4, in 
> gui.gui.start()
> AttributeError: 'module' object has no attribute 'gui'
>
> Am I shooting myself in the foot by trying to structure? Or are there
> better more elegant ways?
>
> Regards,
> - Jorgen

I'm not finding much info on this subject. But here's the most
interesting links I've found as of yet:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456362
http://www.thescripts.com/forum/thread549516.html
http://www.thescripts.com/forum/thread42319.html
http://docs.python.org/tut/node8.html

Dunno if any of these will help you though. Sorry.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and how to return text entry to main program?

2007-04-19 Thread kyosohma
On Apr 19, 2:38 pm, Tyler <[EMAIL PROTECTED]> wrote:
> Hello All:
>
> I am currently working on a project to create an FEM model for school.
> I was thinking about using wxPython to gather the 12 input variables
> from the user, then, after pressing the "Run" button, the GUI would
> close, and the 12 input variables would then be available for the rest
> of the program.
>
> So far, what I have been able to do is mostly a reverse engineering
> job to get the frame to look right and return the text variable to a
> dialog box.
>
> I have read about a "redirect" that could be used to send the values
> to a file. But, then I would have to open the file and read in the
> data from there. This seems crude and lacking elegance.
>
> Any help on how to get the program to output the data back to the main
> python program and close when I press submit? My apologies if this is
> something of a simple question, but I have only started in on wxPython
> about a week ago, and Python this term.
>
> The codes I am using are below.
>
> Any help (or suggested reading material) is greatly appreciated.
>
> Cheers,
>
> t.
>
> MY MAIN PROGRAM
>
> #!/usr/bin/env python
> import femGUI
> app = femGUI.MyApp(False)
> dlg = femGUI.FemInput()
> dlg.Destroy()
> app.MainLoop()
>
> # Then do something with inputs here
>
> THE FEMINPUT GUI CLASS
>
> import wx
>
> class FemInput(wx.Frame):
> def __init__(self):
> wx.Frame.__init__(self, None, -1, "Options Input Interface")
> panel = wx.Panel(self)
>
> # First create the controls
>
> # Title
> topLbl = wx.StaticText(panel, -1, "FEM 2D Basket Put Option
> ",size=(420,-1))
> topLbl.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
>
> # S1 lower and upper bounds for grid
> s1label = wx.StaticText(panel, -1, "S1 Low , S2 Low: ",
> size=(220,-1))
> self.s1lower = wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.s2lower = wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # S2 lower and upper bounds for grid
> s2label = wx.StaticText(panel, -1, "S1 High, S2 High: ",
> size=(220,-1))
> self.s1upper = wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.s2upper = wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # S1 and S2 volatility
> vlabel = wx.StaticText(panel, -1, "S1 Volatility, S2
> Volatility: ", size=(220,-1))
> self.v1vol  = wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.v2vol  = wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # Risk free rate and correlation
> prlabel = wx.StaticText(panel, -1, "Interest Rate,
> Correlation: ", size=(220,-1))
> self.risk= wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.corr= wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # Strike and Exercise Date
> kTlabel = wx.StaticText(panel, -1, "Srike Price, Exercise
> Date: ", size=(220,-1))
> self.strike= wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.finalT= wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # deltaT and deltaX
> dTXlabel = wx.StaticText(panel, -1, "delta T, delta X: ",
> size=(220,-1))
> self.deltaT= wx.TextCtrl(panel, -1, "", size=(100,-1));
> self.deltaX= wx.TextCtrl(panel, -1, "", size=(100,-1));
>
> # Execute program
> runBtn = wx.Button(panel, -1, "Run")
> self.Bind(wx.EVT_BUTTON, self.OnSubmit, runBtn)
>
> # Now do the layout.
>
> # mainSizer is the top-level one that manages everything
> mainSizer = wx.BoxSizer(wx.VERTICAL)
> mainSizer.Add(topLbl, 0, wx.ALL, 5)
> mainSizer.Add(wx.StaticLine(panel), 0,
> wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
>
> # femSizer is a grid that holds all of the address info
> femSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
> femSizer.AddGrowableCol(1)
>
> # S1 and S2 LOWER label
> femSizer.Add(s1label, 0,
> wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
> # the lower and upper S1 bounds are in a sub-sizer
> s1Sizer = wx.BoxSizer(wx.HORIZONTAL)
> s1Sizer.Add(self.s1lower, 1)
> s1Sizer.Add((10,10)) # some empty space
> s1Sizer.Add(self.s2lower, 1, wx.LEFT|wx.RIGHT, 5)
> femSizer.Add(s1Sizer, 1, wx.EXPAND)
>
> # S1 and S2 HIGH label
> femSizer.Add(s2label, 0,
> wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
> # the lower and upper S1 bounds are in a sub-sizer
> s2Sizer = wx.BoxSizer(wx.HORIZONTAL)
> s2Sizer.Add(self.s1upper, 1)
> s2Sizer.Add((10,10)) # some empty space
> s2Sizer.Add(self.s2upper, 1, wx.LEFT|wx.RIGHT, 5)
> femSizer.Add(s2Sizer, 1, wx.EXPAND)
>
> # Volatility label
> femSizer.Add(vlabel, 0,
> wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
> # the lower and upper S1 bounds are in a sub-sizer
> volSizer =

  1   2   3   4   5   6   7   8   >