7. In a convex polygon, draw all diagonals, and color each side and each diagonal with one of $k$ colors, so that there is no monochromatic closed broken line with the vertices of the polygon as its vertices. How many vertices can such a polygon have at most?
7. Let the number of vertices of a polygon be $n$, then an $n$-sided polygon has $C_{\mathrm{n}}^{2}=\frac{1}{2} n(n-1)$ edges and diagonals. If there is a segment of the same color, then by a graph theory theorem, there must be a graph, i.e., there must be a closed broken line, which contradicts the given condition. Therefore, the number of segments of each color does not exceed $n-1$. Thus, we have
$$
\frac{1}{2} n(n-1) \leqslant k(n-1) .
$$

Solving this, we get $n \leqslant 2 k$.
Next, we show that when $n=2 k$, a coloring that meets the requirements exists. Take a regular $2 k$-sided polygon $A_{1} A_{2} \cdots A_{21}$, and color the broken line $A_{1} A_{2 \mathrm{~L}} A_{2} A_{2 \mathrm{~L}-1} \cdots A_{\mathrm{k}} A_{\mathrm{b}+1}$ with the first color, color the broken line obtained by rotating the first broken line by $\frac{\pi}{k}$ with the second color, color the broken line obtained by rotating the first broken line by $\frac{2 \pi}{k}$ with the third color, and so on. It is not difficult to see that each segment is colored exactly one of the $k$ colors, and there is no closed broken line of the same color.