Change the left control panel size

I want to reduce the left control panel size in code
can you help me

The module panel is sized automatically based on constraints defined by the widgets that are displayed in it. You can set a maximum width for the module panel (see below), but it will break the layout (widgets will “stick out” from it) if you reduce it beyond the feasible size.

mainWindow = slicer.util.mainWindow()
modulePanelDockWidget = mainWindow.findChildren('QDockWidget','PanelDockWidget')[0]

If you want to make the module panel more compressible without breaking layouts, you can change the font size or screen scaling. See more information here: