| 19 | |
| 20 | |
| 21 | class PathComboBox(QComboBox): |
| 22 | |
| 23 | def __init__(self, *args, is_item=False, **kwargs): |
| 24 | super(PathComboBox, self).__init__(*args, **kwargs) |
| 25 | self.is_item = is_item |
| 26 | if not self.is_item: |
| 27 | self.setEditable(True) |
| 28 | layout = QHBoxLayout(self) |
| 29 | layout.setSpacing(0) |
| 30 | layout.setContentsMargins(0, 0, 0, 23) |
| 31 | layout.addItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) |
| 32 | else: |
| 33 | self.f_model = QFileSystemModel(self) |
| 34 | self.f_model.setRootPath('') |
| 35 | self.setModel(self.f_model) |
| 36 | |
| 37 | def addWidget(self, widget): |
| 38 | self.layout().insertWidget(self.layout().count() - 1, widget) |
| 39 | |
| 40 | |
| 41 | if __name__ == '__main__': |