def qicon_to_sni_image_list(qicon):
 import socket
 ans = dbus.Array(signature=u'(iiay)')
 if (not qicon.isNull()):
  sizes = (qicon.availableSizes() or (QSize(x, x) for x in (32, 64, 128, 256)))
  tc = ('L' if (array.array('I').itemsize < 4) else 'I')
  for size in sizes:
   i = qicon.pixmap(size).toImage().convertToFormat(QImage.Format_ARGB32)
   (w, h) = (i.width(), i.height())
   data = i.constBits().asstring(((4 * w) * h))
   if (socket.htonl(1) != 1):
    data = array.array(tc, i.constBits().asstring(((4 * i.width()) * i.height())))
    data.byteswap()
    data = data.tostring()
   ans.append((w, h, dbus.ByteArray(data)))
 return ans

def qicon_to_sni_image_list ( qicon ) : import socket ans = dbus . Array ( signature = u'(iiay)' ) if ( not qicon . isNull ( ) ) : sizes = ( qicon . availableSizes ( ) or ( QSize ( x , x ) for x in ( 32 , 64 , 128 , 256 ) ) ) tc = ( 'L' if ( array . array ( 'I' ) . itemsize < 4 ) else 'I' ) for size in sizes : i = qicon . pixmap ( size ) . toImage ( ) . convertToFormat ( QImage . Format_ARGB32 ) ( w , h ) = ( i . width ( ) , i . height ( ) ) data = i . constBits ( ) . asstring ( ( ( 4 * w ) * h ) ) if ( socket . htonl ( 1 ) != 1 ) : data = array . array ( tc , i . constBits ( ) . asstring ( ( ( 4 * i . width ( ) ) * i . height ( ) ) ) ) data . byteswap ( ) data = data . tostring ( ) ans . append ( ( w , h , dbus . ByteArray ( data ) ) ) return ans
see URL .