This may work, for some time
But it doesn't solve the main issue, i.e. someone being reckless with their money. Yes, we can take money from children, and they won't be able to spend it on something stupid. But we expect them to grow up in due course and be responsible for their actions on their own. In this way, setting up obstacles that would prevent you from reckless spending is more like fighting with symptoms rather than the disease itself (read, you will lose this fight in the end)
But here's the catch. Time makes people mature.
If we take money away from kids so that they won't spend $1000 on a toy car, they may whine a bit. Let's say I won't give him that much money for the next 10 years, after that, if I give him $1000, would he spend the same amount on a toy car?
Time is flowing all the time. So the habit would never be constant, it will fade.
If we lock ourselves from gambling, we are not treating the gambling problem which you are correct at, but at the same time, I'm not gambling for a long time (even if that's forcefully) and it will instill a habit in me for not to gamble and after months, I just won't gamble and I don't even have to force myself to.