Hi Pier,
Thank you thank you THANK YOU! it's working! =D
Your second solution was the way to go, with a little twist.
First I added locals() to InteractiveInterpreter (it is
InteractiveInterpreter instead of InteractiveConsole, your line number
was right), but I only got the dictionary from Py_Shell.py. I actually
wanted the dictionary from Gui.py that has got Py_Shell embedded. So, I
got the locals() from Gui.py right before instantiating Shell_Gui and
passed to Shell_Gui as an additional parameter (sim_locals). Then in
the Shell_Gui __init__, I did pretty much what you said to do:
self.core=code.InteractiveInterpreter(sim_locals)
Now the embedded python console have access to all the functions and
variables that are loaded with the gui.
Sincerely,
~ Yang
p.s. now i just have to fix the error with pygtk.require('2.0') so i
can use your latest version of Py_Shell :)
On Wed, 2003-11-05 at 05:44, Pier Carteri wrote:
> Hi Yang,
> I'm not sure to undestand well you question (feel free to correct me).
> There are two possibilities: the former is use Py_Shell to load your
> program, but this way can be really difficult especially if the program
> you load is a gui (with gui I mean something that call the
> gtk.main_loop) because the second call to main_loop will freeze the
> Py_Shell interface; a lot of work should be done to avoid possible
> deadlock etc., and this is a bit out of scope for Py_Shell.
>
> The latter way is create your gui which embed Py_Shell and pass to the
> shell a local dictionary. I'm going to explain last sentence (that's not
> clear also to me :-))
> Py_Shell is based on InteractiveConsole (IC) (InteractiveConsole and
> InteractiveInterpreter are located into the code module, you can see the
> python doc for more infos). When you create an IC object you can pass it
> a dictionary; every command send to the IC will be executed into the
> environment based on that dictionary so this is probably what you are
> looking for .
>
> So try somethings like this: in Py_Shell change the line where it's
> created the InteractiveConsole (around line 287)
>
> self.core=code.InteractiveConsole()
>
> and replace with
>
> self.core=code.InteractiveConsole(locals())
>
> Hope this helps
>
> Best regards!
> Pier
>
> Il mar, 2003-11-04 alle 23:55, Yang Zheng ha scritto:
> > Hello Pier,
> >
> > That fixed my problem, thanks a lot for your program and help!
> >
> > I know this is going to be a bit out of scope of the GUI, but I was
> > wondering if it's possible for this Py_Shell to be the original shell
> > that is used to load up the gui in the first place. Say I have this
> > Gui.py that loads up functions, variables, and the glade stuff. When I
> > run it, the gui pops out, with your Py_Shell embedded inside.
> > Currently, the Py_Shell inside the gui is a completely new one that has
> > no knowlege of the Gui.py functions/variables. Is there a way for
> > Py_Shell to have acess to them?
> >
> > thanks again,
> > ~ Yang
> >
> >
> > On Tue, 2003-11-04 at 11:46, Pier Carteri wrote:
> > > Hi Yang!
> > > main_shell=Py_Shell.Shell_Gui(with_window=0)
> > > > xml.get_widget("vpaned1").add2(main_shell.gui)
> > >
> > > I've looked to my code, I think the solution is that you miss a
> > > main_shell.gui.show_all()
> > > In my code I call it with the empty frame, that's why you see only the
> > > frame.
> > > You ca fix it:
> > > put line 313 " frame.show_all()" after line 314 "frame.add(box)"
> > >
> > > > >>> import pygtk
> > > > >>> pygtk.require('2.0')
> > > > Traceback (most recent call last):
> > > > File "<stdin>", line 1, in ?
> > > > File "pygtk.py", line 73, in require
> > > > assert versions.has_key(version), \
> > > > AssertionError: required version '2.0' not found on system
> > >
> > > It seems that somethings is wrong with your configuration; are you sure
> > > you have installed pygtk into the right location? The script doesn't
> > > find the required version of pygtk
> > >
> > > Hope this help!
> > >
> > > Best regards!
> > >
> > > Pier
> > >
> > > _______________________________________________
> > > pygtk mailing list [EMAIL PROTECTED]
> > > http://www.daa.com.au/mailman/listinfo/pygtk
> > > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >
> > _______________________________________________
> > pygtk mailing list [EMAIL PROTECTED]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/