A somewhat dated, mild insult for a slow-witted or clumsy person. Often used in a teasing or self-deprecating way rather than as a strong slur.
また鍵を忘れたの?とんまだなあ。
You forgot your keys again? You're such a dope.
He keeps making stupid mistakes.
とんま is an old-fashioned, mildly comic word for a dimwit, while アホ is the everyday Kansai term with a wider range of tone from teasing to insulting.
Standard kanji spelling; the characters are ateji.
Kana spelling is common in casual writing.
The exact derivation is uncertain. The kanji 頓 (sudden, dull) and 馬 (horse) are ateji, and the word may have originated as a slang term in the Edo period.