当前位置: 首页>>代码示例>>Python>>正文


Python Project.fromFile方法代码示例

本文整理汇总了Python中Project.Project.fromFile方法的典型用法代码示例。如果您正苦于以下问题:Python Project.fromFile方法的具体用法?Python Project.fromFile怎么用?Python Project.fromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project.Project的用法示例。


在下文中一共展示了Project.fromFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: importShiftData

# 需要导入模块: from Project import Project [as 别名]
# 或者: from Project.Project import fromFile [as 别名]
def importShiftData(parent):
  pyrite_file_name, filt = QFileDialog.getOpenFileName(parent,
      "Select Pyrite Project", filter="Pyrite Projects (*.pyrite)")
  if not pyrite_file_name:
    return
  pyrite_project = Project.fromFile(pyrite_file_name)
  design_package = pyrite_project.design.package
  design_die = design_package.dies[0]

  excel_file_name, filt = QFileDialog.getOpenFileName(parent,
      "Select Shifts Excel File", filter="Excel Files (*.xlsx *.xlsm)")
  if not excel_file_name:
    return

  panel_id = ""
  match = re.search("(?:D[0-9]+_[A-Z]_)([0-9]+)(?:.*\.xls.*)|(?:MP.+\.)"
      "([0-9]+)(?:\..*\.xls.*)", excel_file_name)
  if match:
    panel_id += [g for g in match.groups() if g is not None][0]

  panel_id, good = QInputDialog.getText(parent, "Panel ID",
      "Enter the panel ID", text=panel_id)
  if not panel_id:
    return

  excel_wb = openpyxl.reader.excel.load_workbook(excel_file_name)
  sheet_names = excel_wb.get_sheet_names()

  preselect_sheets = [s for s in sheet_names
                      if "calculated values" in s.lower()]
  global_offset_txt = ""
  if preselect_sheets:
    sheet = excel_wb.get_sheet_by_name(preselect_sheets[0])
    if sheet.cell("A1").value == "Global X Shift:" and\
            sheet.cell("A2").value == "Global Y Shift:":
              global_offset_txt = "{0}, {1}".format(sheet.cell("C1").value,
                  sheet.cell("C2").value)

  while True:
    global_offset_txt, good = QInputDialog.getText(parent, "Global Offset",
        "Enter the panel's global offset (x, y) (e.g. 533.33, 434.3)",
        text=global_offset_txt)
    if not global_offset_txt:
      return
    try:
      tokens = [t.strip() for t in global_offset_txt.split(',')]
      global_x = float(tokens[0])
      global_y = float(tokens[1])
      break
    except:
      QMessageBox.warning(parent, "Global Offset",
          "{0} is not a valid global offset".format(global_offset_txt))

  data_selector = ExcelShiftDataSelector(parent, sheet_names)
  data_selector.setWindowTitle("Select Die Shifts")
  preselect_sheets = [s for s in sheet_names
                      if "calculated values" in s.lower()]
  if preselect_sheets:
    data_selector.cmboSheet.setCurrentIndex(
        sheet_names.index(preselect_sheets[0]))
    sheet = excel_wb.get_sheet_by_name(preselect_sheets[0])
    if sheet.cell("B4").value == "Package Nominal":
      if sheet.cell("B5").value == "X (um)":
        data_selector.txtNomX.setText("B6")
      if sheet.cell("C5").value == "Y (um)":
        data_selector.txtNomY.setText("C6")
    if sheet.cell("D4").value == "Die Shift (Deviation)":
      if sheet.cell("D5").value == "X (um)":
        data_selector.txtXShift.setText("D6")
      if sheet.cell("E5").value == "Y (um)":
        data_selector.txtYShift.setText("E6")
      if sheet.cell("F5").value == "Theta (deg)":
        data_selector.txtTheta.setText("F6")
    if sheet.cell("D1").value == "Package Count:":
      data_selector.txtCount.setText(str(sheet.cell("F1").value))

  data_selector.exec_()
  if data_selector.result() == QDialog.Rejected:
    return
  die_shifts = []
  worksheet = excel_wb.get_sheet_by_name(data_selector.sheetName)
  for i in range(data_selector.count):
    nomx = float(worksheet.cell(row=data_selector.nomXRow + i,
        column=data_selector.nomXCol).value)
    nomy = float(worksheet.cell(row=data_selector.nomYRow + i,
        column=data_selector.nomYCol).value)
    shiftx = float(worksheet.cell(row=data_selector.shiftXRow + i,
        column=data_selector.shiftXCol).value)
    shifty = float(worksheet.cell(row=data_selector.shiftYRow + i,
        column=data_selector.shiftYCol).value)
    theta = float(worksheet.cell(row=data_selector.thetaRow + i,
        column=data_selector.thetaCol).value)
    die_shifts.append((nomx, nomy, shiftx, shifty, theta))

  data_selector = ExcelShiftDataSelector(parent, sheet_names)
  data_selector.setWindowTitle("Select Fiducial Die Shifts")
  data_selector.txtDieName.setText("FIDUCIAL")
  preselect_sheets = [s for s in sheet_names
                      if "fiducial" in s.lower()]
  if preselect_sheets:
#.........这里部分代码省略.........
开发者ID:countrymarmot,项目名称:deca_tech,代码行数:103,代码来源:ShiftDataImporter.py


注:本文中的Project.Project.fromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。