11from PyQt5 .QtWidgets import (QDialog , QVBoxLayout , QHBoxLayout , QGroupBox , QLabel , QCheckBox ,
22 QLineEdit , QComboBox , QPushButton , QFileDialog , QGridLayout , QDoubleSpinBox ,
3- QRadioButton , QButtonGroup )
3+ QRadioButton , QButtonGroup , QSizePolicy )
44from PyQt5 .QtCore import Qt
55import os
66
@@ -9,7 +9,7 @@ class GlobalParamsDialog(QDialog):
99 def __init__ (self , parent = None , params = None ):
1010 super ().__init__ (parent )
1111 self .setWindowTitle ("全局参数设置" )
12- self .setMinimumWidth (500 )
12+ self .setMinimumWidth (680 )
1313
1414 # 初始化参数
1515 self .params = params or {}
@@ -55,6 +55,7 @@ def _init_ui(self):
5555 self .verbosity_combo = QComboBox ()
5656 self .verbosity_combo .setStyleSheet ("background-color: white;" )
5757 self .verbosity_combo .addItems (["0 (基本信息)" , "1 (调试信息)" , "2 (详细信息)" ])
58+ self ._configure_combo_width (self .verbosity_combo , min_width = 220 )
5859 verbosity_layout .addWidget (self .verbosity_combo )
5960 verbosity_layout .addStretch ()
6061 verbosity_group .setLayout (verbosity_layout )
@@ -67,6 +68,7 @@ def _init_ui(self):
6768 self .mesh_type_combo = QComboBox ()
6869 self .mesh_type_combo .setStyleSheet ("background-color: white;" )
6970 self .mesh_type_combo .addItems (["三角形网格" , "三角形/四边形混合网格" ])
71+ self ._configure_combo_width (self .mesh_type_combo , min_width = 300 )
7072 self .mesh_type_combo .currentIndexChanged .connect (self ._on_mesh_type_changed )
7173 mesh_type_layout .addWidget (self .mesh_type_combo , 0 , 1 )
7274
@@ -75,6 +77,7 @@ def _init_ui(self):
7577 mesh_type_layout .addWidget (self .mesh_algorithm_label , 1 , 0 )
7678 self .mesh_algorithm_combo = QComboBox ()
7779 self .mesh_algorithm_combo .setStyleSheet ("background-color: white;" )
80+ self ._configure_combo_width (self .mesh_algorithm_combo , min_width = 300 )
7881 self .mesh_algorithm_combo .currentIndexChanged .connect (self ._on_algorithm_changed )
7982 mesh_type_layout .addWidget (self .mesh_algorithm_combo , 1 , 1 )
8083
@@ -84,6 +87,7 @@ def _init_ui(self):
8487 self .triangle_to_quad_combo = QComboBox ()
8588 self .triangle_to_quad_combo .setStyleSheet ("background-color: white;" )
8689 self .triangle_to_quad_combo .addItems (["greedy_merge" , "q_morph" ])
90+ self ._configure_combo_width (self .triangle_to_quad_combo , min_width = 300 )
8791 self .triangle_to_quad_combo .setToolTip ("greedy_merge: 贪婪合并算法\n q_morph: Q-Morph 算法" )
8892 self .triangle_to_quad_combo .currentIndexChanged .connect (self ._on_triangle_to_quad_changed )
8993 mesh_type_layout .addWidget (self .triangle_to_quad_combo , 2 , 1 )
@@ -103,7 +107,7 @@ def _init_ui(self):
103107 backend_layout .addStretch ()
104108 mesh_type_layout .addLayout (backend_layout , 3 , 1 )
105109
106- mesh_type_layout .setColumnStretch (2 , 1 )
110+ mesh_type_layout .setColumnStretch (1 , 1 )
107111 mesh_type_group .setLayout (mesh_type_layout )
108112 main_layout .addWidget (mesh_type_group )
109113
@@ -150,6 +154,11 @@ def _init_ui(self):
150154
151155 main_layout .addLayout (button_layout )
152156
157+ def _configure_combo_width (self , combo , min_width = 260 ):
158+ combo .setMinimumWidth (min_width )
159+ combo .setSizeAdjustPolicy (QComboBox .AdjustToContentsOnFirstShow )
160+ combo .setSizePolicy (QSizePolicy .Expanding , QSizePolicy .Fixed )
161+
153162 def _browse_output_path (self ):
154163 file_path , _ = QFileDialog .getSaveFileName (
155164 self , "选择输出文件路径" , "./out/mesh.vtk" , "VTK Files (*.vtk)" )
0 commit comments