Re: [pygtk] gtk.Window act as gtk.Dialog

2011-07-19 Thread Tim Evans

On 2011-07-18 04:13, Mauro Giacomini wrote:

Hi,
I have one question.
Is it possible to make a gtk.Window act as a gtk.Dialog?
I am in this situation:
In my app I have one gtk.Window (the main window); in this windows I
open a second Window where I collect input from the user.
I made this second window modal and set transient for parent (main
window), but I want that the flow in main window stops until I collect
the input in the second window.
I know gtk.Dialog acts as I want, but, if gtk.Dialog is pre-build with a
vbox and action area.
If I want to add widget, then I must wrote:
dialog.vbox.pack_start(widget).
The window from which I collect data is little complex, I have 2
notebooks, various treeview.
I hope that I explained well


Attached is a small class that runs a gtk.Window in the way that 
gtk.Dialog.run does. It includes a few features that I hope make it easy 
to use in real code. If you click Ok it'll print 'ok', or 'cancel' if 
you click Cancel, or None if you close the window without clicking a button.


A few points to be careful of:
 - Remember to show the window before calling RunAsDialog.run().
 - Remember to explicitly destroy the window afterwards, after pulling
   any information you need from the widgets within the window.

--
Tim Evans
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120  |  e: t.ev...@aranz.com
www.aranzgeo.com
from __future__ import division

import gtk, gobject


class RunAsDialog(object):
def __init__(self, window):
self.window = window
self.window.connect('delete-event', self.__on_delete_event)
self.__loop = None
self.__response = None

def __on_delete_event(self, window, event):
self.finish(None)
return True

def register_button(self, button, response):
def on_clicked(button):
self.finish(response)
button.connect('clicked', on_clicked)

def run(self):
self.__loop = gobject.MainLoop()
self.__loop.run()
return self.__response

def finish(self, response):
if self.__loop is not None:
self.__response = response
self.__loop.quit()
self.__loop = None


def test():
ok = gtk.Button(stock='gtk-ok')
cancel = gtk.Button(stock='gtk-cancel')
box = gtk.HButtonBox()
box.props.spacing = 6
box.pack_start(cancel)
box.pack_start(ok)
w = gtk.Window()
w.props.border_width = 12
w.add(box)
w.show_all()
runner = RunAsDialog(w)
runner.register_button(ok, 'ok')
runner.register_button(cancel, 'cancel')
print runner.run()
w.destroy()

if __name__ == '__main__':
test()
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] Windows all in one bundle broken?

2011-07-19 Thread Dieter Verfaillie

Hi,

Quoting "Mathew Yeates" :

I just tried downloading pygtk-all-in-one-2.24.0.win32-py2.7.msi

and glade-3.exe doesn't work. I get
"The system cannot execute the specified program.".

This is on Windows XP.


We'll need a bit more information to be able to help you:

1) How do you execute glade-3.exe? Via the shortcut the installer
   created in the start menu or some other method?
2) What does your PATH environment variable look like? > open a
   "Command Prompt" aka cmd.exe and execute "echo %PATH%"
3) Where is Python 2.7 installed?
4) Assuming Python 2.7 is installed in C:\Python27, does
   C:\Python27\Lib\site-packages\gtk-2.0\runtime\bin actually
   contain glade-3.exe?
5) Open the attached clean.py script in your favorite text editor
   and edit the paths on line 7 and 8 to correspond to the values
   applicable on your system. Then run the script. Does the script
   output any values?

mvg,
Dieter



This message was sent using IMP, the Internet Messaging Program.


clean.py
Description: application/force-download
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] Windows all in one bundle broken?

2011-07-19 Thread Mathew Yeates
Hi
I just tried downloading pygtk-all-in-one-2.24.0.win32-py2.7.msi

and glade-3.exe doesn't work. I get
"The system cannot execute the specified program.".

This is on Windows XP.

???

-Mathew
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/