Beispiel #1
0
def reload_lys(technology=None, clear=False, dataprep=False):
    ''' Updates lys from the lyp files. Also updates the layer display in GUI mode.
        If any of the layers are already there, it does nothing.
        If no lyp is found, does nothing
    '''
    if technology is None:
        technology = active_technology()
    elif isinstance(technology, str):
        technology = Technology.technology_by_name(technology)

    if clear: lys.clear()
    try:
        lyp_file = tech_layer_properties(
            technology) if not dataprep else tech_dataprep_layer_properties(
                technology)
        lys.appendFile(lyp_file, doubles_ok=True)
    except (FileNotFoundError, AttributeError):
        message_loud(
            'No lyp file found. Likely that technology hasn\'t loaded yet, or you don\'t have the standalone klayout'
        )

    if isGUI():
        lv = gui_view()
        orig_list_index = lv.current_layer_list
        was_transacting = lv.is_transacting()
        if was_transacting:
            lv.commit()
        lv.load_layer_props(lyp_file)
        if was_transacting:
            lv.transaction('Bump transaction')
        lv.current_layer_list = orig_list_index
Beispiel #2
0
def set_active_technology(tech_name):
    if not Technology.has_technology(tech_name):
        raise ValueError('Technology not found. Available are {}'.format(
            Technology.technology_names()))
    if isGUI() and tech_name != gui_active_technology().name:
        raise RuntimeError('Cannot set technology via lymask while in GUI')
    global _active_technology
    _active_technology = Technology.technology_by_name(tech_name)
    reload_lys(tech_name, clear=True)
Beispiel #3
0
def active_technology():
    ''' Gets active technology from GUI if in GUI, otherwise gives the stored variable, otherwise gives default last open
    '''
    global _active_technology
    if isGUI():
        return gui_active_technology()
    else:
        if _active_technology is None:
            _active_technology = Technology.technology_by_name(
                klayout_last_open_technology())
        return _active_technology
Beispiel #4
0
def use_gui():
    if isGUI() and True:
        main = pya.Application.instance().main_window()
        main.create_layout(1)
    else:
        raise RuntimeError('Not in GUI')
Beispiel #5
0
from __future__ import print_function
from lygadgets import pya, isGUI

if isGUI():
    main_window = pya.Application.instance().main_window()
    message = lambda msg: main_window.message(msg, 5000)
    message_loud = lambda msg: pya.MessageBox.info('Message for you', msg, pya.
                                                   MessageBox.Ok)
else:
    PINK = '\033[95m'
    NORMAL_COLOR = '\033[0m'
    message = print
    message_loud = lambda msg: print(PINK + str(msg), NORMAL_COLOR)