def enable(self, app=None): """DEPRECATED since IPython 5.0 Enable event loop integration with PyGTK. Parameters ---------- app : ignored Ignored, it's only a placeholder to keep the call signature of all gui activation methods consistent, which simplifies the logic of supporting magics. Notes ----- This methods sets the PyOS_InputHook for PyGTK, which allows the PyGTK to integrate with terminal based applications like IPython. """ warn( "This function is deprecated since IPython 5.0 and will be removed in future versions.", DeprecationWarning, stacklevel=2, ) import gtk try: gtk.set_interactive(True) except AttributeError: # For older versions of gtk, use our own ctypes version from IPython.lib.inputhookgtk import inputhook_gtk self.manager.set_inputhook(inputhook_gtk)
def enable_gtk(self, app=None): """Enable event loop integration with PyGTK. Parameters ---------- app : ignored Ignored, it's only a placeholder to keep the call signature of all gui activation methods consistent, which simplifies the logic of supporting magics. Notes ----- This methods sets the PyOS_InputHook for PyGTK, which allows the PyGTK to integrate with terminal based applications like IPython. """ import gtk try: gtk.set_interactive(True) self._current_gui = GUI_GTK except AttributeError: # For older versions of gtk, use our own ctypes version from IPython.lib.inputhookgtk import inputhook_gtk self.set_inputhook(inputhook_gtk) self._current_gui = GUI_GTK
def check_for_gtk(): "check for the presence of pygtk" gotit = False explanation = None try: import gtk except ImportError: explanation = ( 'Building for Gtk+ requires pygtk; you must be able to "import gtk" in your build/install environment' ) except RuntimeError: explanation = "pygtk present but import failed" else: version = (2, 2, 0) if gtk.pygtk_version < version: explanation = "Error: GTK backend requires PyGTK %d.%d.%d (or later), " "%d.%d.%d was detected." % ( version + gtk.pygtk_version ) else: gotit = True if gotit: module = make_extension("test", []) add_pygtk_flags(module) if not find_include_file(module.include_dirs, os.path.join("gtk", "gtk.h")): explanation = "Could not find Gtk+ headers in any of %s" % ", ".join( ["'%s'" % x for x in module.include_dirs] ) gotit = False def ver2str(tup): return ".".join([str(x) for x in tup]) if gotit: import gobject if hasattr(gobject, "pygobject_version"): pygobject_version = ver2str(gobject.pygobject_version) else: pygobject_version = "[pre-pygobject]" print_status( "Gtk+", "gtk+: %s, glib: %s, pygtk: %s, pygobject: %s" % (ver2str(gtk.gtk_version), ver2str(gobject.glib_version), ver2str(gtk.pygtk_version), pygobject_version), ) else: print_status("Gtk+", "no") if explanation is not None: print_message(explanation) # Switch off the event loop for PyGTK >= 2.15.0 if gotit: try: gtk.set_interactive(False) except AttributeError: # PyGTK < 2.15.0 pass return gotit
def __init__(self, **kwargs): self.plotobj = BasePlotView(**kwargs) self.alive = True #self.bf = bf try: gtk.set_interactive(False) except: pass
def check_for_gtk(): 'check for the presence of pygtk' gotit = False explanation = None try: import gtk except ImportError: explanation = 'Building for Gtk+ requires pygtk; you must be able to "import gtk" in your build/install environment' except RuntimeError: explanation = 'pygtk present but import failed' else: version = (2, 2, 0) if gtk.pygtk_version < version: explanation = "Error: GTK backend requires PyGTK %d.%d.%d (or later), " \ "%d.%d.%d was detected." % ( version + gtk.pygtk_version) else: gotit = True if gotit: module = Extension('test', []) add_pygtk_flags(module) if not find_include_file(module.include_dirs, os.path.join("gtk", "gtk.h")): explanation = ("Could not find Gtk+ headers in any of %s" % ", ".join(["'%s'" % x for x in module.include_dirs])) gotit = False def ver2str(tup): return ".".join([str(x) for x in tup]) if gotit: import gobject if hasattr(gobject, 'pygobject_version'): pygobject_version = ver2str(gobject.pygobject_version) else: pygobject_version = '[pre-pygobject]' print_status( "Gtk+", "gtk+: %s, glib: %s, pygtk: %s, pygobject: %s" % (ver2str(gtk.gtk_version), ver2str(gobject.glib_version), ver2str(gtk.pygtk_version), pygobject_version)) else: print_status("Gtk+", "no") if explanation is not None: print_message(explanation) # Switch off the event loop for PyGTK >= 2.15.0 if gotit: try: gtk.set_interactive(False) except AttributeError: # PyGTK < 2.15.0 pass return gotit
def check_gtk(mode): try: import gtk except ImportError: return mode if hasattr(gtk,'set_interactive'): gtk.set_interactive(False) return 'tkthread' else: return mode
def __init__(self, bf=None, **kwargs): #gobject.threads_init() gtk.Window.__init__(self) X64PlotBase.__init__(self, bf=bf, **kwargs) self.set_title("X64 Plot Window") x, y = 800, 600 self.set_default_size(x, y) #self.connect("destroy", lambda x: gtk.main_quit()) self.connect("delete_event", self.delete_event) #self.vbox = gtk.VBox(False, 0) #self.add(self.vbox) self.plotobj = MainView(self, **kwargs) self.add(self.plotobj) self.alive = True self.show_all() self.gtk_catchup() if not MATPLOTLIBV1_0: gtk.set_interactive()
def __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=1, shell_class=MTInteractiveShell): import gtk # Check for set_interactive, coming up in new pygtk. # Disable it so that this code works, but notify # the user that he has a better option as well. # XXX TODO better support when set_interactive is released try: gtk.set_interactive(False) print "Your PyGtk has set_interactive(), so you can use the" print "more stable single-threaded Gtk mode." print "See https://bugs.launchpad.net/ipython/+bug/270856" except AttributeError: pass self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2, 4, 0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=1,shell_class=MTInteractiveShell): import gtk ## # Check for set_interactive, coming up in new pygtk. ## # Disable it so that this code works, but notify ## # the user that he has a better option as well. ## # XXX TODO better support when set_interactive is released ## try: gtk.set_interactive(False) ## print "Your PyGtk has set_interactive(), so you can use the" ## print "more stable single-threaded Gtk mode." ## print "See https://bugs.launchpad.net/ipython/+bug/270856" ## except AttributeError: ## pass self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def enable_gtk(self, app=False): """Enable event loop integration with PyGTK. Parameters ---------- app : bool Create a running application object or not. Because gtk does't have an app class, this does nothing. Notes ----- This methods sets the PyOS_InputHook for PyGTK, which allows the PyGTK to integrate with terminal based applications like IPython. """ import gtk try: gtk.set_interactive(True) self._current_gui = GUI_GTK except AttributeError: # For older versions of gtk, use our own ctypes version from IPython.lib.inputhookgtk import inputhook_gtk self.set_inputhook(inputhook_gtk) self._current_gui = GUI_GTK
## Foundation, Inc., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <*****@*****.**> ## import gtk import mock from stoqlib.api import api from stoqlib.domain.profile import ProfileSettings from stoqlib.gui.uitestutils import GUITest from stoq.gui.shell.shellwindow import ShellWindow import stoq gtk.set_interactive(False) class BaseGUITest(GUITest): def create_app(self, window_class, app_name): self.user = api.get_current_user(self.store) # FIXME: Perhaps we should just ignore permission checking, it'll # save quite a few selects settings = self.store.find(ProfileSettings, app_dir_name=app_name, user_profile=self.user.profile).one() if settings is None: settings = self.create_profile_settings(self.user.profile, app_name) api.user_settings.set(u'actual-version', stoq.stoq_version)
import gtk gtk.set_interactive(False) # allow gtk threads with interactive console gtk.gdk.threads_init() # allow gtk threads, must protect gtk calls import time from threading import Thread, current_thread class Gooey( object ): """root level gooey class manages windows and gtk loop in separate thread this setup allows interactive interpreter to be used """ def __init__( self ): # holds gtk main loop thread self._gtk_thread = None # set of running windows self.windows = set() # ident of thread currently inside gtk thread or none self.in_thread = None class Gtk_Lock(object): """used in 'with' block (potentially recursively) to guard gtk calls """ def __init__(self, gooey, mark=False): self.gooey = gooey self.mark = mark # used inside callback to mark without locking self.really_leave = False
## ## Author(s): Stoq Team <*****@*****.**> ## import gtk import mock from stoqlib.api import api from stoqlib.domain.profile import ProfileSettings from stoqlib.gui.test.uitestutils import GUITest import stoq from stoq.gui.shell.shellapp import ShellApp from stoq.gui.shell.shellwindow import ShellWindow gtk.set_interactive(False) class BaseGUITest(GUITest): def setUp(self): original_refresh = ShellApp.refresh # We need to do do this mock since the store here doesn't get # confirmed, so an action to an item that results in the results # getting refreshed would make the results disapear self._refresh_mock = mock.patch( 'stoq.gui.shell.shellapp.ShellApp.refresh', new=lambda s: original_refresh(s, rollback=False)) self._refresh_mock.start() super(BaseGUITest, self).setUp()
import Tkinter root = Tkinter.Tk() import sys try: import pygtk pygtk.require("2.0") except: pass try: import gtk import gtk.glade gtk.set_interactive(1) except: sys.exit(1) class tpv: def __init__(self): #Set the Glade file self.gladefile = "facturador.glade" self.wTree = gtk.glade.XML(self.gladefile, "login_facturador") #Create our dictionay and connect it dic = {"on_loginFacturador_destroy" : gtk.main_quit , "on_AddFactura" : self.OnAddFactura, "on_loginCancel_destroy" : gtk.main_quit, "on_Exit_destroy" : gtk.main_quit, "on_AddProduct" : self.OnAddProduct,
File "/home/diver/Desktop/gtk-tut-python/interactivefilesel.py", line 77 self.filew=gtk.FileSelection("File Selection") DeprecationWarning: use gtk.FileChooserDialog Warning (from warnings module): File "/home/diver/Desktop/gtk-tut-python/interactivefilesel.py", line 85 self.filew.set_filename("penguin.png") DeprecationWarning: use gtk.FileChooserDialog """ import pygtk pygtk.require("2.0") import gtk gtk.set_interactive(True) if hasattr('_gtk', '_lazyutils'): ns = LazyNamespace(gtk, locals()) ns.add_submodule('glade', '_glade') ns.add_submodule('_gtk', 'gtk._gtk') sys.modules['gtk'] = ns sys.modules['gtk.glade'] = LazyModule('_glade', {}) else: print("No LazyNamespace...") # gtk.set_interactive(True) class FileSelectionExample: # delete event message def delete_event(self, widget, event, data=None):
File "/home/diver/Desktop/gtk-tut-python/interactivefilesel.py", line 77 self.filew=gtk.FileSelection("File Selection") DeprecationWarning: use gtk.FileChooserDialog Warning (from warnings module): File "/home/diver/Desktop/gtk-tut-python/interactivefilesel.py", line 85 self.filew.set_filename("penguin.png") DeprecationWarning: use gtk.FileChooserDialog """ import pygtk pygtk.require("2.0") import gtk gtk.set_interactive(True) if hasattr("_gtk", "_lazyutils"): ns = LazyNamespace(gtk, locals()) ns.add_submodule("glade", "_glade") ns.add_submodule("_gtk", "gtk._gtk") sys.modules["gtk"] = ns sys.modules["gtk.glade"] = LazyModule("_glade", {}) else: print ("No LazyNamespace...") # gtk.set_interactive(True) class FileSelectionExample: # delete event message def delete_event(self, widget, event, data=None):