Passing variables to pygtk popup window

Post here if you need help with creating a Graphical User Interface in Python.

Passing variables to pygtk popup window

Postby DennisT » Thu Sep 29, 2016 5:57 pm

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?
DennisT
 
Posts: 21
Joined: Thu Apr 21, 2016 4:00 pm

Re: Passing variables to pygtk popup window

Postby DennisT » Thu Sep 29, 2016 6:09 pm

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
DennisT
 
Posts: 21
Joined: Thu Apr 21, 2016 4:00 pm


Return to GUI

Who is online

Users browsing this forum: No registered users and 0 guests