Call function from another class

Diez B. Roggisch deets at
Mon Jul 27 12:43:14 CEST 2009

Lars wrote:

> Hi
> I'm trying to make an simple image viewer in wxPython and rotate an
> image with a slider. The code at Pastebin is striped down at bit. The
> class Frame(wx.Frame) is the main window, the function "def
> CreateMenuBar" (l. 39) creates a menu, where the function "def onRotate
> (self,event):" (l. 43) is called. The slider appear in at 2nd window,
> class rotationSlider(wx.Frame).
> My problem is what to do, when the Okay button is pressed in the
> "rotationSlider" frame. How to get the slider value to my main window
> and how to call a function to do the rotation. I tried something with
> a global variable, but it would make no difference regarding the
> function problem. Amongst the other things I've tried is to bind the
> event of the 2nd/slider window closing (l. 46), but no.
> Python code at Pastebin:
> So some help on Classes and etc., would be appreciated.

If I'm not mistaken, in "doRotate" you should be able to refer to the
to-be-closed dialog via


Now if you change the "sliderUpdate"-code to store that angle instead of
just letting it fall out of scope, you could access that value through

def sliderUpdate(self, event):
        self.angle = angle 

def doRotate(self,event):
    """Rotating image"""
    print self.frameRotate.angle


More information about the Python-list mailing list