For a class of non-smooth constrained optimization problem, by constructing appropriate time-varying gain function and dynamic event-triggered communication mechanism, we propose a distributed predefined-time and dynamic event-triggered optimization algorithm. Compared with the existing distributed non-smooth optimization, the proposed algorithm mainly has the following three features: 1) Better convergence performance: the convergence time can be pre-set by the user in advance and the upper bound of the convergence time is independent of the initial conditions and the control parameters of the system; 2) Higher communication efficiency: avoiding the waste of communication resources in the traditional continuous time/period communication mechanisms; 3) Simpler algorithm structure: traditional fractional power feedback and additional auxiliary variables are not required. By leveraging the predefined-time convergence theory, penalty function method, algebraic graph theory and convex optimization theory, we prove that the decision variables of the system can converge to a tunable neighborhood of the optimal solution in a predefined-time. The Zeno phenomenon is excluded. The effectiveness of the algorithm is verified by simulations.