Hello everyone,
I have three modules A, B, C;
A declares this globally :
UpdateEvent, UPDATE_EVENT_ID = wx.lib.newevent.NewEvent()
Then they import stuff from each other:
- A imports a constant from module B (in "__main__")
- A imports a class and some constants from module C
- B imports a constant from module A
- C imports UPDATE_EVENT_ID from module A
What happens is that since A imports stuff from B which then in turn loads something from A, UPDATE_EVENT_ID gets redefined and when A sends an event to C, C doesn't do anything since it doesn't have the same UPDATE_EVENT_ID. Does anyone have an idea on how to fix this? I'd either like to define UPDATE_EVENT_ID manually (what about clashes, I have other new events defined)
or ?
Thank you,
Gabriel
Gabriel Rossetti wrote:
Hello everyone,
I have three modules A, B, C;
A declares this globally :
UpdateEvent, UPDATE_EVENT_ID = wx.lib.newevent.NewEvent()
Then they import stuff from each other:
- A imports a constant from module B (in "__main__")
- A imports a class and some constants from module C
- B imports a constant from module A
- C imports UPDATE_EVENT_ID from module A
What happens is that since A imports stuff from B which then in turn loads something from A, UPDATE_EVENT_ID gets redefined and when A sends an event to C, C doesn't do anything since it doesn't have the same UPDATE_EVENT_ID. Does anyone have an idea on how to fix this? I'd either like to define UPDATE_EVENT_ID manually (what about clashes, I have other new events defined)
or ?
Thank you,
Gabriel
If I'm not mistaken, it sounds like you want your modules to send events to each other, correct? If so, I think what you need to do is read up on the pubsub module:
http://wiki.wxpython.org/PubSub
http://wiki.wxpython.org/Controlling%20GUI%20with%20pubsub
http://www.wxpython.org/docs/api/wx.lib.pubsub-module.html
I think it will suit your needs much better.
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Mike Driscoll wrote:
Gabriel Rossetti wrote:
Hello everyone,
I have three modules A, B, C;
A declares this globally :
UpdateEvent, UPDATE_EVENT_ID = wx.lib.newevent.NewEvent()
Then they import stuff from each other:
- A imports a constant from module B (in "__main__")
- A imports a class and some constants from module C
- B imports a constant from module A
- C imports UPDATE_EVENT_ID from module A
What happens is that since A imports stuff from B which then in turn loads something from A, UPDATE_EVENT_ID gets redefined and when A sends an event to C, C doesn't do anything since it doesn't have the same UPDATE_EVENT_ID. Does anyone have an idea on how to fix this? I'd either like to define UPDATE_EVENT_ID manually (what about clashes, I have other new events defined)
or ?
Thank you,
Gabriel
If I'm not mistaken, it sounds like you want your modules to send events to each other, correct? If so, I think what you need to do is read up on the pubsub module:
http://wiki.wxpython.org/PubSub
Controlling GUI with pubsub - wxPyWiki
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
I think it will suit your needs much better.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Thanks Mike (sorry for the late reply), it looks better as you stated, I'll give it a try
Gabriel