Pass Data to a Console within PyQt application

92 views
Skip to first unread message

bmic...@gmail.com

unread,
May 2, 2016, 10:06:32 AM5/2/16
to pyqtgraph
I'm on a steep learning curve at the moment - I've managed to create a PyQt application with two tabs, that loads a Pandas HDFStore and then creates additional dataframes based on user selections and plots them using pyqtgraph. I've also been able to implement a pyqtgraph console on the second tab.

My question is - within my application is it possible to have access to the application data from within the console.

E.g. I have self.store, and self.df1, etc and it would be good to address them directly in the console.

Thanks in advance for helping a newbie.

Best Regards,

Ben

Luke Campagnola

unread,
May 9, 2016, 2:00:12 AM5/9/16
to pyqt...@googlegroups.com
This is what the "namespace" argument is for in ConsoleWidget.__init__(). You can provide a dictionary of variables that will be immediately available from the console.

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/c0cf8eec-4284-483d-bce8-1ebf98147a33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Vergnes

unread,
Apr 19, 2017, 5:40:55 PM4/19/17
to pyqtgraph
Hi,

I managed to pass my globals() to the console while creating it but then after how to update the console namespace then?

namespace = {'pg': pg, 'np': np,  'outlet':outlet, 'inlet':inlet,  'dft1':dft1}
text = ""
w2 = pg.console.ConsoleWidget(namespace=globals(),  text=text)
d2.addWidget(w2) #added my consoleWidget to a dock 

#all this woks well BUT how to update the namespace after...?

//...... other code and update all variables in my main routine.....///

I tried these below but nothing works and can't find a proper definition of what would work ... even the log is not logged...

w2.locals['zib']=123
w2.user_ns.update(zob = 123)
w2.consoleWidget.log("prout=123")
w2.kernel.shell.push({'lfilename':lfilename,'inlet':inlet, 'outlet':outlet})
w2.pushVariables(prout=123)

any idea?

many thanks for support.

Best

Robert

Robert Vergnes

unread,
Apr 20, 2017, 11:35:54 AM4/20/17
to pyqtgraph
Found my error - I forget to declare some of the variable global earlier... hence not the globals()...
Reply all
Reply to author
Forward
0 new messages