Page 1 of 1

Passing variables to pygtk popup window

PostPosted: Thu Sep 29, 2016 5:57 pm
by DennisT
I have a popup window I would like to pass some variables to.
Main Window:
Code: Select all
class MWin(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
... some stuff ...
       MyVariable1 = 1
       MyVariable2 = 2
       dialog = InfoPopup(self)

and the popup"
Code: Select all
class InfoPopup(Gtk.Dialog):
    def __init__(self, main_window):
        Gtk.Dialog.__init__(self, "Popup", main_window, 0, ("Exit", Gtk.ResponseType.OK))
... some stuff ...
        if MyVariable1 == 1: do something
        if MyVariable2 == 2 : do something


How can I pass MyVariable1 & MyVariable2 to InfoPopup?

Re: Passing variables to pygtk popup window

PostPosted: Thu Sep 29, 2016 6:09 pm
by DennisT
Figured it out:
Code: Select all
    class MWin(Gtk.Window):
        def __init__(self):
            Gtk.Window.__init__(self)
    ... some stuff ...
           self.MyVariable1 = 1
           self.MyVariable2 = 2
           dialog = InfoPopup(self)


Code: Select all
    class InfoPopup(Gtk.Dialog):
        def __init__(self, main_window):
            Gtk.Dialog.__init__(self, "Popup", main_window, 0, ("Exit", Gtk.ResponseType.OK))
    ... some stuff ...
            if main_window.MyVariable1 == 1: do something
            if main_window.MyVariable2 == 2 : do something