Skip to content

Commit cb07608

Browse files
committed
add version in mainwindow title
1 parent 6a782db commit cb07608

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

pyfmm_gui/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2"
1+
__version__ = "0.2.1"

pyfmm_gui/main.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
from scipy.ndimage import gaussian_filter
1919

2020
from .subwidget import MatplotlibWidget
21-
from .utils import try_except_decorator
21+
from .utils import try_except_decorator, read_version
2222

2323

2424
class MainWindow(QMainWindow):
2525
def __init__(self):
2626
super().__init__()
2727
uic.loadUi(os.path.join(os.path.dirname(__file__), "main.ui"), self) # 加载 UI 文件
2828

29+
# 设置标题
30+
self.version = read_version()
31+
self.setWindowTitle(f"PyFMM-GUI v{self.version}")
2932

3033
self.mplwidget = MatplotlibWidget(self)
3134

pyfmm_gui/utils.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"""
2+
:file: utils.py
3+
:author: Zhu Dengda ([email protected])
4+
:date: 2024-11
5+
6+
辅助函数
7+
8+
"""
9+
10+
import os
111

212
def try_except_decorator(status_bar_str):
313
def decorator(func):
@@ -9,4 +19,11 @@ def wrapper(self, *args, **kwargs):
919
status_bar.showMessage(f"Error! {str(e)}", 3000)
1020

1121
return wrapper
12-
return decorator
22+
return decorator
23+
24+
25+
# 读取版本号
26+
def read_version():
27+
with open(os.path.join(os.path.dirname(__file__), "_version.py")) as f:
28+
exec(f.read())
29+
return locals()['__version__']

0 commit comments

Comments
 (0)