<s> import ginga . toolkit <EOL> toolkit = ginga . toolkit . toolkit <EOL> have_gtk3 = False <EOL> have_gtk2 = False <EOL> if toolkit in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> try : <EOL> import pygtk <EOL> pygtk . require ( '<STR_LIT>' ) <EOL> have_gtk2 = True <EOL> except ImportError : <EOL> pass <EOL> if toolkit in ( '<STR_LIT>' , '<STR_LIT>' ) and ( not have_gtk2 ) : <EOL> try : <EOL> from gi import pygtkcompat <EOL> from gi . repository import GdkPixbuf <EOL> pygtkcompat . enable ( ) <EOL> pygtkcompat . enable_gtk ( version = '<STR_LIT>' ) <EOL> have_gtk3 = True <EOL> except ImportError : <EOL> pass <EOL> import gtk <EOL> import gobject <EOL> if have_gtk3 : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> ginga . toolkit . use ( '<STR_LIT>' ) <EOL> def pixbuf_new_from_xpm_data ( xpm_data ) : <EOL> xpm_data = bytes ( '<STR_LIT:\n>' . join ( xpm_data ) ) <EOL> return GdkPixbuf . Pixbuf . new_from_xpm_data ( xpm_data ) <EOL> def pixbuf_new_from_array ( data , rgbtype , bpp ) : <EOL> daht , dawd , depth = data . shape <EOL> stride = dawd * <NUM_LIT:4> * bpp <EOL> rgb_buf = data . tostring ( order = '<STR_LIT:C>' ) <EOL> hasAlpha = False <EOL> rgbtype = GdkPixbuf . Colorspace . RGB <EOL> return GdkPixbuf . Pixbuf . new_from_data ( rgb_buf , rgbtype , hasAlpha , <NUM_LIT:8> , <EOL> dawd , daht , stride , None , None ) <EOL> def pixbuf_new_from_data ( rgb_buf , rgbtype , hasAlpha , bpp , dawd , daht , stride ) : <EOL> return GdkPixbuf . Pixbuf . new_from_data ( rgb_buf , rgbtype , hasAlpha , bpp , <EOL> dawd , daht , stride , None , None ) <EOL> def pixbuf_new_from_file_at_size ( foldericon , width , height ) : <EOL> return GdkPixbuf . Pixbuf . new_from_file_at_size ( foldericon , <EOL> width , height ) <EOL> def make_cursor ( widget , iconpath , x , y ) : <EOL> image = gtk . Image ( ) <EOL> image . set_from_file ( iconpath ) <EOL> pixbuf = image . get_pixbuf ( ) <EOL> screen = widget . get_screen ( ) <EOL> display = screen . get_display ( ) <EOL> return gtk . gdk . Cursor ( display , pixbuf , x , y ) <EOL> elif have_gtk2 : <EOL> ginga . toolkit . use ( '<STR_LIT>' ) <EOL> def pixbuf_new_from_xpm_data ( xpm_data ) : <EOL> return gtk . gdk . pixbuf_new_from_xpm_data ( xpm_data ) <EOL> def pixbuf_new_from_array ( data , rgbtype , bpp ) : <EOL> return gtk . gdk . pixbuf_new_from_array ( data , rgbtype , bpp ) <EOL> def pixbuf_new_from_data ( rgb_buf , rgbtype , hasAlpha , bpp , dawd , daht , stride ) : <EOL> return gtk . gdk . pixbuf_new_from_data ( rgb_buf , rgbtype , hasAlpha , bpp , <EOL> dawd , daht , stride ) <EOL> def pixbuf_new_from_file_at_size ( foldericon , width , height ) : <EOL> return gtk . gdk . pixbuf_new_from_file_at_size ( foldericon , <EOL> width , height ) <EOL> def make_cursor ( widget , iconpath , x , y ) : <EOL> pixbuf = gtk . gdk . pixbuf_new_from_file ( iconpath ) <EOL> screen = widget . get_screen ( ) <EOL> display = screen . get_display ( ) <EOL> return gtk . gdk . Cursor ( display , pixbuf , x , y ) <EOL> else : <EOL> raise ImportError ( "<STR_LIT>" ) </s>
