#NEWLINE# def PackMENUITEMINFO( fType = None , fState = None , wID = None , hSubMenu = None , hbmpChecked = None , hbmpUnchecked = None , dwItemData = None , text = None , hbmpItem = None , dwTypeData = None ) : #NEWLINE# #INDENT# extras = [ ] #NEWLINE# assert ( ( dwItemData is None ) or ( dwTypeData is None ) ) , 'sorry - these were confused - you probably want dwItemData' #NEWLINE# if ( dwTypeData is not None ) : #NEWLINE# #INDENT# import warnings #NEWLINE# warnings . warn ( 'PackMENUITEMINFO: please use dwItemData instead of dwTypeData' ) #NEWLINE# #UNINDENT# if ( dwItemData is None ) : #NEWLINE# #INDENT# dwItemData = ( dwTypeData or 0 ) #NEWLINE# #UNINDENT# fMask = 0 #NEWLINE# if ( fType is None ) : #NEWLINE# #INDENT# fType = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_FTYPE #NEWLINE# #UNINDENT# if ( fState is None ) : #NEWLINE# #INDENT# fState = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_STATE #NEWLINE# #UNINDENT# if ( wID is None ) : #NEWLINE# #INDENT# wID = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_ID #NEWLINE# #UNINDENT# if ( hSubMenu is None ) : #NEWLINE# #INDENT# hSubMenu = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_SUBMENU #NEWLINE# #UNINDENT# if ( hbmpChecked is None ) : #NEWLINE# #INDENT# assert ( hbmpUnchecked is None ) , 'neither or both checkmark bmps must be given' #NEWLINE# hbmpChecked = hbmpUnchecked = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( hbmpUnchecked is not None ) , 'neither or both checkmark bmps must be given' #NEWLINE# fMask |= win32con . MIIM_CHECKMARKS #NEWLINE# #UNINDENT# if ( dwItemData is None ) : #NEWLINE# #INDENT# dwItemData = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_DATA #NEWLINE# #UNINDENT# if ( hbmpItem is None ) : #NEWLINE# #INDENT# hbmpItem = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fMask |= win32con . MIIM_BITMAP #NEWLINE# #UNINDENT# if ( text is not None ) : #NEWLINE# #INDENT# fMask |= win32con . MIIM_STRING #NEWLINE# if isinstance ( text , unicode ) : #NEWLINE# #INDENT# text = text . encode ( 'mbcs' ) #NEWLINE# #UNINDENT# str_buf = array . array ( 'c' , ( dwTypeData + '\x00' ) ) #NEWLINE# cch = len ( str_buf ) #NEWLINE# lptext = str_buf . buffer_info ( ) [ 0 ] #NEWLINE# extras . append ( str_buf ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lptext = 0 #NEWLINE# cch = 0 #NEWLINE# #UNINDENT# item = struct . pack ( menuitem_fmt , struct . calcsize ( menuitem_fmt ) , fMask , fType , fState , wID , long ( hSubMenu ) , long ( hbmpChecked ) , long ( hbmpUnchecked ) , dwItemData , lptext , cch , long ( hbmpItem ) ) #NEWLINE# return ( array . array ( 'c' , item ) , extras )