简体   繁体   中英

How to iterate through a nested dictionary into a Schemdraw circuit

I'm trying to iterate through a nested dictionary into an integrated circuit with schemdraw but the values overlap each other in the final drawing instead of creating new entries on the integrated circuit. I think I might need one more level of iteration but not really sure what that should be. Any help appreciated!

Here's what I'm working with:

import schemdraw
import schemdraw.elements.intcircuits as eInt



dict1 = {'channel 1':
                 {'source_name': '1', 
                 }, 
        'channel 2': 
                {'source_name': '2', 
                }}


with schemdraw.Drawing(file='/Users/Desktop/circuitdrawing.png') as d:
    for channel, info in dict1.items():
        if channel != None:
            for channel, info in dict1.items(): #might need another level of iteration here?
                d += eInt.Ic(pins=[eInt.IcPin(name=(channel), pin=(info['source_name']), side='left')],
                    edgepadW = 2,
                    pinspacing = 1).label('console 1', 'top', fontsize=12)
        else:
            continue

This is the output from the code: Circuit Drawing

Solved by adding an additional slot argument to the pin info so it ended up looking like this:

d += eInt.Ic(pins=[eInt.IcPin(name=(channel), pin=(info['source_name']), side='left'), slot='1/2'],
                    edgepadW = 2,
                    pinspacing = 1).label('console 1', 'top', fontsize=12)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM