So we do it in RabbitVCS. Essentially, the main application creates a dialog and launches it using the PyGTK gtk.Dialog run () method .
Extract this from the main application (see action.py ):
def get_login(self, realm, username, may_save):
gtk.gdk.threads_enter()
dialog = rabbitvcs.ui.dialog.Authentication(
realm,
may_save
)
result = dialog.run()
gtk.gdk.threads_leave()
return result
This get_login function is specified as a callback for the PySVN client instance.
Pay attention to the threads_enter () and threads_leave () methods! They allow GTK to use Python threads, but note that GIL may be blocked by other extensions.
, ( Glade), run() PyGTK (. dialog.py):
def run(self):
returner = None
self.dialog = self.get_widget("Authentication")
result = self.dialog.run()
login = self.get_widget("auth_login").get_text()
password = self.get_widget("auth_password").get_text()
save = self.get_widget("auth_save").get_active()
self.dialog.destroy()
if result == gtk.RESPONSE_OK:
return (True, login, password, save)
else:
return (False, "", "", False)
RabbitVCS, , , , . get_widget Glade. Glade, .
, :)