MCPcopy Create free account
hub / github.com/echQoQ/RustSL / IcoComboBox

Class IcoComboBox

gui/widgets.py:44–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 self.setCurrentIndex(self.count() - 1)
43
44class IcoComboBox(QComboBox):
45 def __init__(self, parent=None):
46 super().__init__(parent)
47 self.setView(QListView())
48 self.setItemDelegate(QStyledItemDelegate())
49 self.refresh()
50
51 def refresh(self):
52 self.clear()
53 ico_files = list_ico_files()
54 if not ico_files:
55 icon_path = os.path.join('icons', 'excel.ico')
56 self.addItem(QIcon(icon_path), 'excel.ico', icon_path)
57 else:
58 for f in ico_files:
59 icon_path = os.path.join('icons', f)
60 self.addItem(QIcon(icon_path), f, icon_path)
61 if self.count() > 0 and self.currentIndex() == -1:
62 self.setCurrentIndex(0)
63
64 def choose_file(self, parent=None):
65 path, _ = QFileDialog.getOpenFileName(parent, 'Select Icon File', '.', 'Icon Files (*.ico);;All Files (*)')
66 if path:
67 display_name = os.path.basename(path)
68 for i in range(self.count()):
69 if self.itemData(i) == path:
70 self.setCurrentIndex(i)
71 return
72def list_bundle_files():
73 bundle_dir = os.path.join(os.getcwd(), 'bundle')
74 if not os.path.isdir(bundle_dir):

Callers 1

_create_icon_groupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected