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

Class BinComboBox

gui/widgets.py:11–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 return [f for f in os.listdir(app_icons_dir) if f.lower().endswith('.ico')]
10
11class BinComboBox(QComboBox):
12 def __init__(self, parent=None):
13 super().__init__(parent)
14 self.setView(QListView())
15 self.setItemDelegate(QStyledItemDelegate())
16 self.refresh()
17
18 def refresh(self):
19 self.clear()
20 input_dir = os.path.join(os.getcwd(), 'input')
21 default_idx = -1
22 bin_icon = QIcon(os.path.join('gui', 'icons', 'bin.ico')) if os.path.exists(os.path.join('gui', 'icons', 'bin.ico')) else QIcon()
23 if os.path.isdir(input_dir):
24 files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]
25 for i, f in enumerate(files):
26 self.addItem(bin_icon, f, os.path.abspath(os.path.join(input_dir, f)))
27 if files:
28 default_idx = 0
29 if self.count() > 0 and self.currentIndex() == -1:
30 self.setCurrentIndex(default_idx)
31
32 def choose_file(self, parent=None):
33 path, _ = QFileDialog.getOpenFileName(parent, 'Select Bin File', '.', 'Bin Files (*.bin);;All Files (*)')
34 if path:
35 display_name = os.path.basename(path)
36 bin_icon = QIcon(os.path.join('icons', 'bin.ico')) if os.path.exists(os.path.join('icons', 'bin.ico')) else QIcon()
37 for i in range(self.count()):
38 if self.itemData(i) == path:
39 self.setCurrentIndex(i)
40 return
41 self.addItem(bin_icon, display_name, path)
42 self.setCurrentIndex(self.count() - 1)
43
44class IcoComboBox(QComboBox):
45 def __init__(self, parent=None):

Callers 2

_create_bin_groupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected