Polynomial Hamiltonians associated with Painlevé equations, II. Differential equations satisfied by polynomial Hamiltonians