Re: [spyder] Sharing objects between Widgets and IPy console

2018-02-14 Thread 'UHV' via spyder
Hi Carlos,

Thanks for taking the time to consider this.

What I'd like to do is use Spyder to control the same piece of hardware 
(for example a motor) through both a UI plugin and the ipython console. I 
can subclass `spyder.app.mainwindow.MainWindow` so that on `setup()` it 
instantiates a connection to my motor which is stored as an attribute of 
`MainWindow`. UI plugins can send instructions to the motor through its 
methods because they have access to the `MainWindow` namespace. So far so 
good. But there are more complicated situations where I'd like to be able 
to instruct my motor through the console. However, the ipython console 
exists in a different process, with its own namespace, plus the operating 
system won't allow more than one process to access the motor at a time. So 
I haven't been able to find a way to devise a way to run hardware that can 
be controlled through both the console and the GUI. I suspect that this is 
a fundamental limitation that stems from ipython running in its own 
process, and the object that I want to share not being serializable.

Note that I can get this to work using the internal console. But that has 
two drawbacks: it blocks when executing slow processes, and it lacks many 
of the fun features of ipython.

I'd love to hear any other ideas that you might have. 



On Wednesday, February 14, 2018 at 10:41:01 AM UTC-4, Carlos Córdoba wrote:
>
> I’d like to be able to be able to control the device through both the 
> console and a UI plugin
>
> I still don’t understand what you want to do. Do you want to create a 
> Spyder plugin for your experiment? Or do you already have a GUI interface 
> to it?
>
> Cheers,
> Carlos
>
> El 14/02/18 a las 07:12, ‘UHV’ via spyder escribió:
>
> Thanks for the suggestion, but I'm not sure that 
> `refresh_namespacebrowser` will work the way I need it to. If I understand 
> it correctly, it calls for the console to return the serialized contents of 
> the console namespace. The objects I want to exchange are instances that 
> contain things like open COM ports or device handles that can't be pickled. 
> And even if they could, the widget and console versions of the object would 
> be copies of one another (not views) and changes to one would not be 
> reflected in the other (without some sort of refresh mechanism to make a 
> new copy). Am I understanding this properly? or does that method really 
> return a view?
>
> Thanks. 
>
> On Tuesday, February 13, 2018 at 3:00:17 PM UTC-4, Carlos Córdoba wrote: 
>>
>> Hi,
>>
>> Now we have refresh_namespacebrowser:
>>
>>
>> https://github.com/spyder-ide/spyder/blob/3.x/spyder/widgets/ipythonconsole/namespacebrowser.py#L57
>>
>> which is a method of every console. Perhaps that’s what you need?
>>
>> Cheers,
>> Carlos
>>
>> El 13/02/18 a las 12:13, ‘UHV’ via spyder escribió:
>>
>> I'd like to share an object between the console and the GUI front end, so 
>> that changes made by one are reflected in the other. The objects I want to 
>> share are interfaces to devices and instruments, so only one instance of 
>> each is allowed (or even meaningful). I'd like to be able to be able to 
>> control the device through both the console and a UI plugin. Separately 
>> they work, but I haven't found a way of sharing the device. The method used 
>> by the `namespace_browser` is to push and pull copies of the objects. That 
>> won't work in my case. In the past, with the (very) old style console this 
>> could be done with the `update_namespace()` method.  
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "spyder" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to spyderlib+...@googlegroups.com.
>> To post to this group, send email to spyd...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/spyderlib.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> ​
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "spyder" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to spyderlib+...@googlegroups.com .
> To post to this group, send email to spyd...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/spyderlib.
> For more options, visit https://groups.google.com/d/optout.
>
> ​
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spyderlib+unsubscr...@googlegroups.com.
To post to this group, send email to spyderlib@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


Re: [spyder] Sharing objects between Widgets and IPy console

2018-02-14 Thread Carlos Córdoba

   Am I understanding this properly? or does that method really return
   a view?

No, the namespace browser always returns serialized copies of the 
objects present in the console.


   I’d like to be able to be able to control the device through both
   the console and a UI plugin

I still don’t understand what you want to do. Do you want to create a 
Spyder plugin for your experiment? Or do you already have a GUI 
interface to it?


Cheers,
Carlos

El 14/02/18 a las 07:12, ‘UHV’ via spyder escribió:

Thanks for the suggestion, but I'm not sure that 
`refresh_namespacebrowser` will work the way I need it to. If I 
understand it correctly, it calls for the console to return the 
serialized contents of the console namespace. The objects I want to 
exchange are instances that contain things like open COM ports or 
device handles that can't be pickled. And even if they could, the 
widget and console versions of the object would be copies of one 
another (not views) and changes to one would not be reflected in the 
other (without some sort of refresh mechanism to make a new copy). Am 
I understanding this properly? or does that method really return a view?


Thanks.

On Tuesday, February 13, 2018 at 3:00:17 PM UTC-4, Carlos Córdoba wrote:

Hi,

Now we have |refresh_namespacebrowser|:


https://github.com/spyder-ide/spyder/blob/3.x/spyder/widgets/ipythonconsole/namespacebrowser.py#L57



which is a method of every console. Perhaps that’s what you need?

Cheers,
Carlos

El 13/02/18 a las 12:13, ‘UHV’ via spyder escribió:


I'd like to share an object between the console and the GUI front
end, so that changes made by one are reflected in the other. The
objects I want to share are interfaces to devices and
instruments, so only one instance of each is allowed (or even
meaningful). I'd like to be able to be able to control the device
through both the console and a UI plugin. Separately they work,
but I haven't found a way of sharing the device. The method used
by the `namespace_browser` is to push and pull copies of the
objects. That won't work in my case. In the past, with the (very)
old style console this could be done with the
`update_namespace()` method.


-- 
You received this message because you are subscribed to the

Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to spyderlib+...@googlegroups.com .
To post to this group, send email to spyd...@googlegroups.com
.
Visit this group at https://groups.google.com/group/spyderlib
.
For more options, visit https://groups.google.com/d/optout
.

​

--
You received this message because you are subscribed to the Google 
Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to spyderlib+unsubscr...@googlegroups.com 
.
To post to this group, send email to spyderlib@googlegroups.com 
.

Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


​

--
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spyderlib+unsubscr...@googlegroups.com.
To post to this group, send email to spyderlib@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


Re: [spyder] Sharing objects between Widgets and IPy console

2018-02-14 Thread 'UHV' via spyder
Thanks for the suggestion, but I'm not sure that `refresh_namespacebrowser` 
will work the way I need it to. If I understand it correctly, it calls for 
the console to return the serialized contents of the console namespace. The 
objects I want to exchange are instances that contain things like open COM 
ports or device handles that can't be pickled. And even if they could, the 
widget and console versions of the object would be copies of one another 
(not views) and changes to one would not be reflected in the other (without 
some sort of refresh mechanism to make a new copy). Am I understanding this 
properly? or does that method really return a view?

Thanks.

On Tuesday, February 13, 2018 at 3:00:17 PM UTC-4, Carlos Córdoba wrote:
>
> Hi,
>
> Now we have refresh_namespacebrowser:
>
>
> https://github.com/spyder-ide/spyder/blob/3.x/spyder/widgets/ipythonconsole/namespacebrowser.py#L57
>
> which is a method of every console. Perhaps that’s what you need?
>
> Cheers,
> Carlos
>
> El 13/02/18 a las 12:13, ‘UHV’ via spyder escribió:
>
> I'd like to share an object between the console and the GUI front end, so 
> that changes made by one are reflected in the other. The objects I want to 
> share are interfaces to devices and instruments, so only one instance of 
> each is allowed (or even meaningful). I'd like to be able to be able to 
> control the device through both the console and a UI plugin. Separately 
> they work, but I haven't found a way of sharing the device. The method used 
> by the `namespace_browser` is to push and pull copies of the objects. That 
> won't work in my case. In the past, with the (very) old style console this 
> could be done with the `update_namespace()` method.  
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "spyder" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to spyderlib+...@googlegroups.com .
> To post to this group, send email to spyd...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/spyderlib.
> For more options, visit https://groups.google.com/d/optout.
>
> ​
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spyderlib+unsubscr...@googlegroups.com.
To post to this group, send email to spyderlib@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


Re: [spyder] Sharing objects between Widgets and IPy console

2018-02-13 Thread Carlos Córdoba

Hi,

Now we have |refresh_namespacebrowser|:

https://github.com/spyder-ide/spyder/blob/3.x/spyder/widgets/ipythonconsole/namespacebrowser.py#L57

which is a method of every console. Perhaps that’s what you need?

Cheers,
Carlos

El 13/02/18 a las 12:13, ‘UHV’ via spyder escribió:

I'd like to share an object between the console and the GUI front end, 
so that changes made by one are reflected in the other. The objects I 
want to share are interfaces to devices and instruments, so only one 
instance of each is allowed (or even meaningful). I'd like to be able 
to be able to control the device through both the console and a UI 
plugin. Separately they work, but I haven't found a way of sharing the 
device. The method used by the `namespace_browser` is to push and 
pull copies of the objects. That won't work in my case. In the past, 
with the (very) old style console this could be done with the 
`update_namespace()` method.



--
You received this message because you are subscribed to the Google 
Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to spyderlib+unsubscr...@googlegroups.com 
.
To post to this group, send email to spyderlib@googlegroups.com 
.

Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


​

--
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spyderlib+unsubscr...@googlegroups.com.
To post to this group, send email to spyderlib@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.


[spyder] Sharing objects between Widgets and IPy console

2018-02-13 Thread 'UHV' via spyder
I'd like to share an object between the console and the GUI front end, so 
that changes made by one are reflected in the other. The objects I want to 
share are interfaces to devices and instruments, so only one instance of 
each is allowed (or even meaningful). I'd like to be able to be able to 
control the device through both the console and a UI plugin. Separately 
they work, but I haven't found a way of sharing the device. The method used 
by the `namespace_browser` is to push and pull copies of the objects. That 
won't work in my case. In the past, with the (very) old style console this 
could be done with the `update_namespace()` method. 


-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spyderlib+unsubscr...@googlegroups.com.
To post to this group, send email to spyderlib@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.