"Particle in a box' typically means we apply Born-von Karmen boundary conditions, or in other words we study quantum mechanics on the Pointrjagyn dual of the box instead.
Let be a Hamiltonian that acts on the Hilbert space of sections of a FLAT Hermitian line bundle . Let us suppose the Weil integrality condition is satisfied and a proper holomorphic polarization on the tangent bundle is given to simply our discussion.
For each Hilbert section covariantly constant on (i.e. a -wavefunction), Born-von Karmen periodic boundary conditions means that descends to the quotient space , where iff for some and for all . Now since is compact, the Fourier transform is an isometric, fibre-preserving automorphism on the Hilbert sections of the Hermtian line bundle , hence is a Hilbert section on the Hermitian line bundle , where is the Pontrjagyn dual of . If is bounded from below, then spectrum of its "Fourier pullback" is isomorphic to . These give rise to the discrete/quantized energy levels.
Hope this is clear enough.