Re: Desktop Notification/Alerts In Python

2006-08-29 Thread bugnthecode

Chaos wrote:
 alex23 wrote:
  Chaos wrote:
   I am looking for ways to have a Desktop Alert, like the one most IM
   Messengers have (MSN, AIM) at the lower right above the taskbar. Can
   anyone point me to the right resources to use?

I get these alerts from gmail-notify. It's for linux, but a quick look
over the source shows that it uses gtk which I believe to be a cross
platform library (though may be a little ugly on windows) I wouldn't
imagine it to be too hard to modify this to your needs.

Project home page:
http://gmail-notify.sourceforge.net/

HTH,
Will

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


Re: import

2006-08-20 Thread bugnthecode
How are you trying to import it? Is it in the same directory as your
other script? If not is your python path set correctly?

When importing a module that you have written you exlude the .py
extension. You should be using:
import hello

Hope that helps,
Will

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


Re-evaluating a string?

2006-07-23 Thread bugnthecode
I'm writing a program to send data over the serial port. I'm using
pyserial, and I'm on WindowsXP. When I use literals I can get the data
accross how I want it for example:

   1 2  3  4 5  6
serialport.write('!SC'+'\x01'+'\x05'+'\xFA'+'\x00'+'\r')

1=Get devices attention
2=Select channel on device
3=Rate for movement
4=Low byte of 16 bits
5=High bytes of 16 bits
6=Carriage return signaling command is over

This command works as desired. Sends the first 3 ASCII characters, then
some numbers in hex followed by a carriage return.

My problem is that the write() function only takes a string, and I
want to substitute variables for the hex literals.

I know that I can use the hex() function and it will return a string
with the appropriate hex value, and I could combine this with some
other literals like \\ to create my desired hex literal, but then I
would need something to re-parse my string to change my ASCII text into
the appropriate hex values.

Any ideas on how I may do this? Any help is greatly appreciated.

Thanks,
Will

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


Re: Re-evaluating a string?

2006-07-23 Thread bugnthecode
Thanks Tim, and John for your quick responses!

Tim, I tested your function and it works! Though I don't completely
understand how. Could you possibly explain this?

John, I test your MEDUIM_WAYand it works as well. How is it that
putting the string together this way translates into a hex value to be
transmitted to the serial port? When I manually tried to put a string
together I couldn't get this to happen. I was trying:

controlString = '!SC' + '\\' + ch.__str__() + '\\' + rate.__str__()
...etc

also I noticed you added another line to the code which appears to
split the low and high bytes for me? If so thanks! Could you also offer
an explanation on how this works. I tried a google search and couldn't
get a decent explanation. I implemented this a little differently as
you can see in my Position class. Could you possibly offer any info on
the benefits/drawbacks of the different methods?

Thanks again to both of you for your quick responses and help.

Will

import serial
import types

class Position:
def __init__(self, num):
Takes the position as an int, and splits the low and high
bytes

into instance members.
self.lowByte = num  0x00FF
self.highByte = (num  0xFF00)  8

def __str__(self):
Mainly for debugging purposes. Allows meaningful output when
printed
return 'Low: ' + self.lowByte.__str__() + '\nHigh: ' +
self.highByte.__str__()

def makeString(a):
Takes in  a list, and intelligentlly smashes everything
together.

Outputs everything as a hex string.
Posted by: Tim Chase on comp.lang.python
return ''.join([type(x) != types.IntType and
str(x) or chr(x) for x in a])

def getVer(localpsc):
Gets the version from the PSC. Mainly just to verify a
connection

localpsc.write('!SCVER?\r')
localpsc.read(8) #Discard the echo!
s = localpsc.read(3)
print s

def moveServo(localpsc, ch, rate, position):
Takes in a serial object, the desired channel, the ramp rate,
and
the desired position of ther servo. Moves the servo to the desired
postion.

#localpsc.write('!SC', ch, rate, position.low, position.high, '\r')
#controlString = makeString(['!SC', ch, rate, position.lowByte,
position.highByte, '\r'])
#localpsc.write(controlString)
#localpsc.flushInput() #discard the echo!

Following line from John Machin
controlString = !SC%c%c%c%c\r % (ch, rate, position.lowByte,
position.highByte)
localpsc.write(controlString)

psc = serial.Serial(1, 2400)

mypos = Position(2500)

moveServo(psc, 0, 5, mypos)
psc.close()

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