[wxPython-users] calling a class inside a function

Varsha Purohit varsha.purohit at gmail.com
Tue Feb 5 15:45:51 PST 2008


Hello everyone,
           I have a  scenario in which i am having a button which will be
binded to an event handler. And that event handler should call a function
which is defined in another file. That function should contain a class for
scrollbar. And i want to call this function from the button handler
function. So i want to know is it okay to call a class within a function. I
am attachin sample code.

file1.py

import wx

def scrollimage(imageFile):

    im =3D Image.open(imageFile)
    im2=3D self.im.resize((700,550),Image.BICUBIC)
    FormFiche(im2) #is it okay to pass the image as parameter to the class
or am i messing up something here ??

    class FormFiche(wx.Frame):
         def __init__(self,name):


             wx.Frame.__init__(self,None,-1,"Title",size=3Dwx.Size(500,400))


             scroll=3Dwx.ScrolledWindow(self,-1)

             self.bmp =3D wx.Image('DSCN3378.jpg',wx.BITMAP_TYPE_JPEG
).ConvertToBitmap()
             wx.StaticBitmap(scroll, -1, self.bmp)
             self.Show(1)
             scroll.SetScrollbars(20, 20, 55, 40)


    myapp=3Dwx.PySimpleApp()
    FormFiche()
    myapp.MainLoop()


---------------------------------------------------------------------------=
-------------------

i want to call this function and give image file as a parameter to this
funciton which would show a frame with scrollbars. But i am not able to do
that i am getting error. I have included file1.py in this main.py file.

def button1click(self, event):
        scrollimage(self.bmp)



-- =

Varsha Purohit,
Graduate Student
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200802=
05/585d5acc/attachment.htm


More information about the wxpython-users mailing list