1
+ import os
1
2
import sys
2
3
import threading
3
4
import time
4
5
5
- import pcbnew
6
6
import wx
7
7
import wx .aui
8
8
9
- from .generate_interactive_bom import InteractiveHtmlBomPlugin
10
-
11
9
12
10
def check_for_bom_button ():
13
11
# From Miles McCoo's blog
@@ -22,19 +20,20 @@ def find_pcbnew_window():
22
20
def callback (_ ):
23
21
plugin .Run ()
24
22
25
- import os
26
23
path = os .path .dirname (__file__ )
27
24
while not wx .GetApp ():
28
25
time .sleep (1 )
29
26
bm = wx .Bitmap (path + '/icon.png' , wx .BITMAP_TYPE_PNG )
30
27
button_wx_item_id = 0
28
+
29
+ from pcbnew import ID_H_TOOLBAR
31
30
while True :
32
31
time .sleep (1 )
33
- pcbwin = find_pcbnew_window ()
34
- if not pcbwin :
32
+ pcbnew_window = find_pcbnew_window ()
33
+ if not pcbnew_window :
35
34
continue
36
35
37
- top_tb = pcbwin .FindWindowById (pcbnew . ID_H_TOOLBAR )
36
+ top_tb = pcbnew_window .FindWindowById (ID_H_TOOLBAR )
38
37
if button_wx_item_id == 0 or not top_tb .FindTool (button_wx_item_id ):
39
38
top_tb .AddSeparator ()
40
39
button_wx_item_id = wx .NewId ()
@@ -44,13 +43,16 @@ def callback(_):
44
43
top_tb .Realize ()
45
44
46
45
47
- plugin = InteractiveHtmlBomPlugin ()
48
- plugin .defaults ()
49
- plugin .register ()
46
+ if not os .environ .get ('INTERACTIVE_HTML_BOM_CLI_MODE' , False ):
47
+ from .ecad .kicad import InteractiveHtmlBomPlugin
48
+
49
+ plugin = InteractiveHtmlBomPlugin ()
50
+ plugin .defaults ()
51
+ plugin .register ()
50
52
51
- # Add a button the hacky way if plugin button is not supported
52
- # in pcbnew, unless this is linux.
53
- if not plugin .pcbnew_icon_support and not sys .platform .startswith ('linux' ):
54
- t = threading .Thread (target = check_for_bom_button )
55
- t .daemon = True
56
- t .start ()
53
+ # Add a button the hacky way if plugin button is not supported
54
+ # in pcbnew, unless this is linux.
55
+ if not plugin .pcbnew_icon_support and not sys .platform .startswith ('linux' ):
56
+ t = threading .Thread (target = check_for_bom_button )
57
+ t .daemon = True
58
+ t .start ()
0 commit comments