Yet another split string by spaces preserving single quotes problem

2012-05-14 Thread Massi
Hi everyone,
I know this question has been asked thousands of times, but in my case
I have an additional requirement to be satisfied. I need to handle
substrings in the form 'string with spaces':'another string with
spaces' as a single token; I mean, if I have this string:

s =This is a 'simple test':'string which' shows 'exactly my'
problem

I need to split it as follow (the single quotes must be mantained in
the splitted list):

[This, is,  a,  'simple test':'string which', shows,
'exactly my', problem]

Up to know I have written some ugly code which uses regular
expression:

splitter = re.compile((?=\s|^)('[^']+') | ('[^']+')(?=\s|$))

temp = [t for t in splitter.split(s) if t not in [None, '']]
print temp
t = []
for i, p in enumerate(temp) :
for x in ([p] if (p[0] == ' and p[1] == ') else p.split('
')) :
t.append(x)

But it does not handle colon case.
Any hints? Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


PyDev and multithreaded application debug

2011-12-12 Thread Massi
Hi everyone, I've just started to use pydev to develop my python
application and I'm encountering some problems to debug it. The
application I'm dealing with is a multithreaded application; when I
try to debug it with pydev, it seems not to be able to handle the
execution of multiple threads. The problem is that when the execution
reaches a breakpoint in one of the threads, all the other ones don't
stop, but they continue their execution.
Have I to make some specific settings or am I missing something?
Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic variable creation from string

2011-12-09 Thread Massi
Thank you all for your replies, first of all my Sum function was an
example simplifying what I have to do in my real funciton. In general
the D dictionary is complex, with a lot of keys, so I was searching
for a quick method to access all the variables in it without doing the
explicit creation:

a, b, c = D['a'], D['b'], D['c']

and without using directly the D dictionary (boring...).
When I talked about nested function I meant both cases Chris, but this
is not a really tighten bound.
I tried to follow the hints of Chris together with some help by google
and used the following code:

for k in D : exec %s = D[k] %k

That seems to do the trick, but someone speaks about dirty code, can
anyone point me out which problems this can generate?
Again, thank you for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamic variable creation from string

2011-12-07 Thread Massi
Hi everyone,

in my script I have a dictionary whose items are couples in the form
(string, integer values), say

D = {'a':1, 'b':2, 'c':3}

This dictionary is passed to a function as a parameter, e.g. :

def Sum(D) :
return D['a']+D['b']+D['c']

Is there a way to create three variables dynamically inside Sum in
order to re write the function like this?

def Sum(D) :
# Here some magic to create a,b,c from D
return a+b+c

It is really important that the scope of a,b,c is limited to the Sum
function, they must not exisit outside it or inside any other nested
functions.
Thanks in advance for your help!

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


Automatic import of submodules

2011-11-25 Thread Massi
Hi everyone,

in my project I have the following directory structure:

plugins
|
-- wav_plug
  |
  -- __init__.py
  -- WavPlug.py
-- mp3_plug
  |
  -- __init__.py
  -- Mp3Plug.py
...
-- etc_plug
  |
  -- __init__.py
  -- EtcPlug.py

Every .py file contain a class definition whose name is identical to
to the file name, so in my main script I have to import each submodule
like that:

from plugins.wav_plug.WavPlug import WavPlug
from plugins.wav_plug.Mp3Plug import Mp3Plug

and so on. This is uncomfortable, since when a new plugin is added I
have to import it too. So my question is, is it possible to iterate
through the 'plugins' directory tree in order to automatically import
the submodules contained in each subdirectory?
I googled and found that the pkgutil could help, but it is not clear
how. Any hints?
Thanks in advance.

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


String splitting by spaces question

2011-11-23 Thread Massi
Hi everyone,

I have to parse a string and splitting it by spaces. The problem is
that the string can include substrings comprises by quotations which
must mantain the spaces. What I need is to pass from a string like:

This is an 'example string'

to the following vector:

[This, is, an, example string]

Which is the best way to achieve this?
Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Multiple windows services on the same machine

2011-06-05 Thread Massi
Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
_svc_name_ = 'MyService'
_svc_display_name_ = 'Instance ofMyService'

def __init__(self, args) :
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self) :
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
sys.stopservice = true
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self) :
#Do something...

So can anyone point me out which is the best way to parametrize the
service name? Thanks in advance for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


py2exe: executable is slower than code run from the interpreter

2011-06-04 Thread Massi
Hi everyone,
I'm writing a big program (windows 7, python 2.6.6) which includes
lots of python libraries (SQLalchemy, PyQt, SocketServer,
Matplotlib,...). Now I'm trying to build a stand alone executable with
py2exe (0.6.9) and everything works great. The only issue is that the
executable seems to be slower with respect to the same code run from
Idle.
For example, at stratup my program sets up a server and during the
execution sends commands to it and waits for reply. In the code case
the average time needed to process a given command is 0.24s, in the
executable case it raises to 0.30 (times are obviously measured
considering the same command).
It is really difficult for me to build a small example script to show
the problem, so I guess if anyone knows if there are some issues in
py2exe that could bring such a performance loss. Any hints is welcome,
thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Py2exe problem with pyqt+matplotlib

2011-03-15 Thread Massi
I everyone,

I'm trying to write a setup file for py2exe (0.6.9) to convert my
script into a windows (on win 7) executable. In my script (python2.6)
I use PyQt and matplotlib. Here is the setup.py file:

from distutils.core import setup
import py2exe
import matplotlib as mpl
import glob, shutil

mpl.use('qt4agg')
shutil.rmtree(build, ignore_errors=True)

includes = ['sip', 'PyQt4', 'PyQt4.QtGui', 'matplotlib.backends',
win32com, win32service, win32serviceutil,
win32event,
sqlalchemy.dialects.mssql, pyodbc, datetime,
decimal,
sqlalchemy.dialects.mysql, MySQLdb]
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter', 'pydoc', 'doctest', 'test',
'wx']
packages = ['matplotlib', 'pytz', encodings]
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
'tcl84.dll',
libgdk_pixbuf-2.0-0.dll, 'tk84.dll']
data_files = mpl.get_py2exe_datafiles()

setup(name=MyProg,
  windows=[{script: 'Main.pyw',
icon_resources: [(1, colorrulex.ico)]}],
  options = {py2exe: {compressed:2, optimize:2,
includes:includes,
excludes: excludes, packages:
packages,
dll_excludes: dll_excludes,
bundle_files:2,
dist_dir:'dist', xref:False,
skip_archive:False, ascii: False,
custom_boot_script:''}},
zipfile = r'lib\library.zip',
data_files=data_files
)

If I run 'python setup.py py2exe' at the command line the executable
is successfully created, but when I run MyProg.exe I get the following
error:
Traceback (most recent call last):
  File Main.pyw, line 4, in module
  File zipextimporter.pyo, line 82, in load_module
  File gui\tree\ComponentTree.pyo, line 2, in module
  File zipextimporter.pyo, line 82, in load_module
  File gui\stage\Item.pyo, line 6, in module
  File zipextimporter.pyo, line 82, in load_module
  File components\CompDataView.pyo, line 10, in module
  File zipextimporter.pyo, line 82, in load_module
  File components\dataview\PlotPanel.pyo, line 2, in module
  File zipextimporter.pyo, line 82, in load_module
  File plot\PlotCanvas.pyo, line 8, in module
  File zipextimporter.pyo, line 82, in load_module
  File pylab.pyo, line 1, in module
  File zipextimporter.pyo, line 82, in load_module
  File matplotlib\pylab.pyo, line 263, in module
  File zipextimporter.pyo, line 82, in load_module
  File matplotlib\pyplot.pyo, line 95, in module
  File matplotlib\backends\__init__.pyo, line 25, in pylab_setup
  File zipextimporter.pyo, line 82, in load_module
  File matplotlib\backends\backend_tkagg.pyo, line 8, in module
ImportError: No module named Tkinter

Obviously Tkinter is not imported since I'm using pyqt, so can anyone
point me out what I'm doing wrong?
Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


SocketServer problem: client hangs trying to reconnect after server restart

2011-02-28 Thread Massi
Hi everyone!

in my script (Python 2.6 on windows 7) I have to set up a SocketServer
server and use it to handle external connections. During the execution
It can happen that this server should be closed and restarted (for
example with different port or host). The following piece of code
simulates the situation I have to deal with:

import SocketServer, socket, threading
from time import sleep
BUF_LENGTH = 1024

class MyHandler(SocketServer.BaseRequestHandler) :
def handle(self):
while 1:
data = self.request.recv(1024)
self.request.send(data)
if data.strip() == 'bye':
return

class MyServer(SocketServer.ThreadingTCPServer) :
def __init__(self, host, port, handler) :
self.allow_reuse_address = True
self.__handler = handler
self.__serving = True
SocketServer.ThreadingTCPServer.__init__ (self, (host, port),
handler)

def StartServer(self) :
self.serve_forever()

def StopServer(self) :
self.shutdown()

def Init() :
server = MyServer(localhost, 5000, MyHandler)
threading.Thread(target=server.StartServer).start()
sleep(0.5)

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((localhost, 5000))
sock.send(hi)
sock.recv(BUF_LENGTH)
sock.send(bye)
return server

def CleanUp(server) :
server.StopServer()

for i in range(3) :
print -- Connection: +str(i)+ --
server = Init()
CleanUp(server)

print Finished

If you ran the code you'll see that the client hangs after the first
connection. Can anyone point me out where I'm doing wrong? Thanks in
advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SocketServer problem: client hangs trying to reconnect after server restart

2011-02-28 Thread Massi
On 28 Feb, 13:34, cmcp mcphail_co...@hotmail.com wrote:
 In method StopServer() of class MyServer try calling  self.server_close() 
 after the self.shutdown() call.  I believe this will actually close the 
 server's socket and allow its reuse.

It works! Thank you!!
-- 
http://mail.python.org/mailman/listinfo/python-list


SQLalchemy+py2exe+pymssql error

2010-07-21 Thread Massi
Hi everyone, I'm trying to build an executable with py2exe. My script
uses SQLalchemy and pymssql with python 2.6. Here is my setup file:

from distutils.core import setup
import py2exe

manifest = 
?xml version=1.0 encoding=UTF-8 standalone=yes?
assembly xmlns=urn:schemas-microsoft-com:asm.v1
manifestVersion=1.0
assemblyIdentity
version=0.64.1.0
processorArchitecture=x86
name=Controls
type=win32
/
descriptionmyProgram/description
dependency
dependentAssembly
assemblyIdentity
type=win32
name=Microsoft.Windows.Common-Controls
version=6.0.0.0
processorArchitecture=X86
publicKeyToken=6595b64144ccf1df
language=*
/
/dependentAssembly
/dependency
dependency
dependentAssembly
assemblyIdentity
type=win32
name=Microsoft.VC90.CRT
version=9.0.21022.8
processorArchitecture=x86
publicKeyToken=1fc8b3b9a1e18e3b
/
/dependentAssembly
/dependency
/assembly



setup(name=MyProg,
  windows=[{script: MyProg.py,
  other_resources: [(24,1,manifest)]}],
  options={py2exe: {includes:[ sqlalchemy.dialects.mssql,
pymssql, _mssql]}}
)

The executable is successfully built up, but when I run the program I
get the following error message:

Exception in thread Thread-3:
Traceback (most recent call last):
  File threading.pyc, line 532, in __bootstrap_inner
  File threading.pyc, line 484, in run
  File MyProg.py, line 166, in DatabaseSetup
  File sqlalchemy\engine\__init__.pyc, line 241, in create_engine
  File sqlalchemy\engine\strategies.pyc, line 60, in create
  File sqlalchemy\dialects\mssql\pymssql.pyc, line 61, in dbapi
  File pymssql.pyc, line 12, in module
  File pymssql.pyc, line 10, in __load
  File _mssql.pxd, line 10, in init pymssql (pymssql.c:7364)
  File _mssql.pyc, line 12, in module
  File _mssql.pyc, line 10, in __load
  File _mssql.pyx, line 36, in init _mssql (_mssql.c:14941)
ImportError: No module named uuid

Can anyone point  me out what I am doing wrong? Thanks you in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


SqlAlchemy: remote connection on problem on mysql database

2010-07-09 Thread Massi
Hi everyone,

in my script I'm trying to connect to a remote database using
sqlalchemy. Since I'm pretty new to this library I'm not really sure
of what I am doing :-). Up to now what I'm doing to connect to the
database is this:

engine = create_engine(mysql://
my_username:my_passw...@phpmyadmin.myhost.com/my_db_name)
metadata = MetaData(engine, reflect=True)

If I run this script I get the following error:

Traceback (most recent call last):
  File C:\Documents and Settings\pc2\Desktop\prova.py, line 9, in
module
metadata = MetaData(engine, reflect=True)
  File C:\Python25\lib\site-packages\sqlalchemy-0.6.0-py2.5.egg
\sqlalchemy\schema.py, line 1770, in __init__
self.reflect()
  File C:\Python25\lib\site-packages\sqlalchemy-0.6.0-py2.5.egg
\sqlalchemy\schema.py, line 1879, in reflect
connection=conn))
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\base.py, line 1604, in table_names
conn = self.contextual_connect()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\base.py, line 1592, in contextual_connect
return self.Connection(self, self.pool.connect(),
close_with_result=close_with_result, **kwargs)
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 154, in connect
return _ConnectionFairy(self).checkout()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 318, in __init__
rec = self._connection_record = pool.get()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 173, in get
return self.do_get()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 665, in do_get
con = self.create_connection()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 134, in create_connection
return _ConnectionRecord(self)
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 209, in __init__
self.connection = self.__connect()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\pool.py, line 271, in __connect
connection = self.__pool._creator()
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\strategies.py, line 76, in connect
return dialect.connect(*cargs, **cparams)
  File c:\python25\lib\site-packages\SQLAlchemy-0.6.0-py2.5.egg
\sqlalchemy\engine\default.py, line 227, in connect
return self.dbapi.connect(*cargs, **cparams)
  File C:\Python25\lib\site-packages\MySQLdb\__init__.py, line 74,
in Connect
return Connection(*args, **kwargs)
  File C:\Python25\lib\site-packages\MySQLdb\connections.py, line
170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (2003, Can't connect to MySQL
server on 'phpmyadmin.myhost.com' (10060)) None None

Is there something I am missing? thanks in advance for the help!
-- 
http://mail.python.org/mailman/listinfo/python-list


ctypes:Multiple library access problem

2010-05-06 Thread Massi
Hi everyone,

in my script I need to execute multiple separated loading of the same
dll library, in order to handle the internal variables with different
threads.
Consider the followin piece of code:

lib1 = cdll.LoadLibrary(MyLib.dll))
lib2 = cdll.LoadLibrary(MyLib.dll))

lib1.var1 = 0
lib2.var1 = 1

Now, if I print the value of lib1.var1 I get 1, that is lib1 and lib2
point to the same memory space. Is there a way to create different
instances of the same library? Or, alternatively, does it exist any
workaround to avoid lib1 and lib2 share the same memory space?

Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Create a new process to run python function

2010-05-05 Thread Massi
Hi everyone,

in my script (python 2.5 on windows xp) I need to run a simple
function in a separate process. In other words I need something
similar to the fork function under UNIX. I tried with threads:

import os, threading

def func(s) :
print I'm thread number +s, os.getpid()

threading.Thread(target=func, args=(1,)).start()
threading.Thread(target=func, args=(2,)).start()

but this does not work, since the two threads share the same pid. Can
anyone give me a suggestion?
Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Urllib and login

2009-09-10 Thread Massi
Hi everyone, I'm trying to get data from an internet page which is
accessed from a login page. Looking at the html source code of the
login page I found that the name of the controls which handle username
and password are login_un and login_pw. So I tried to write a
piece of code to access the data of the protected page:

import urllib2, urllib

opener = urllib2.build_opener()
login_data = urllib.urlencode({login_un : my_un, login_pw :
my_pw})
opener.open('http://www.myprotectedsite.com/login_page', login_data)
resp = opener.open('http://www.myprotectedsite.com/hidden_page')
print resp.read()

But it doesn't work, since it prints the html code of the login page.
Can anyone point me out what I'm doing wrong?
Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Web page data and urllib2.urlopen

2009-08-05 Thread Massi
Hi everyone, I'm using the urllib2 library to get the html source code
of web pages. In general it works great, but I'm having to do with a
financial web site which does not provide the souce code I expect. As
a matter of fact if you try:

import urllib2
res = urllib2.urlopen(http://www.marketwatch.com/story/mondays-
biggest-gaining-and-declining-stocks-2009-07-27)
page = res.read()
print page

you will see that the printed code is very different from the one
given, for example, by mozilla. Since I have really little knowledge
in html I can't even understand if this is a python or html problem.
Can anyone give me some help?
Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Bug in IEHtmlWindow?

2009-07-30 Thread Massi
Hi everyone, I'm trying to use IEHtmlWindow in my application (python
2.5, wxpython 2.8 on win xp). Everything is ok, but I encountered a
problem which also affects the demo. If I make a research on google a
strange message appears, saying (I'll try to translate from italian):

Error during execution.
Do you want to run the debug?

line 29:
error: 'r' is NULL or it is not an object

Did anybody have the same problem? is it a bug?
Thanks in advance for your help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Ctypes debug of dll function

2009-02-21 Thread Massi
Hi everyone, I'm pretty new to the ctypes module and I'm encountering
a problem. I'm working under windows xp with python 2.5 and in my
script I use ctypes to call from a dll some functions I wrote in C.
When I call one of these functions it happens that my script crashes
raising the following error:
WindowsError: exception: access violation writing 0x
My question is...is there a way to debug my C function from the dll
while it is run from the python script?
Thanks in advance for the help.
--
http://mail.python.org/mailman/listinfo/python-list


Matplotlib on Leopard Mac OS

2008-11-26 Thread Massi
Hi everyone, I've got some problems trying to install matplotlib on my
mac (Leopard OS). I'm following the instructions I found in the
official site to install it from the egg file (http://
matplotlib.sourceforge.net/users/installing.html), but when I run
easy_install ./matplotlib-0.98.3-py2.5-macosx-10.3.egg, I get this
error message:

BUILDING MATPLOTLIB
matplotlib: 0.98.3
python: 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC
4.0.1 (Apple Inc. build 5465)]
  platform: darwin

REQUIRED DEPENDENCIES
* numpy 1.1 or later is required; you have
1.0.1
error: Setup script exited with 1

In fact I did install numpy 1.2.1, so I can't understand why it
doesn't fin it! Any help? Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Midi manipulation

2008-11-17 Thread Massi
On 16 Nov, 23:23, Tim Roberts [EMAIL PROTECTED] wrote:
 Massi [EMAIL PROTECTED] wrote:

 Hi everyone, I'm searching for something which allows me to write
 scripts which handle midi files. I'm totally a newbie in audio
 manipulation, therefore any suggestion or link related to this field
 is welcome. Thanks in advance.

 Google is much faster than this newsgroup.  Search for python midi
 library and the first page gives you a number of good hits.

 However, there's a lot to manipulating MIDI.  What kinds of things are you
 hoping to accomplish?  MIDI, for example, is not a particularly good way to
 store music for composition.
 --
 Tim Roberts, [EMAIL PROTECTED]
 Providenza  Boekelheide, Inc.

I'm writing a script for didactic musical purpose. As first step I
need something as simple as possible, for example a library of
functions which are able to play a certain note, with a given
instrument and a given length. I thought midi was good for this aim,
am I wrong?
--
http://mail.python.org/mailman/listinfo/python-list


Installing Python2.6 on Mac Os (Leopard)

2008-11-17 Thread Massi
Hi everyone, I'm trying to install Python2.6 on my mac (Leopard
10.5.5), but I'm encountering some problems. To install the package I
followed the instructions I found at this link:
http://wiki.python.org/moin/MacPython/Leopard
If I open wing, it turns out that the installed version is actually
2.6, but if i run python from terminal it displays version 2.5.1, that
is the default version for leopard. Furthermore I can't launch idle.
I'm pretty new to mac os environment so forgive me if my questions are
silly. Any hint?
--
http://mail.python.org/mailman/listinfo/python-list


Midi manipulation

2008-11-16 Thread Massi
Hi everyone, I'm searching for something which allows me to write
scripts which handle midi files. I'm totally a newbie in audio
manipulation, therefore any suggestion or link related to this field
is welcome. Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wx.Grid and popup over cells

2008-10-14 Thread Massi
On 14 Ott, 16:13, Mike Driscoll [EMAIL PROTECTED] wrote:
 On Oct 14, 5:21 am, Massi [EMAIL PROTECTED] wrote:

  Hi everyone,

  I'm writing a python script which uses a grid (PyGridTableBase) whose
  cells can contain very large values (not only numbers, but also
  strings). I've also written a custom renderer which dinamically shows
  only the first n characters (according to the width of the cell)
  replacing the last ones with dots. Now I would like to know if it is
  possible to have a popup which shows the whole contents of a certain
  cell when the mouse stops over the cell itself. Any ideas?
  Thanks in advance.

  Massi

 First off, let me recommend the wxPython mailing list for questions of
 this sort. You'll probably get more relevant help quicker if you go
 that route.

 Anyway, I've done tooltips on cells in a grid before and you'll need
 the same concept to use a pop-up dialog too. To begin, you'll want to
 bind to the mouse event, EVT_MOTION, like this:

 self.myGrid.GetGridWindow().Bind(wx.EVT_MOTION, self.onMouseOver)

 Next, you'll need to do something like the following in your mouse
 over function:

 code

 def onMouseOver(self, event):
 '''
 Method to calculate where the mouse is pointing and
 then set the tooltip dynamically.
 '''

 # Use CalcUnscrolledPosition() to get the mouse position
 within the
 # entire grid including what's offscreen
 x, y =
 self.totals_sheet.CalcUnscrolledPosition(event.GetX(),event.GetY())

 coords = self.totals_sheet.XYToCell(x, y)
 # you only need these if you need the value in the cell
 row = coords[0]
 col = coords[1]
 event.GetEventObject().SetToolTipString(My amazing tooltip)

 /code

 Hopefully that will get you going. If not, just ask more questions
 (here or at the wxPython list).

 ---
 Mike Driscoll

 Blog:  http://blog.pythonlibrary.org
 Python Extension Building Network:http://www.pythonlibrary.org

That's exactly what I needed, thank you!
--
http://mail.python.org/mailman/listinfo/python-list


Wx.Grid and popup over cells

2008-10-14 Thread Massi
Hi everyone,

I'm writing a python script which uses a grid (PyGridTableBase) whose
cells can contain very large values (not only numbers, but also
strings). I've also written a custom renderer which dinamically shows
only the first n characters (according to the width of the cell)
replacing the last ones with dots. Now I would like to know if it is
possible to have a popup which shows the whole contents of a certain
cell when the mouse stops over the cell itself. Any ideas?
Thanks in advance.

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


wxpython-wx.CheckListBox: changing item bacgkground color

2008-01-13 Thread Massi
Hi everyone! In my application (under windows) I'm using a
wx.checklistbox. I would like the background color of an item to
become red whenever an EVT_LISTBOX_DCLICK occurs. Is there any simple
way to achieve it?
Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Getting stdout from ctypes module

2007-03-02 Thread Massi
Hi everyone, I have a program which is written in C and interfaced
with python via
Ctypes.  The functions I call print stuff out to the console, using
the usual function printf. I would like to know if it is possible to
redirect the output of my C module to python. I'm working on windows
environment. Thanks in advance.

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


wxGrid: Problem with unicode mathematical symbols

2006-12-20 Thread Massi
Hi everyone, I'm trying to build (on windows environment) a grid in
which every cell contains a mathematical formula, the problem is the
following:
when I try to put in the cells some mathematical symbol (such as those
for belong to, for all or exists) with the method SetCellValue I
always see ∊ as the value of the cells, even if I use both the
unicode wx version and the right unicode strings for the symbols (such
as u'\u2208' for belong to ). In fact if I do (on IDLE):

print u'\u2208'

everything works fine. I can't understand why I am wrong. I also tried
to change the font of the cells in Arial Unicode MS, but the result
was the same.
Have you got any idea about?. Thanks in advance,
Massi

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

Cactching Stdout

2006-11-08 Thread Massi
Hi everyone! I'm writing a python script which uses a C-written dll. I
call the functions in the dll using ctypes, but I don't know how to
catch the output of the printf which the C functions use. In fact I
don't even know if it is possible! I've heard something about PIPE and
popen...is this what I need? How can I use them? It is very important
for me that I could take the output in real-time.
Thanks for the help!
Massi

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


Enum

2006-10-12 Thread Massi
Hi Everyone! Does anybody know how to implemet Enumeration in python
for Ctypes? Thank you!
Massi

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


Code generator

2006-10-12 Thread Massi
Hello NG! Can anybody explain me how to install the code generator fo
ctypes on my pc? I use windows...
for example I found this line command on the overview:

python h2xml.py windows.h -o windows.xml -q -c

Where do I have to type? and where do I have to put the file that I got
from the repository?
Thank you for the help!

Massi

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