Skip to content

Commit 67f11b2

Browse files
committed
Add the button the right way
Fallback to the hack only if button is not supported in pcbnew. Don't use the hack on linux because it crashes pcbnew.
1 parent 0012cf1 commit 67f11b2

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

InteractiveHtmlBom/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import wx.aui
55
import threading
66
import time
7-
8-
plugin = GenerateInteractiveBomPlugin()
9-
plugin.register()
10-
7+
import sys
118

129
def check_for_bom_button():
1310
# From Miles McCoo's blog
@@ -42,6 +39,12 @@ def callback(_):
4239
top_tb.Realize()
4340

4441

45-
t = threading.Thread(target=check_for_bom_button)
46-
t.daemon = True
47-
t.start()
42+
plugin = GenerateInteractiveBomPlugin()
43+
plugin.register()
44+
45+
# Add a button the hacky way if plugin button is not supported
46+
# in pcbnew, unless this is linux.
47+
if not plugin.pcbnew_icon_support and not sys.platform.startswith('linux'):
48+
t = threading.Thread(target=check_for_bom_button)
49+
t.daemon = True
50+
t.start()

InteractiveHtmlBom/generate_interactive_bom.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ def defaults(self):
479479
"""
480480
self.name = "Generate Interactive HTML BOM"
481481
self.category = "Read PCB"
482+
self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
483+
self.show_toolbar_button = True
484+
self.icon_file_name = os.path.join(os.path.dirname(__file__), 'icon.png')
482485
self.description = "Generate interactive HTML page that contains BOM " \
483486
"table and pcb drawing."
484487

0 commit comments

Comments
 (0)