Problem with difflib SequenceMatcher

2016-09-12 Thread Jay
Hello

I am having an odd problem with difflib.SequenceMatcher. Sample code below:

The strings "src" and "trg" differ only a little. The
SequenceMatcher.ratio() for these strings 0.0. Many other similar
strings are working fine without problems (see below) with non-zero
ratios depending on how much difference there is between strings (as
expected).

Tested on Python 2.7 on Ubuntu 14.04

Program follows:
---
from difflib import SequenceMatcher as SM

src = u"N KPT T HS KMNST KNFKXNS AS H KLT FR 0 ALMNXN AF PRFT PRPRT AN
RRL ARS T P RPLST P KMNS H ASTPLXT HS ANTSTRL KR0 PRKRM NN AS 0 KRT LP
FRRT 0S PRKRM KLT FR 0 RPT TRNSFRMXN AF XN FRM AN AKRRN AKNM T A SSLST
ANTSTRL SST"
trg = u"M KPT T HS KMNST KNFKXNS AS H KLT FR 0 ALMNXN AF PRFT PRPRT AN
RRL ARS T P RPLST P KMNS H ASTPLXT HS ANTSTRL KR0 PRKRM NN AS 0 KRT LP
FRRT 0S PRKRM KLT FR 0 RPT TRNSFRMXN AF XN FRM AN AKRRN AKNM T SSLST
ANTSTRL SST"
print src, '\n', trg, '\n', SM(None, trg, src).ratio()
---


The following sequence prints a ratio() of 0.989795918367 which seems
about right.
---
src = u"M STNK AS AN AF 0 MST AMPRTNT LTRS TRNK 0 TNT0 SNTR HS MST
PRMNNT AKMPLXMNT AS 0 ASTPLXMNT AF 0 PPLS RPPLK AF XN HS A0R AXFMNTS
ANKLTT LTNK HS PPL AN 0 LNK MRX AFR FR 0SNT MLS T KP 0 KMNST MFMNT
ALF"
trg = u"M STNK AS AN AF 0 MST AMPRTNT LTRS TRNK 0 0 SNTR HS MST PRMNNT
AKMPLXMNT AS 0 ASTPLXMNT AF 0 PPLS RPPLK AF XN HS A0R AXFMNTS ANKLT
LTNK HS PPL AN 0 LNK MRX AFR FR 0SNT MLS T KP 0 KMNST MFMNT ALF"
print src, '\n', trg, '\n', SM(None, trg, src).ratio()
---

What could be the cause? Is there something I am doing wrong?

Thanks in advance
-- 
Regards
Jay
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: writing a web client

2005-07-29 Thread Jay
thats pretty cool, could someone post a example program of a python
web-based program?

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


Re: writing a web client

2005-07-29 Thread Jay
thats pretty cool, could someone post a example program of a python
web-based program?

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


Hiding

2005-07-29 Thread Jay
Well, im not no expert on the python programming language but i just
wanted to know if there was a quick way to hide certain things when
programming in python. Such as, i wanted some music or sound effects
with my python program. So, i type...

print "Music is by blah blah"
music-file = open(file containing the music"
hide(music-file)

thats wat im looking for, something i can hide the opening of files
because if i open that file, Windows Media Player will open and i would
like to hide that. And advise

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


Re: Hiding

2005-07-29 Thread Jay
thanks for the great info and urls, i have downloaded the pymedia
module and playing around with it now. Thx alot

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


Re: Hiding

2005-07-30 Thread Jay
but also, wat if i needed to hide the loading of a file or the even
hide the whole python window to run in background?? is there no module
or function i can use

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


keylogger in Python

2005-07-30 Thread Jay
ok, i thought for 2 seconds i might have created a Keylogger in python
but i still have one major think stopping me... PYTHON. when i run the
program i have python create a file named keylog2.log and it then logs
all keys pressed/typed in the python IDE into that file. All i want to
know now is how do i hide or background python so that it will log all
the keys pressed outside of Python.

feel free to play around with my program... but please post ur findings
on my post...
#
class keylogger:
pass

keylogging = keylogger()
keylog = open("keylog2.log", "w")
text = raw_input()

keylog.write(text)
keylog.close
keylog = open("keylog2.log", "r")
keylog.read

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


Re: keylogger in Python

2005-07-30 Thread Jay
yo, thanks for the great input. And the only reason i want to create a
python based keylogger is because there is none. Just a fun project...
But im gonna do some more research on the keyboard drivers and stuff
like that and to learn how to attach my python porgrams into the
sub-processes so that it would instead log every char instead of just
char in the IDE. 
 thx

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


Using XML w/ Python...

2005-12-10 Thread Jay
OK, I have this  XML doc, i dont know much about XML, but what i want
to do is take certain parts of the XML doc, such as  blah
 and take just that and put onto a text doc. Then same thing
doe the  part. Thats about it, i checked out some of the xml
modules but dont understand how to use them. Dont get parsing, so if
you could please explain working with XML and python to me. Email me at
[EMAIL PROTECTED]

Aim- jayjay08balla
MSN- [EMAIL PROTECTED]
Yahoo- raeraefad72


Thx

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
Yes i know, i did check out a couple but i could never understand it.
They were confusing for me and i wasnt hoping for a full typed
tutorial, just like some help with excactly wat im trying to do, not
the whole module... but watever, Thx alot for the feedbak.

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
some great suggestions.
Ok, i am now understanding some of parseing and how to use it and
nodes, things like that. But say i wanted to take the title of
http://www.digg.com/rss/index.xml

and XMLTramp seemed the most simple to understand.

would the path be something like this?

import xmltramp
rssDigg = xmltramp.load("http://www.digg.com/rss/index.xml";)
print note.rss.channel.item.title


I think thats wat im having the most confusion on now, is how to direct
to the path that i want... 
Suggestions?

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
Ok, im convinced to that i need to get Amara, I just installed 4Suite
and now installed Amara. Still doesnt work because like i said before,
i use ActivePython from

http://www.activestate.com/Products/ActivePython/

And the requirements for Amara is Python 2.4 so Thats where we have
a problem, i need Amara for ActivePython. And i would like to keep
working on ActivePython w/o downloading Python 2.4.

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
Ummm, my error conditions.
PythonWin 2.3.5 (#62, Feb  9 2005, 16:17:08) [MSC v.1200 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.

>>> import amara
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named amara

Pretty straight forward
As far as it should work since their both transparent, umm, well its
not.
But what would be a help would be if u knew the install dir for
ActivePython so maybe i can install amara stand alone into the
ActivePython installation dir. ?? Maybe

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
No, when i said
 "As far as it should work since their both transparent, umm, well its
not."

I meant that only mine isnt, maybe urs is but for some reason it isnt.
And you said amara works fine for you, ok, then could you tell me what
package to install...

I have installed Amara 1.1.6 for Python 2.4 and it works on python 2.4
only.
Now, which package should i download for it to work on any python
prompt:
  Allinone
  Standalone 
  Or something else

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
h, i just tryed the same thing earlier today and it didnt work, but
now it does, i downloaded the standalone package and now it works in
activepython when it didnt before and i tryed the same thing.

And yes, last time i did type python setup.py install.

Thx anyway.

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


Re: Using XML w/ Python...

2005-12-11 Thread Jay
Spoke too soon, i get this error when running amara in ActivePython

>>> import amara
>>> amara.parse("http://www.digg.com/rss/index.xml";)
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python23\Lib\site-packages\amara\__init__.py", line 50, in
parse
if IsXml(source):
NameError: global name 'IsXml' is not defined

So im guessing theres an error with one of the files...

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
when putting excactly what you got, i got
>>> python -c "import amara; print dir(amara)"
Traceback (  File "", line 1
python -c "import amara; print dir(amara)"
 ^
SyntaxError: invalid syntax

when doing it seperately, i got>

>>> import amara
>>> print dir(amara)
['__builtins__', '__doc__', '__file__', '__name__', '__path__',
'__version__', 'binderytools', 'os', 'parse']
>>>

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
Umm, yea, u definatly hijacked my thread. If you didnt mean to then
dont

But anyway, i get this...
>>> import amara
>>>from amara import domtools
>>> print domtools.py
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'domtools' is not defined
>>>


suggestions?

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
you might be on to something

>>> from amara import domtools
>>> print domtools.__file__
C:\Python23\lib\site-packages\amara\domtools.pyc
>>>

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
Suggestions maybe?

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
come on guys, the post isnt dead yet

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


ActivePython and Amara

2005-12-12 Thread Jay
Ok, i had this posted on the other thread "XML w/ Python" but it kinda
got off topic from the title to ill start a new thread. My question is
this...

the import of amara works in ActivePython...

PythonWin 2.3.5 (#62, Feb  9 2005, 16:17:08) [MSC v.1200 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.
>>> import amara

 # the only problem is that when i try to parse a file

>>> amara.parse('htttp://www.digg.com/rss/index.xml')
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python23\lib\site-packages\amara\__init__.py", line 50, in
parse
if IsXml(source):
NameError: global name 'IsXml' is not defined

# So, someone else suggested i type

>>> import amara
>>> print dir(amara)

['__builtins__', '__doc__', '__file__', '__name__', '__path__',
'__version__', 'binderytools', 'os', 'parse']


# they told me that i didnt have
#Quote: So it's not able to load domtools.
What do you get trying
>>> from amara import domtools
>>> print print domtools.__file__

Then i got
you might be on to something

>>> from amara import domtools
>>> print domtools.__file__
C:\Python23\lib\site-packages\amara\domtools.pyc


This is where i no longer got replies, how would i got about fixing
this?

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


Re: ActivePython and Amara

2005-12-12 Thread Jay
Woah woah woah, calm your ass down a little.

I didn't say that the "hijacker" made it go off topic. Did I? I just
said that the thread was going off topic from the dam title. We
weren't
talking about XML no more now were we. And who the hell are you talking
to thinking that I haven't researched my ass off up till 4AM in the
dam
morning looking for an explanation on Google, friends and other
resources... Also,

>If you had ANY understanding of Python,
you would have realized this. <

So now your saying I don't know any
python when I have read about a shitload of tutorials... So, I think
first of all, you got some damn attitude, second of all, I never asked
anyone to debug my program all I freaking asked for was help trying to
get a module onto activepython which, I would love for you to Google
"activepython and amara" not many relevant results. Third of all, I
don't appreciate you saying that I don't know python when I have
worked
my ass off learning it!

Now, with that out of the way. Stay the hell of my thread cuz you have
some damn attitude problem and I don't need your rants about my
questions.

"Sometimes you really need to slow down and learn something before you
can continue with what you want to do."
^^Take your post, and shove it up your ass.

BYE
-Jay

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


Re: Using XML w/ Python...

2005-12-12 Thread Jay
ok, thx

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


Re: ActivePython and Amara

2005-12-12 Thread Jay
On that note... I would like to open up the floor again.. lol

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


Re: ActivePython and Amara

2005-12-13 Thread Jay
Ok, ok, i over-reacted. When first reading it seemed as an attack and i
quickly put up a defense because i dont like being attacked for no
reason. I was actually quite obnoxious and i apoligize.

And again, thx James for pointing that out.
Once again, i apoligize for my actions and words and i will make sure
it doesnt happen again. Lets just start off on a clean slate. :-)


-Jay

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


Re: ActivePython and Amara

2005-12-14 Thread Jay
really quick question, if you look at the XML doc of digg.com then you
will see that there are multiple items in channel, how do i tell it to
go to the next item and get that title??

title2 = rssDigg.find("//channel/item//title").text  Didnt work
title2 = rssDigg.find("//channel/item[1]/title").textDidnt work

Umm, any help?

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


Re: ActivePython and Amara

2005-12-15 Thread Jay
that like displays all the items, i want to just get one two three and
such. Can't i get just the first three and i also want them to display
individually such as title1 = just the title of item 1 and descp =
would be the descrp of item one, and so one... I dont need a list of
all titles... Is there a good tutorial that would show wat i want to
do.. i checked and alot of tutorials have basic  tutorials that have
examples of just one item'd xml's....

thx. 

-Jay

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


Re: ActivePython and Amara

2005-12-15 Thread Jay
i knew someone would snap on me... lol. Its not that i dibt ubderstand
all of python, its just that i dont understand this specific module
since i couldnt find any good tutorials on this specific module. its
not the whole programming part, its just the module. I made my program
jsut how i wanted it using amara and it did everything i wanted it to
do. Once again, i know much about python and i dont excactly need help
learning the basics of python because i know it, once again, its the
module i need help with... not all of python programming... if you want
i can post my program that i made without elementtree that used amara,
its just a simple program that took the top 5 rss feeds of digg.com and
wrote them to a document and then printed it using a batch file...

So, i understand youy fustration but i just want you to know that i do
understand most of python (not calling myself a pro but definatly no
noob), and that all i wanted was a reference to a quick tutorial that
had more advanced examples or the one module elementtree...

Thx again James. :-6

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


Re: ActivePython and Amara

2005-12-15 Thread Jay
i knew someone would snap on me... lol. Its not that i dibt ubderstand
all of python, its just that i dont understand this specific module
since i couldnt find any good tutorials on this specific module. its
not the whole programming part, its just the module. I made my program
jsut how i wanted it using amara and it did everything i wanted it to
do. Once again, i know much about python and i dont excactly need help
learning the basics of python because i know it, once again, its the
module i need help with... not all of python programming... if you want
i can post my program that i made without elementtree that used amara,
its just a simple program that took the top 5 rss feeds of digg.com and
wrote them to a document and then printed it using a batch file...

So, i understand youy fustration but i just want you to know that i do
understand most of python (not calling myself a pro but definatly no
noob), and that all i wanted was a reference to a quick tutorial that
had more advanced examples or the one module elementtree...

Thx again James. :-6

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


Re: ActivePython and Amara

2005-12-15 Thread Jay
BTW, i finished this tutorial long ago...

http://www.ibiblio.org/obp/thinkCSpy/

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


Re: ActivePython and Amara

2005-12-15 Thread Jay
lol, u guys love picking on me... LOL, i didnt even realize it was
creating a list, i know, dumb but true...

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


Re: ActivePython and Amara

2005-12-16 Thread Jay
sigh... i keep telling you guys im not a newbie, its just that i had a
question about that module... But, i understand i may sound like a noob
because i was asking for detailed questions instead of the broad ones
that you guys were giving me... but i would not like to be considered a
noob around here and definatly not a master, just sort of in-between.
Because i have dont some work with python for a couple years (plus im
in school so i dont get much time to program) Thx for the link and
im not being defensive i just dont want to be called something that im
not when i spent some time learning python. Like i said b4, i didnt
know nothing about that certain *module*... 

but have a great day...

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


Re: Email Policy Violation

2005-12-16 Thread Jay
wat is the question that your asking??

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


Re: Email Policy Violation

2005-12-16 Thread Jay
wat is the question that your asking??

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


Re: urllib.urlopen

2005-12-17 Thread Jay
Easy Fix...

import urllib
the_url = "http://www.google.com";
req = urllib.urlopen(the_url)

Does this work for you??

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


IRC sockets and queries

2005-12-29 Thread Jay
ok have this program and i set a socket 2  connect to the server...so i
can chat on the channels and stuff. my question is how would i go about
set a socket directly 2 an individual query?

my program is right here...
http://h1.ripway.com/jay001/CopyofPyIRCnMo.txt

BTW, im trying to set up a connection between IMServ and my computer
and if you dont know wat IMserv is then please follow..
http://www.zevils.com/linux/imirc/ which is bascially a gateway between
AIM and IRC. so, this IMServ creates a query called IMServ where u give
it commands such as signon and stuff. my prog can only connect to the
host the is hosting IMserv and after you are conected to the IMServ
query... nothing else is transmited to the hosting channel or server...
just the query called IMServ...

Once again, my question is how to create a socket directly to a IRC
query...?

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


Re: IRC sockets and queries

2005-12-30 Thread Jay
LMFAO! those were jokes for my friends. lol.and btw the dccpoper and
bot and crap were jokes that i made up for my friends on the #python
channel in freenode... It was a joke.Anyway.. My bad, its ok if u dont
want to help... no one likes me on this group anyway... u guys just
joined the crowd... btw, wat do u mean

>get yourself aquainted with the language
(and maybe programming in general).<

 Dude, why do u think im not? ive programmed many small and many big
programs, if this is a noob question then my bad, ive asked many ppl
and they cant answer me and this was my last resort since i knew i
would get this kind of bullshit.
I know most of the language fairly and im tired of coming on here and
always getting pointed to python tutorials, its actually pretty
annying, if you dont have a liable answer then could u please not post
then, it only makes sense. Instead of telling someone that their dumb
and that u dont know python, how about just help answering the
question. But watever, i dont know y but this whole group just hates
me... If anyone has a answer then please feel free to post(unlikely).
But thx anyway..

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


Re: raw audio in windows

2006-09-01 Thread Jay
I'm afraid I can't do that.  Don't take it personally.  I would send it
to you, but at this time, I'm developing this app with a friend and I
don't know his feelings about the program's distribution or licensing.
I can't send it around until I speak to him about it.

Sorry.


spiffy wrote:
> On 31 Aug 2006 21:34:13 -0700, "Putty" <[EMAIL PROTECTED]> wrote:
>
> >Hi.  I've written a small python script that was primarily meant for
> >use in a unix-compatible environment.  It writes a bunch of raw audio
> >to a file and then sends the file to /dev/audio and the system plays
> >the audio.  Very simple.
> >
> >Is there a simple way I could edit the script (which just uses the
> >system call to do this) to run under windows?
> >
> >This is the code that would have to change:
> >os.system("cat audioBuf > /dev/audio")
>
>
> hey, that sounds like some stuff i've been working on...
> is there any possibility that you could send me that script so I could
> take a look at it and learn?
> i'm new to python and programming in general. i'm working on some
> algorithmic composition stuff and also trying to write some synths
> here's my email...
> [EMAIL PROTECTED]

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


Re: raw audio in windows

2006-09-01 Thread Jay
So, are you saying this would be possible to do with the PlaySound
function?

Fredrik Lundh wrote:
> Ben Sizer wrote:
>
> > Not really. You'll have to convert it to .wav and then pass it to a
> > helper app.
> >
> > 
>
> >>> import winsound
> >>> help(winsound)
> Help on module winsound:
>
> NAME
> winsound
>
> FILE
> c:\python24\dlls\winsound.pyd
>
> DESCRIPTION
> PlaySound(sound, flags) - play a sound
> SND_FILENAME - sound is a wav file name
> SND_ALIAS - sound is a registry sound association name
> SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC
> SND_MEMORY - sound is a memory image of a wav file
> SND_PURGE - stop all instances of the specified sound
> SND_ASYNC - PlaySound returns immediately
> SND_NODEFAULT - Do not play a default beep if the sound can not be found
> SND_NOSTOP - Do not interrupt any sounds currently playing
> SND_NOWAIT - Return immediately if the sound driver is busy
>
> Beep(frequency, duration) - Make a beep through the PC speaker.
>
> FUNCTIONS
> Beep(...)
> Beep(frequency, duration) - a wrapper around the Windows Beep API
>
> The frequency argument specifies frequency, in hertz, of the sound.
> This parameter must be in the range 37 through 32,767.
> The duration argument specifies the number of milliseconds.
> On WinNT and 2000, the platform Beep API is used directly.  Else funky
> code doing direct port manipulation is used; it's unknown whether that
> will work on all systems.
>
> MessageBeep(...)
> MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.
>
> PlaySound(...)
> PlaySound(sound, flags) - a wrapper around the Windows PlaySound API
>
> The sound argument can be a filename, data, or None.
> For flag values, ored together, see module documentation.
>
> DATA
> MB_ICONASTERISK = 64L
> MB_ICONEXCLAMATION = 48L
> MB_ICONHAND = 16L
> MB_ICONQUESTION = 32L
> MB_OK = 0L
> SND_ALIAS = 65536L
> SND_APPLICATION = 128L
> SND_ASYNC = 1L
> SND_FILENAME = 131072L
> SND_LOOP = 8L
> SND_MEMORY = 4L
> SND_NODEFAULT = 2L
> SND_NOSTOP = 16L
> SND_NOWAIT = 8192L
> SND_PURGE = 64L
> 
> 

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


pictures as characters in a Tk text box?

2006-09-01 Thread Jay
This may be really obscure, but I had a dream about programming
something like this, so don't blame me.  Is it possible to take a small
image or icon and display it as a character in a Tk text box?  Think
how Thunderbird displays text smilies as actual smiley icons.  Or how
in AIM as you type a smiley, it replaces it with the picture.  Does
anyone know how to display these specifically in a Tk text box?  Thanks.

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


Re: pictures as characters in a Tk text box?

2006-09-02 Thread Jay
PERFECT!!!  Thanks so much!


Simon Forman wrote:
> Jay wrote:
> > This may be really obscure, but I had a dream about programming
> > something like this, so don't blame me.  Is it possible to take a small
> > image or icon and display it as a character in a Tk text box?  Think
> > how Thunderbird displays text smilies as actual smiley icons.  Or how
> > in AIM as you type a smiley, it replaces it with the picture.  Does
> > anyone know how to display these specifically in a Tk text box?  Thanks.
>
> Dreaming in Python, eh?  Maybe you should take a break.  ;-)
>
> Sure, quoting the link below: "You can put an image or bitmap into a
> text widget. It is treated as a single character whose size is the
> natural size of the object."
>
> You can also embed any Tk widget in a Tk Text widget, including
> ImageTks and widgets with bitmaps.
>
> See:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-image.html
> and
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-window.html
> 
> 
> HTH,
> ~Simon

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


Re: pictures as characters in a Tk text box?

2006-09-02 Thread Jay
Can you do the same in wxPython?

Simon Forman wrote:
> Jay wrote:
> > This may be really obscure, but I had a dream about programming
> > something like this, so don't blame me.  Is it possible to take a small
> > image or icon and display it as a character in a Tk text box?  Think
> > how Thunderbird displays text smilies as actual smiley icons.  Or how
> > in AIM as you type a smiley, it replaces it with the picture.  Does
> > anyone know how to display these specifically in a Tk text box?  Thanks.
>
> Dreaming in Python, eh?  Maybe you should take a break.  ;-)
>
> Sure, quoting the link below: "You can put an image or bitmap into a
> text widget. It is treated as a single character whose size is the
> natural size of the object."
>
> You can also embed any Tk widget in a Tk Text widget, including
> ImageTks and widgets with bitmaps.
>
> See:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-image.html
> and
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-window.html
> 
> 
> HTH,
> ~Simon

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


tkinter text event

2006-09-06 Thread Jay
I'm having trouble with using the  event with the Text object.
When I use them together (which is a logical combination), I use this
code:

textbox = Text(root, wrap="word", height=15, width=50)
textbox.bind("", resolveGlyphs)

def resolveGlyphs(event):
textBuf = textbox.get(1.0, END)
print(textBuf)

What it prints out for me is everything except for the last character
-- the one that triggered the event.  How can I get the entire
contents?

I apologize if this has already been discussed.  I searched and
couldn't find it.

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


Re: tkinter text event

2006-09-08 Thread Jay
That makes sense, but it's not working.


John McMonagle wrote:
> On Wed, 2006-09-06 at 17:54 -0700, Jay wrote:
> > I'm having trouble with using the  event with the Text object.
> > When I use them together (which is a logical combination), I use this
> > code:
> >
> > textbox = Text(root, wrap="word", height=15, width=50)
> > textbox.bind("", resolveGlyphs)
> >
> > def resolveGlyphs(event):
> > textBuf = textbox.get(1.0, END)
> > print(textBuf)
> >
> > What it prints out for me is everything except for the last character
> > -- the one that triggered the event.  How can I get the entire
> > contents?
> >
>
> bind the textbox to the  event because by then it has been
> drawn on the Text widget.  The  event is equivalent to the
>  event
>
> Regards,
>
> John
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.

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


Re: tkinter text event

2006-09-08 Thread Jay
Nevermind.  It works.  Sorry.  I got my files mixed up!  :-)
John McMonagle wrote:
> On Wed, 2006-09-06 at 17:54 -0700, Jay wrote:
> > I'm having trouble with using the  event with the Text object.
> > When I use them together (which is a logical combination), I use this
> > code:
> >
> > textbox = Text(root, wrap="word", height=15, width=50)
> > textbox.bind("", resolveGlyphs)
> >
> > def resolveGlyphs(event):
> > textBuf = textbox.get(1.0, END)
> > print(textBuf)
> >
> > What it prints out for me is everything except for the last character
> > -- the one that triggered the event.  How can I get the entire
> > contents?
> >
>
> bind the textbox to the  event because by then it has been
> drawn on the Text widget.  The  event is equivalent to the
>  event
>
> Regards,
>
> John
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.

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


best split tokens?

2006-09-08 Thread Jay
Let's say, for instance, that one was programming a spell checker or
some other function where the contents of a string from a text-editor's
text box needed to be split so that the resulting array has each word
as an element.  Is there a shortcut to do this and, if not, what's the
best and most efficient token group for the split function to achieve
this?

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


Re: ubuntu crash

2006-09-08 Thread Jay
Here are some commands to try:

apt-get install ubuntu-standard
apt-get install ubuntu-desktop

Also, I'd recommend trying Ubuntu's official forums website.  I've
found their community to be extremely helpful.

http://www.ubuntuforums.org/

Plus, why on earth would you want to ax Python?

[EMAIL PROTECTED] wrote:
> I typed in apt-get remove python
> and everything essentially was wiped off my computer.  I jsut want to get it
> back to the point of whwen I installed ubuntu, I'd like to get my documentst
> back as well but doubt I'll be able to do this.  I installed gnome so I have a
> graphical  interface again but can only log in as root. Is there a way to
> resintall??? thanks
> Ben

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


Re: python loops

2006-09-08 Thread Jay
Here are my benchmarks for those interested in version 2.4.3

[EMAIL PROTECTED]:~$ python -V
Python 2.4.3
[EMAIL PROTECTED]:~$ python -mtimeit 'for x in range(1000):pass'
1 loops, best of 3: 64.2 usec per loop
[EMAIL PROTECTED]:~$ python -mtimeit 'for x in xrange(1000):pass'
1 loops, best of 3: 50.5 usec per loop
[EMAIL PROTECTED]:~$ python -mtimeit -s'y=range(1000)' 'for x in y:pass'
1 loops, best of 3: 68.2 usec per loop
[EMAIL PROTECTED]:~$ python -mtimeit -s'y=xrange(1000)' 'for x in y:pass'
1 loops, best of 3: 51.4 usec per loop
[EMAIL PROTECTED]:~$ python -mtimeit -s'from itertools import repeat'
'for x in repeat(None, 1000): pass'
1 loops, best of 3: 45.6 usec per loop
[EMAIL PROTECTED]:~$

Alex Martelli wrote:
> Tim Roberts <[EMAIL PROTECTED]> wrote:
>...
> > xrange used to be better.  As I understand it, that's no longer the case.
>
> measuring is better than guessing:
>
> brain:~/codejam alex$ python -V
> Python 2.5c1
> brain:~/codejam alex$ python -mtimeit 'for x in range(1000):pass'
> 1 loops, best of 3: 71.9 usec per loop
> brain:~/codejam alex$ python -mtimeit 'for x in xrange(1000):pass'
> 1 loops, best of 3: 54 usec per loop
> brain:~/codejam alex$ python -mtimeit -s'y=range(1000)' 'for x in
> y:pass'
> 1 loops, best of 3: 44.8 usec per loop
> brain:~/codejam alex$ python -mtimeit -s'y=xrange(1000)' 'for x in
> y:pass'
> 1 loops, best of 3: 53.2 usec per loop
> brain:~/codejam alex$
>
> So: in 2.5 (2.4 too, do your own timings;-) range is better if you can
> create the range once and use it repeatedly, xrange if you have to
> create the range each time.  But actually:
>
> brain:~/codejam alex$ python -mtimeit -s'from itertools import repeat'
> 'for x in repeat(None, 1000): pass'
> 1 loops, best of 3: 41.3 usec per loop
>
> if you don't actually need the iteration-index in the loop (you just
> need to repeat the loop N times), itertools.repeat is even better (well,
> if every microsecond counts, anyway;-).
> 
> 
> Alex

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


Re: ubuntu crash

2006-09-09 Thread Jay
Oh..  Sorry about that, then.

Did my suggestions work at all?


Peter Otten wrote:
> Jay wrote:
>
> > Here are some commands to try:
> >
> > apt-get install ubuntu-standard
> > apt-get install ubuntu-desktop
> >
> > Also, I'd recommend trying Ubuntu's official forums website.  I've
> > found their community to be extremely helpful.
> >
> > http://www.ubuntuforums.org/
> >
> > Plus, why on earth would you want to ax Python?
>
> Because you trust the experts on c.l.py?
>
> http://mail.python.org/pipermail/python-list/2006-September/360376.html
> 
> Peter

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


time-based point system

2006-09-13 Thread Jay
I'm writing a game script and the point system will be based upon time.
 The less time there is between event one and event two, the higher
score you'll get for event two.  However, I've got a problem figuring
how to do this.  Here's why.  I don't want the score system to just be
a straight charted system.  Y'know, like if the time is between x and y
then the points you get are z.  I want to mathematically figure out the
pointage.  That's what I can't figure out how to do.  If it were such
that the more time there is, the more points there are, that would be
easy.  I could just multiply the time by something or other.  Or, if
there was a time limit between the two events, that, too, would be easy
because I could subtract the amount of time spent from the possible
amount of time and multiply by something for points.  Neither of these
are the case.  Any suggestions?

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


Re: time-based point system

2006-09-13 Thread Jay
Okay, this is a game.  So the points are abstract.  It's like an arcade
game in respect to the points.  They don't actually mean or represent
anything.  The only point is to get a high score.  The idea is that the
faster the user acts (or reacts) the greater amount of points they'll
receive.  Simplified, I need a fuction or statement that takes in a
small number and spits out a big number.  The smaller the input, the
larger the output.


Erik Max Francis wrote:
> Jay wrote:
>
> > I'm writing a game script and the point system will be based upon time.
> >  The less time there is between event one and event two, the higher
> > score you'll get for event two.  However, I've got a problem figuring
> > how to do this.  Here's why.  I don't want the score system to just be
> > a straight charted system.  Y'know, like if the time is between x and y
> > then the points you get are z.  I want to mathematically figure out the
> > pointage.  That's what I can't figure out how to do.  If it were such
> > that the more time there is, the more points there are, that would be
> > easy.  I could just multiply the time by something or other.  Or, if
> > there was a time limit between the two events, that, too, would be easy
> > because I could subtract the amount of time spent from the possible
> > amount of time and multiply by something for points.  Neither of these
> > are the case.  Any suggestions?
>
> You haven't indicated what _is_ the case, so this question cannot yet be
> answered.  You have to specify what the points measure, how they measure
> it, and how they change over time.  Once you do that, you can define (or
> get help defining) how to calculate them.  As it is you've not given
> nearly enough information to answer your question.
>
> --
> Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
>   San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
>Get married, but never to a man who is home all day.
> -- George Bernard Shaw

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


Re: Looking for the Perfect Editor

2006-09-13 Thread Jay
I, too, am a hardcore fan of jEdit.  It's nice to finally see some user
support on this forum.  :-)


Wildemar Wildenburger wrote:
> stu wrote:
> > jedit
> >
> > http://www.jedit.org/
>
> Finally! I usually try to stay out of these discussions; yet I'm always
> disappointed at how few people seem to be using jEdit and how long it
> takes them to come out of their holes.
> 
> So let me enforce that:
> 
> jEdit
> www.jedit.org
> 
> wildemar

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


Re: time-based point system

2006-09-13 Thread Jay
That function is absolutely no good for this situation.

1. Take a small number.
5.4348809719085693

2. Put it in the function.
f(5.4348809719085693) = 1/5.4348809719085693

3. Get a large number???
0.18399666987533483

That number is even smaller.  I want a large one coming out.

Erik Max Francis wrote:
> Jay wrote:
>
> > Okay, this is a game.  So the points are abstract.  It's like an arcade
> > game in respect to the points.  They don't actually mean or represent
> > anything.  The only point is to get a high score.  The idea is that the
> > faster the user acts (or reacts) the greater amount of points they'll
> > receive.  Simplified, I need a fuction or statement that takes in a
> > small number and spits out a big number.  The smaller the input, the
> > larger the output.
>
> There are any number of functions which fit this property, like f(x) =
> 1/x.  You'll have to define more clearly what properties of this
> negative function you want to narrow it down beyond that.
>
> --
> Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
>   San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
>Get married, but never to a man who is home all day.
> -- George Bernard Shaw

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


Re: time-based point system

2006-09-13 Thread Jay
I'm sorry.  I never considered what you said about the relationship
about the input and output.  I'll take my thread elsewhere to a math
board.


Erik Max Francis wrote:
> Jay wrote:
>
> > That function is absolutely no good for this situation.
> >
> > 1. Take a small number.
> > 5.4348809719085693
> >
> > 2. Put it in the function.
> > f(5.4348809719085693) = 1/5.4348809719085693
> >
> > 3. Get a large number???
> > 0.18399666987533483
> >
> > That number is even smaller.  I want a large one coming out.
>
> f(x) = 1/x is just one example of a function that has the property of
> being a "negative function" -- the smaller number you put in, the larger
> number you get out, and vice versa.  Your statement didn't clearly
> indicate that the outputs need to be bigger than the inputs, just that
> they need to be bigger the smaller the outputs are.  The more general
> function would be f(x) = A/(x - B).  Choose A and B as desired so that
> f(x) > x for all x you care about.  Or choose another function, like
> f(x) = A - B x or any number of other functions.  There literally are an
> infinite number of possibilities.
>
> The point is, as I've already said, you haven't given nearly enough
> information to give you a useful answer.  You haven't indicated, for
> instance, anything at all about the domain or range of the function that
> you want:  What values do you need to plug in?  What range of values do
> you need to get out?  Once you have clarified to yourself what
> properties you want, that will help you define the function.
>
> At this point you're the only one who knows what properties you want,
> and unless you define them up front, it results in a very unsatisfactory
> guessing game of proposing a function, you telling me what's wrong with
> it, and repeat until either or both of us get bored.
>
> And, by the way, this is a question about mathematics, and so has
> nothing to do specifically with Python.
>
> --
> Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
>   San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
>Get married, but never to a man who is home all day.
> -- George Bernard Shaw

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


Tkinter.Button(... command) lambda and argument problem

2006-09-15 Thread Jay
I'm having a problem using lambda to use a command with an argument for
a button in Tkinter.

buttons = range(5)
for x in xrange(5):
buttons[x] = Button(frame, text=str(x+1), 
command=lambda:
self.highlight(x))
buttons[x].pack(side=LEFT)

The buttons are correctly numbered 1 through 5, but no matter which
button I click on, it sends the number 4 as an argument to the
highlight function.  How can I correct this?

By the way, I've tried changing xrange to range with no success.

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


Re: Tkinter.Button(... command) lambda and argument problem

2006-09-15 Thread Jay
Perfect.  Thanks.


Paul Rubin wrote:
> "Jay" <[EMAIL PROTECTED]> writes:
>
> > I'm having a problem using lambda to use a command with an argument for
> > a button in Tkinter.
> >
> > buttons = range(5)
> > for x in xrange(5):
>
> > self.highlight(x))
> > buttons[x].pack(side=LEFT)
> >
> > The buttons are correctly numbered 1 through 5, but no matter which
> > button I click on, it sends the number 4 as an argument to the
> > highlight function.
>
> x is not bound by the lambda and so the lambda body gets it from the
> outside environment at the time the body is executed.  You have to
> capture it at the time you create the lambda.  There's an ugly but
> idiomatic trick in Python usually used for that:
>
>   buttons[x] = Button(frame, text=str(x+1),   \
> command=lambda x=x: self.highlight(x))
>
> See the "x=x" gives the lambda an arg whose default value is set to
> x at the time the lambda is created, as opposed to when it's called.

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


Re: Tkinter.Button(... command) lambda and argument problem

2006-09-15 Thread Jay
Thanks for the tip, but that breaks things later for what I'm doing.

[EMAIL PROTECTED] wrote:
> In that case you don't need a lambda:
>
> import Tkinter as tk
>
> class Test:
> def __init__(self, parent):
> buttons = [tk.Button(parent, text=str(x+1),
> command=self.highlight(x)) for x in range(5)]
> for button in buttons:
> button.pack(side=tk.LEFT)
>
> def highlight(self, x):
> print "highlight", x
>
> root = tk.Tk()
> d = Test(root)
> root.mainloop()
> 
> Bye,
> bearophile

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


mp3 libs and programs

2006-09-15 Thread Jay
I'm writing a python script that involves playing mp3 files.  The first
approach I had was sending commands to unix command-line programs in
order to play them.  I tired mpg123 and moosic, but there was a key
feature to my program's success that's missing.  SEEK!  I need to be
able to start playing a song at an arbitrary point in the song.  I
can't find anything to let me do this.  Does anyone have any advice or
has anyone needed something similar?

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


Re: mp3 libs and programs

2006-09-15 Thread Jay
Only if I have to.  PyMedia is a pain and a half to build and why do
that if I can just pipe it out to some other program?


Tim Williams wrote:
> On 15 Sep 2006 18:16:41 -0700, Jay <[EMAIL PROTECTED]> wrote:
> > I'm writing a python script that involves playing mp3 files.  The first
> > approach I had was sending commands to unix command-line programs in
> > order to play them.  I tired mpg123 and moosic, but there was a key
> > feature to my program's success that's missing.  SEEK!  I need to be
> > able to start playing a song at an arbitrary point in the song.  I
> > can't find anything to let me do this.  Does anyone have any advice or
> > has anyone needed something similar?
> 
> http://pymedia.org/   maybe
> 
> :)

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


Re: mp3 libs and programs

2006-09-15 Thread Jay
That's definately a good choice, but what about mplayer in slave mode?
Can I use that with python?  Would that be able to seek?


Harold Fellermann wrote:
> hi,
>
> Jay wrote:
> > I'm writing a python script that involves playing mp3 files.  The first
> > approach I had was sending commands to unix command-line programs in
> > order to play them.  I tired mpg123 and moosic, but there was a key
> > feature to my program's success that's missing.  SEEK!  I need to be
> > able to start playing a song at an arbitrary point in the song.  I
> > can't find anything to let me do this.  Does anyone have any advice or
> > has anyone needed something similar?
> 
> check out pyxmms.

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


Re: mp3 libs and programs

2006-09-15 Thread Jay
I checked it and I can most definitely do the seeking from the command
line with mplayer.  Can I use slave mode with python?


Jay wrote:
> That's definately a good choice, but what about mplayer in slave mode?
> Can I use that with python?  Would that be able to seek?
>
>
> Harold Fellermann wrote:
> > hi,
> >
> > Jay wrote:
> > > I'm writing a python script that involves playing mp3 files.  The first
> > > approach I had was sending commands to unix command-line programs in
> > > order to play them.  I tired mpg123 and moosic, but there was a key
> > > feature to my program's success that's missing.  SEEK!  I need to be
> > > able to start playing a song at an arbitrary point in the song.  I
> > > can't find anything to let me do this.  Does anyone have any advice or
> > > has anyone needed something similar?
> > 
> > check out pyxmms.

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


Re: Python programs always open source?

2006-09-17 Thread Jay
Speaking of the bytecode, how does one create it?


Ben Finney wrote:
> "Guy Fawkes" <[EMAIL PROTECTED]> writes:
>
> > I was wondering if Python programs always need to include the source
> > code with the program itself. I'm asking this because I don't want
> > my program to be open-source and so far all the Python programs I've
> > seen included the source code.
>
> You can license your own work to anyone you like, under any terms you
> choose. The source code to a work is necessary for users to exercise a
> free software license, but that doesn't mean that distributing source
> code necessarily grants a free software license.
>
> You're right that there is a great amount of Python code available
> under free software licenses. No-one can force you to join us, but
> you're welcome to.
>
> --
>  \ "My girlfriend has a queen sized bed; I have a court jester |
>   `\   sized bed. It's red and green and has bells on it, and the ends |
> _o__)  curl up."  -- Steven Wright |
> Ben Finney

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


mp3 file length in time

2006-09-17 Thread Jay
In python, I know there are a couple of modules for getting id3 info,
but what about the length of an mp3 file in time?  Is there a way to
aquire that info?  Most of my MP3s don't have id3 tags.  I don't care
for them.  But I need to use python to get their file lengths.  How?

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


Re: mp3 file length in time

2006-09-17 Thread Jay
Any tips on how to do that?

Paul Rubin wrote:
> "Jay" <[EMAIL PROTECTED]> writes:
> > In python, I know there are a couple of modules for getting id3 info,
> > but what about the length of an mp3 file in time?  Is there a way to
> > aquire that info?  Most of my MP3s don't have id3 tags.  I don't care
> > for them.  But I need to use python to get their file lengths.  How?
>
> You have to count the frames.  Lots of mp3 files use variable bit
> rates, so you can't go by the file length.

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


gnome module

2006-09-18 Thread Jay
Am I correct in assuming that I can use the gnome module to minimize
all windows (aka show desktop)?  If so, how?

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


Re: gnome module

2006-09-18 Thread Jay
Sorry.  Nevermind.  It's no longer an issue.  :-)
Jay wrote:
> Am I correct in assuming that I can use the gnome module to minimize
> all windows (aka show desktop)?  If so, how?

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


Re: noob question

2006-09-22 Thread Jay
http://code.google.com/hosting/

xandeer wrote:
> where is a good open-source project website?
> thank-you
> (sorry for being so annoying)(if I'm annoying)(if not then I'm not
> sorry)

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


grabbing random words

2006-09-22 Thread Jay
How would I be able to grab random words from an internet source.  I'd
like to grab a random word from a comprehensive internet dictionary.
What would be the best source and the best way to go about this?
Thanks.

(Sorry if this sounds/is super noobish.)

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


vector and particle effects

2006-09-28 Thread Jay
I'd like to experiment a little bit with vector graphics in python.
When I say 'vector graphics' I don't mean regular old svg-style.  I
mean vector game style as in simulation of vector beam drawn graphics.
If you still don't know what I'm talking about, see Grid Wars 2
(http://gridwars.marune.de/) or Battlezone
(http://en.wikipedia.org/wiki/Battlezone).

Anyway, I need help choosing a module or modules to support this.
Would pygame support this or should I try pyopengl?  Or is there a
better module for this?

Any tutorials for the basics would be GREATLY appreciated.

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


Re: Resuming a program's execution after correcting error

2006-09-28 Thread Jay
I don't know how much help this is going to be, but you could store
values in a temporary file on the hard disk and write checkpoints to
read in the data and begin from a point somewhere in the middle of the
script.

Sheldon wrote:
> Hi.
>
> Does anyone know if one can resume a python script at the error point
> after the error is corrected?
> I have a large program that take forever if I have to restart from
> scratch everytime. The error was the data writing a file so it seemed
> such a waste if all the data was lost and must be recalculated again.
> 
> Sincerely,
> Sheldon

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


vector and particle effects

2006-09-28 Thread Jay
I'd like to experiment a little bit with vector graphics in python.
When I say 'vector graphics' I don't mean regular old svg-style.  I
mean vector game style as in simulation of vector beam drawn graphics.
If you still don't know what I'm talking about, see Grid Wars 2
(http://gridwars.marune.de/) or Battlezone
(http://en.wikipedia.org/wiki/Battlezone).  I'm guessing I'd just be
drawing shapes with particle effects?

Anyway, I need help choosing a module or modules to support this.
Would pygame support this or should I try pyopengl?  Or is there a
better module for this?

Any tutorials for the basics would be GREATLY appreciated.

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


Re: vector and particle effects

2006-09-28 Thread Jay
Sorry for the double post.  Google groups was being stubborn.
Jay wrote:
> I'd like to experiment a little bit with vector graphics in python.
> When I say 'vector graphics' I don't mean regular old svg-style.  I
> mean vector game style as in simulation of vector beam drawn graphics.
> If you still don't know what I'm talking about, see Grid Wars 2
> (http://gridwars.marune.de/) or Battlezone
> (http://en.wikipedia.org/wiki/Battlezone).
>
> Anyway, I need help choosing a module or modules to support this.
> Would pygame support this or should I try pyopengl?  Or is there a
> better module for this?
> 
> Any tutorials for the basics would be GREATLY appreciated.

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


Re: analyzing removable media

2006-09-28 Thread Jay
Well, in linux you can get a lot of info about where a file is based
upon where it lies in the file system.  For example, if the folder the
file is located in resides in the /media or /mnt directories, then the
file is, barring a few rare circumstances, located upon a removable
medium of some sort.  Once you get the name of that directory that is
right below /media or /mnt, then you can cross check the name in
/etc/fstab file.

However, the contents of your post lead me to believe that you're
working in a win32 environment.  That's a bit trickier.  Things aren't
so simple.  You could probably grab similar information from the full
path itself.  For example, just getting the drive letter that the file
resides on could tell you a lot.  Now, where you'd cross check that is
more of a mystery to me.  I'd guess the registry?  For an easier way of
accessing the registry, I believe that the wrapper pywin32 may be of
interest to you.  It shouldn't be that hard considering that you'd only
be getting some information, not setting anything.

If by chance we're talking about MacOS, I'm of almost no help.  In the
case of MacOS X, it has a unix core, so I'd imagine that the method I
described for linux could probably be adapted.

Jay

glenn wrote:
> Hi
> can anyone tell me how given a directory or file path, I can
> pythonically  tell if that item is on 'removable media', or sometype of
> vfs, the label of the media (or volume) and perhaps any other details
> about the media itself?
> thanks
> Glenn

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


Re: analyzing removable media

2006-09-29 Thread Jay
Dennis is absolutely right.  The reason you won't find a method in the
standard libraries for doing this task specifically is because python
aims to by cross-platform.  If it were to support a method that worked
in the way you describe specifically for Windows, that would
essentially break python's cross-platform compatibility.  It would
create a method that simply wouldn't work on two of the three major
operating systems.  Sorry.

You could write a method or series of methods that does the task you're
describing and have the first method in the chain detect what operating
system it is running on (which I believe is possible through the
standard library) and route the request to the appropriate OS-specific
method.

Just a thought.

Jay
Dennis Lee Bieber wrote:
> On 28 Sep 2006 23:23:23 -0700, "glenn" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > Hi  Jay
> > pls excuse top post - Im actually doing this project in linux, but am
> > wanting it to be cross platform. I definitley have to cater for win32
> > also.  I was hoping that burried in sys or os or that there'd be some x
> > platform  module that did all that stuff for me
>
>   As soon as you ask for "cross platform" and something that is
> device/OS specific... you have conflict.
>
> From the win32 extensions:
>
> win32file.GetDriveType
> int = GetDriveType()
>
> Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk,
> or network drive.
>
> Return Value
> The result is one of the DRIVE_* constants.
>
>   I suspect Linux would require checking parameters in the fstab file.
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

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


DAT file compilation

2006-09-29 Thread Jay
Is there a way through python that I can take a few graphics and/or
sounds and combine them into a single .dat file?  If so, how?  And how
can I access the data in the .dat file from inside the python script?

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


Re: DAT file compilation

2006-09-29 Thread Jay
That's one solution, but I'd rather a file format the end-user can't
easily mess around with.
Diez B. Roggisch wrote:
> Jay schrieb:
> > Is there a way through python that I can take a few graphics and/or
> > sounds and combine them into a single .dat file?  If so, how?  And how
> > can I access the data in the .dat file from inside the python script?
> 
> Use a zip-file. See the zipfile-module.
> 
> Diez

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


Re: DAT file compilation

2006-09-29 Thread Jay
That cgi idea is really cool, but I don't have any web space to host
the files.  Plus the bandwidth required would be deadly.  I think I'll
just have to stick to the zip file idea.  The problem with the
read-only is that this program is aimed at a Windows audience.

James Stroud wrote:
> Jay wrote:
> > That's one solution, but I'd rather a file format the end-user can't
> > easily mess around with.
>
> Require the program to be installed as root and installation to be in a
> read-only directory--or serve the resources to your program from a cgi
> script somewhere, only to be downloaded when needed. This way, the user
> would at least have to reverse engineer your program to see where the
> resources were coming from so they could plug the appropriate query in
> their web browser.
>
> James
>
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
> 
> http://www.jamesstroud.com/

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


int vs long

2007-06-02 Thread jay
I was reading in a book that the 'int' type can store whole numbers  
up to 32 bits.  I'm not exactly sure what that means, but got me  
wondering, what's the largest number you can store as an 'int' before  
you need to switch over to 'long'?

Thanks for looking at my question.

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


Re: int vs long

2007-06-03 Thread jay
Hi Dan, Paul, and Kaens,

Thanks  very much for replying to my question.  I appreciate you all  
taking the time to answer this for me!

Jay


> On 02 Jun 2007 20:18:02 -0700, Paul Rubin
> <"http://phr.cx"@nospam.invalid> wrote:
>> Dan Bishop <[EMAIL PROTECTED]> writes:
>> > Note that recent versions of Python automatically promote the  
>> results
>> > of integer arithmetic to long if necessary, so the distinction  
>> is less
>> > relevant than it used to be.
>>
>> Note however that even in recent versions, there are still parts of
>> Python that get stuck at sys.maxint, for example the enumerate  
>> function.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> I didn't know that - I'll keep it in mind though. I can imagine that
> causing some pretty nasty annoyances if you ran into it unexpectedly

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


A few questions

2007-05-20 Thread jay
Hi,

I'm totally new to Python and was hoping someone might be able to  
answer a few questions for me:

1.  What are your views about Python vs Perl?  Do you see one as  
better than the other?

2.  Is there a good book to start with while learning Python?  I'm  
currently reading 'Python Essential Reference' by David M. Beazley.   
So far it looks like a pretty good book, but would like more  
tutorials to work with (I've also been reading through the tutorials  
at 'python.org' which has some excellent stuff!).

3.  Currently, I write most of my code with Xcode (on the Mac  
platform) using Applescript.  This gives me GUI capabilities.  Is  
there anything you'd recommend that I could use for Python that would  
give me a GUI interface?  I'd like this to be able to work for both  
the Mac and Windows platforms.  I've been reading a little about  
'Claro Graphics Toolkit' and 'PyGUI'... would you recommend either of  
those?  I'll be writing code on a Mac so I need something that will  
run on that system.

Thanks for looking at my questions.

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


Re: A few questions

2007-05-21 Thread jay
Wow!!  Thanks so much for your quick and helpful replies!  I really  
appreciate it!!  :-)

I tried installing off 'wxPython2.8-osx-ansi-2.8.4.0-universal10.4- 
py2.5.dmg' on my OS 10.4.9 system which wouldn't install.  So I  
installed off 'python-2.5-macosx.dmg' and then installed off  
'wxPython2.8-osx-ansi-2.8.4.0-universal10.4-py2.5.dmg' which seemed  
to work.  I find the instructions confusing as to what to install.   
After this I went to the tutorial and started trying out some of the  
examples.  I pasted the code to separate text files and then ran them  
through a Terminal window.  This stuff is freaking cool!!!  Now I  
just have to figure out how this all works!

Anyway, I had one more quick question...  in order to run wxPython  
apps, do I have to have MacPython, etc. loaded on each Mac (or PC) in  
order for it to run any apps I write?  Or is there a way to compile  
the code to where I can distribute an app I write and the other users  
don't need to load anything in order to run the app?

Thanks again for your help with all this.  I really appreciate you  
all taking the time to look and answer our questions.

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


Re: xlrd question

2007-08-05 Thread jay
Hi Has,


>> 2.3.5 (#1, Jan 30 2006, 13:30:29)
>> [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)]
>> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
>> python2.3/site -packages/
>> xlrd/__init__.pyc
>
> Note that:
>
> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/
> site-packages
>
> is actually just a symlink to:
>
> /Library/Python/2.3/site-packages
>
> While third-party modules do usually go in python2.x/site-packages,
> Apple don't like users messing about in /System so their stock Python
> installation keeps third-party modules under /Library instead...


Thanks very much for your incredibly helpful and detailed  
info!  :-)So if I'm understanding this correctly, it really only  
installs something in '/Library/Python/2.3/site-packages' (as well as  
an alias to it from '/System/Library/Frameworks/Python.framework/ 
Versions/2.3/lib/python2.3/site-packages').  I'll keep the  
documentation, etc. as you encouraged.


> You can script Excel directly from Python via appscript which talks to
> scriptable Mac apps via the same API as AppleScript:...


Very cool!  Thanks very much for sharing this.  I'll definitely look  
into 'appscript'.


> If you need more info just ask.


Thanks again Has, for taking the time to share all this!  I really  
appreciate it!

Jay

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


Python mode

2007-08-09 Thread jay

I'm starting to learn how to use emacs (on Mac OS 10.4)
and I found that you can load something called python-mode.el which  
looks like it can help when writing Python
code in emacs.  I'm hoping it can color python syntax as well as  
indent it correctly, etc.

My problems are:

1.  Where should you place the 'python-mode.el' file?  I downloaded a  
folder from 'sourceforge.net' that contains 4
files (python-mode.el, doctest-mode.el, pycomplete.el and  
pycomplete.py).  I couldn't find any installation
instructions anywhere.  Do I use all 4 files or just the one and where  
should it go?  One web-site said the 'python-
mode.el' file needed to be compiled before being moved to whereever it  
needs to go.  How does one compile these things?


2.  All the web-sites I found about installing this said I should  
change my .emacs file which should be located in
my home folder.  I can't find a .emacs file anywhere on my machine.   
The only thing close to it is a .emacs.d folder
which contains an autosave folder.  Does anyone know where this .emacs  
file is located?  Or do I need to manually create one?


Thanks for looking at my questions.

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

Extending logging module

2007-08-09 Thread jay
Hello,

I've been using the python logging module a lot lately, and I've come
across an instance where I need some new levels.  Specifically, python
does not include ALERT and NOTICE in the default set of logging
levels.  I am wondering how trivial it would be to extend the logging
module to include these 2 levels that are standard with syslog?

My first test was just to use the addLevelName method to add the two
new levels, but syslog ignores them and logs at the next highest
priority, no matter what I use.

Looking further into the code and as a test, I changed the following
to see if this would even work

lib/python2.5/logging/__init__.py
  -> class Logger
  -> add new notice and alert root level functions
  -> new _levelNames for notice and alert
  -> new default level names for notice and alert

lib/python2.5/logging/handlers.py
  -> class SysLogHandler priority_map was changed to include notice
and alert

It actually worked, but this is not the way I would like to handle the
problem.  I would prefer to extend the classes instead.  However, I'm
not too familiar with that, and I had to change things in so many
places, I'm wondering if its even possible?  I don't like changing the
standard libraries, what happens if I have to upgrade python?  My
changes get overwritten.

Can anyone offer some help or suggestions?  Thanks

Jay

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


connect to server question

2007-12-03 Thread jay
Is there a way to connect to servers on OS X using Python?

Here's the code I presently use in a Bash Shell script:

 /bin/mkdir -p /Volumes/A_Share
 /sbin/mount_afp "afp://username:[EMAIL PROTECTED]/A_Share" "/ 
Volumes/A_Share"

Can something similar be done with Python?

Thanks!

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


Compleated Begginers Guide. Now What?

2006-04-08 Thread Jay
I have compleated the beginers guide to python
http://www.freenetpages.co.uk/hp/alan.gauld/.
then i found the Toolkit Tkinter and started on that. its graight and
av made lots of apps to help me with litle things but i have a big
problem. the CLASS method.

when i seperate things up into classes i carnt get one class to tell
the other class somthing. it just opens another coppy of the class. i
am confused.

oh and i carnt fathem out how to run to loops at the same time. EG .
Ball Blaster i wanted to permenetly run the ball with a loop well my
main loop ran the bat.

can sumone point me to the right studeing material.

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


Re: Compleated Begginers Guide. Now What?

2006-04-08 Thread Jay
Verry true but no help at all

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


Re: Compleated Begginers Guide. Now What?

2006-04-08 Thread Jay
Verry true but no help at all

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


Re: Compleated Begginers Guide. Now What?

2006-04-08 Thread Jay
Thank you Martin Christensen and i am sorry for not explaning well. i
will tack that advice

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


Tkinter

2006-04-08 Thread Jay
Cold somebody please enlighten me at why code 1 works perfectly and yet
code to will not display the gif file.

code 1
---START-

from Tkinter import *

root = Tk()

MainFrame = Canvas(root)
MainFrame.pack()

BackgroundFile = PhotoImage(file="Background.GIF")
Background = MainFrame.create_image(0, 0, image=BackgroundFile)

root.mainloop()

---END-

code 2
---START-

from Tkinter import *

class App:
def __init__(self, root):
self.MainFrame = Canvas(root)
self.MainFrame.pack(fill=BOTH, expand=1)

BackgroundFile = PhotoImage(file="Background.GIF")
Tank1 = self.MainFrame.create_image(0, 0, image=BackgroundFile)

root = Tk()
app = App(root)
root.mainloop()

---END-----
Thanks 

Jay

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


Re: Tkinter

2006-04-09 Thread Jay
Now I just get this error message.

AttributeError: 'int' object has no attribute 'image'

But the picture appears so I am almost their.

---START---

from Tkinter import *

class App:
def __init__(self, root):
self.MainFrame = Canvas(root)
self.MainFrame.pack(fill=BOTH, expand=1)

BackgroundFile = PhotoImage(file="Background.GIF")
Background = self.MainFrame.create_image(0, 0,
image=BackgroundFile)
Background.image = BackgroundFile # keep a reference!


root = Tk()
app = App(root)
root.mainloop()

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


Re: Tkinter

2006-04-09 Thread Jay
Brill, Thanks for the help

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


Python Shell window

2006-04-10 Thread Jay
Is their any way of setting wear the Python Shell window appears on the
screen when I run my program?

I am testing a full screen program with no Window Frame on a comp with
2 monitors and I have to keep pressing the  Key to bring the
Shell to the front and then moving it manually to the other screen
every time I restart the program.

I would like it to just appear on the other screen from the start.

Any ideas

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


base64

2006-04-12 Thread Jay
I have bean trying to get my head around reading .GIF files from base64
strings,
Basically I need to specify a filename and convert it to base64 then I
can copy/past the string to wear I want it.
Cold somebody check this for me to see what I have done wrong:

If you run this program and enter a path for a .GIF file into the white
box and hit  it should display the string in the blue box.

To test this if you click the menu File Display it will create a top
level window displaying the image and giving the original string
underneath.

The bit I can not understand:

It will generate the base64 string but when trying to display it, it
reads the string up until the first ("/n") ("Cg==") 
and then stops.

The base 64 string seams to be complete but when converted back it is
incomplete.

Thanks

Jay Dee

...START..

from Tkinter import *
from base64 import *



# Module:   Base64 Encoder / Decoder.py
# Author:   Jay Dee
# Date: 08/04/2006
# Version:  Draft 0.1
# Coments:  A Base64 Encoder / Decoder for converting files into Base64
strings



class App:
def __init__(self, root):
root.title("Base64 Encoder / Decoder")

#   Menu Bar

self.menubar = Menu(root)
# create a pulldown menu, and add it to the menu bar
self.filemenu = Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label="Display!",
command=self.Display)
self.filemenu.add_separator()
self.filemenu.add_command(label="Quit!", command=root.quit)
self.menubar.add_cascade(label="File", menu=self.filemenu)
# display the menu
root.config(menu=self.menubar)

#   Main

#   File Input
self.FileInputFrame = Frame(root)
self.FileInputFrame.pack(side=TOP, fill=X)

self.FileInputLine = Entry(self.FileInputFrame,
  bg="white",
  width=70)
self.FileInputLine.pack(side=LEFT, fill=X, expand=1)
#   Display Area
self.DisplayFrame = Frame(root)
self.DisplayFrame.pack(side=TOP, fill=BOTH, expand=1)

self.DisplayText = Text(self.DisplayFrame,
 bg="lightblue",
 width=95,
 height=40)
self.DisplayText.pack(side=LEFT, fill=BOTH, expand=1)

root.bind("",self.Encode)

def Encode(self,event):
'''
Take's the string from (self.FileInputLine),
converts it to base64 then desplays it in (self.DisplayText)
'''
self.DisplayText.delete(1.0,END)

info = self.FileInputLine.get()
if info == "":
self.DisplayText.insert(END, "...Empty String...")
else:
try:
file = open(info)
try:
while 1:
line = file.readline()
if not line:
break
Encode = b64encode(line)
self.DisplayText.insert(END, Encode)
except:
self.DisplayText.insert(END, "...Data Problem...")

except:
self.DisplayText.insert(END, "...No Sutch File...")

def Display(self):
'''
Take's the string from (self.DisplayText), Creats a topleval
frame and displays the Data
'''
info = self.DisplayText.get(1.0,END)
# Display as Image
try:
self.DisplayImage = Toplevel()

self.InfoDisplay = PhotoImage(data=info)
PhotoSize =
[self.InfoDisplay.width(),self.InfoDisplay.height()]

self.DisplayImageCanvas = Canvas(
self.DisplayImage,
width=150,
height=PhotoSize[1] + 15)
self.DisplayImageCanvas.pack(fill=BOTH, expand=1)


self.InfoDisplay2 = self.DisplayImageCanvas.create_image(
PhotoSize[0] / 2 + 10,
PhotoSize[1] / 2 + 10,
image=self.InfoDisplay)
self.InfoDisplay2 = self.DisplayImageCanvas
except:pass
# Display as Text
  

Re: base64

2006-04-13 Thread Jay
I don't know whether it is right yet but it dues what I wanted it to
do now so thank you all,

Oh and sorry for my bad grammar.

One last thing though is that I would like to be able to split the
string up into lines of 89 carictors, I have lookd through the split
methods and all I can find is splitting up words and splitting at a
pacific caricature, I can not see how you split after a number of
caricatures


...START..

from Tkinter import *
from base64 import *

#
#
# Module:   Base64 Encoder / Decoder.py
# Author:   Jay Dee
# Date: 08/04/2006
# Version:  Draft 0.1
# Coments:  A Base64 Encoder / Decoder for converting files into Base64
strings
#
#

class App:
def __init__(self, root):
root.title("Base64 Encoder / Decoder")
#
#   Menu Bar
#
self.menubar = Menu(root)
# create a pulldown menu, and add it to the menu bar
self.filemenu = Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label="Display!",
command=self.Display)
self.filemenu.add_separator()
self.filemenu.add_command(label="Quit!", command=root.quit)
self.menubar.add_cascade(label="File", menu=self.filemenu)
# display the menu
root.config(menu=self.menubar)
#
#   Display B64 Text
#
#   File Input
self.FileInputFrame = Frame(root)
self.FileInputFrame.pack(side=TOP, fill=X)

self.FileInputLine = Entry(self.FileInputFrame,
  bg="white",
  width=70)
self.FileInputLine.pack(side=LEFT, fill=X, expand=1)
#   Display Area
self.DisplayFrame = Frame(root)
self.DisplayFrame.pack(side=TOP, fill=BOTH, expand=1)

self.DisplayText = Text(self.DisplayFrame,
 bg="lightblue",
 width=95,
 height=40)
self.DisplayText.pack(side=LEFT, fill=BOTH, expand=1)

root.bind("",self.Encode)

def Encode(self,event):
'''
Take's the file name from (self.FileInputLine),
opens file,
converts it to base64 then desplays it in (self.DisplayText)
'''
self.DisplayText.delete(1.0,END)

info = self.FileInputLine.get()
if info == "":
self.DisplayText.insert(END, "...Please enter file...")
else:
try:
file = open(info,"rb")
try:
Data = file.read()
Encode = b64encode(Data)
Encode = Encode.split()
self.DisplayText.insert(END, Encode)
except:
self.DisplayText.insert(END, "...Data Erra...")

except:
self.DisplayText.insert(END, "...No Sutch File...")

def Display(self):
'''
Take's the string from (self.DisplayText), Creats a topleval
frame and displays the Data as an image,if that fales it
displays it as text.
'''
info = self.DisplayText.get(1.0,END)
# Display as Image
try:
self.DisplayImage = Toplevel()

self.InfoDisplay = PhotoImage(data=info)
PhotoSize =
[self.InfoDisplay.width(),self.InfoDisplay.height()]

self.DisplayImageCanvas = Canvas(
self.DisplayImage,
width=150,
height=PhotoSize[1] + 15)
self.DisplayImageCanvas.pack(fill=BOTH, expand=1)


self.InfoDisplay2 = self.DisplayImageCanvas.create_image(
PhotoSize[0] / 2 + 10,
PhotoSize[1] / 2 + 10,
image=self.InfoDisplay)
self.InfoDisplay2 = self.DisplayImageCanvas

# Display as Text
except:
self.DisplayBase64Text = Text(
self.DisplayImage,
width=70,
height=30)
self.DisplayBase64Text.pack(fill=BOTH, expand=1)

Decode = b64decode(info)
self.DisplayImageText.insert(END, Decode)


root = Tk()
app = App(root)
root.mainloop()

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


Tkinter

2006-04-16 Thread Jay
I wold like to be able to generate buttons from a list in a file.
How would I go about making each button have a different command,
Lets say make the button print its label instead of print "."

The problem I have is I don't know what the list is going to be until
it is opened or how big so I carnet make a def for each.

And I don't know how to do it with a loop

Thanks

--Code---

from Tkinter import *

class App:
def __init__(self, root):

self.DisplayAreaListsFrame = Frame(root)
self.DisplayAreaListsFrame.pack()

Lists = ["A1","B2","C3","D4"]

for i in Lists:
self.DisplayAreaListButton = Button(
self.DisplayAreaListsFrame,
text=i,
command=self.ListButtonCommand)
self.DisplayAreaListButton.pack(side=LEFT,padx=10)

def ListButtonCommand(self):
print "."

root = Tk()
app = App(root)
root.mainloop()

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


Re: Tkinter

2006-04-16 Thread Jay
I still dont quite get it, is their sum kind of way you can [def Newdef
+ i()] for example so that the def is different from the string, all
the buttons now have numbers on

If I am not mistaken Fredrik Lundh rote the tutorial Learning to
program (Python) www.freenetpages.co.uk/hp/alan.gauld/   and
www.effbot.org

If this is the same person then thank you for everything I no about
python it seams what ever I try and learn about Python it is always you
who helps or has wrote docs to help Newbie's and well everyone
really.

---code---
 from Tkinter import *

class App:
def __init__(self, root):

self.DisplayAreaListsFrame = Frame(root)
self.DisplayAreaListsFrame.pack()

Lists = ["A1","B2","C3","D4"]
for i in Lists:
def i():
print i
self.DisplayAreaListButton = Button(
self.DisplayAreaListsFrame,
text=i,
command=i)
self.DisplayAreaListButton.pack(side=LEFT,padx=10)



root = Tk()
app = App(root)
root.mainloop()

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


CGI scripts

2006-04-17 Thread Jay
Can I use Python for CGI scripts. It is telling me to use Perl and I
don't know any

To be honest I don't really no what CGI scripts are (soz)

I have purchased a domain name of my ISP PIPEX and 100MB space

And I don't know what I can do with it now

OPPs

Jay Dee

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


automate minesweeper with python

2010-06-30 Thread Jay
I would like to create a python script that plays the Windows game
minesweeper.

The python code logic and running minesweeper are not problems.
However, "seeing" the 1-8 in the minesweeper map and clicking on
squares is. I have no idea how to proceed.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >