How to separate out multiple pubsub instances

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

How to separate out multiple pubsub instances

Mike Driscoll-2
Hi.

I've been working on some sample applications with wxPython and it's been going quite well. The first one I made is a simple XML editor. It can edit only one XML file at a time though as I haven't added any logic to open a second set of widgets to edit another...

And this is where the problem is actually. I know that I want to have the new file opened in a new Notebook (not implemented), but I'm using pubsub to tell the TreeCtrl to update when I edit the XML it shows. If I open a new tab, those new widgets will be using the same pubsub signatures and if I update the second XML then that update will be broadcast to both files, which will at best make the XML in the first have extra cruft and at worst, I'll probably throw an exception.

I really like how simple pubsub makes the single file version of the application. My first impulse for fixing this is to use a unique id for each set of pubsub messages to keep the code generic. However I was curious if anyone had alternate suggestions?

You can see my code here: https://github.com/driscollis/boomslang

Thanks,
Mike

-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Books: Python 101, Python 201: Intermediate Python 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to separate out multiple pubsub instances

Steven Sproat
Hey Mike, long time no speak! This is totally off the top of my head since it's been about 6 years since I've done any python / wx stuff but I would keep a reference to what the currently selected page in the notebook is, and then any subscription event can reference that. I believe that's what I done for whiteboard, where there's one active drawing tab
Nice to see you still here! 
Steven

On 1 Jun 2017 14:24, "Mike Driscoll" <[hidden email]> wrote:
Hi.

I've been working on some sample applications with wxPython and it's been going quite well. The first one I made is a simple XML editor. It can edit only one XML file at a time though as I haven't added any logic to open a second set of widgets to edit another...

And this is where the problem is actually. I know that I want to have the new file opened in a new Notebook (not implemented), but I'm using pubsub to tell the TreeCtrl to update when I edit the XML it shows. If I open a new tab, those new widgets will be using the same pubsub signatures and if I update the second XML then that update will be broadcast to both files, which will at best make the XML in the first have extra cruft and at worst, I'll probably throw an exception.

I really like how simple pubsub makes the single file version of the application. My first impulse for fixing this is to use a unique id for each set of pubsub messages to keep the code generic. However I was curious if anyone had alternate suggestions?

You can see my code here: https://github.com/driscollis/boomslang

Thanks,
Mike

-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Books: Python 101, Python 201: Intermediate Python 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to separate out multiple pubsub instances

Mike Driscoll
Hey Steven,

On Thursday, June 1, 2017 at 11:14:47 AM UTC-5, Steven Sproat wrote:
Hey Mike, long time no speak! This is totally off the top of my head since it's been about 6 years since I've done any python / wx stuff but I would keep a reference to what the currently selected page in the notebook is, and then any subscription event can reference that. I believe that's what I done for whiteboard, where there's one active drawing tab
Nice to see you still here! 
Steven

 This is actually pretty much what I was going to do. It's good to know that other people think that's a good idea as well.

It's good to see you here too. Hopefully you're re-joining us in Python-land?

Mike

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

nice example py code

firefox
In reply to this post by Mike Driscoll-2

The book examples of yours on github are pretty interesting!

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: nice example py code

Mike Driscoll-2
What exactly are you referring to? These posts to the group don't seem to have any context.

Mike

-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Books: Python 101, Python 201: Intermediate Python 

On Sat, Jun 10, 2017 at 4:06 AM, <[hidden email]> wrote:

The book examples of yours on github are pretty interesting!

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to separate out multiple pubsub instances

Dev Player
In reply to this post by Mike Driscoll-2
Typically you do:

    from pubsub import pub

This leads me to believe "pub" is an instance.  Which makes me wonder if there is a way to create multiple "pub" instances, pub0, pub1, etc.

Although it may not be optimal it could be another technique.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to separate out multiple pubsub instances

GadgetSteve


On 21/06/2017 02:50, Dev Player wrote:

> Typically you do:
>
>      from pubsub import pub
>
> This leads me to believe "pub" is an instance.  Which makes me wonder if
> there is a way to create multiple "pub" instances, pub0, pub1, etc.
>
> Although it may not be optimal it could be another technique.
>
> --

No in your example, (which doesn't work with pubsub 0.1.2), pub is not
an instance - it is a namespace!  In general:

from library import some_item

Gets the name space some_item from that library but does not create an
instance of anything.  Assuming that some_item is a class, (rather than
a sub-library or module), you only create an instance when you call the
creator __init__(self, ....) by having a line such as:

my_item = some_item()

To take some concrete examples:
     In [7]: from os import path # Import a module

     In [8]: type(path) # Check
     Out[8]: module

     In [9]: from os.path import join # Import a function from a module

     In [10]: type(join)
     Out[10]: function

     In [15]: from wx import App, AppConsole # Import some classes

     In [16]: type(App)  # What are they?
     Out[16]: sip.wrappertype

     In [17]: a = AppConsole() # Create an instance

     In [18]: type(a) # Check
     Out[18]: wx._core.AppConsole

     In [19]: b = AppConsole() # Create another instance

     In [20]: type(b) # Check
     Out[20]: wx._core.AppConsole

     In [21]: a == b # Are they the same?
     Out[21]: False

     In [22]: isinstance(b, type(a)) # But are they instances of the same?
     Out[22]: True

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.
http://www.avg.com

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

class

firefox

issubclass (App, AppConsole)    True

issubclass (AppConsole , App)   False



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: class

Tim Roberts
On Jun 21, 2017, at 1:36 AM, [hidden email] wrote:
>
> issubclass (App, AppConsole)    True
>
> issubclass (AppConsole , App)   False

You have a bad habit of firing off one- or two-line posts with no context and no explanation.  Remember that many of us read this list as an email list, where there's little notion of what came before or after.  There's no way to know whether you were asking a question, trying to make a point, or trying to respond to something on another thread.

Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to separate out multiple pubsub instances

Mike Driscoll-2
In reply to this post by Dev Player


On Tue, Jun 20, 2017 at 8:50 PM, Dev Player <[hidden email]> wrote:
Typically you do:

    from pubsub import pub

This leads me to believe "pub" is an instance.  Which makes me wonder if there is a way to create multiple "pub" instances, pub0, pub1, etc.

Although it may not be optimal it could be another technique.


I believe pubsub uses Singletons. Anyway, I already fixed the issue by making each editor instance use a unique message id. 

Thanks,
Mike

-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Books: Python 101Python 201: Intermediate Python 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

edlin

firefox
In reply to this post by Tim Roberts
On 21.06.2017 14:21, Tim Roberts wrote:
> On Jun 21, 2017, at 1:36 AM, [hidden email] wrote:
>>
>> issubclass (App, AppConsole)    True
>>
>> issubclass (AppConsole , App)   False
>
> You have a bad habit of firing off one- or two-line posts with no context and no explanation.  Remember that many of us read this list as an email list, where there's little notion of what came before or after.  There's no way to know whether you were asking a question, trying to make a point, or trying to respond to something on another thread.


I was assuming the 21st. century pros around here have obtained threaded
newsreaders already, but seemingly DOS edlin is still a popular
newsreader too.


I was just trying to expand on the point made by the OP.




--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Andrea Gavana

On Wed, 21 Jun 2017 at 19.53, <[hidden email]> wrote:
On 21.06.2017 14:21, Tim Roberts wrote:
> On Jun 21, 2017, at 1:36 AM, [hidden email] wrote:
>>
>> issubclass (App, AppConsole)    True
>>
>> issubclass (AppConsole , App)   False
>
> You have a bad habit of firing off one- or two-line posts with no context and no explanation.  Remember that many of us read this list as an email list, where there's little notion of what came before or after.  There's no way to know whether you were asking a question, trying to make a point, or trying to respond to something on another thread.


I was assuming the 21st. century pros around here have obtained threaded
newsreaders already, but seemingly DOS edlin is still a popular
newsreader too.


I was just trying to expand on the point made by the OP.


I believe many people receive messages from wxPython-users on GMail or similar tools. Your constant changing of threads and messages with no context, no questions and often no meaning has gotten me - and I think others too - on a 9 out of 10 scale of being fed up.

I am mostly a lurker these days but always passionate about wxPython. If you have a genuine question or a meaningful answer to other people's queries, I'm sure everybody will benefit from it. Otherwise it's just noise.

Andrea.






--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Tim Roberts
In reply to this post by firefox
On Jun 21, 2017, at 10:53 AM, [hidden email] wrote:

>
> On 21.06.2017 14:21, Tim Roberts wrote:
>> On Jun 21, 2017, at 1:36 AM, [hidden email] wrote:
>>>
>>> issubclass (App, AppConsole)    True
>>>
>>> issubclass (AppConsole , App)   False
>>
>> You have a bad habit of firing off one- or two-line posts with no context and no explanation.  Remember that many of us read this list as an email list, where there's little notion of what came before or after.  There's no way to know whether you were asking a question, trying to make a point, or trying to respond to something on another thread.
>
> I was assuming the 21st. century pros around here have obtained threaded
> newsreaders already, but seemingly DOS edlin is still a popular
> newsreader too.

The fact of the matter is that "21st century pros" do not use newsreaders at all.  NNTP is, sadly, no longer relevant.

This list is actually an email mailing list, but happens to be echoed as a web forum, and is mapped by Gmane as an NNTP newsgroup.  When you post with your fancy threaded newsreader and change the subject, the Gmane-to-mailing-list gateway loses the threading, so all the rest of us see you as a clueless newbie.

Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Igor Korot
2firefox;
Please don't "ass-u-me".
In addition to what Tim said, you have an even uglier habit - changing
the "Subject" line.
So even if people will read this as a newsreader, the threading will
be broken and there will
be just one post sitting there without a context.


On Wed, Jun 21, 2017 at 11:49 PM, Tim Roberts <[hidden email]> wrote:

> On Jun 21, 2017, at 10:53 AM, [hidden email] wrote:
>>
>> On 21.06.2017 14:21, Tim Roberts wrote:
>>> On Jun 21, 2017, at 1:36 AM, [hidden email] wrote:
>>>>
>>>> issubclass (App, AppConsole)    True
>>>>
>>>> issubclass (AppConsole , App)   False
>>>
>>> You have a bad habit of firing off one- or two-line posts with no context and no explanation.  Remember that many of us read this list as an email list, where there's little notion of what came before or after.  There's no way to know whether you were asking a question, trying to make a point, or trying to respond to something on another thread.
>>
>> I was assuming the 21st. century pros around here have obtained threaded
>> newsreaders already, but seemingly DOS edlin is still a popular
>> newsreader too.
>
> The fact of the matter is that "21st century pros" do not use newsreaders at all.  NNTP is, sadly, no longer relevant.
>
> This list is actually an email mailing list, but happens to be echoed as a web forum, and is mapped by Gmane as an NNTP newsgroup.  When you post with your fancy threaded newsreader and change the subject, the Gmane-to-mailing-list gateway loses the threading, so all the rest of us see you as a clueless newbie.
> —
> Tim Roberts, [hidden email]
> Providenza & Boekelheide, Inc.
>
> --
> You received this message because you are subscribed to the Google Groups "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

firefox
On 22.06.2017 14:58, Igor Korot wrote:

> In addition to what Tim said, you have an even uglier habit - changing
> the "Subject" line.
> So even if people will read this as a newsreader, the threading will
> be broken and there will
> be just one post sitting there without a context.



what kind of funny "newsreader" would that be?

just click on   nntp://gmane.org   ~~  in thunderbird, and you will
never look back.     gmane.comp.python.wxpython

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Igor Korot
On Thu, Jun 22, 2017 at 4:17 PM, Fox <[hidden email]> wrote:

> On 22.06.2017 14:58, Igor Korot wrote:
>
>> In addition to what Tim said, you have an even uglier habit - changing
>> the "Subject" line.
>> So even if people will read this as a newsreader, the threading will
>> be broken and there will
>> be just one post sitting there without a context.
>
>
>
>
> what kind of funny "newsreader" would that be?
>
> just click on   nntp://gmane.org   ~~  in thunderbird, and you will never
> look back.     gmane.comp.python.wxpython

Why?
I, for one, use the gmail to read the MAILING LIST!

Besides most corporate world does not like installing a software that
is of no use.
But you probably never worked at the "Corporate Office"....

Thank you.

>
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

firefox
>>> In addition to what Tim said, you have an even uglier habit - changing
>>> the "Subject" line.
>>> So even if people will read this as a newsreader, the threading will
>>> be broken and there will
>>> be just one post sitting there without a context.
>>
>>
>>
>>
>> what kind of funny "newsreader" would that be?
>>
>> just click on   nntp://gmane.org   ~~  in thunderbird, and you will never
>> look back.     gmane.comp.python.wxpython
>
> Why?
> I, for one, use the gmail to read the MAILING LIST!
>
> Besides most corporate world does not like installing a software that
> is of no use.
> But you probably never worked at the "Corporate Office"....



why should anyone restrict himself to any degree just to be with
whatever it is you call corp. office? many workshops have crappier tools
than I have at home.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Igor Korot


On Jun 22, 2017 4:51 PM, "Fox" <[hidden email]> wrote:
In addition to what Tim said, you have an even uglier habit - changing
the "Subject" line.
So even if people will read this as a newsreader, the threading will
be broken and there will
be just one post sitting there without a context.




what kind of funny "newsreader" would that be?

just click on   nntp://gmane.org   ~~  in thunderbird, and you will never
look back.     gmane.comp.python.wxpython

Why?
I, for one, use the gmail to read the MAILING LIST!

Besides most corporate world does not like installing a software that
is of no use.
But you probably never worked at the "Corporate Office"....



why should anyone restrict himself to any degree just to be with whatever it is you call corp. office? many workshops have crappier tools than I have at home.

Because nobody cares what you have at home?
Like I said previously,  some people are actually working for big corporation and they don't want to be fired. 

But you don't care, right? Because - why should you? You have everything at home - mom,dad, food, bed, etc.



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

firefox

> Because nobody cares what you have at home?
> Like I said previously,  some people are actually working for big
> corporation and they don't want to be fired.
>
> But you don't care, right? Because - why should you? You have everything
> at home - mom,dad, food, bed, etc.


so you live in panic of getting fired each day, yet they don't pay you
enuff so can afford a bed ?  Wow !

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: edlin

Florian Höch
In reply to this post by firefox
Am 21.06.2017 um 19:53 schrieb [hidden email]:
> I was assuming the 21st. century pros around here have obtained threaded
> newsreaders already, but seemingly DOS edlin is still a popular
> newsreader too.

Myself, I use Thundebird to read this list. It has threaded display as
an option, and works quite well. It also has very useful filtering
functionality. For example, you can have a filter that moves messages
from specific senders directly into the Junk or Trash folders...

Florian.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
12