This may help:
Hajnal, Kanamori, and Shelah analyzed regressive partition relations for infinite cardinals in their paper
Regressive partition relations for infinite cardinals. Trans. Amer. Math. Soc. 299 (1987), no. 1, 145–154.
They characterize Mahlo cardinals (even n+1-Mahlo cardinals for each $n<\omega$) in terms of these regressive partition relations:
For example, Theorem 3.4 tells us that $\kappa$ is Mahlo if and only if
For any closed unbounded $C\subseteq\kappa$ and regressive coloring $f$ of $[C]^4$, there is a min-homogeneous set of size $\omega$.
There are some comments in the paper about how weakly compact cardinals satisfy these regressive partition relations, but it's not clear to me (yet) if there's a direct proof or if the proofs need to go through the tree property. I feel like Asaf --- I need to look at it after I get some other work done!
Edit: One can prove directly that if $\kappa\rightarrow (\kappa)^5_2$ then $\kappa$ satisfies the regressive partition relation mentioned above that is equivalent to being Mahlo.
This is still unsatisfying, but what I'm wondering is if this can be put together with the result from the paper to get something like:
If $\kappa$ is not Mahlo, then there is a 2-coloring of the 5-tuples from $\kappa$ with no homogeneous set of size $\kappa$.
Another edit based on another strategy:
If $\kappa>\omega$ is not $\omega$-Mahlo, then $\kappa\nrightarrow(\kappa)^2_2$ by virtue of results on negative square-brackets partition relations: If $\kappa$ has a non-reflecting stationary subset this follows from Todorcevic's result that $\kappa\nrightarrow[\kappa]^2_\kappa$ for such $\kappa$. Otherwise, $\kappa$ must be weakly inaccessible with a stationary subset that does not reflect in an inaccessible cardinal, and by results in Shelah's Cardinal Arithmetic, we have $\kappa\nrightarrow[\kappa]^2_\theta$ for every $\theta<\kappa$.
In either case, we certainly have $\kappa\nrightarrow[\kappa]^2_2$, which is equivalent to $\kappa\nrightarrow(\kappa)^2_2$, so $\kappa$ cannot be weakly compact.
So the explicit "bad coloring" of pairs is there to see. It's just really really complicated.
Final Edit
Suppose $\kappa$ is weakly inaccessible and not Mahlo. Let $\langle C_\delta:\delta<\kappa\rangle$ be a $C$-sequence in the sense of Todorcevic, so $C_\delta$ is club in $\delta$ of order-type ${\rm cf}(\delta)$. Let $c(\alpha,\beta)$ be the length of the minimal walk from $\beta$ down to $\alpha$ (so $c:[\kappa]^2\rightarrow\omega$). The fact that $\kappa$ isn't Mahlo implies that the $C$-sequence is non-trivial in the sense of Todorcevic, and his work shows that for any $H\subseteq\kappa$ of size $\kappa$ the range of $c$ restricted to the pairs from $H$ is infinite. In particular, $\kappa\nrightarrow(\kappa)^2_{\omega}$ and so $\kappa$ is not weakly compact.
Still not as simple as we'd like, but I don't see how to do better! This is why the tree property is a good thing...