return [('cancel'self quit)('parts'self onparts)('attach'self onattach)('send'self onsend)need method to use self popupwindow verifies cancel edon' padcentered def onparts(self)caveatdeletes not currently supported if not self attachesshowinfo(appname'nothing attached'elsemsg '\njoin(['already attached:\ 'self attachesshowinfo(appnamemsgdef onattach(self)""attach file to the mailname added here will be added as part on sendinside the mailtools pkg ecould ask unicode type here instead of on send ""if not self opendialogself opendialog open(title=appname 'select attachment file'filename self opendialog show(remember prior dir if filenameself attaches append(filenameto be opened in send method def resolveunicodeencodings(self)""eto prepare for sendresolve unicode encoding for text partsboth main text partand any text part attachmentsthe main text part may have had known encoding if this is reply or forwardbut not for writeand it may require different encoding after editing anyhowsmtplib in requires that full message text be encodable per ascii when sent (if it' str)so it' crucial to get this right hereelse fails if reply/fwd to utf text when config=ascii if any non-ascii charstry user setting and reply but fall back on general utf as last resort""def istextkind(filename)contypeencoding mimetypes guess_type(filenameif contype is none or encoding is not none utility return false no guesscompressedmaintypesubtype contype split('/' check for text/return maintype ='textresolve many body text encoding bodytextencoding mailconfig maintextencoding if bodytextencoding =noneasknow askstring('pymailgui''enter main text unicode encoding name'bodytextencoding asknow or 'latin- or sys getdefaultencoding()last chanceuse utf- if can' encode per prior selections if bodytextencoding !'utf- 'try the pymailgui client