Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
program-updater
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
program-updater
Commits
1fe37dcd
Commit
1fe37dcd
authored
Oct 29, 2026
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: 更新readme
parent
d0d64dfd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
README.md
updater/README.md
+4
-4
No files found.
updater/README.md
View file @
1fe37dcd
...
@@ -150,19 +150,19 @@ def main() -> int:
...
@@ -150,19 +150,19 @@ def main() -> int:
),
),
)
)
progress
=
QProgressDialog
(
"正在
检查
更新…"
,
""
,
0
,
0
)
progress
=
QProgressDialog
(
"正在
下载
更新…"
,
""
,
0
,
0
)
progress
.
setWindowTitle
(
"程序更新"
)
progress
.
setWindowTitle
(
"程序更新"
)
progress
.
setWindowModality
(
Qt
.
WindowModal
)
progress
.
setWindowModality
(
Qt
.
WindowModal
)
progress
.
setMinimumDuration
(
0
)
progress
.
setMinimumDuration
(
0
)
progress
.
setAutoClose
(
False
)
progress
.
setAutoClose
(
False
)
progress
.
setAutoReset
(
False
)
progress
.
setAutoReset
(
False
)
progress
.
show
()
QApplication
.
processEvents
()
def
on_progress
(
downloaded
:
int
,
total
:
int
)
->
None
:
def
on_progress
(
downloaded
:
int
,
total
:
int
)
->
None
:
progress
.
setLabelText
(
"正在下载更新…"
)
progress
.
setLabelText
(
"正在下载更新…"
)
progress
.
setRange
(
0
,
1000
)
progress
.
setRange
(
0
,
1000
)
progress
.
setValue
(
int
(
downloaded
*
1000
/
total
)
if
total
else
0
)
progress
.
setValue
(
int
(
downloaded
*
1000
/
total
)
if
total
else
0
)
if
not
progress
.
isVisible
():
progress
.
show
()
QApplication
.
processEvents
()
QApplication
.
processEvents
()
def
confirm_update
(
update
)
->
bool
:
def
confirm_update
(
update
)
->
bool
:
...
@@ -209,7 +209,7 @@ if __name__ == "__main__":
...
@@ -209,7 +209,7 @@ if __name__ == "__main__":
raise
SystemExit
(
main
())
raise
SystemExit
(
main
())
```
```
示例中的
`on_progress(downloaded, total)`
是下载进度回调,可以用它驱动 QProgressDialog 等进度条。更新流程在调用线程中同步执行,所以需要在回调里调用
`QApplication.processEvents()`
让界面刷新;其他 GUI 框架使用对应的消息处理函数。
示例中的
`on_progress(downloaded, total)`
是下载进度回调,可以用它驱动 QProgressDialog 等进度条。更新流程在调用线程中同步执行,所以需要在回调里调用
`QApplication.processEvents()`
让界面刷新;其他 GUI 框架使用对应的消息处理函数。
不要在检查更新之前调用
`progress.show()`
,否则即使已经是最新版本,每次启动也会闪出进度框;只在用户确认更新或第一次收到下载进度时显示。
`update_before_startup()`
会同步检查清单。选择“否”时本次继续启动旧版,下次启动会再次提醒;选择“是”时才下载和校验 exe、启动 helper,并返回
`True`
。目标进程随后退出,helper 替换 exe 并自动启动新版。新版启动检查时发现已是最新版本,就会继续启动主窗口。LAN 服务不可用或更新失败时,上例记录错误并继续启动旧版;强制更新的程序可以改为提示错误并停止启动。
`update_before_startup()`
会同步检查清单。选择“否”时本次继续启动旧版,下次启动会再次提醒;选择“是”时才下载和校验 exe、启动 helper,并返回
`True`
。目标进程随后退出,helper 替换 exe 并自动启动新版。新版启动检查时发现已是最新版本,就会继续启动主窗口。LAN 服务不可用或更新失败时,上例记录错误并继续启动旧版;强制更新的程序可以改为提示错误并停止启动。
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment