コード例 #1
0
 def __init__(self):
     super(KiBuzzardPlugin, self).__init__()
     self.name = "Create Labels"
     self.category = "Modify PCB"
     self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
     self.show_toolbar_button = True
     icon_dir = os.path.dirname(os.path.dirname(__file__))
     self.icon_file_name = os.path.join(icon_dir, 'icon.png')
     self.description = "Create Labels"
     self.config = FileConfig(localFilename=self.config_file)
     self._pcbnew_frame = None
コード例 #2
0
 def __init__(self):
     super(KiBuzzardPlugin, self).__init__()
     self.name = "Create Labels"
     self.category = "Modify PCB"
     self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
     self.show_toolbar_button = True
     icon_dir = os.path.dirname(os.path.dirname(__file__))
     self.icon_file_name = os.path.join(icon_dir, 'icon.png')
     self.description = "Create Labels"
     self.config = FileConfig(localFilename=self.config_file)
     self._pcbnew_frame = None
     self.kicad_version = pcbnew.GetBuildVersion()
     self.buzzard_label_library_path = "/buzzard_labels.pretty"
     self.buzzard_label_module_name = "buzzard_labels"
コード例 #3
0
ファイル: plugin.py プロジェクト: edwin-oetelaar/KiBuzzard
    def __init__(self):
        super(KiBuzzardPlugin, self).__init__()

        self.InitLogger()
        self.logger = logging.getLogger(__name__)

        self.name = "Create Labels"
        self.category = "Modify PCB"
        self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
        self.show_toolbar_button = True
        icon_dir = os.path.dirname(os.path.dirname(__file__))
        self.icon_file_name = os.path.join(icon_dir, 'icon.png')
        self.description = "Create Labels"
        self.config = FileConfig(localFilename=self.config_file)

        self._pcbnew_frame = None

        self.kicad_build_version = pcbnew.GetBuildVersion()
        if '5.1' in self.kicad_build_version or '5.0' in self.kicad_build_version:
            # Library location for KiCad 5.1
            self.filepath = os.path.join(tempfile.mkdtemp(),
                                         'buzzard_labels.pretty',
                                         'label.kicad_mod')
            try:  # Use try/except here because python 2.7 doesn't support exist_ok
                os.makedirs(os.path.dirname(self.filepath))
            except:
                pass
コード例 #4
0
ファイル: test_dialog.py プロジェクト: gkeyboard/KiBuzzard
    def OnInit(self):

        config_file = os.path.join(os.path.dirname(__file__), '..',
                                   'config.ini')
        config = FileConfig(localFilename=config_file)

        self.frame = frame = Dialog(None, config, Buzzard(), self.run)
        if frame.ShowModal() == wx.ID_OK:
            print("Graceful Exit")
        frame.Destroy()
        return True
コード例 #5
0
ファイル: config.py プロジェクト: gregdavill/KiZip
    def save(self):
        f = FileConfig(localFilename=self.config_file)

        f.SetPath('/general')
        output_dest_dir = self.output_dest_dir
        if output_dest_dir.startswith(self.rel_directory):
            output_dest_dir = os.path.relpath(output_dest_dir,
                                              self.rel_directory)
        f.Write('output_dest_dir', output_dest_dir)
        f.Write('output_name_format', self.output_name_format)

        f.SetPath("/layers")
        for index in range(len(self.layers)):
            l = self.layers[index]
            f.WriteBool(f'layer{l.id}_enabled', l.enabled)
            f.Write(f'layer{l.id}_ext', l.ext)

        f.Flush()
コード例 #6
0
ファイル: config.py プロジェクト: gregdavill/KiZip
    def load_from_ini(self):
        """Init from config file if it exists."""
        if not os.path.isfile(self.config_file):
            return
        f = FileConfig(localFilename=self.config_file)
        f.SetPath('/general')
        self.output_dest_dir = f.Read('output_dest_dir', self.output_dest_dir)
        self.output_name_format = f.Read('output_name_format',
                                         self.output_name_format)

        f.SetPath("/layers")
        for index in range(len(self.layers)):
            l = self.layers[index]
            l.enabled = f.ReadBool(f'layer{l.id}_enabled', l.enabled)
            l.ext = f.Read(f'layer{l.id}_ext', l.ext)
コード例 #7
0
class KiBuzzardPlugin(pcbnew.ActionPlugin, object):
    config_file = os.path.join(os.path.dirname(__file__), '..', 'config.ini')
    buzzard_path = os.path.join(os.path.dirname(__file__), '..', 'deps',
                                'buzzard')

    def __init__(self):
        super(KiBuzzardPlugin, self).__init__()
        self.name = "Create Labels"
        self.category = "Modify PCB"
        self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
        self.show_toolbar_button = True
        icon_dir = os.path.dirname(os.path.dirname(__file__))
        self.icon_file_name = os.path.join(icon_dir, 'icon.png')
        self.description = "Create Labels"
        self.config = FileConfig(localFilename=self.config_file)
        self._pcbnew_frame = None

    def defaults(self):
        pass

    def Run(self):
        buzzard_script = os.path.join(self.buzzard_path, 'buzzard.py')

        if self._pcbnew_frame is None:
            self._pcbnew_frame = [
                x for x in wx.GetTopLevelWindows()
                if 'pcbnew' in x.GetTitle().lower()
                and not 'python' in x.GetTitle().lower()
            ][0]

        def run_buzzard(str):
            import re

            str = str + ' -o ki -stdout'
            args = [a.strip('"') for a in re.findall('".+?"|\S+', str)]
            if sys.platform.startswith('win'):
                args = [re.sub('([<>])', r'^\1', a)
                        for a in args]  # escape '<' or '>' with a caret, '^<'

            # Execute Buzzard
            process = None
            if sys.platform.startswith('linux') or sys.platform == 'darwin':
                process = subprocess.Popen(['python3', buzzard_script] + args,
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.PIPE)
            else:
                process = subprocess.Popen(
                    ['C:\\Python38\\python.exe', buzzard_script] + args,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    shell=True)
            stdout, stderr = process.communicate()
            if stderr:
                wx.MessageBox(stderr, 'Error', wx.OK | wx.ICON_ERROR)

            # check for errors
            error_line = [
                s for s in stderr.decode('utf8').split('\n') if 'error' in s
            ]
            if len(error_line) > 0:
                wx.MessageBox(error_line[0], 'Error', wx.OK | wx.ICON_ERROR)

            else:
                # Copy footprint into clipboard
                if sys.platform.startswith('linux'):
                    clip_args = ['xclip', '-sel', 'clip', '-noutf8']
                elif sys.platform == 'darwin':
                    clip_args = ['pbcopy']
                else:
                    clip_args = ['clip.exe']

                process = subprocess.Popen(clip_args, stdin=subprocess.PIPE)
                process.communicate(stdout)

                dlg.EndModal(wx.ID_OK)

        dlg = Dialog(self._pcbnew_frame, self.config, self.buzzard_path,
                     run_buzzard)
        try:
            if dlg.ShowModal() == wx.ID_OK:
                # Set focus to main window and execute a Paste operation
                self._pcbnew_frame.Raise()
                wx.Yield()
                keyinput = wx.UIActionSimulator()
                keyinput.Char(ord("V"), wx.MOD_CONTROL)
        finally:
            self.config.Flush()
            dlg.Destroy()
コード例 #8
0
    def __init__(self):
        """Init from config file if it exists."""
        if not os.path.isfile(self.config_file):
            return
        f = FileConfig(localFilename=self.config_file)

        f.SetPath('/html_defaults')
        self.dark_mode = f.ReadBool('dark_mode', self.dark_mode)
        self.show_silkscreen = f.ReadBool('show_silkscreen',
                                          self.show_silkscreen)
        self.highlight_pin1 = f.ReadBool('highlight_pin1', self.highlight_pin1)
        self.redraw_on_drag = f.ReadBool('redraw_on_drag', self.redraw_on_drag)
        self.board_rotation = f.ReadInt('board_rotation', self.board_rotation)
        self.checkboxes = f.Read('checkboxes', self.checkboxes)
        self.bom_view = f.Read('bom_view', self.bom_view)
        self.layer_view = f.Read('layer_view', self.layer_view)
        self.open_browser = f.ReadBool('open_browser', self.open_browser)

        f.SetPath('/general')
        self.bom_dest_dir = f.Read('bom_dest_dir', self.bom_dest_dir)
        self.component_sort_order = self._split(
            f.Read('component_sort_order',
                   ','.join(self.component_sort_order)))
        self.component_blacklist = self._split(
            f.Read('component_blacklist', ','.join(self.component_blacklist)))
        self.blacklist_virtual = f.ReadBool('blacklist_virtual',
                                            self.blacklist_virtual)
        self.blacklist_empty_val = f.ReadBool('blacklist_empty_val',
                                              self.blacklist_empty_val)

        f.SetPath('/extra_fields')
        self.extra_fields = self._split(
            f.Read('extra_fields', ','.join(self.extra_fields)))
        self.board_variant_field = f.Read('board_variant_field',
                                          self.board_variant_field)
        self.board_variant_whitelist = self._split(
            f.Read('board_variant_whitelist',
                   ','.join(self.board_variant_whitelist)))
        self.board_variant_blacklist = self._split(
            f.Read('board_variant_blacklist',
                   ','.join(self.board_variant_blacklist)))
        self.dnp_field = f.Read('dnp_field', self.dnp_field)
コード例 #9
0
    def save(self):
        f = FileConfig(localFilename=self.config_file)

        f.SetPath('/html_defaults')
        f.WriteBool('dark_mode', self.dark_mode)
        f.WriteBool('show_silkscreen', self.show_silkscreen)
        f.WriteBool('highlight_pin1', self.highlight_pin1)
        f.WriteBool('redraw_on_drag', self.redraw_on_drag)
        f.WriteInt('board_rotation', self.board_rotation)
        f.Write('checkboxes', self.checkboxes)
        f.Write('bom_view', self.bom_view)
        f.Write('layer_view', self.layer_view)
        f.WriteBool('open_browser', self.open_browser)

        f.SetPath('/general')
        bom_dest_dir = self.bom_dest_dir
        if bom_dest_dir.startswith(self.netlist_initial_directory):
            bom_dest_dir = os.path.relpath(bom_dest_dir,
                                           self.netlist_initial_directory)
        f.Write('bom_dest_dir', bom_dest_dir)
        f.Write('component_sort_order', ','.join(self.component_sort_order))
        f.Write('component_blacklist', ','.join(self.component_blacklist))
        f.WriteBool('blacklist_virtual', self.blacklist_virtual)
        f.WriteBool('blacklist_empty_val', self.blacklist_empty_val)

        f.SetPath('/extra_fields')
        f.Write('extra_fields', ','.join(self.extra_fields))
        f.Write('board_variant_field', self.board_variant_field)
        f.Write('board_variant_whitelist',
                ','.join(self.board_variant_whitelist))
        f.Write('board_variant_blacklist',
                ','.join(self.board_variant_blacklist))
        f.Write('dnp_field', self.dnp_field)
        f.Flush()
コード例 #10
0
    def save(self):
        f = FileConfig(localFilename=self.config_file)

        f.Flush()
コード例 #11
0
 def load_from_ini(self):
     """Init from config file if it exists."""
     if not os.path.isfile(self.config_file):
         return
     f = FileConfig(localFilename=self.config_file)
コード例 #12
0
    def load_from_ini(self):
        """Init from config file if it exists."""
        if os.path.isfile(self.local_config_file):
            file = self.local_config_file
        elif os.path.isfile(self.global_config_file):
            file = self.global_config_file
        else:
            return

        f = FileConfig(localFilename=file)

        f.SetPath('/html_defaults')
        self.dark_mode = f.ReadBool('dark_mode', self.dark_mode)
        self.show_pads = f.ReadBool('show_pads', self.show_pads)
        self.show_fabrication = f.ReadBool(
            'show_fabrication', self.show_fabrication)
        self.show_silkscreen = f.ReadBool(
            'show_silkscreen', self.show_silkscreen)
        self.highlight_pin1 = f.ReadBool('highlight_pin1', self.highlight_pin1)
        self.redraw_on_drag = f.ReadBool('redraw_on_drag', self.redraw_on_drag)
        self.board_rotation = f.ReadInt('board_rotation', self.board_rotation)
        self.checkboxes = f.Read('checkboxes', self.checkboxes)
        self.bom_view = f.Read('bom_view', self.bom_view)
        self.layer_view = f.Read('layer_view', self.layer_view)
        self.compression = f.ReadBool('compression', self.compression)
        self.open_browser = f.ReadBool('open_browser', self.open_browser)

        f.SetPath('/general')
        self.bom_dest_dir = f.Read('bom_dest_dir', self.bom_dest_dir)
        self.bom_name_format = f.Read('bom_name_format', self.bom_name_format)
        self.component_sort_order = self._split(f.Read(
            'component_sort_order',
            ','.join(self.component_sort_order)))
        self.component_blacklist = self._split(f.Read(
            'component_blacklist',
            ','.join(self.component_blacklist)))
        self.blacklist_virtual = f.ReadBool(
            'blacklist_virtual', self.blacklist_virtual)
        self.blacklist_empty_val = f.ReadBool(
            'blacklist_empty_val', self.blacklist_empty_val)
        self.include_tracks = f.ReadBool('include_tracks', self.include_tracks)
        self.include_nets = f.ReadBool('include_nets', self.include_nets)

        f.SetPath('/fields')
        self.show_fields = self._split(f.Read(
            'show_fields', self._join(self.show_fields)))
        self.group_fields = self._split(f.Read(
            'group_fields', self._join(self.group_fields)))
        self.normalize_field_case = f.ReadBool(
            'normalize_field_case', self.normalize_field_case)
        self.board_variant_field = f.Read(
            'board_variant_field', self.board_variant_field)
        self.board_variant_whitelist = self._split(f.Read(
            'board_variant_whitelist',
            self._join(self.board_variant_whitelist)))
        self.board_variant_blacklist = self._split(f.Read(
            'board_variant_blacklist',
            self._join(self.board_variant_blacklist)))
        self.dnp_field = f.Read('dnp_field', self.dnp_field)
コード例 #13
0
    def save(self, locally):
        file = self.local_config_file if locally else self.global_config_file
        print('Saving to', file)
        f = FileConfig(localFilename=file)

        f.SetPath('/html_defaults')
        f.WriteBool('dark_mode', self.dark_mode)
        f.WriteBool('show_pads', self.show_pads)
        f.WriteBool('show_fabrication', self.show_fabrication)
        f.WriteBool('show_silkscreen', self.show_silkscreen)
        f.WriteBool('highlight_pin1', self.highlight_pin1)
        f.WriteBool('redraw_on_drag', self.redraw_on_drag)
        f.WriteInt('board_rotation', self.board_rotation)
        f.Write('checkboxes', self.checkboxes)
        f.Write('bom_view', self.bom_view)
        f.Write('layer_view', self.layer_view)
        f.WriteBool('compression', self.compression)
        f.WriteBool('open_browser', self.open_browser)

        f.SetPath('/general')
        bom_dest_dir = self.bom_dest_dir
        if bom_dest_dir.startswith(self.netlist_initial_directory):
            bom_dest_dir = os.path.relpath(
                bom_dest_dir, self.netlist_initial_directory)
        f.Write('bom_dest_dir', bom_dest_dir)
        f.Write('bom_name_format', self.bom_name_format)
        f.Write('component_sort_order',
                ','.join(self.component_sort_order))
        f.Write('component_blacklist',
                ','.join(self.component_blacklist))
        f.WriteBool('blacklist_virtual', self.blacklist_virtual)
        f.WriteBool('blacklist_empty_val', self.blacklist_empty_val)
        f.WriteBool('include_tracks', self.include_tracks)
        f.WriteBool('include_nets', self.include_nets)

        f.SetPath('/fields')
        f.Write('show_fields', self._join(self.show_fields))
        f.Write('group_fields', self._join(self.group_fields))
        f.WriteBool('normalize_field_case', self.normalize_field_case)
        f.Write('board_variant_field', self.board_variant_field)
        f.Write('board_variant_whitelist',
                self._join(self.board_variant_whitelist))
        f.Write('board_variant_blacklist',
                self._join(self.board_variant_blacklist))
        f.Write('dnp_field', self.dnp_field)
        f.Flush()
コード例 #14
0
 def save(self):
     f = FileConfig(localFilename=self.config_file)
     f.SetPath('/general')
     gcode_dest_dir = self.gcode_dest_dir
     if gcode_dest_dir.startswith(self.netlist_initial_directory):
         gcode_dest_dir = os.path.relpath(gcode_dest_dir,
                                          self.netlist_initial_directory)
     f.Write('gcode_dest_dir', gcode_dest_dir)
     f.Write('gcode_name_format', self.gcode_name_format)
     f.Write('laser_x_width', str(self.laser_x_width))
     f.Write('laser_y_width', str(self.laser_y_width))
     f.Write('laser_pad_passes', str(self.laser_pad_passes))
     f.Write('laser_pad_intensity', str(self.laser_pad_intensity))
     f.Write('laser_border_intensity', str(self.laser_border_intensity))
     f.Write('laser_speed', str(self.laser_speed))
     f.Write('laser_border_speed', str(self.laser_border_speed))
     f.Write('component_blacklist', ','.join(self.component_blacklist))
     f.WriteBool('blacklist_virtual', self.blacklist_virtual)
     f.WriteBool('blacklist_empty_val', self.blacklist_empty_val)
     f.Flush()
コード例 #15
0
    def load_from_ini(self):
        """Init from config file if it exists."""
        if not os.path.isfile(self.config_file):
            return
        f = FileConfig(localFilename=self.config_file)

        f.SetPath('/general')
        self.gcode_dest_dir = f.Read('gcode_dest_dir', self.gcode_dest_dir)
        self.gcode_name_format = f.Read('gcode_name_format',
                                        self.gcode_name_format)

        self.laser_x_width = f.Read('laser_x_width', str(self.laser_x_width))
        self.laser_y_width = f.Read('laser_x_width', str(self.laser_y_width))
        self.laser_pad_passes = f.Read('laser_pad_passes',
                                       str(self.laser_pad_passes))
        self.laser_pad_intensity = f.Read('laser_pad_intensity',
                                          str(self.laser_pad_intensity))
        self.laser_border_intensity = f.Read('laser_border_intensity',
                                             str(self.laser_border_intensity))
        self.laser_speed = f.Read('laser_speed', str(self.laser_speed))
        self.laser_border_speed = f.Read('laser_border_speed',
                                         str(self.laser_border_speed))
        self.component_blacklist = self._split(
            f.Read('component_blacklist', ','.join(self.component_blacklist)))
        self.blacklist_virtual = f.ReadBool('blacklist_virtual',
                                            self.blacklist_virtual)
        self.blacklist_empty_val = f.ReadBool('blacklist_empty_val',
                                              self.blacklist_empty_val)