當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。