From a5366f5666b8279424e991ea34e22c9286412cde Mon Sep 17 00:00:00 2001 From: py2cn Date: Wed, 18 Aug 2021 23:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dreadme=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=EF=BC=8C=E5=87=86?= =?UTF-8?q?=E5=A4=87=E8=B0=83=E6=95=B4=E4=B8=BB=E7=A8=8B=E5=BA=8F=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 37 +++++++++++++++++++++++-------------- pyminer/__main__.py | 5 +++++ pyminer/app2.py | 37 ++++++++++++++++++++++++++++++------- pyminer/utils/__init__.py | 8 +++++--- pyminer/utils/environ.py | 23 ++++++++++++++++++----- pyminer/utils/path.py | 9 +++++++++ pyminer/utils/platform.py | 4 ++-- 7 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 pyminer/__main__.py diff --git a/README.md b/README.md index e02daced..1f3e11c5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- +

@@ -110,7 +110,7 @@ pyminer希望成为一个伟大的开源项目,也希望得到大家的认可 2. 建议新建全新的虚拟环境,尤其是当旧的虚拟环境中存在其他依赖于PyQt/PySide2的程序时。pyminer与这些程序可能发生依赖冲突。 -#### Windows安装 +#### Windows安装 pyminer ```bash #第一步:下载源代码 @@ -118,7 +118,22 @@ git clone https://gitee.com/py2cn/pyminer.git #安装依赖 (如果下载太慢,请复制源码目录下的 pip.ini 文件到python安装目录下) pip install pyminer #第三步:运行主程序 -python app2.py +在控制台输入 pyminer 回车,即可打开pyminer + + +``` + +#### 虚拟环境安装 pyminer + +```bash +#第一步:创建pip虚拟环境 +pip install pipenv +pipenv --three # 使用当前系统中的python3创建环境 +#第二步:启动当前目录下的虚拟环境 +pipenv shell +#第三步:为虚拟环境安装pyminer +pipenv install pyminer -i https://mirrors.cloud.tencent.com/pypi/simple + ``` @@ -141,24 +156,18 @@ pyminer项目现在的开发目标是,打造初学者友好的Python编程环 作者:pyminer Development Team -邮箱:team@py2cn.com +邮箱:team@pyminer.com 欢迎各位开发者大佬加入

-QQ群 +QQ群

-## 📱 支持我们 -
-微信支付 -支付宝 -
- ## 🚥 许可说明 本项目遵循LGPL许可证。 @@ -168,11 +177,11 @@ pyminer项目现在的开发目标是,打造初学者友好的Python编程环 ## 📸 预览截图 基本界面 -![avatar](src/pyminer/resources/screenshot/main.png) +![avatar](pyminer/resources/screenshot/main.png) 代码提示 -![avatar](src/pyminer/resources/screenshot/code.png) +![avatar](pyminer/resources/screenshot/code.png) 绘图 -![avatar](src/pyminer/resources/screenshot/check_data.png) +![avatar](pyminer/resources/screenshot/check_data.png) diff --git a/pyminer/__main__.py b/pyminer/__main__.py new file mode 100644 index 00000000..7f16ed1f --- /dev/null +++ b/pyminer/__main__.py @@ -0,0 +1,5 @@ +from app2 import main + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/pyminer/app2.py b/pyminer/app2.py index bb3d1258..0d1717df 100644 --- a/pyminer/app2.py +++ b/pyminer/app2.py @@ -17,8 +17,11 @@ import time import traceback from multiprocessing import shared_memory + sys.path.append(os.path.dirname(__file__)) -sys.path.append(os.path.join(os.path.dirname(__file__), "resources")) + +import utils +sys.path.append(utils.get_resources_dir()) # 异常处理设置 cgitb.enable(format='text') @@ -51,17 +54,15 @@ sys.excepthook.handle = exception_handler import PySide2 -dirname = os.path.dirname(PySide2.__file__) -plugin_path = os.path.join(dirname, 'plugins', 'platforms') -os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path +os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = utils.get_pysideplugins_directory() os.environ['QT_API'] = 'pyside2' os.environ['PYQTGRAPH_QT_LIB'] = 'PySide2' os.environ['FORCE_QT_API'] = "1" from typing import List, Callable, Tuple, ClassVar, Optional from PySide2.QtCore import Signal, QTimer, Qt, QCoreApplication -from PySide2.QtGui import QCloseEvent, QTextCursor, QResizeEvent, QMoveEvent, QFont, QIcon, QPixmap +from PySide2.QtGui import QCloseEvent, QCursor, QTextCursor, QResizeEvent, QMoveEvent, QFont, QIcon, QPixmap from PySide2.QtWidgets import QApplication, QMessageBox, QSplashScreen, QStatusBar, QDialog, QVBoxLayout, QProgressBar import pmgwidgets @@ -78,7 +79,7 @@ from features.ui.widgets.controlpanel import PMPageExt from features.ui.pmwidgets import BaseMainWindow from features.io.exceptions import PMExceptions from features.pluginsmanager.pluginsmanager import MarketplaceForm -import utils + from load_modules import load_translator, load_fonts from pmgui import PMToolBarHome, LogOutputConsole @@ -143,6 +144,7 @@ class MainWindow(BaseMainWindow): extensions: 如果指定,则仅加载指定的插件,否则加载全部插件 """ super().__init__(parent) + self.setWindowFlags(Qt.FramelessWindowHint) self.extension_names = extensions # 需要加载的插件名称 # settings = Settings() t00 = time.time() @@ -233,6 +235,27 @@ class MainWindow(BaseMainWindow): self.dock_widgets[k].widget().closeEvent(a0) super().closeEvent(a0) + def mousePressEvent(self, event): + if event.button()==Qt.LeftButton: + self.m_flag=True + self.m_Position=event.globalPos()-self.pos() + event.accept() + self.setCursor(QCursor(Qt.OpenHandCursor)) + + def mouseMoveEvent(self, QMouseEvent): + if Qt.LeftButton and self.m_flag: + self.move(QMouseEvent.globalPos()-self.m_Position) + QMouseEvent.accept() + + def mouseReleaseEvent(self, QMouseEvent): + self.m_flag=False + self.setCursor(QCursor(Qt.ArrowCursor)) + + def mouseDoubleClickEvent(self, event): + self.window_maximum() + event.accept() # 接受事件,禁止传到父控件 + + def moveEvent(self, a0: 'QMoveEvent') -> None: self.window_geometry_changed_signal.emit() @@ -353,7 +376,7 @@ class MainWindow(BaseMainWindow): def login_form_display(self): """ 显示"登录"窗口 - Displays the "Quick Action" window + Displays the "Login In" window """ shared_memo = shared_memory.SharedMemory(name="sharedMemory") # 通过name找到共享内存token buff = shared_memo.buf diff --git a/pyminer/utils/__init__.py b/pyminer/utils/__init__.py index e565842a..3e96dcc2 100644 --- a/pyminer/utils/__init__.py +++ b/pyminer/utils/__init__.py @@ -9,13 +9,15 @@ from .debug import * from .environ import ( get_python_version, get_python_modules_directory, - getPySideModulesDirectory, - getScriptsPath, - getDesignerPath + get_pysidemodules_directory, + get_pysideplugins_directory, + get_scripts_path, + get_designer_path ) from .io import * from .path import ( get_root_dir, + get_resources_dir, get_user_dir, get_desktop_dir, get_documents_dir, diff --git a/pyminer/utils/environ.py b/pyminer/utils/environ.py index c2ee544a..3283d683 100644 --- a/pyminer/utils/environ.py +++ b/pyminer/utils/environ.py @@ -25,11 +25,11 @@ def get_python_modules_directory(): return distutils.sysconfig.get_python_lib(True) -def getPySideModulesDirectory(version=2): +def get_pysidemodules_directory(version=2): """ - Function to determine the path to PyQt5 modules directory. + Function to determine the path to PySide2 modules directory. - @return path to the PyQt5 modules directory (string) + @return path to the PySide2 modules directory (string) """ import distutils.sysconfig @@ -39,8 +39,21 @@ def getPySideModulesDirectory(version=2): return "" +def get_pysideplugins_directory(version=2): + """ + Function to determine the path to PySide2 plugins directory. + + @return path to the PySide2 plugins directory (string) + """ + import distutils.sysconfig + dirname = get_pysidemodules_directory() + PySidePath = os.path.join(dirname, 'plugins', 'platforms') + if os.path.exists(PySidePath): + return PySidePath + + return "" -def getScriptsPath(version=2): +def get_scripts_path(version=2): """ Module function to get the path of the PySide tools. @@ -68,7 +81,7 @@ def getScriptsPath(version=2): return path -def getDesignerPath(version=2): +def get_designer_path(version=2): """ Module function to get the path of the Qt binaries. diff --git a/pyminer/utils/path.py b/pyminer/utils/path.py index fc36a962..ea087385 100644 --- a/pyminer/utils/path.py +++ b/pyminer/utils/path.py @@ -19,6 +19,15 @@ def get_root_dir() -> str: path = os.path.dirname(os.path.dirname(__file__)) return path +def get_resources_dir() -> str: + """ + 获取根路径。 + Returns: + + """ + path = os.path.join(get_root_dir(),'resources') + return path + def get_user_dir() -> str: """ diff --git a/pyminer/utils/platform.py b/pyminer/utils/platform.py index d050ee11..bd1f9625 100644 --- a/pyminer/utils/platform.py +++ b/pyminer/utils/platform.py @@ -37,7 +37,7 @@ def is_kde_desktop(): @return flag indicating a KDE desktop @rtype bool """ - if not isLinuxPlatform(): + if not is_linux_platform(): return False isKDE = False @@ -62,7 +62,7 @@ def is_gnome_desktop(): @return flag indicating a Gnome desktop @rtype bool """ - if not isLinuxPlatform(): + if not is_linux_platform(): return False isGnome = False -- Gitee