def defineEnvPrepareWindow(self):
envFrame = LabelFrame(self.rootPage, text="Test Prepare Window")
envFrame.place(relx=0.01, relwidth=0.95, rely=0.21, relheight=0.3)
def Jenkins():
jenkins = LabelFrame(envFrame, text="Jenkins")
jenkins.place(relx=0.01, relwidth=0.32, rely=0.01, relheight=0.95)
buildBtn = Button(jenkins, text="Build Code",
command=lambda: self.BuildOrDownloadFile(isBuild=True))
buildBtn.place(relx=0.1, relwidth=0.3, rely=0.01, relheight=0.1)
downloadLabel = Label(jenkins, text="Download Files: ")
downloadLabel.place(relx=0.041, relwidth=0.4, rely=0.2, relheight=0.1)
downloadEntry = Entry(jenkins, textvariable=self.downloadFile, state="normal")
downloadEntry.place(relx=0.38, relwidth=0.4, rely=0.2, relheight=0.1)
downloadSubmit = Button(jenkins, text="开始下载", command=lambda: self.BuildOrDownloadFile())
downloadSubmit.place(relx=0.8, relwidth=0.15, rely=0.2, relheight=0.1)
note = Label(jenkins, text="注: 填写下载名称示例, debug_elf、ForBoot.hex", fg="#FF0000")
note.place(relx=0.2, relwidth=0.8, rely=0.32, relheight=0.1)
downloadPath = Label(jenkins, text="Download Path: ")
downloadPath.place(relx=0.041, relwidth=0.4, rely=0.5, relheight=0.1)
downloadPathEntry = Entry(jenkins, textvariable=self.downloadPath, state="normal")
downloadPathEntry.place(relx=0.38, relwidth=0.4, rely=0.5, relheight=0.1)
downloadPathSelect = Button(jenkins, text="选择路径",
command=lambda: api.SelectPath("Jenkins Config", "PcDownloadPath",
self.downloadPath, isFile=False))
downloadPathSelect.place(relx=0.8, relwidth=0.15, rely=0.5, relheight=0.1)
def modifyValue():
if self.isOnlineDownload.get():
self.isOnlineDownloadFile = True
else:
self.isOnlineDownloadFile = False
print(f'当前winIDEA下载文件来源是否是Jenkins: {self.isOnlineDownloadFile}')
onlineDownload = Checkbutton(jenkins, text="", variable=self.isOnlineDownload,
command=lambda: modifyValue())
onlineDownload.place(relx=0.01, relwidth=0.1, rely=0.5, relheight=0.1)
readLocalFile = Label(jenkins, text="Local Download Path: ")
readLocalFile.place(relx=0.006, relwidth=0.4, rely=0.7, relheight=0.1)
readLocalFileEntry = Entry(jenkins, textvariable=self.localDownloadFile, state="normal")
readLocalFileEntry.place(relx=0.38, relwidth=0.4, rely=0.7, relheight=0.1)
readLocalFileSelect = Button(jenkins, text="选择路径",
command=lambda: api.SelectMulFile(value=self.localDownloadFile)
)
readLocalFileSelect.place(relx=0.8, relwidth=0.15, rely=0.7, relheight=0.1)
Jenkins()
def Debugger():
debug = LabelFrame(envFrame, text="Debugger")
debug.place(relx=0.34, relwidth=0.32, rely=0.01, relheight=0.95)
def winIDEA():
def openIdea():
# if self.openWinIDEA.get():
print("正在启动 winIDEA ... ")
api.WinIdeaOperation(winIDEAPrjPath=self.winIdeaPath.get())
openIDEA = Button(debug, text="Open winIDEA",
command=lambda: openIdea())
openIDEA.place(relx=0.12, relwidth=0.25, rely=0.02, relheight=0.12)
def get_downloadFile():
downloadFile = self.downloadFileName
sourDownloadFIlePath = os.path.join(self.downloadPath.get(), downloadFile)
tarDownloadFilePath = api.FileOperations(filePath=sourDownloadFIlePath). \
extractZip(extract_dir=sourDownloadFIlePath.split('.')[0])
print(f"当前winIDEA烧录固件: {tarDownloadFilePath}")
return tarDownloadFilePath
def downloadFiles():
print("winIDEA 开始下载固件...")
if self.isOnlineDownloadFile:
# if self.winIDEADownloads.get():
if get_downloadFile().endswith('.elf') or get_downloadFile().endswith('.hex') or \
get_downloadFile().endswith('.s19'):
api.WinIdeaOperation().downFile(file_path=get_downloadFile())
if get_downloadFile().endswith('.s19'): # 下载merge 代码,需要重新上下电, 让板子启动, 无需再使用debug调试器
api.PowerOperations().setVoltage(value=0)
time.sleep(1)
api.PowerOperations().setVoltage(value=12)
time.sleep(1)
if api.PowerOperations().queryElectricity() > 0.05:
print("merge 代码烧录完成, 重新上下电正常运行")
self.isDebug = False
pass
else:
tkinter.messagebox.showinfo("Error", f"winIDEA 下载代码文件错误, 请确认输入的Download Files正确性!!!")
else:
list_str = self.localDownloadFile.get()
downloadFileList = list_str.split(',')
api.WinIdeaOperation().downFile(file_path=downloadFileList)
print(f"下载文件: {downloadFileList}")
Download = Button(debug, text="winIDEA Download Files",
command=lambda: downloadFiles())
Download.place(relx=0.12, relwidth=0.4, rely=0.18, relheight=0.12)
def on_entry_change(*args):
"""当 Entry 内容变化时更新 Label"""
waitTimeLabel.config(text=f"注意: 复位运行后等待 {self.waitTime.get()} ms, 开始进行测试...")
def runs():
if self.winIDEArun.get():
api.WinIdeaOperation().resetAndRun(waitTime=int(self.waitTime.get()))
else:
api.WinIdeaOperation().stop()
run = Checkbutton(debug, text="winIDEA RESET, RUN", variable=self.winIDEArun, # 修改为 Button控件
command=lambda: runs())
run.place(relx=0.11, relwidth=0.4, rely=0.3, relheight=0.2)
waitTime = Entry(debug, textvariable=self.waitTime, state='normal')
waitTime.place(relx=0.15, relwidth=0.07, rely=0.45, relheight=0.1)
self.waitTime.trace_add("write", on_entry_change)
waitTimeLabel = Label(debug, text=f"注: 复位运行后等待 {self.waitTime.get()} ms, 开始进行测试...", fg="#FF0000")
waitTimeLabel.place(relx=0.2, relwidth=0.65, rely=0.45, relheight=0.1)
winIDEA()
Debugger()
def Other():
other = LabelFrame(envFrame, text="Other")
other.place(relx=0.67, relwidth=0.32, rely=0.01, relheight=0.95)
testCode = Button(other, text="代码生成", command="lambda: test()")
testCode.place(relx=0.12, relwidth=0.2, rely=0.02, relheight=0.1)
Other()
这个代码转换为 pyqt6的代码实现,并且能正常运行起来, 原来界面布局不变化
最新发布