Fixing the wx.lib.pubsub has been depreciated, please migrate your code to use pypubsub error

44 Views Asked by At

I am having this error wx.lib.pubsub has been depreciated, please migrate your code to use pypubsub, every time i try and run a particular application. I've seen this been answered with installing "pypubsub"

and then replacing the line from wx.lib.pubsub import pub to from pubsub import pub.

I'm not a technical guru and i have no idea what file they are editing here when they make this change. if somebody knows how to do this, I would appreciate it if you would point me in the right direction

I've looked into all the files under the pypubsub folder hoping to find the file i need to make these changes too.

1

There are 1 best solutions below

2
chickity china chinese chicken On

The install for PySubPub as stated in the documentation PySubPub mentions running in a command prompt or terminal emulator:

pip install pypubsub

Then pypubsub can be used in your python script as shown in the documentation Quick Start
Simplest example of use:

"""
One listener is subscribed to a topic called 'rootTopic'.
One 'rootTopic' message gets sent. 
"""

from pubsub import pub


# ------------ create a listener ------------------

def listener1(arg1, arg2=None):
    print('Function listener1 received:')
    print('  arg1 =', arg1)
    print('  arg2 =', arg2)


# ------------ register listener ------------------

pub.subscribe(listener1, 'rootTopic')

# ---------------- send a message ------------------

print('Publish something via pubsub')
anObj = dict(a=456, b='abc')
pub.sendMessage('rootTopic', arg1=123, arg2=anObj)

Running the above as a script (available in the docs/usage folder of the source distribution as helloworld.py) will produce the result:

Publish something via pubsub
Function listener1 received:
  arg1 = 123
  arg2 = {'a': 456, 'b': 'abc'}