Conversation started Jun 28, 2011 at 21:00.
Jun 28, 2011 21:00
to explain how pubsub works
when importing wx.lib.pubsub, we import Publisher as pub
this has 2 methods we use: sendMessage and subscribe (there may be more but I don't need them yet)
like I shared the link, we will have to update this at some point, but not now
you send a message by giving a string " "
but what is the message then?
where it goes?
you decide what this will be, it can be anything as long as they are unique or they will override similar messages (perhaps not allowed)
pub.sendMessage("ButtonClass.toggledbutton", -1/1)
then you pass along your actual 'message', being the object you want to move elsewhere
so I could very well do this: pub.sendMessage("HolyCrapItsIVO",-1/1)
if I wanted to?... like the message has nothing to do with other sections of the code
the other method we use is pub.**subscribe**("message you're subscribed to", object your sending)
yup
I started using the standard of MainClass.function, because it allows me to backtrack where they came from
you just use that syntax to keep track of what you're doing?
brb
Jun 28, 2011 21:05
yeah and its predictable, because I know what the format SHOULD be
ok that makes sense then... but what if you have multiple message to the same function?
the function can subscribe to as many messages as it wants to
and several functions can send the same message too
its like delivering mail
it makes 1 round, delivers to all subscribers and then quits
so all buttons sent one message: "ButtonClass.toggledbutton"
so I can have two functions that send the same HolyCrapItsIVO message
Jun 28, 2011 21:08
what's nice is that you don't necessarily have to tweak your message
thats also what the new style API with keywords is for, you can deliver different data with the same message by adding a keyword
ya thats really nice
but we're not using that
also, I believe you NEED to use the same keyword everywhere, because pubsub compares all the subscribers + sendmessage pairs
hence I just use 'message' in each function
its useful to use the same thing everywhere, because it makes your code predictable/readable
message being the "Class.function" ?
no
def functioname(self, message): <-- this message
oh got it.. ok
that makes sense as well
Jun 28, 2011 21:14
@KronoS then message is an object, to get the object out of it you have to use message.data
ok so when I 'subscribe' to something i have to use message.data
@KronoS yes, the subscribed function needs the message keyword in the def statement and message.data to use it
btw you can also sent empty messages, basically its a way to trigger functions elsewhere
we use that between the ribbon + mainframe + other functions
 
Conversation ended Jun 28, 2011 at 21:16.