NepTrainKit 2.0.4__tar.gz → 2.0.5.dev82__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/MANIFEST.in +1 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/PKG-INFO +3 -2
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/pyproject.toml +2 -1
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/requirements.txt +2 -1
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/setup.py +19 -4
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/__init__.py +2 -3
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/_version.py +2 -2
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/calculator.py +9 -6
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/canvas/base/canvas.py +1 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/canvas/pyqtgraph/canvas.py +6 -9
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/canvas/vispy/canvas.py +6 -15
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/config.py +5 -3
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/__init__.py +14 -0
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/card_widget.py +99 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/custom_widget/completer.py +2 -4
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/custom_widget/dialog.py +2 -2
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/docker.py +99 -0
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/input.py +50 -0
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/label.py +56 -0
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/custom_widget/layout.py +99 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/custom_widget/search_widget.py +3 -3
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/custom_widget/settingscard.py +1 -2
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/io/nep.py +613 -0
- {neptrainkit-2.0.4/src/NepTrainKit/core/widget → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/pages}/__init__.py +2 -2
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/pages/makedata.py +215 -0
- {neptrainkit-2.0.4/src/NepTrainKit/core/widget → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/pages}/settings.py +9 -10
- {neptrainkit-2.0.4/src/NepTrainKit/core/widget → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/pages}/show_nep.py +50 -21
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/structure.py +118 -8
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/types.py +2 -1
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/update.py +2 -7
- neptrainkit-2.0.5.dev82/src/NepTrainKit/core/views/cards.py +1082 -0
- {neptrainkit-2.0.4/src/NepTrainKit/core/plot → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/views}/nep.py +8 -16
- {neptrainkit-2.0.4/src/NepTrainKit/core/plot → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/views}/structure.py +105 -30
- {neptrainkit-2.0.4/src/NepTrainKit/core/plot → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/views}/toolbar.py +2 -2
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/main.py +27 -12
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/src_rc.py +1568 -875
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/utils.py +75 -8
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/PKG-INFO +3 -2
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/SOURCES.txt +13 -8
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/requires.txt +1 -0
- neptrainkit-2.0.4/src/NepTrainKit/core/custom_widget/__init__.py +0 -5
- neptrainkit-2.0.4/src/NepTrainKit/core/custom_widget/card_widget.py +0 -28
- neptrainkit-2.0.4/src/NepTrainKit/core/io/nep.py +0 -556
- neptrainkit-2.0.4/src/NepTrainKit/core/widget/makedata.py +0 -61
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/.gitattributes +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/.readthedocs.yml +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/LICENSE +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/README.md +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/setup.cfg +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/Config/config.sqlite +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/Config/ptable.json +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/__init__.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/io/__init__.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/io/base.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/io/select.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/io/utils.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/message.py +0 -0
- {neptrainkit-2.0.4/src/NepTrainKit/core/plot → neptrainkit-2.0.5.dev82/src/NepTrainKit/core/views}/__init__.py +1 -1
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/version.py +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/dependency_links.txt +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/entry_points.txt +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/not-zip-safe +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit.egg-info/top_level.txt +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/nep_cpu/dftd3para.h +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/nep_cpu/nep.cpp +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/nep_cpu/nep.h +0 -0
- {neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/nep_cpu/nep_cpu.cpp +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: NepTrainKit
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5.dev82
|
|
4
4
|
Summary: NepTrainKit is a Python package for visualizing and manipulating training datasets for NEP.
|
|
5
5
|
Author: Chen Cheng bing
|
|
6
6
|
Author-email: Chen Cheng bing <1747193328@qq.com>
|
|
@@ -20,10 +20,11 @@ Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
|
20
20
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
21
21
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
-
Requires-Python: <3.13,>=3.
|
|
23
|
+
Requires-Python: <3.13,>=3.10
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: PySide6-Fluent-Widgets>=1.7.0
|
|
27
|
+
Requires-Dist: sobolsequence
|
|
27
28
|
Requires-Dist: loguru>=0.7.2
|
|
28
29
|
Requires-Dist: requests>=2.32.3
|
|
29
30
|
Requires-Dist: pyqtgraph>=0.13.7
|
|
@@ -18,7 +18,7 @@ description = """
|
|
|
18
18
|
NepTrainKit is a Python package for visualizing and manipulating training datasets for NEP.
|
|
19
19
|
"""
|
|
20
20
|
readme = "README.md"
|
|
21
|
-
requires-python = ">=3.
|
|
21
|
+
requires-python = ">=3.10,<3.13"
|
|
22
22
|
license= { "text"="GPL-3.0" }
|
|
23
23
|
classifiers = [
|
|
24
24
|
"Development Status :: 4 - Beta",
|
|
@@ -36,6 +36,7 @@ classifiers = [
|
|
|
36
36
|
dependencies = [
|
|
37
37
|
|
|
38
38
|
"PySide6-Fluent-Widgets>=1.7.0",
|
|
39
|
+
"sobolsequence",
|
|
39
40
|
"loguru>=0.7.2",
|
|
40
41
|
"requests>=2.32.3",
|
|
41
42
|
"pyqtgraph>=0.13.7",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
1
|
+
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
# @Time : 2024/10/24 14:22
|
|
4
4
|
# @Author : 兵
|
|
5
5
|
# @email : 1747193328@qq.com
|
|
6
|
-
"""
|
|
6
|
+
"""NepTrainKit package configuration."""
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
import tempfile
|
|
@@ -36,16 +36,23 @@ if sys.platform == "win32":
|
|
|
36
36
|
extra_compile_args.append('/O2' )
|
|
37
37
|
extra_compile_args.append('/std:c++11' )
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
|
|
39
41
|
extra_link_args.append('/openmp')
|
|
40
42
|
extra_link_args.append('/O2' )
|
|
41
43
|
extra_link_args.append('/std:c++11' )
|
|
44
|
+
|
|
45
|
+
|
|
42
46
|
elif sys.platform == "darwin":
|
|
43
47
|
# 对于 macOS 和 Clang 使用 -fopenmp 编译标志
|
|
44
48
|
# Clang 好像不支持openmp 先注释掉
|
|
45
49
|
# extra_compile_args.append('-fopenmp' )
|
|
46
|
-
#
|
|
50
|
+
#
|
|
47
51
|
# extra_link_args.append('-fopenmp')
|
|
48
|
-
|
|
52
|
+
# 通过环境变量获取目标架构,默认为 arm64(Apple Silicon)
|
|
53
|
+
target_arch = os.environ.get('ARCHFLAGS', '-arch arm64').split()[-1]
|
|
54
|
+
# extra_compile_args.append(f'-arch {target_arch}')
|
|
55
|
+
# extra_link_args.append(f'-arch {target_arch}')
|
|
49
56
|
|
|
50
57
|
extra_compile_args.append('-O3')
|
|
51
58
|
extra_compile_args.append('-std=c++11')
|
|
@@ -53,6 +60,12 @@ elif sys.platform == "darwin":
|
|
|
53
60
|
|
|
54
61
|
extra_link_args.append('-O3')
|
|
55
62
|
extra_link_args.append('-std=c++11')
|
|
63
|
+
|
|
64
|
+
omp_include = os.getenv("OMP_INCLUDE_PATH", "/opt/homebrew/opt/libomp/include")
|
|
65
|
+
omp_lib = os.getenv("OMP_LIB_PATH", "/opt/homebrew/opt/libomp/lib")
|
|
66
|
+
extra_compile_args.extend(["-Xpreprocessor", "-fopenmp", f"-I{omp_include}"])
|
|
67
|
+
extra_link_args.extend(["-lomp", f"-L{omp_lib}"])
|
|
68
|
+
|
|
56
69
|
pass
|
|
57
70
|
|
|
58
71
|
else:
|
|
@@ -62,10 +75,12 @@ else:
|
|
|
62
75
|
extra_compile_args.append('-O3')
|
|
63
76
|
extra_compile_args.append('-std=c++11')
|
|
64
77
|
|
|
78
|
+
|
|
65
79
|
extra_link_args.append('-fopenmp')
|
|
66
80
|
extra_link_args.append('-O3')
|
|
67
81
|
extra_link_args.append('-std=c++11')
|
|
68
82
|
|
|
83
|
+
|
|
69
84
|
# 定义扩展模块
|
|
70
85
|
ext_modules = [
|
|
71
86
|
Extension(
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
# @Time : 2024/11/28 12:52
|
|
4
|
-
# @Author :
|
|
4
|
+
# @Author :
|
|
5
5
|
# @email : 1747193328@qq.com
|
|
6
6
|
import os
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
from loguru import logger
|
|
10
9
|
|
|
11
10
|
try:
|
|
@@ -19,7 +18,7 @@ except NameError:
|
|
|
19
18
|
|
|
20
19
|
if is_nuitka_compiled:
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
logger.add("./Log/{time:%Y-%m}.log",
|
|
24
23
|
level="INFO",
|
|
25
24
|
)
|
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '2.0.
|
|
21
|
-
__version_tuple__ = version_tuple = (2, 0,
|
|
20
|
+
__version__ = version = '2.0.5.dev82'
|
|
21
|
+
__version_tuple__ = version_tuple = (2, 0, 5, 'dev82')
|
|
@@ -6,15 +6,14 @@
|
|
|
6
6
|
import contextlib
|
|
7
7
|
import multiprocessing
|
|
8
8
|
import os
|
|
9
|
-
import sys
|
|
10
9
|
import traceback
|
|
11
10
|
|
|
12
11
|
import numpy as np
|
|
13
|
-
from PySide6.QtCore import QObject
|
|
14
12
|
from loguru import logger
|
|
15
13
|
|
|
16
14
|
from NepTrainKit import utils
|
|
17
|
-
from NepTrainKit.core import Structure,MessageManager
|
|
15
|
+
from NepTrainKit.core import Structure, MessageManager
|
|
16
|
+
|
|
18
17
|
try:
|
|
19
18
|
from NepTrainKit.nep_cpu import CpuNep
|
|
20
19
|
except ImportError:
|
|
@@ -32,11 +31,12 @@ class Nep3Calculator( ):
|
|
|
32
31
|
super().__init__()
|
|
33
32
|
if not isinstance(model_file, str):
|
|
34
33
|
model_file = str(model_file )
|
|
34
|
+
self.initialized = False
|
|
35
35
|
|
|
36
36
|
if CpuNep is None:
|
|
37
37
|
MessageManager.send_message_box("Failed to import nep_cpu.\n To use the display functionality normally, please prepare the *_train.out and descriptor.out files.","Error")
|
|
38
|
-
|
|
39
|
-
return
|
|
38
|
+
|
|
39
|
+
return
|
|
40
40
|
|
|
41
41
|
if os.path.exists(model_file):
|
|
42
42
|
|
|
@@ -49,7 +49,7 @@ class Nep3Calculator( ):
|
|
|
49
49
|
self.element_list=self.nep3.get_element_list()
|
|
50
50
|
self.type_dict = {e: i for i, e in enumerate(self.element_list)}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
self.initialized = True
|
|
53
53
|
|
|
54
54
|
def compose_structures(self, structures:list[Structure]):
|
|
55
55
|
group_size = []
|
|
@@ -114,6 +114,9 @@ class Nep3Calculator( ):
|
|
|
114
114
|
return descriptors_per_atom
|
|
115
115
|
@utils.timeit
|
|
116
116
|
def get_structures_descriptor(self,structures:list[Structure]):
|
|
117
|
+
"""
|
|
118
|
+
返回的已经结构的描述符了 无需平均
|
|
119
|
+
"""
|
|
117
120
|
if not self.initialized:
|
|
118
121
|
return np.array([])
|
|
119
122
|
_types, _boxs, _positions, group_size = self.compose_structures(structures)
|
{neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/canvas/pyqtgraph/canvas.py
RENAMED
|
@@ -5,20 +5,17 @@
|
|
|
5
5
|
# @email : 1747193328@qq.com
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
from functools import partial
|
|
9
9
|
|
|
10
|
+
import numpy as np
|
|
11
|
+
import pyqtgraph as pg
|
|
12
|
+
from PySide6.QtCore import Qt
|
|
13
|
+
from pyqtgraph import GraphicsLayoutWidget, mkPen, ScatterPlotItem, PlotItem, ViewBox, TextItem
|
|
10
14
|
|
|
11
15
|
from NepTrainKit import utils
|
|
12
|
-
from PySide6.QtCore import Signal, Qt
|
|
13
|
-
from pyqtgraph import GraphicsLayoutWidget, mkPen, ScatterPlotItem, PlotItem, GraphicsView, ViewBox, TextItem
|
|
14
|
-
from ..base.canvas import CanvasBase,CanvasLayoutBase
|
|
15
16
|
from NepTrainKit.core.types import Brushes, Pens
|
|
16
|
-
|
|
17
|
-
from functools import partial
|
|
18
|
-
|
|
19
|
-
from ... import MessageManager
|
|
17
|
+
from ..base.canvas import CanvasLayoutBase
|
|
20
18
|
from ...io import NepTrainResultData
|
|
21
|
-
import pyqtgraph as pg
|
|
22
19
|
|
|
23
20
|
pg.setConfigOption('background', 'w') # 设置背景为白色
|
|
24
21
|
pg.setConfigOption('foreground', 'k') # 设置前景元素为黑色(如坐标轴)
|
|
@@ -14,28 +14,19 @@
|
|
|
14
14
|
|
|
15
15
|
import numpy as np
|
|
16
16
|
import vispy
|
|
17
|
-
from PySide6.QtGui import QBrush, QColor, QPen
|
|
18
|
-
from
|
|
17
|
+
from PySide6.QtGui import QBrush, QColor, QPen
|
|
18
|
+
from vispy import scene
|
|
19
|
+
# 不要去掉
|
|
20
|
+
from vispy.app.backends import _pyside6
|
|
19
21
|
from vispy.color import ColorArray
|
|
20
22
|
from vispy.visuals.filters import MarkerPickingFilter
|
|
21
23
|
|
|
22
24
|
from NepTrainKit import utils
|
|
23
|
-
from
|
|
24
|
-
#不要去掉
|
|
25
|
-
from vispy.app.backends import _pyside6
|
|
26
|
-
from vispy import scene
|
|
27
|
-
|
|
28
|
-
from vispy.app import use_app
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
from NepTrainKit.core import MessageManager
|
|
32
|
-
from NepTrainKit.core.canvas.base.canvas import CanvasLayoutBase, VispyCanvasLayoutBase
|
|
25
|
+
from NepTrainKit.core.canvas.base.canvas import VispyCanvasLayoutBase
|
|
33
26
|
from NepTrainKit.core.io import NepTrainResultData
|
|
34
27
|
from NepTrainKit.core.types import Brushes, Pens
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
_pyside6
|
|
39
30
|
vispy.use("PySide6", "gl2")
|
|
40
31
|
|
|
41
32
|
class ViewBoxWidget(scene.Widget):
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
|
-
|
|
3
|
-
from PySide6.QtSql import QSqlDatabase, QSqlDriver, QSqlQuery,QSql
|
|
4
2
|
import platform
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
from PySide6.QtSql import QSqlDatabase, QSqlQuery
|
|
6
|
+
|
|
5
7
|
from NepTrainKit import module_path
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
|
|
8
10
|
class Config:
|
|
9
11
|
"""
|
|
10
12
|
使用数据库保存软件配置
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2024/11/28 22:45
|
|
4
|
+
# @Author : 兵
|
|
5
|
+
# @email : 1747193328@qq.com
|
|
6
|
+
from .layout import *
|
|
7
|
+
from .label import *
|
|
8
|
+
from .completer import *
|
|
9
|
+
from .dialog import *
|
|
10
|
+
from .input import *
|
|
11
|
+
from .card_widget import *
|
|
12
|
+
from .docker import *
|
|
13
|
+
from .search_widget import *
|
|
14
|
+
from .settingscard import *
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2025/1/7 23:23
|
|
4
|
+
# @Author : 兵
|
|
5
|
+
# @email : 1747193328@qq.com
|
|
6
|
+
from PySide6.QtCore import Qt, Signal, QMimeData
|
|
7
|
+
from PySide6.QtGui import QIcon, QDrag, QPixmap
|
|
8
|
+
from PySide6.QtWidgets import QWidget, QVBoxLayout, QGridLayout
|
|
9
|
+
from qfluentwidgets import HeaderCardWidget, CheckBox, TransparentToolButton
|
|
10
|
+
|
|
11
|
+
from NepTrainKit.core import MessageManager
|
|
12
|
+
|
|
13
|
+
from qfluentwidgets import FluentIcon as FIF
|
|
14
|
+
from NepTrainKit.core.custom_widget import ProcessLabel
|
|
15
|
+
from NepTrainKit import utils
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CheckableHeaderCardWidget(HeaderCardWidget):
|
|
20
|
+
|
|
21
|
+
def __init__(self, parent=None):
|
|
22
|
+
super(CheckableHeaderCardWidget, self).__init__(parent)
|
|
23
|
+
self.state_checkbox=CheckBox()
|
|
24
|
+
self.state_checkbox.setChecked(True)
|
|
25
|
+
self.state_checkbox.stateChanged.connect(self.state_changed)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
self.headerLayout.insertWidget(0, self.state_checkbox, 0,Qt.AlignmentFlag.AlignLeft)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
self.headerLayout.setStretch(1, 3)
|
|
32
|
+
self.headerLayout.setContentsMargins(10, 0, 3, 0)
|
|
33
|
+
self.headerLayout.setSpacing(3)
|
|
34
|
+
self.viewLayout.setContentsMargins(6, 0, 6, 0)
|
|
35
|
+
self.headerLayout.setAlignment(self.headerLabel, Qt.AlignmentFlag.AlignLeft)
|
|
36
|
+
self.check_state=True
|
|
37
|
+
def state_changed(self, state):
|
|
38
|
+
if state == 2:
|
|
39
|
+
self.check_state = True
|
|
40
|
+
else:
|
|
41
|
+
self.check_state = False
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ShareCheckableHeaderCardWidget(CheckableHeaderCardWidget):
|
|
45
|
+
exportSignal=Signal()
|
|
46
|
+
def __init__(self, parent=None):
|
|
47
|
+
super(ShareCheckableHeaderCardWidget, self).__init__(parent)
|
|
48
|
+
self.export_button=TransparentToolButton(QIcon(":/images/src/images/export1.svg"),self)
|
|
49
|
+
self.export_button.clicked.connect(self.exportSignal)
|
|
50
|
+
|
|
51
|
+
self.close_button=TransparentToolButton(FIF.CLOSE,self)
|
|
52
|
+
self.close_button.clicked.connect(self.close)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
self.headerLayout.addWidget(self.export_button, 0, Qt.AlignmentFlag.AlignRight)
|
|
56
|
+
self.headerLayout.addWidget(self.close_button, 0, Qt.AlignmentFlag.AlignRight)
|
|
57
|
+
|
|
58
|
+
class MakeDataCardWidget(ShareCheckableHeaderCardWidget):
|
|
59
|
+
windowStateChangedSignal=Signal( )
|
|
60
|
+
def __init__(self, parent=None):
|
|
61
|
+
super().__init__(parent)
|
|
62
|
+
self.setMouseTracking(True)
|
|
63
|
+
self.window_state="expand"
|
|
64
|
+
self.collapse_button=TransparentToolButton(QIcon(":/images/src/images/collapse.svg"),self)
|
|
65
|
+
self.collapse_button.clicked.connect(self.collapse)
|
|
66
|
+
self.headerLayout.insertWidget(0, self.collapse_button, 0,Qt.AlignmentFlag.AlignLeft)
|
|
67
|
+
self.windowStateChangedSignal.connect(self.update_window_state)
|
|
68
|
+
|
|
69
|
+
def mouseMoveEvent(self, e):
|
|
70
|
+
if e.buttons() != Qt.LeftButton:
|
|
71
|
+
return
|
|
72
|
+
drag = QDrag(self)
|
|
73
|
+
mime = QMimeData()
|
|
74
|
+
drag.setMimeData(mime)
|
|
75
|
+
|
|
76
|
+
# 显示拖拽时的控件预览
|
|
77
|
+
pixmap = QPixmap(self.size())
|
|
78
|
+
self.render(pixmap)
|
|
79
|
+
drag.setPixmap(pixmap)
|
|
80
|
+
drag.setHotSpot(e.pos())
|
|
81
|
+
|
|
82
|
+
drag.exec(Qt.MoveAction)
|
|
83
|
+
def collapse(self):
|
|
84
|
+
|
|
85
|
+
if self.window_state == "collapse":
|
|
86
|
+
self.window_state = "expand"
|
|
87
|
+
else:
|
|
88
|
+
|
|
89
|
+
self.window_state = "collapse"
|
|
90
|
+
|
|
91
|
+
self.windowStateChangedSignal.emit( )
|
|
92
|
+
def update_window_state(self):
|
|
93
|
+
if self.window_state == "expand":
|
|
94
|
+
self.collapse_button.setIcon(QIcon(":/images/src/images/collapse.svg"))
|
|
95
|
+
else:
|
|
96
|
+
self.collapse_button.setIcon(QIcon(":/images/src/images/expand.svg"))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
{neptrainkit-2.0.4 → neptrainkit-2.0.5.dev82}/src/NepTrainKit/core/custom_widget/completer.py
RENAMED
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
# @email : 1747193328@qq.com
|
|
6
6
|
from collections import defaultdict
|
|
7
7
|
|
|
8
|
-
from PySide6.QtCore import Qt, QAbstractListModel, QModelIndex
|
|
9
|
-
from PySide6.
|
|
10
|
-
from PySide6.QtWidgets import QApplication, QMainWindow, QLineEdit, QCompleter, QVBoxLayout, QWidget, \
|
|
11
|
-
QStyleOptionViewItem, QStyledItemDelegate, QStyle
|
|
8
|
+
from PySide6.QtCore import Qt, QAbstractListModel, QModelIndex
|
|
9
|
+
from PySide6.QtWidgets import QApplication, QCompleter, QStyleOptionViewItem, QStyledItemDelegate, QStyle
|
|
12
10
|
|
|
13
11
|
CountRole = Qt.UserRole +1
|
|
14
12
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# @Time : 2024/11/28 22:45
|
|
4
4
|
# @Author : 兵
|
|
5
5
|
# @email : 1747193328@qq.com
|
|
6
|
-
from PySide6.QtWidgets import QVBoxLayout,
|
|
7
|
-
from qfluentwidgets import MessageBoxBase,
|
|
6
|
+
from PySide6.QtWidgets import QVBoxLayout, QFrame, QGridLayout
|
|
7
|
+
from qfluentwidgets import MessageBoxBase, SpinBox, CaptionLabel, DoubleSpinBox, ProgressBar, \
|
|
8
8
|
FluentStyleSheet
|
|
9
9
|
from qframelesswindow import FramelessDialog
|
|
10
10
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2025/4/6 13:27
|
|
4
|
+
# @Author : 兵
|
|
5
|
+
# @email : 1747193328@qq.com
|
|
6
|
+
# !/usr/bin/env python
|
|
7
|
+
# -*- coding: utf-8 -*-
|
|
8
|
+
# @Time : 2024/12/20 17:18
|
|
9
|
+
# @Author : 兵
|
|
10
|
+
# @email : 1747193328@qq.com
|
|
11
|
+
|
|
12
|
+
from PySide6.QtWidgets import QWidget, QApplication, QScrollArea
|
|
13
|
+
|
|
14
|
+
from NepTrainKit.core.custom_widget import FlowLayout
|
|
15
|
+
from NepTrainKit.core.views.cards import CardGroup, MakeDataCard
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MakeWorkflowArea(QScrollArea):
|
|
19
|
+
"""
|
|
20
|
+
微扰训练集制作
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, parent=None):
|
|
24
|
+
super().__init__(parent)
|
|
25
|
+
self._parent = parent
|
|
26
|
+
self.setObjectName("MakeWorkflowArea")
|
|
27
|
+
self.setWidgetResizable(True)
|
|
28
|
+
|
|
29
|
+
self.setAcceptDrops(True)
|
|
30
|
+
|
|
31
|
+
self.init_ui()
|
|
32
|
+
@property
|
|
33
|
+
def cards(self):
|
|
34
|
+
return [item.widget() for item in self.flow_layout.itemList]
|
|
35
|
+
def dragEnterEvent(self, event):
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if isinstance(event.source(), (MakeDataCard,CardGroup)):
|
|
39
|
+
event.acceptProposedAction()
|
|
40
|
+
else:
|
|
41
|
+
event.ignore() # 忽略其他类型的拖拽
|
|
42
|
+
|
|
43
|
+
def dropEvent(self, event):
|
|
44
|
+
|
|
45
|
+
if isinstance(event.source(), (MakeDataCard,CardGroup)):
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
dragged_widget = event.source()
|
|
49
|
+
drag_start_index = self.flow_layout.findWidgetAt(dragged_widget)[0]
|
|
50
|
+
drop_pos = event.position().toPoint()
|
|
51
|
+
drop_index, _ = self.flow_layout.findItemAt(drop_pos)
|
|
52
|
+
|
|
53
|
+
if drop_index == -1:
|
|
54
|
+
drop_index = self.flow_layout.count() - 1
|
|
55
|
+
|
|
56
|
+
drop_index = min(max(0, drop_index), self.flow_layout.count())
|
|
57
|
+
|
|
58
|
+
if drag_start_index==-1:
|
|
59
|
+
self.flow_layout.insertWidget(drop_index,dragged_widget)
|
|
60
|
+
else:
|
|
61
|
+
if drag_start_index != drop_index:
|
|
62
|
+
self.flow_layout.moveItem(drag_start_index, drop_index)
|
|
63
|
+
|
|
64
|
+
self.flow_layout.update()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
event.acceptProposedAction()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def init_ui(self):
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
self.container = QWidget(self)
|
|
76
|
+
self.flow_layout = FlowLayout(self.container)
|
|
77
|
+
self.container.setLayout(self.flow_layout)
|
|
78
|
+
self.setWidget(self.container)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def add_card(self, card):
|
|
83
|
+
self.flow_layout.addWidget(card)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def clear_cards(self):
|
|
87
|
+
for item in self.cards:
|
|
88
|
+
item.close()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
import sys
|
|
93
|
+
|
|
94
|
+
app = QApplication(sys.argv)
|
|
95
|
+
|
|
96
|
+
window = MakeWorkflowArea()
|
|
97
|
+
window.resize(800, 600)
|
|
98
|
+
window.show()
|
|
99
|
+
sys.exit(app.exec())
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2025/4/5 20:11
|
|
4
|
+
# @Author : 兵
|
|
5
|
+
# @email : 1747193328@qq.com
|
|
6
|
+
from PySide6.QtWidgets import QFrame, QHBoxLayout, QSpinBox, QDoubleSpinBox,QLineEdit
|
|
7
|
+
from qfluentwidgets import BodyLabel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SpinBoxUnitInputFrame(QFrame):
|
|
11
|
+
def __init__(self, parent=None):
|
|
12
|
+
super(SpinBoxUnitInputFrame, self).__init__(parent)
|
|
13
|
+
self._layout = QHBoxLayout(self)
|
|
14
|
+
self._layout.setContentsMargins(0, 0, 0, 0)
|
|
15
|
+
self.object_dict = []
|
|
16
|
+
def set_input(self, unit_str,object_num ,input_type="int"):
|
|
17
|
+
if isinstance(unit_str,str):
|
|
18
|
+
unit_str = [unit_str]*object_num
|
|
19
|
+
elif isinstance(unit_str,list):
|
|
20
|
+
unit_str=unit_str
|
|
21
|
+
else:
|
|
22
|
+
raise TypeError('unit_str must be str or list')
|
|
23
|
+
|
|
24
|
+
for i in range(object_num):
|
|
25
|
+
if input_type=="int":
|
|
26
|
+
input_object = QSpinBox(self)
|
|
27
|
+
input_object.setButtonSymbols(QSpinBox.NoButtons)
|
|
28
|
+
elif input_type=="float":
|
|
29
|
+
input_object = QDoubleSpinBox(self)
|
|
30
|
+
input_object.setDecimals(3)
|
|
31
|
+
input_object.setButtonSymbols(QSpinBox.NoButtons)
|
|
32
|
+
else:
|
|
33
|
+
raise TypeError('input_type must be int or float')
|
|
34
|
+
|
|
35
|
+
input_object.setFixedHeight(25)
|
|
36
|
+
self._layout.addWidget(input_object)
|
|
37
|
+
self._layout.addWidget(BodyLabel(unit_str[i%len(unit_str)],self))
|
|
38
|
+
self.object_dict.append(input_object)
|
|
39
|
+
|
|
40
|
+
def setRange(self, min_value, max_value):
|
|
41
|
+
for input_object in self.object_dict:
|
|
42
|
+
input_object.setRange(min_value, max_value)
|
|
43
|
+
|
|
44
|
+
def get_input_value(self):
|
|
45
|
+
|
|
46
|
+
return [input_object.value() for input_object in self.object_dict]
|
|
47
|
+
|
|
48
|
+
def set_input_value(self, value_list):
|
|
49
|
+
for i, input_object in enumerate(self.object_dict):
|
|
50
|
+
input_object.setValue(value_list[i])
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# @Time : 2025/4/7 14:06
|
|
4
|
+
# @Author : 兵
|
|
5
|
+
# @email : 1747193328@qq.com
|
|
6
|
+
from qfluentwidgets import BodyLabel
|
|
7
|
+
|
|
8
|
+
from PySide6.QtGui import QPainter, QLinearGradient, QColor
|
|
9
|
+
from PySide6.QtCore import Qt, QRectF
|
|
10
|
+
|
|
11
|
+
class ProcessLabel(BodyLabel):
|
|
12
|
+
def __init__(self, parent=None):
|
|
13
|
+
super(ProcessLabel, self).__init__(parent)
|
|
14
|
+
|
|
15
|
+
self._progress = 0 # 0~100
|
|
16
|
+
self.set_colors( ["white" ])
|
|
17
|
+
def set_progress(self, value):
|
|
18
|
+
"""设置进度(0-100)"""
|
|
19
|
+
self._progress = max(0, min(100, value))
|
|
20
|
+
self.update() # 触发重绘
|
|
21
|
+
def set_colors(self, colors):
|
|
22
|
+
"""设置渐变颜色列表(QColor对象或十六进制字符串)"""
|
|
23
|
+
if len(colors)==1:
|
|
24
|
+
colors=[colors[0] ]*2
|
|
25
|
+
|
|
26
|
+
self._colors = [QColor(c) if isinstance(c, str) else c for c in colors]
|
|
27
|
+
|
|
28
|
+
self.update()
|
|
29
|
+
|
|
30
|
+
def paintEvent(self, event):
|
|
31
|
+
painter = QPainter(self)
|
|
32
|
+
painter.setRenderHint(QPainter.Antialiasing)
|
|
33
|
+
|
|
34
|
+
# 计算进度对应的宽度
|
|
35
|
+
progress_width = self.width() * (self._progress / 100)
|
|
36
|
+
|
|
37
|
+
# 创建水平渐变
|
|
38
|
+
gradient = QLinearGradient(0, 0, self.width(), 0)
|
|
39
|
+
for i, color in enumerate(self._colors):
|
|
40
|
+
gradient.setColorAt(i / (len(self._colors) - 1), color)
|
|
41
|
+
|
|
42
|
+
# 绘制背景(全宽度,半透明)
|
|
43
|
+
painter.setBrush(gradient)
|
|
44
|
+
painter.setPen(Qt.NoPen)
|
|
45
|
+
painter.drawRect(QRectF(0, 0, self.width(), self.height()))
|
|
46
|
+
|
|
47
|
+
# 绘制进度遮罩(右侧未完成部分用灰色覆盖)
|
|
48
|
+
if self._progress < 100:
|
|
49
|
+
mask_color = QColor("white")
|
|
50
|
+
painter.setBrush(mask_color)
|
|
51
|
+
painter.drawRect(QRectF(progress_width, 0,
|
|
52
|
+
self.width() - progress_width, self.height()))
|
|
53
|
+
|
|
54
|
+
# 可选:绘制进度文本
|
|
55
|
+
painter.setPen(Qt.black)
|
|
56
|
+
painter.drawText(self.rect(), Qt.AlignCenter,self.text())
|