0

I'm trying to display a value on the status bar according to a position on a plot made on a panel. So I want to call the method SetStatusText with the value in a string. The instance of RefreshPanel is set within a frame called 'frame', which is an instance of a subclass MyFrame of wx.Frame in which the status bar is set. But when I left click in the plot on the panel I get

line 51, in OnLeftDown
frame.SetStatusText("%.1f kHz" % freqkhz)
AttributeError: 'builtin_function_or_method' object has no attribute 'SetStatusText'

class RefreshPanel(wx.Panel):
    def __init__(self, parent, id, pos, size):
        wx.Panel.__init__(self, parent, id, pos, size)

        
        global xaxis,yaxis,z
        
        
        
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown


    def OnLeftDown(self, event):
        """left mouse button is pressed"""
        pt = event.GetPosition()  # position tuple
        freqkhz = (600 - pt[1])/500.0/1000.0*(yaxis[-1]-yaxis[0])
        print "%.1f kHz" % freqkhz
        
        frame.SetStatusText("%.1f kHz" % freqkhz)
3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by marboleon
0

Line 6 looks strange. Use attributes not global variables.

Looks like frame would be global variable. Print also value of frame on line 17.

0

You can try the following, assuming frame is the parent of the panel.
In def __init__ of class RefreshPanel, add

self.parent = parent

Then, instead of frame.SetStatusText(), use self.parent.SetStatusText()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.