sending values over classes

"Rafał Janas" rafal at ewipo.pl
Sat Aug 19 13:50:34 EDT 2006


Hi,

Exactly I want to set global value (like session - who is log in)
I writing simple program with more than one class - every window has different
class in different file.
Example:
2 files (main and wind). Main is main window and wind is child window.
I want to send value from main to child from entry to entry and I know how to do
it
But I can't send value from child to main.

My main.py
#!/usr/bin/env python
    
#----------------------------------------------------------------------
# main.py
# Dave Reed
# 08/19/2006
#----------------------------------------------------------------------

import sys
import wind
from GladeWindow import *
global dupa
#----------------------------------------------------------------------

class Main(GladeWindow):

    #----------------------------------------------------------------------

    def __init__(self):

        ''' '''
        self.init()

    #----------------------------------------------------------------------

    def init(self):

        filename = 'main.glade'

        widget_list = [
            'pokoj',
            'entry1',
            'button1',
            ]

        handlers = [
            'on_button1_clicked',
            ]

        top_window = 'pokoj'
        GladeWindow.__init__(self, filename, top_window, widget_list, handlers)
    #----------------------------------------------------------------------

    def on_button1_clicked(self, *args):
        #self.wind=wind.Wind(self)
        #self.wind.top_window='win1'
        #self.wind.show()
        dupa='test123'
        b=wind.Wind()
        b.show()

    


#----------------------------------------------------------------------

def main(argv):

    w = Main()
    w.show()
    gtk.main()

#----------------------------------------------------------------------

if __name__ == '__main__':
    main(sys.argv)


And wind.py

#!/usr/bin/env python
    
#----------------------------------------------------------------------
# wind.py
# Dave Reed
# 08/19/2006
#----------------------------------------------------------------------

import sys
#import main
from GladeWindow import *

#----------------------------------------------------------------------

class Wind(GladeWindow):

    #----------------------------------------------------------------------

    def __init__(self):

        ''' '''
        #self.main=main
        self.init()

    #----------------------------------------------------------------------

    def init(self):

        filename = 'wind.glade'

        widget_list = [
            'win1',
            'entry1',
            'button1',
            ]

        handlers = [
            'on_button1_clicked',
            ]

        top_window = 'win1'
        GladeWindow.__init__(self, filename, top_window, widget_list, handlers)
    #----------------------------------------------------------------------

    def on_button1_clicked(self, *args):
        #self.main.widgets['entry1'].set_text(self.widgets['entry1'].get_text())
        self.widgets['entry1'].set_text(dupa)


    


#----------------------------------------------------------------------

def main(argv):

    w = Wind()
    w.show()
    gtk.main()

#----------------------------------------------------------------------

if __name__ == '__main__':
    main(sys.argv)

Rafał


More information about the Python-list mailing list