This is a continuation of this question. I understand that we cannot access input_items
in __init__
of a sync_block but we can do so in hier_block
(eg. here). I wanted to add a panel on the top block frame which can only be done by assigning a panel to self.win
in __init__
(like in the hier_block example). If I try to assign a panel to self.win
inside the work function of a sync_block then it gives the error : 'xyz' object has no attribute 'win'. Though it works if I assign a panel to self.win
inside __init__
of a sync_block (that's why I wanted to access input_items
inside __init__
in the first place)
In response to Marcus answer
If I want to draw a plot on a wxPanel and then put the panel on the top_block wxFrame. Here is an example -
class xyz(gr.sync_block):
"""
docstring for block add_python
"""
def __init__(self,parent):
.......
gr.sync_block.__init__(self,
name="xyz",
in_sig=[numpy.float32,numpy.float32],
out_sig=None)
self.win = xyzPlot(parent,input_items) # Comment 1 -> this will not work as I dont have access to input_items here
def work(self, input_items, output_items):
..........
..........
self.win = xyzPlot(parent,input_items) # Comment 2 -> this doesnt work as Marcus says "Only __init__ block has the graphical framework's window object set as property."
..........
..........
class xyzPlot(wx.Panel):
def __init__(self, parent , input_items):
wx.Panel.__init__(self , parent , -1 ,size=(1000,1000))
..............
..............
#plots a plot on the panel depending on the input_items
..............
..............
Check out both the comments I have added in the code above. Since both ways don't work , how to do what I want to that?