You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I messed a bit with code, and wrote a simple PoC. I hardcoded element count to "30" for now:
Instead of hardcoding element count, an additional field could be added to the menu at the top, with target component count. Near it, a simple switch for toggling this feature should be present too.
As mentioned in linked issue, JLC API is not stable, so this feature should handle all parsing faults as gracefully as possible, and fallback to the default view on any error.
Another annoying issue I tried to deal here is "description" field, which is arguably even messier. I tried to highlight the searched phrase, to improve glance value when selecting component.
The scenario i'm trying to deal with: looking for "100n" component with "0402" package - when I'm obviously looking for a capacitor, I get "100nH 0402" choke listed.
This challenge however defeated me - I don't know if it's even possible to print bold text using wx component used here (and how portable such feature would be). For now i wrap keyword in ||double pipes||, but this doesn't really look useful at all.
Here's the snippet I made - obviously requiring a lot more sanitation before being prod-ready:
self.populate_part_list(result, search_duration, self.keyword.GetValue())
[...]
defpopulate_part_list(self, parts, search_duration, keyword):
"""Populate the list with the result of the search."""target_count=30search_duration_text= (
f"{search_duration:.2f}s"ifsearch_duration>1elsef"{search_duration*1000.0:.0f}ms"
)
self.part_list.DeleteAllItems()
ifpartsisNone:
returncount=len(parts)
ifcount>=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}")
forpinparts:
item= [str(c) forcinp]
# Munge price to be more readablepricecol=8# Must match order in library.py search functiondescriptioncol=7price= []
try:
fortinitem[pricecol].split(","):
qty, p=t.split(":")
qty_low, qty_high=qty.split("-")
qty_low_f=float(qty_low)
try:
qty_high_f=float(qty_high)
exceptValueError:
qty_high_f=float("inf")
if (target_count>=qty_low_f) and (target_count<qty_high_f):
p=float(p)
ifp<1.0:
price.append(f"{qty}: {p*100:.2f}c")
else:
price.append(f"{qty}: ${p:.2f}")
self.logger.warning(f"${p:.2f}")
# if p < 1.0:# price.append(f"{qty}: {p * 100:.2f}c")# else:# price.append(f"{qty}: ${p:.2f}")item[pricecol] =", ".join(price)
exceptValueError:
self.logger.warning("unable to parse price %s", item[pricecol])
item[descriptioncol] =item[descriptioncol].replace(keyword, f"||{keyword}||")
self.part_list.AppendItem(item)
Please tell me if it's something worth being merged-in, I could finish this and make an PR sometime in the future.
Bonus question - is it even remotely possible for kicad addon to utilize some other GUI-rendering framework? :)
The text was updated successfully, but these errors were encountered:
Nuff said - Price column is a mess :) #382
I messed a bit with code, and wrote a simple PoC. I hardcoded element count to "30" for now:
Instead of hardcoding element count, an additional field could be added to the menu at the top, with target component count. Near it, a simple switch for toggling this feature should be present too.
As mentioned in linked issue, JLC API is not stable, so this feature should handle all parsing faults as gracefully as possible, and fallback to the default view on any error.
Another annoying issue I tried to deal here is "description" field, which is arguably even messier. I tried to highlight the searched phrase, to improve glance value when selecting component.
The scenario i'm trying to deal with: looking for "100n" component with "0402" package - when I'm obviously looking for a capacitor, I get "100nH 0402" choke listed.
This challenge however defeated me - I don't know if it's even possible to print bold text using wx component used here (and how portable such feature would be). For now i wrap keyword in ||double pipes||, but this doesn't really look useful at all.
Here's the snippet I made - obviously requiring a lot more sanitation before being prod-ready:
Please tell me if it's something worth being merged-in, I could finish this and make an PR sometime in the future.
Bonus question - is it even remotely possible for kicad addon to utilize some other GUI-rendering framework? :)
The text was updated successfully, but these errors were encountered: