forked from Bouni/kicad-jlcpcb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
partselector.py
670 lines (608 loc) · 22.8 KB
/
partselector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
"""This module contains the part selector modal window."""
import logging
import time
import wx # pylint: disable=import-error
from .events import AssignPartsEvent, UpdateSetting
from .helpers import HighResWxSize, loadBitmapScaled
from .partdetails import PartDetailsDialog
class PartSelectorDialog(wx.Dialog):
"""The part selector window."""
def __init__(self, parent, parts):
wx.Dialog.__init__(
self,
parent,
id=wx.ID_ANY,
title="JLCPCB Library",
pos=wx.DefaultPosition,
size=HighResWxSize(parent.window, wx.Size(1300, 800)),
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX,
)
self.logger = logging.getLogger(__name__)
self.parent = parent
self.parts = parts
lcsc_selection = self.get_existing_selection(parts)
# ---------------------------------------------------------------------
# ---------------------------- Hotkeys --------------------------------
# ---------------------------------------------------------------------
quitid = wx.NewId()
self.Bind(wx.EVT_MENU, self.quit_dialog, id=quitid)
entries = [wx.AcceleratorEntry(), wx.AcceleratorEntry(), wx.AcceleratorEntry()]
entries[0].Set(wx.ACCEL_CTRL, ord("W"), quitid)
entries[1].Set(wx.ACCEL_CTRL, ord("Q"), quitid)
entries[2].Set(wx.ACCEL_SHIFT, wx.WXK_ESCAPE, quitid)
accel = wx.AcceleratorTable(entries)
self.SetAcceleratorTable(accel)
# ---------------------------------------------------------------------
# --------------------------- Search bar ------------------------------
# ---------------------------------------------------------------------
keyword_label = wx.StaticText(
self,
wx.ID_ANY,
"Keyword",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.keyword = wx.TextCtrl(
self,
wx.ID_ANY,
lcsc_selection,
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
wx.TE_PROCESS_ENTER,
)
self.keyword.SetHint("e.g. 10k 0603")
manufacturer_label = wx.StaticText(
self,
wx.ID_ANY,
"Manufacturer",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.manufacturer = wx.TextCtrl(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
wx.TE_PROCESS_ENTER,
)
self.manufacturer.SetHint("e.g. Vishay")
package_label = wx.StaticText(
self,
wx.ID_ANY,
"Package",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.package = wx.TextCtrl(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
wx.TE_PROCESS_ENTER,
)
self.package.SetHint("e.g. 0603")
category_label = wx.StaticText(
self,
wx.ID_ANY,
"Category",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.category = wx.ComboBox(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
choices=parent.library.categories,
)
self.category.SetHint("e.g. Resistors")
part_no_label = wx.StaticText(
self,
wx.ID_ANY,
"Part number",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.part_no = wx.TextCtrl(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
wx.TE_PROCESS_ENTER,
)
self.part_no.SetHint("e.g. DS2411")
solder_joints_label = wx.StaticText(
self,
wx.ID_ANY,
"Solder joints",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.solder_joints = wx.TextCtrl(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
wx.TE_PROCESS_ENTER,
)
self.solder_joints.SetHint("e.g. 2")
subcategory_label = wx.StaticText(
self,
wx.ID_ANY,
"Subcategory",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.subcategory = wx.ComboBox(
self,
wx.ID_ANY,
"",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
)
self.subcategory.SetHint("e.g. Variable Resistors")
basic_label = wx.StaticText(
self,
wx.ID_ANY,
"Include basic parts",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.basic_checkbox = wx.CheckBox(
self,
wx.ID_ANY,
"Basic",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
0,
name="basic",
)
extended_label = wx.StaticText(
self,
wx.ID_ANY,
"Include extended parts",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.extended_checkbox = wx.CheckBox(
self,
wx.ID_ANY,
"Extended",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
0,
name="extended",
)
stock_label = wx.StaticText(
self,
wx.ID_ANY,
"Only show parts in stock",
size=HighResWxSize(parent.window, wx.Size(150, 15)),
)
self.assert_stock_checkbox = wx.CheckBox(
self,
wx.ID_ANY,
"in Stock",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
0,
name="stock",
)
self.basic_checkbox.SetValue(
self.parent.settings.get("partselector", {}).get("basic", True)
)
self.extended_checkbox.SetValue(
self.parent.settings.get("partselector", {}).get("extended", True)
)
self.assert_stock_checkbox.SetValue(
self.parent.settings.get("partselector", {}).get("stock", False)
)
self.basic_checkbox.Bind(wx.EVT_CHECKBOX, self.update_settings)
self.extended_checkbox.Bind(wx.EVT_CHECKBOX, self.update_settings)
self.assert_stock_checkbox.Bind(wx.EVT_CHECKBOX, self.update_settings)
help_button = wx.Button(
self,
wx.ID_ANY,
"Help",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(100, -1)),
0,
)
self.search_button = wx.Button(
self,
wx.ID_ANY,
"Search",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(100, -1)),
0,
)
search_sizer_one = wx.BoxSizer(wx.VERTICAL)
search_sizer_one.Add(keyword_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_one.Add(
self.keyword,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_one.Add(
manufacturer_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5
)
search_sizer_one.Add(
self.manufacturer,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_one.Add(package_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_one.Add(
self.package,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_two = wx.BoxSizer(wx.VERTICAL)
search_sizer_two.Add(category_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_two.Add(
self.category,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_two.Add(part_no_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_two.Add(
self.part_no,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_two.Add(
solder_joints_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5
)
search_sizer_two.Add(
self.solder_joints,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_three = wx.BoxSizer(wx.VERTICAL)
search_sizer_three.Add(
subcategory_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5
)
search_sizer_three.Add(
self.subcategory,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_four = wx.BoxSizer(wx.VERTICAL)
search_sizer_four.Add(basic_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_four.Add(
self.basic_checkbox,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_four.Add(extended_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_four.Add(
self.extended_checkbox,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_four.Add(stock_label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
search_sizer_four.Add(
self.assert_stock_checkbox,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_five = wx.BoxSizer(wx.VERTICAL)
search_sizer_five.Add(
help_button,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
search_sizer_five.AddSpacer(80)
search_sizer_five.Add(
self.search_button,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
5,
)
help_button.SetBitmap(
loadBitmapScaled(
"mdi-help-circle-outline.png",
self.parent.scale_factor,
)
)
help_button.SetBitmapMargins((2, 0))
self.search_button.SetBitmap(
loadBitmapScaled(
"mdi-database-search-outline.png",
self.parent.scale_factor,
)
)
self.search_button.SetBitmapMargins((2, 0))
search_sizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, "Search")
search_sizer.Add(search_sizer_one, 0, wx.RIGHT, 20)
search_sizer.Add(search_sizer_two, 0, wx.RIGHT, 20)
search_sizer.Add(search_sizer_three, 0, wx.RIGHT, 20)
search_sizer.Add(search_sizer_four, 0, wx.RIGHT, 20)
search_sizer.Add(search_sizer_five, 0, wx.RIGHT, 20)
# search_sizer.Add(help_button, 0, wx.RIGHT, 20)
self.keyword.Bind(wx.EVT_TEXT_ENTER, self.search)
self.manufacturer.Bind(wx.EVT_TEXT_ENTER, self.search)
self.package.Bind(wx.EVT_TEXT_ENTER, self.search)
self.category.Bind(wx.EVT_COMBOBOX, self.update_subcategories)
self.category.Bind(wx.EVT_TEXT, self.update_subcategories)
self.category.Bind(wx.EVT_TEXT_ENTER, self.search)
self.part_no.Bind(wx.EVT_TEXT_ENTER, self.search)
self.solder_joints.Bind(wx.EVT_TEXT_ENTER, self.search)
self.search_button.Bind(wx.EVT_BUTTON, self.search)
help_button.Bind(wx.EVT_BUTTON, self.help)
# ---------------------------------------------------------------------
# ------------------------ Result status line -------------------------
# ---------------------------------------------------------------------
self.result_count = wx.StaticText(
self, wx.ID_ANY, "0 Results", wx.DefaultPosition, wx.DefaultSize
)
result_sizer = wx.BoxSizer(wx.HORIZONTAL)
result_sizer.Add(self.result_count, 0, wx.LEFT | wx.TOP, 5)
# ---------------------------------------------------------------------
# ------------------------- Result Part list --------------------------
# ---------------------------------------------------------------------
self.part_list = wx.dataview.DataViewListCtrl(
self,
wx.ID_ANY,
wx.DefaultPosition,
wx.DefaultSize,
style=wx.dataview.DV_SINGLE,
)
self.part_list.AppendTextColumn(
"LCSC",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 80),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"MFR Number",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 140),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Package",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 100),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Joints",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 40),
align=wx.ALIGN_CENTER,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Type",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 80),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Manufacturer",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 140),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Description",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 300),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Price",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 100),
align=wx.ALIGN_LEFT,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.AppendTextColumn(
"Stock",
mode=wx.dataview.DATAVIEW_CELL_INERT,
width=int(parent.scale_factor * 50),
align=wx.ALIGN_CENTER,
flags=wx.dataview.DATAVIEW_COL_RESIZABLE,
)
self.part_list.SetMinSize(HighResWxSize(parent.window, wx.Size(1050, 500)))
self.part_list.Bind(
wx.dataview.EVT_DATAVIEW_COLUMN_HEADER_CLICK, self.OnSortPartList
)
self.part_list.Bind(
wx.dataview.EVT_DATAVIEW_SELECTION_CHANGED, self.OnPartSelected
)
table_sizer = wx.BoxSizer(wx.HORIZONTAL)
table_sizer.SetMinSize(HighResWxSize(parent.window, wx.Size(-1, 400)))
table_sizer.Add(self.part_list, 20, wx.ALL | wx.EXPAND, 5)
# ---------------------------------------------------------------------
# ------------------------ Right side toolbar -------------------------
# ---------------------------------------------------------------------
self.select_part_button = wx.Button(
self,
wx.ID_ANY,
"Select part",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(150, -1)),
0,
)
self.part_details_button = wx.Button(
self,
wx.ID_ANY,
"Show part details",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(150, -1)),
0,
)
self.select_part_button.Bind(wx.EVT_BUTTON, self.select_part)
self.part_details_button.Bind(wx.EVT_BUTTON, self.get_part_details)
self.select_part_button.SetBitmap(
loadBitmapScaled(
"mdi-check.png",
self.parent.scale_factor,
)
)
self.select_part_button.SetBitmapMargins((2, 0))
self.part_details_button.SetBitmap(
loadBitmapScaled(
"mdi-text-box-search-outline.png",
self.parent.scale_factor,
)
)
self.part_details_button.SetBitmapMargins((2, 0))
tool_sizer = wx.BoxSizer(wx.VERTICAL)
tool_sizer.Add(self.select_part_button, 0, wx.ALL, 5)
tool_sizer.Add(self.part_details_button, 0, wx.ALL, 5)
table_sizer.Add(tool_sizer, 3, wx.EXPAND, 5)
# ---------------------------------------------------------------------
# ------------------------------ Sizers ------------------------------
# ---------------------------------------------------------------------
layout = wx.BoxSizer(wx.VERTICAL)
layout.Add(search_sizer, 1, wx.ALL, 5)
# layout.Add(self.search_button, 5, wx.ALL, 5)
layout.Add(result_sizer, 1, wx.LEFT, 5)
layout.Add(table_sizer, 20, wx.ALL | wx.EXPAND, 5)
self.SetSizer(layout)
self.Layout()
self.Centre(wx.BOTH)
self.enable_toolbar_buttons(False)
def update_settings(self, event):
"""Update the settings on change"""
wx.PostEvent(
self.parent,
UpdateSetting(
section="partselector",
setting=event.GetEventObject().GetName(),
value=event.GetEventObject().GetValue(),
),
)
@staticmethod
def get_existing_selection(parts):
"""Check if exactly one LCSC part number is amongst the selected parts."""
s = set(parts.values())
if len(s) != 1:
return ""
return list(s)[0]
def quit_dialog(self, *_):
"""Close this window."""
self.Destroy()
self.EndModal(0)
def OnSortPartList(self, e):
"""Set order_by to the clicked column and trigger list refresh."""
self.parent.library.set_order_by(e.GetColumn())
self.search(None)
def OnPartSelected(self, *_):
"""Enable the toolbar buttons when a selection was made."""
if self.part_list.GetSelectedItemsCount() > 0:
self.enable_toolbar_buttons(True)
else:
self.enable_toolbar_buttons(False)
def enable_toolbar_buttons(self, state):
"""Control the state of all the buttons in toolbar on the right side"""
for b in [
self.select_part_button,
self.part_details_button,
]:
b.Enable(bool(state))
def search(self, *_):
"""Search the library for parts that meet the search criteria."""
parameters = {
"keyword": self.keyword.GetValue(),
"manufacturer": self.manufacturer.GetValue(),
"package": self.package.GetValue(),
"category": self.category.GetValue(),
"subcategory": self.subcategory.GetValue(),
"part_no": self.part_no.GetValue(),
"solder_joints": self.solder_joints.GetValue(),
"basic": self.basic_checkbox.GetValue(),
"extended": self.extended_checkbox.GetValue(),
"stock": self.assert_stock_checkbox.GetValue(),
}
start = time.time()
result = self.parent.library.search(parameters)
search_duration = time.time() - start
self.populate_part_list(result, search_duration)
def update_subcategories(self, *_):
"""Update the possible subcategory selection."""
self.subcategory.Clear()
if self.category.GetSelection() != wx.NOT_FOUND:
subcategories = self.parent.library.get_subcategories(
self.category.GetValue()
)
self.subcategory.AppendItems(subcategories)
def populate_part_list(self, parts, search_duration):
"""Populate the list with the result of the search."""
search_duration_text = (
f"{search_duration:.2f}s"
if search_duration > 1
else f"{search_duration * 1000.0:.0f}ms"
)
self.part_list.DeleteAllItems()
if parts is None:
return
count = len(parts)
if count == 1000:
self.result_count.SetLabel(
f"{count} Results (limited) in {search_duration_text}"
)
else:
self.result_count.SetLabel(f"{count} Results in {search_duration_text}")
for p in parts:
self.part_list.AppendItem([str(c) for c in p])
def select_part(self, *_):
"""Save the selected part number and close the modal."""
item = self.part_list.GetSelection()
row = self.part_list.ItemToRow(item)
if row == -1:
return
selection = self.part_list.GetTextValue(row, 0)
stock = self.part_list.GetTextValue(row, 8)
wx.PostEvent(
self.parent,
AssignPartsEvent(
lcsc=selection,
stock=stock,
references=self.parts.keys(),
),
)
self.EndModal(wx.ID_OK)
def get_part_details(self, *_):
"""Fetch part details from LCSC and show them in a modal."""
item = self.part_list.GetSelection()
row = self.part_list.ItemToRow(item)
if row == -1:
return
part = self.part_list.GetTextValue(row, 0)
if part != "":
busy_cursor = wx.BusyCursor()
dialog = PartDetailsDialog(self.parent, part)
del busy_cursor
dialog.ShowModal()
def help(self, *_):
"""Show message box with help instructions"""
title = "Help"
text = """
Use % as wildcard selector. \n
For example DS24% will match DS2411\n
%QFP% wil match LQFP-64 as well as TQFP-32\n
The keyword search box is automatically post- and prefixed with wildcard operators.
The others are not by default.\n
The keyword search field is applied to "LCSC Part", "Description", "MFR.Part",
"Package" and "Manufacturer".\n
Enter triggers the search the same way the search button does.\n
The results are limited to 1000.
"""
wx.MessageBox(text, title, style=wx.ICON_INFORMATION)