[pygtk] Using pyGtk under windows application

Matteo Boscolo matteo.boscolo at boscolini.eu
Mon Mar 7 17:36:40 WST 2011


Hi Arjan,

Il 05/03/2011 22:11, Arjan Molenaar ha scritto:
>
> Hi,
>
> Okay, so you want to run a gtk app inside a non-gtk app (the fax 
> application does not use gtk, right?).
>
Right. it's a windows mfc application.
>
> First question that comes to mind is: why? Doesn't the application 
> have a GUI library of its own?
>
Because I already have a  gtk application and I  need to use it unbedded 
in my mfc application
>
> If you want to use gtk, The trick now is to let both behave in tandem. 
> I suppose the cad app is also running a main loop. Is there any chance 
> you can register a idle handler there?
>
I do dot have any source code of the main application.
I use the api-com to crete a new instance inside my cad application

> Then you can use object.main_iteration() to run a single iteration at 
> a time. Hence the cad app is not blocking. Personally I'm not in favor 
> of using multiple GUI toolkit in one app.
>
Me too but the effort to rewrite the gtk applicatin is too big .. :-(
>
> Another solution can be to create a subprocess. Either by forking or 
> by launching a new process. It depends on the data you want to show, 
> though. Maybe fetch up to date information through a socket ;)
>
Thanks for the tip .. I will do some test in this direction

Regards,
Matteo
>
> Regards,
> Arjan
>
> Op 5 mrt. 2011 08:12 schreef "Matteo Boscolo" 
> <matteo.boscolo at boscolini.eu <mailto:matteo.boscolo at boscolini.eu>> het 
> volgende:
> > Sorry for my english .. may be some code is more explicit.
> >
> > this is my com class:
> > #!/usr/bin/env python
> > #oi:=newObj('OpenClient.Interface')
> > #oi->showDialog()
> > # example base.py
> > import pygtk
> > pygtk.require('2.0')
> > import gtk
> > S_OK =0
> > E_FAIL=1
> > class Base:
> > def __init__(self):
> > self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> > self.window.show()
> >
> > def main(self):
> > gtk.main()
> >
> > class CustomInterface(object):
> > _reg_clsid_ = "{F184147B-E26F-419E-8BEE-71B669F39D44}"
> > _reg_desc_ = "Client interface"
> > _reg_progid_ = "OpenClient.Interface"
> >
> > _public_methods_ = [
> > 'setParent',
> > 'showDialog'
> > ]
> >
> > def __init__(self):
> > self._application = None
> > self._interface=Base()
> >
> > def setParent(self, application):
> > self._application=application
> > return S_OK
> >
> > def showDialog(self):
> > self._interface.main()
> > return S_OK
> > def destrory(self):
> > gtk.main_quit()
> >
> > if __name__ == "__main__":
> > import sys
> > import win32com.server.register
> > sys.argv.append('--debug')
> > win32com.server.register.UseCommandLine(CustomInterface)
> >
> > from a vbs script I call this class :
> > dim o
> > msgbox "test"
> > set o=createObject("OpenClient.Interface")
> > msgbox "test1"
> > o.showDialog()
> > msgbox "test2"
> > o.destrory()
> >
> > when the method showDialog() is executed the execution is inside the
> > method .. so the test2 msgbox dose not appear
> > what I need to do is extending may main application with some form 
> using
> > the gtk ..
> > so looking at the code the system have to execute the showdialog and go
> > out and stop at the test2 msgbox.
> >
> > with qt I do the following
> > class Base:
> > def __init__(self):
> > self._app = QtGui.QApplication(sys.argv)
> > self.MainForm = QtGui.QWidget()
> > self.MainForm.resize(250, 150)
> > self.MainForm.setWindowTitle('Exsample')
> >
> > def main(self):
> > self.MainForm.show()
> >
> > and it works as I wont
> >
> > Regards,
> > Matteo
> >
> >
> >
> > Il 05/03/2011 00:13, Arjan Molenaar ha scritto:
> >>
> >> Hi Matteo,
> >>
> >> I'm not totally sure if I get your question right, but it seems to me
> >> you should just create a new top-level window. With
> >> gtk.Window.set_transient_for() you're able to create a parent-child
> >> relation for this (utility) window.
> >>
> >> Regards,
> >>
> >> Arjan
> >>
> >> Op 4 mrt. 2011 22:55 schreef "Matteo Boscolo"
> >> <matteo.boscolo at boscolini.eu <mailto:matteo.boscolo at boscolini.eu> 
> <mailto:matteo.boscolo at boscolini.eu 
> <mailto:matteo.boscolo at boscolini.eu>>> het
> >> volgende:
> >> > Hi All,
> >> > I'm developing an application inside a cad package written in c++ 
> using
> >> > a python Com server.
> >> > in this application I would like to create a windows form with a list
> >> > view reading data from a database ..
> >> >
> >> > I would like to have a no modal window so the user can leave the gtk
> >> > application open.
> >> >
> >> > my problem is that if I use the gtk..mainloop()the code is into 
> the gtk
> >> > application and I cannot use the cad application..
> >> >
> >> > I do some test with python thread ..
> >> > there is other way to do such a think ?
> >> >
> >> > Regards,
> >> > Matteo
> >> >
> >>
> >> 
> ------------------------------------------------------------------------
> >> 
> ------------------------------------------------------------------------
> >>
> >> Nessun virus nel messaggio.
> >> Controllato da AVG - www.avg.com <http://www.avg.com> 
> <http://www.avg.com>
> >> Versione: 10.0.1204 / Database dei virus: 1435/3481 - Data di
> >> rilascio: 04/03/2011
> >>
> >
>
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
>
> Nessun virus nel messaggio.
> Controllato da AVG - www.avg.com <http://www.avg.com>
> Versione: 10.0.1204 / Database dei virus: 1435/3482 - Data di 
> rilascio: 04/03/2011
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20110307/3eaa70de/attachment.html>


More information about the pygtk mailing list