Back to index

python3.2  3.2.2
Functions | Variables
tkinter.test.support Namespace Reference

Functions

def check_tk_availability
def get_tk_root
def root_deiconify
def root_withdraw
def simulate_mouse_click

Variables

 _tk_unavailable = None

Function Documentation

Check that Tk is installed and available.

Definition at line 7 of file support.py.

00007 
00008 def check_tk_availability():
00009     """Check that Tk is installed and available."""
00010     global _tk_unavailable
00011 
00012     if _tk_unavailable is None:
00013         _tk_unavailable = False
00014         if sys.platform == 'darwin':
00015             # The Aqua Tk implementations on OS X can abort the process if
00016             # being called in an environment where a window server connection
00017             # cannot be made, for instance when invoked by a buildbot or ssh
00018             # process not running under the same user id as the current console
00019             # user.  To avoid that, raise an exception if the window manager
00020             # connection is not available.
00021             from ctypes import cdll, c_int, pointer, Structure
00022             from ctypes.util import find_library
00023 
00024             app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
00025 
00026             if app_services.CGMainDisplayID() == 0:
00027                 _tk_unavailable = "cannot run without OS X window manager"
00028             else:
00029                 class ProcessSerialNumber(Structure):
00030                     _fields_ = [("highLongOfPSN", c_int),
00031                                 ("lowLongOfPSN", c_int)]
00032                 psn = ProcessSerialNumber()
00033                 psn_p = pointer(psn)
00034                 if (  (app_services.GetCurrentProcess(psn_p) < 0) or
00035                       (app_services.SetFrontProcess(psn_p) < 0) ):
00036                     _tk_unavailable = "cannot run without OS X gui process"
00037         else:   # not OS X
00038             import tkinter
00039             try:
00040                 tkinter.Button()
00041             except tkinter.TclError as msg:
00042                 # assuming tk is not available
00043                 _tk_unavailable = "tk not available: %s" % msg
00044 
00045     if _tk_unavailable:
00046         raise unittest.SkipTest(_tk_unavailable)
00047     return

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 48 of file support.py.

00048 
00049 def get_tk_root():
00050     check_tk_availability()     # raise exception if tk unavailable
00051     try:
00052         root = tkinter._default_root
00053     except AttributeError:
00054         # it is possible to disable default root in Tkinter, although
00055         # I haven't seen people doing it (but apparently someone did it
00056         # here).
00057         root = None
00058 
00059     if root is None:
00060         # create a new master only if there isn't one already
00061         root = tkinter.Tk()
00062 
00063     return root

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 64 of file support.py.

00064 
00065 def root_deiconify():
00066     root = get_tk_root()
00067     root.deiconify()

Here is the call graph for this function:

Definition at line 68 of file support.py.

00068 
00069 def root_withdraw():
00070     root = get_tk_root()
00071     root.withdraw()
00072 

Here is the call graph for this function:

def tkinter.test.support.simulate_mouse_click (   widget,
  x,
  y 
)
Generate proper events to click at the x, y position (tries to act
like an X server).

Definition at line 73 of file support.py.

00073 
00074 def simulate_mouse_click(widget, x, y):
00075     """Generate proper events to click at the x, y position (tries to act
00076     like an X server)."""
00077     widget.event_generate('<Enter>', x=0, y=0)
00078     widget.event_generate('<Motion>', x=x, y=y)
00079     widget.event_generate('<ButtonPress-1>', x=x, y=y)
00080     widget.event_generate('<ButtonRelease-1>', x=x, y=y)

Variable Documentation

Definition at line 5 of file support.py.