Re: Python crash after using weave inline

2007-04-18 Thread Soren
On Apr 18, 10:07 pm, Peter  Wang <[EMAIL PROTECTED]> wrote:
> Soren,
>
> For future reference, you might want to direct weave-related questions
> to the [EMAIL PROTECTED] mailing list.
>
> > def cartPolFast(xlen, ylen, x_c, y_c):
>
> > res = zeros((xlen,ylen))
>
> > code = """
> > {
> > int xlen, ylen, x_c, y_c;
>
> This line is unnecessary, because weave exposes those variables inside
> the local scope of your code.  This also makes the braces at the top
> and bottom of the code block unnecessary.
>
> > for( x = 0; x == xlen; x++)
> >for( y = 0; y == ylen; y++)
> > rel_x = x-x_c;
> > rel_y = y_c-y;
>
> > res(x,y) = rel_y*rel_y;
> > }
>
> Two things:
> 1. You need to put curly braces around the three lines of the inner
> loop.
> 2. You need to change "x == xlen" and "y == ylen" to "x < xlen" and "y
> < ylen".
>
> I made these modifications to your code and it runs fine on my machine
> (macbook pro, OS 10.4, scipy 0.5.2.dev2314).
>
> -peter

Thanks alot Peter!

I'm a bit rusty on the C! :)

Soren


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


Embedding Matplotlib in wxpython wx.Panel problem

2007-04-25 Thread Soren
Hi,

I'm trying to create a small GUI program where I can do plots using
Matplotlib. I've been trying to borrow code from the examples at the
matplotlib website, but I can't get it to work.

I want to be able to create a wx.Panel that contains an axis for
plotting. Around it i want other panels containing various settings,
buttons etc. to control the plot. So far I can't even get the program
to actually show a plot in a panel.

Does anyone here have experience in making a wxpython GUI with
matplotlib?

Any help would be appreciated!

Thanks,
Soren

My code shows a frame, and I'm trying to set up two panels.. one with
a plot and one with a button.. The plotpanel is just a little square
in the corner when I run it.. ???

My code is as follows:

import wx
import pylab
from matplotlib.numerix import arange, sin, cos, pi
import matplotlib

matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
matplotlib.interactive(False)

class App(wx.App):

def OnInit(self):
self.frame = MainFrame("Autoplotter", (50,60), (700,700))
self.frame.Show()

return True

class MainFrame(wx.Frame):

def __init__(self, title, pos, size):
wx.Frame.__init__(self, None, -1, title, pos, size)

pPanel = PlotPanel(self, -1)# Plot panel

bPanel = ButtonPanel(self, 100,500, (200,100))# button
panel

sizer = wx.BoxSizer(wx.VERTICAL)

sizer.Add(pPanel,0)
sizer.Add(bPanel,0)

self.SetSizer(sizer)

class ButtonPanel(wx.Panel):

def __init__(self, Parent, xPos, yPos, insize):

pos = (xPos, yPos)
wx.Panel.__init__(self, Parent, -1, pos, style =
wx.RAISED_BORDER, size = insize)

button = wx.Button(self, -1, 'HELLO!!', (10,10), (150,50))

class NoRepaintCanvas(FigureCanvasWxAgg):
"""We subclass FigureCanvasWxAgg, overriding the _onPaint method,
so that
the draw method is only called for the first two paint events.
After that,
the canvas will only be redrawn when it is resized.
"""
def __init__(self, *args, **kwargs):
FigureCanvasWxAgg.__init__(self, *args, **kwargs)
self._drawn = 0

def _onPaint(self, evt):
"""
Called when wxPaintEvt is generated
"""
if not self._isRealized:
self.realize()

if self._drawn < 2:
self.draw(repaint = False)
self._drawn += 1

self.gui_repaint(drawDC=wx.PaintDC(self))


class PlotPanel(wx.Panel):

def __init__(self, parent, id = -1, color = None,\
 dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE,
**kwargs):

wx.Panel.__init__(self, parent, id = id, style = style,
**kwargs)

self.figure = Figure(None, dpi)
self.canvas = NoRepaintCanvas(self, -1, self.figure)
self._resizeflag = True

self.Bind(wx.EVT_IDLE, self._onIdle)
self.Bind(wx.EVT_SIZE, self._onSize)

self._SetSize()

def draw(self):   # just draw something!
if not hasattr(self, 'subplot'):
self.subplot = self.figure.add_subplot(111)
theta = arange(0, 45*2*pi, 0.02)
rad = (0.8*theta/(2*pi)+1)
r = rad*(8 + sin(theta*7+rad/1.8))
x = r*cos(theta)
y = r*sin(theta)
#Now draw it
self.subplot.plot(x,y, '-r')

def _onSize(self, event):
self._resizeflag = True

def _onIdle(self, evt):
 if self._resizeflag:
 self._resizeflag = False
 self._SetSize()
 self.draw()

def _SetSize(self, pixels = None):
"""
This method can be called to force the Plot to be a desired
size, which defaults to
the ClientSize of the panel
"""
if not pixels:
pixels = self.GetClientSize()
self.canvas.SetSize(pixels)
self.figure.set_figsize_inches(pixels[0]/
self.figure.get_dpi(),
pixels[1]/self.figure.get_dpi())


if __name__ == "__main__":

app = App(0)
app.MainLoop()

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


embedding matplotlib in wxpython

2007-04-25 Thread Soren
Hi,

I've been trying to embed matplotlib in wxpython. I want to be able to
put a figure (axes) in a wx.Panel and place it somewhere in my GUI.
The GUI should have other panels with buttons etc. that can control
the output on the figure. I've been looking at the examples from the
matplotlib website, but can't seem to get it to work..

Does anyone here have experience in embedding matplotlib in wxpython?

I have attached my code.. it makes two panels.. one with a matplotlib
plot, and one with a button.. but the plotpanel is just a small square
in the corner !! ..

Any help is appreciated!

Thanks,
Soren


Code:
---

import wx
import pylab
from matplotlib.numerix import arange, sin, cos, pi
import matplotlib

matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
matplotlib.interactive(False)

class App(wx.App):

def OnInit(self):
self.frame = MainFrame("BioXtas - Autoplotter", (50,60),
(700,700))
self.frame.Show()

return True

class MainFrame(wx.Frame):

def __init__(self, title, pos, size):
wx.Frame.__init__(self, None, -1, title, pos, size)

pPanel = PlotPanel(self, -1)# Plot panel

bPanel = ButtonPanel(self, 100,500, (200,100))# button
panel

sizer = wx.BoxSizer(wx.VERTICAL)

sizer.Add(pPanel,0)
sizer.Add(bPanel,0)

self.SetSizer(sizer)

class ButtonPanel(wx.Panel):

def __init__(self, Parent, xPos, yPos, insize):

pos = (xPos, yPos)
wx.Panel.__init__(self, Parent, -1, pos, style =
wx.RAISED_BORDER, size = insize)

button = wx.Button(self, -1, 'HELLO!!', (10,10), (150,50))

class NoRepaintCanvas(FigureCanvasWxAgg):
"""We subclass FigureCanvasWxAgg, overriding the _onPaint method,
so that
the draw method is only called for the first two paint events.
After that,
the canvas will only be redrawn when it is resized.
"""
def __init__(self, *args, **kwargs):
FigureCanvasWxAgg.__init__(self, *args, **kwargs)
self._drawn = 0

def _onPaint(self, evt):
"""
Called when wxPaintEvt is generated
"""
if not self._isRealized:
self.realize()

if self._drawn < 2:
self.draw(repaint = False)
self._drawn += 1

self.gui_repaint(drawDC=wx.PaintDC(self))


class PlotPanel(wx.Panel):

def __init__(self, parent, id = -1, color = None,\
 dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE,
**kwargs):

wx.Panel.__init__(self, parent, id = id, style = style,
**kwargs)

self.figure = Figure(None, dpi)
self.canvas = NoRepaintCanvas(self, -1, self.figure)
self._resizeflag = True

self.Bind(wx.EVT_IDLE, self._onIdle)
self.Bind(wx.EVT_SIZE, self._onSize)

self._SetSize()

def draw(self):
if not hasattr(self, 'subplot'):
self.subplot = self.figure.add_subplot(111)
theta = arange(0, 45*2*pi, 0.02)
rad = (0.8*theta/(2*pi)+1)
r = rad*(8 + sin(theta*7+rad/1.8))
x = r*cos(theta)
y = r*sin(theta)
#Now draw it
self.subplot.plot(x,y, '-r')

def _onSize(self, event):
self._resizeflag = True

def _onIdle(self, evt):
 if self._resizeflag:
 self._resizeflag = False
 self._SetSize()
 self.draw()

def _SetSize(self, pixels = None):
"""
This method can be called to force the Plot to be a desired
size, which defaults to
the ClientSize of the panel
"""
if not pixels:
pixels = self.GetClientSize()
self.canvas.SetSize(pixels)
self.figure.set_figsize_inches(pixels[0]/
self.figure.get_dpi(),
pixels[1]/self.figure.get_dpi())


if __name__ == "__main__":

app = App(0)
app.MainLoop()

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


Multiple select in wx.GenericDirCrtl

2007-04-27 Thread Soren
Hi!

Is it possible to do multiple file selections in a wx.GenericDirCtrl??

Thanks,
Soren

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


Re: Multiple select in wx.GenericDirCrtl

2007-04-28 Thread Soren
On Apr 27, 3:13 pm, [EMAIL PROTECTED] wrote:
> On Apr 27, 7:31 am, Soren <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > Is it possible to do multiple file selections in a wx.GenericDirCtrl??
>
> > Thanks,
> > Soren
>
> I'm not finding anything. I do know you can select multiple files
> using the FileDialog. You should email the wxPython users group
> though. They may have a custom control or they will likely be able to
> point you in the right direction.
>
> http://www.wxpython.org/maillist.php
>
> Mike

I'll try that, thanks Mike!

Soren

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


How do I parse a string to a tuple??

2007-04-30 Thread Soren
Hi!

I have a string that contains some text and newline characters. I want
to parse the string so that the string just before a newline character
goes in as an element in the tuple.

ex:

"text1 \n text2 \n text3 \n text4"   --> (text1, text2, text3, text4)

Is there an easy way to do this?

Thanks!,
Soren

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


Re: How do I parse a string to a tuple??

2007-04-30 Thread Soren

Thanks alot everyone!

Soren

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


Boost Problem! Boost.Build not found

2007-04-16 Thread Soren
Hi!

I'm trying to extend my python program with some C++ code. Right now
I've spent hours just trying to get boost to work!

I'm trying to get the example hello.cpp to work.

Using Windows XP and Visual Studio 8   (.NET 2005)

I've set BOOST_BUILD_PATH = C:\boost\boost_1_33_1  (where i installed
boost)

I've changed the jamrules in C:\boost\boost_1_33_1\libs\python\example
\tutorial to

path-global BOOST_ROOT : C:\boost\boost_1_33_1 ;



No matter what I do i always get:

C:\boost\boost_1_33_1\libs\python\example\tutorial>bjam -sTOOLS=vc-8_0


Unable to load Boost.Build: could not find "boost-build.jam"
---
Attempted search from C:\boost\boost_1_33_1\libs\python\example
\tutorial up to t
he root and in these directories from BOOST_BUILD_PATH and BOOST_ROOT:
C:\boost\boost_1_
33_1.
Please consult the documentation at 'http://www.boost.org'.

Can anyone please tell me what I am doing wrong?? Theres no tutorial
on how to make a boost-build.jam file.. and as I understand I don't
need one as long as I set BOOST_BUILD_PATH ..

Any help is apprecieated!!

Thanks!,
Soren

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


Re: Boost Problem! Boost.Build not found

2007-04-16 Thread Soren
On 16 Apr., 12:53, "Rob Wolfe" <[EMAIL PROTECTED]> wrote:
> Soren wrote:
> > Unable to load Boost.Build: could not find "boost-build.jam"
> > ---
> > Attempted search from C:\boost\boost_1_33_1\libs\python\example
> > \tutorial up to t
> > he root and in these directories from BOOST_BUILD_PATH and BOOST_ROOT:
> > C:\boost\boost_1_
> > 33_1.
> > Please consult the documentation at 'http://www.boost.org'.
>
> > Can anyone please tell me what I am doing wrong?? Theres no tutorial
> > on how to make a boost-build.jam file.. and as I understand I don't
> > need one as long as I set BOOST_BUILD_PATH ..
>
> Try to create boost-build.jam file like this:
>
> # boost-build.jam
> boost-build C:\boost\boost_1_33_1\tools\build\v1 ;
>
> --
> HTH,
> Rob


Hi Rob, Thanks for answer!

It did solve the error... but created a new one:

C:\boost\boost_1_33_1\libs\python\example\tutorial>bjam -sTOOLS=vc-8_0

Unable to load Boost.Build: could not find build system.
-
C:\boost\boost_1_33_1\libs\python\example\boost-build.jam attempted to
load the
build system by invoking

   'boost-build C:/boost/boost_1_33_1/tools/build/v1 ;'

but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching C:\boost\boost_1_33_1, C:/boost/
boost_1_33_1/t
ools/build/v1).


What is boostrap.jam? I haven't seen that one mentioned in the short
tutorial...

Thanks!,
Soren

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


Re: Boost Problem! Boost.Build not found

2007-04-16 Thread Soren
On 16 Apr., 12:53, "Rob Wolfe" <[EMAIL PROTECTED]> wrote:
> Soren wrote:
> > Unable to load Boost.Build: could not find "boost-build.jam"
> > ---
> > Attempted search from C:\boost\boost_1_33_1\libs\python\example
> > \tutorial up to t
> > he root and in these directories from BOOST_BUILD_PATH and BOOST_ROOT:
> > C:\boost\boost_1_
> > 33_1.
> > Please consult the documentation at 'http://www.boost.org'.
>
> > Can anyone please tell me what I am doing wrong?? Theres no tutorial
> > on how to make a boost-build.jam file.. and as I understand I don't
> > need one as long as I set BOOST_BUILD_PATH ..
>
> Try to create boost-build.jam file like this:
>
> # boost-build.jam
> boost-build C:\boost\boost_1_33_1\tools\build\v1 ;
>
> --
> HTH,
> Rob


Hi Rob, Thanks for the answer!

It did solve the error.. but produced a new one:

C:\boost\boost_1_33_1\libs\python\example\tutorial>bjam -sTOOLS=vc-8_0
Unable to load Boost.Build: could not find build system.
-
C:\boost\boost_1_33_1\libs\python\example\boost-build.jam attempted to
load the
build system by invoking

   'boost-build C:/boost/boost_1_33_1/tools/build/v1 ;'

but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching C:\boost\boost_1_33_1, C:/boost/
boost_1_33_1/t
ools/build/v1).

What is bootstrap.jam? .. Haven't seen that one in the short
tutorial...

Thanks alot!,
Soren

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


Re: Boost Problem! Boost.Build not found

2007-04-16 Thread Soren
On 16 Apr., 14:28, "Rob Wolfe" <[EMAIL PROTECTED]> wrote:
> Soren wrote:
> > > Try to create boost-build.jam file like this:
>
> > > # boost-build.jam
> > > boost-build C:\boost\boost_1_33_1\tools\build\v1 ;
>
> > Hi Rob, Thanks for the answer!
>
> > It did solve the error.. but produced a new one:
>
> > C:\boost\boost_1_33_1\libs\python\example\tutorial>bjam -sTOOLS=vc-8_0
> > Unable to load Boost.Build: could not find build system.
> > -
> > C:\boost\boost_1_33_1\libs\python\example\boost-build.jam attempted to
> > load the
> > build system by invoking
>
> >'boost-build C:/boost/boost_1_33_1/tools/build/v1 ;'
>
> > but we were unable to find "bootstrap.jam" in the specified directory
> > or in BOOST_BUILD_PATH (searching C:\boost\boost_1_33_1, C:/boost/
> > boost_1_33_1/t
> > ools/build/v1).
>
> There is something wrong with your boost installation.
> Do you have subdirectory tools/build/v1 in your installation?
>
>
>
> > What is bootstrap.jam? .. Haven't seen that one in the short
> > tutorial...
>
> It is essential for boost build system that the file bootstrap.jam
> could be found.
>
> --
> HTH,
> Rob

Hmm, I see I forgot to install boost-build .. all i did was install
boost_1_33_1.exe.. thought it had it all. Now I have unzipped   boost-
build-2.0-m11.zip inside my boost_1_33_1 directory. It contains a
bootstrap.jam file

and a new error appear:

C:\boost_1_33_1\libs\python\example\tutorial>bjam sTOOLS=vc-8_0

error: Could not find parent for project at '../../../..'
error: Did not find Jamfile or project-root.jam in any parent
directory.

In case you didn't guess... I am totally lost by now! :) If I ever get
this thing up and running.. I will write a new tutorial and send it to
boost.

Thanks!
Soren


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


Re: Boost Problem! Boost.Build not found

2007-04-16 Thread Soren
On 16 Apr., 14:28, "Rob Wolfe" <[EMAIL PROTECTED]> wrote:
> Soren wrote:
> > > Try to create boost-build.jam file like this:
>
> > > # boost-build.jam
> > > boost-build C:\boost\boost_1_33_1\tools\build\v1 ;
>
> > Hi Rob, Thanks for the answer!
>
> > It did solve the error.. but produced a new one:
>
> > C:\boost\boost_1_33_1\libs\python\example\tutorial>bjam -sTOOLS=vc-8_0
> > Unable to load Boost.Build: could not find build system.
> > -
> > C:\boost\boost_1_33_1\libs\python\example\boost-build.jam attempted to
> > load the
> > build system by invoking
>
> >'boost-build C:/boost/boost_1_33_1/tools/build/v1 ;'
>
> > but we were unable to find "bootstrap.jam" in the specified directory
> > or in BOOST_BUILD_PATH (searching C:\boost\boost_1_33_1, C:/boost/
> > boost_1_33_1/t
> > ools/build/v1).
>
> There is something wrong with your boost installation.
> Do you have subdirectory tools/build/v1 in your installation?
>
>
>
> > What is bootstrap.jam? .. Haven't seen that one in the short
> > tutorial...
>
> It is essential for boost build system that the file bootstrap.jam
> could be found.
>
> --
> HTH,
> Rob

Hi Rob! Thanks for the help!

It turned out the installation had not installed all files... .. but
gave no error!!?? .. anyway, I redownloaded and installed and now it
works! Wouldn't have guessed it if you haven't said the installation
was corrupt. thanks!

Cheers,
Soren


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


Python crash after using weave inline

2007-04-18 Thread Soren
Hi,

I have a strange and very annoying problem when using weave in scipy..
when I run the code below.. the first time it needs to compile.. it
says  and then python.exe crashes! and no result is shown..
the second time i run it, it does not compile but gives the completely
wrong answer.. prints a matrix of all zeros except for point 1,1 in
the matrix which seems to have some random high number like
-5.39403959e+08.  !!??

Basicly I run through a 10 by 10 matrix do some calculations with
respect to some center values x_c and y_c and insert the result into
the empty numpy matrix array "res".

Any help is appreciated!

Thanks,
Sroren


from numpy import *
from scipy import weave
from scipy.weave import converters

def cartPolFast(xlen, ylen, x_c, y_c):

res = zeros((xlen,ylen))

code = """
{
int xlen, ylen, x_c, y_c;
double rel_x, rel_y;
int x, y;

for( x = 0; x == xlen; x++)
   for( y = 0; y == ylen; y++)
rel_x = x-x_c;
rel_y = y_c-y;

res(x,y) = rel_y*rel_y;
}
"""

weave.inline(code,['xlen','ylen','x_c','y_c','res'],
type_converters=converters.blitz, compiler="gcc")

return res


if __name__ == "__main__":

tst = cartPolFast(10,10,5,5)
print tst

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


FindWindowById returns None..... ?

2008-01-10 Thread Soren
Hi,

I'm trying to split my GUI into several files since its beginning to
become a bit large.. I've placed a panel  class inside gui2.py, but it
needs some information from a panel in gui1.py... if I import gui1 in
gui2 and try to find the panel by its ID, (using the Id generated in
gui1) I get a None value returned?? using findwindowbyid in gui1 on
the same ID works fine..

I'm guessing i'm doing this the wrong way, can anyone comment on this?

Thanks,
Soren
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FindWindowById returns None..... ?

2008-01-10 Thread Soren
On Jan 10, 9:43 am, Soren <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to split my GUI into several files since its beginning to
> become a bit large.. I've placed a panel  class inside gui2.py, but it
> needs some information from a panel in gui1.py... if I import gui1 in
> gui2 and try to find the panel by its ID, (using the Id generated in
> gui1) I get a None value returned?? using findwindowbyid in gui1 on
> the same ID works fine..
>
> I'm guessing i'm doing this the wrong way, can anyone comment on this?
>
> Thanks,
> Soren

Wops.. and I'm using wxPython :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Parallel port control with USB->Parallel converter

2008-02-14 Thread Soren
Hi,

I want to control some motors using the parallel port.. however, my
laptop does not have any parallel ports (very few do). What I do have
is a USB->Parallel converter... I thought about using PyParallel, but
the USB->Parallel converterdoesn't actually map to the LPT port ..
and PyParallel only looks for LPT ports?

Has anyone tried doing this? What are my options for controlling
parallel connections on a laptop with no parallel port?

I also thought about controlling the USB natively.. but since I dont
have any instructions on how to do this with my Velleman USB->Parallel
port converter... i guess I would be totally blind.

Any help would be appreciated!

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


Re: Parallel port control with USB->Parallel converter

2008-02-14 Thread Soren
Hey Diez, thanks for your answer!

> You could try and see how far you get with pyusb, the wrapping for libusb.
> However, any decent usb2-adapter should register itself as device
> of the mapped kind. For example, usb2serial-converters appear as
> COMx:-ports.

That was my thought too, and that's why I bought one (actually I
bought two), but it turns out that people only use these to interface
with old printers.. and so the converter is listed as a USB printer
port, and does not directly map itself to the LPT port.. Of course,
there must be some way of controlling the USB2PAR the way I want, but
without something like PyParallel or an API for this converter.. im
pretty much in the blind.. :/

> Apart from that, you might consider using products like atmel's USB-Key or
> similar to attach a microcontroller to the USB-port that then will use it's
> own ports to control the motors.

I thought about it.. this would be my last option however... mostly
because it would take too much time to get acquainted with it. I need
the thing running before the beginning of March among other
things.. :) I do have a LabJack USB DAQ, which is really nice... but
unfortunately it's too slow for running 5+ motors in parallel by
sending pulses. I also thought about extending the labjack with faster
pulse generators that could be triggered from the labjack.

Using the parallel port or USB2PARALLEL on the pc would just be so
much simpler, cheaper and faster... So if anyone know how to hack an
USB-Parallel converter to let me send bytes to it.. I'm all ears!! :)

Soren

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


indexing arrays in extensions created with ext_tools (scipy.weave)

2008-10-31 Thread Soren
Hi,

I'm trying to make a weave python extension to use in my program. I
already did it in inline, but that doesn't work with py2exe (needs
compiler), so I'm creating extensions instead using ext_tools.

Is there a way I can use blitz with ext_tools? so that I can refer to
arrays like a(x,y) in the c code?? I have alot of 2D arrays that needs
indexing in the C code..

Any help is appreciated!

Thanks,
Soren
--
http://mail.python.org/mailman/listinfo/python-list


Wxpython. Is it possible to change layout in a running application? Selfmade listbox

2008-04-07 Thread Soren
Hi,

Id like to make my own special listbox.. I want to able (at the push
of a button) to add another item to my special listbox... each item is
a panel with a label, some buttons and maybe a text control.

I've tried adding a new panel object with the stuff i want to the
sizer i'm using for my listbox (which is a panel which can contain
other panels)... and then run update() and refresh() on everything...
But it doesn't work.. i see a panel appearing, but it's just a small
square in the corner of my "listbox" panel, and it only works the
first time... nothing new appears when I push the button again.

Is it at all possible to do this? Has anyone created something
similar? Does anyone know what i'm doing wrong?

Thanks,
Soren
-- 
http://mail.python.org/mailman/listinfo/python-list


Sorting Directories from files in a os.listdir??

2008-04-10 Thread Soren
Hi,

I'd like to read the filenames in a directory, but not the
subdirectories, os.listdir() gives me everything... how do I separate
the directory names from the filenames? Is there another way of doing
this?

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


Re: Sorting Directories from files in a os.listdir??

2008-04-10 Thread Soren
On Apr 10, 12:14 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 10 Apr 2008 06:55:13 -0300, Soren <[EMAIL PROTECTED]>
> escribió:
>
> > I'd like to read the filenames in a directory, but not the
> > subdirectories, os.listdir() gives me everything... how do I separate
> > the directory names from the filenames? Is there another way of doing
> > this?
>
> Check each returned name using os.path.isfile
> (untested):
>
> def files_only(path):
>return [filename for filename in os.listdir(path)
>if os.path.isfile(os.path.join(path, filename))]
>
> --
> Gabriel Genellina

Thanks everyone! That worked! :)
-- 
http://mail.python.org/mailman/listinfo/python-list


SWIG Python undefined reference

2008-04-29 Thread Soren
Hi,

I went through the SWIG tutorial for the example named "simple".

I managed to get to the first step, creating example_wrap.c using
swig, and doing:
"gcc -fpic -c example_wrap.c -IC:\python24\include " to create
example_wrap.o

But when I needed to compile the library file using:
"gcc -shared example_wrap.o -o examplemodule.so" I received a lot of
undefined reference compiler errors like:

example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to
`_imp__PyErr
_SetString'

there are many other similar errors all prefaced with _imp__Py, so I
am assuming there is a linker error with the python libraries. I have
adjusted my PATH variable to include all the python directories (libs/
dlls).

Does anyone here have any suggestions?

FILES FROM TUTORIAL:


//example.c
#include 
double My_variable = 3.0;

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(

Re: SWIG Python undefined reference

2008-04-29 Thread Soren

Ok I found out how to do it using:

gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c
example.c -lpython24 -o _example.pyd

but now I get a "dynamic module does not define init function" error
when I try to import it into python..

Anyone??

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


Re: SWIG Python undefined reference

2008-04-29 Thread Soren
On Apr 29, 11:31 am, Soren <[EMAIL PROTECTED]> wrote:
> Ok I found out how to do it using:
>
> gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c
> example.c -lpython24 -o _example.pyd
>
> but now I get a "dynamic module does not define init function" error
> when I try to import it into python..
>
> Anyone??
>
> Soren

In case anyone is having the same problem the solution for me was:

gcc example.c example_wrap.c -Ic:\python24\include -Lc:\python24\libs -
lpython24 -Xlinker -expoert-dynamic -shared -o _example.pyd

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


py2app with weave fails

2010-07-16 Thread Soren
Hi,

I'm trying to create a standalone app using py2app, but it seems no
matter what I do I get this error:

Traceback (most recent call last):
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/__boot__.py", line 158, in 
_run('RAW.py')
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/__boot__.py", line 134, in _run
execfile(path, globals(), globals())
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/RAW.py", line 42, in 
from masking import CircleMask, RectangleMask, PolygonMask
  File "masking.pyc", line 34, in 
  File "fileIO.pyc", line 29, in 
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/scipy/weave/__init__.py", line 13, in

from inline_tools import inline
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/scipy/weave/inline_tools.py", line 5,
in 
import ext_tools
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/scipy/weave/ext_tools.py", line 6, in

import build_tools
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/scipy/weave/build_tools.py", line 28,
in 
import platform_info
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/scipy/weave/platform_info.py", line
15, in 
from numpy.distutils.core import setup
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/numpy/distutils/core.py", line 25, in

from numpy.distutils.command import config, config_compiler, \
  File "/Users/soren/Documents/workspace/bioxtasraw/dist/RAW.app/
Contents/Resources/lib/python2.6/numpy/distutils/command/
build_ext.py", line 9, in 
from distutils.command.build_ext import build_ext as old_build_ext
  File "distutils/command/build_ext.pyc", line 13, in 
ImportError: cannot import name USER_BASE
2010-07-16 13:10:07.542 RAW[24832] RAW Error
2010-07-16 13:10:07.544 RAW[24832] RAW Error
An unexpected error has occurred during execution of the main script

Does anyone have an idea on how to fix this??

Thanks,
Soren
-- 
http://mail.python.org/mailman/listinfo/python-list