G
gregarican
I have an application I'm writing using PyQt. I'm trying to create the
various windows by subclassing Qt objects. I have a subclassed
QMainWindow as the parent, and then a series of subclassed QWidgets as
other child windows that get used. How can I pass variables back and
forth between the parent and child windows? For example, if I have a
child window that processes a customer lookup I want the retrieved
values to be passed back to the QMainWindow. I have tried using global
variables, but these variables seem to be global only in the sense of
each subclassed object. Not between the subclassed objects.
Here's a generic sample:
parent_window.py
=============
my_value = 'main'
from child_window import *
class Parent_Window(QMainWindow):
def __init__(self):
QMainWindow.__init__(self,None,'application main
window',Qt.WDestructiveClose)
print my_value
child_window= Child_Window()
self.setCentralWidget(child_window)
self.catchEvent()
child_window.py
============
class Child_Window(QWidget):
def __init__(self):
QWidget.__init__(self)
print my_value
This doesn' t seem to work, as the Child_Window class doesn't recognize
the my_value global variable that appears in the Parent_Window class.
various windows by subclassing Qt objects. I have a subclassed
QMainWindow as the parent, and then a series of subclassed QWidgets as
other child windows that get used. How can I pass variables back and
forth between the parent and child windows? For example, if I have a
child window that processes a customer lookup I want the retrieved
values to be passed back to the QMainWindow. I have tried using global
variables, but these variables seem to be global only in the sense of
each subclassed object. Not between the subclassed objects.
Here's a generic sample:
parent_window.py
=============
my_value = 'main'
from child_window import *
class Parent_Window(QMainWindow):
def __init__(self):
QMainWindow.__init__(self,None,'application main
window',Qt.WDestructiveClose)
print my_value
child_window= Child_Window()
self.setCentralWidget(child_window)
self.catchEvent()
child_window.py
============
class Child_Window(QWidget):
def __init__(self):
QWidget.__init__(self)
print my_value
This doesn' t seem to work, as the Child_Window class doesn't recognize
the my_value global variable that appears in the Parent_Window class.