Python 3: pass filename variable from Gtk.FileChooser to __init__ function
<p>I'm writing a Gtk program that does stuff with images. I got app window with menu and connected one of the buttons to Gtk.FileChooser that gets a filename (i can open it with Gtk.Image() but cant do much with such object afaik). The problem is I don't know how to pass the filename to my <strong>init</strong> function so I can open image from that filename using opencv (need to be able to draw with mouse on that image thats why opencv3). Here's the code structure Im using:</p>

<pre><code>class main_win(Gtk.Window):
 def __init__(self):
 '''menu stuff and box with widgets, few labels'''

  def FileChooser(self):
   dialog = Gtk.FileChooserDialog("Open a File Image", self, Gtk.FileChooserAction.OPEN,
                                   (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                    Gtk.STOCK_OPEN, Gtk.ResponseType.OK))


    response = dialog.run()
    if response == Gtk.ResponseType.OK:
       path = dialog.get_filename()
    elif response == Gtk.ResponseType.CANCEL:
       pass
    dialog.destroy()
</code></pre>

<p>Ideally I would prefere to put this inside init:</p>

<pre><code>img = cv2.imread(path,0)
cv2.imshow('image',img)
</code></pre>

<p>Then afaik i could do stuff with the image in opencv window like for example getting pixel  (from a drawn area with mouse or just a single pixel by mouse click) statistics into gtk.label or drawing plots.</p>

<p>Im fairly new to python, so maybe I'm asking sth super easy or super stupid;p
Thanks in advance ;).</p>

<p>Moved to pyqt4, not only opencv but also matplotlib works there smoothly ;)</p>

python variables scope gtk3 opencv3.0