Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
960c9fe5ca | ||
|
|
8fca86e2c9 | ||
|
|
73199b6ec8 | ||
|
|
39e2f60b2e | ||
|
|
16d9609bb8 | ||
|
|
f3f6c9eb6b | ||
|
|
750ed4f4e8 | ||
|
|
127f7133d2 | ||
|
|
5ed12949d3 | ||
|
|
8f559821e7 | ||
|
|
4deb489cbd | ||
|
|
839b7f02ee | ||
|
|
aeea6cb0cb | ||
|
|
4e2d22108d | ||
|
|
71cf617f16 | ||
|
|
cfc03f94e7 | ||
|
|
81d84f0d0d | ||
|
|
1df1853a3f | ||
|
|
f47a9e1701 | ||
|
|
cfd34a8339 |
@@ -9,32 +9,34 @@ on:
|
||||
required: true
|
||||
default: 'dir'
|
||||
jobs:
|
||||
build-linux-x86_64:
|
||||
runs-on: ubuntu-22.04
|
||||
build-linux:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: mamba-org/setup-micromamba@v1
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
init-shell: >-
|
||||
bash
|
||||
# create-args: >-
|
||||
create-args: >-
|
||||
python=3.10
|
||||
- name: pip install cadquery CQ-editor ... etc
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||
sudo apt install -y libxkbcommon0 libxkbcommon-x11-0 libxcb-xinerama0
|
||||
sudo apt install -y libxkbcommon0
|
||||
sudo apt install -y libxkbcommon-x11-0
|
||||
sudo apt install -y libxcb-xinerama0
|
||||
sudo apt install -y qtbase5-dev qt5-qmake
|
||||
micromamba info
|
||||
pip install pyopengl
|
||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
pip install -vvv --pre git+https://github.com/cadquery/cadquery casadi
|
||||
pip install pyinstaller>=5.6
|
||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
||||
pip install path
|
||||
pip install jupyter-rfb
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/gumyr/bd_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d
|
||||
@@ -43,40 +45,37 @@ jobs:
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba activate test
|
||||
micromamba info
|
||||
echo $LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=/home/runner/micromamba/envs/test/lib
|
||||
echo $LD_LIBRARY_PATH
|
||||
pyinstaller --log-level=DEBUG pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: alehechka/upload-tartifact@v2
|
||||
with:
|
||||
name: CQ-editor-Linux-x86_64
|
||||
path: dist
|
||||
build-macos-x86_64:
|
||||
runs-on: macos-13
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: mamba-org/setup-micromamba@v1
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
init-shell: >-
|
||||
bash
|
||||
create-args: >-
|
||||
python=3.10
|
||||
- name: pip install cadquery CQ-editor ... etc
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba info
|
||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
pip install --pre git+https://github.com/cadquery/cadquery casadi
|
||||
pip install pyinstaller>=5.6
|
||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
||||
pip install path
|
||||
pip uninstall -y PyQt5
|
||||
pip install PyQt5==5.15.7
|
||||
pip install PyQtWebEngine==5.15.6
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/gumyr/bd_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d
|
||||
@@ -85,93 +84,48 @@ jobs:
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba activate test
|
||||
micromamba info
|
||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor-mac.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/CQ-editor.sh
|
||||
- uses: actions/upload-artifact@v4
|
||||
cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
- uses: alehechka/upload-tartifact@v1
|
||||
with:
|
||||
name: CQ-editor-MacOS-x86_64
|
||||
path: dist
|
||||
build-macos-arm64:
|
||||
runs-on: macos-14
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: mamba-org/setup-micromamba@v1
|
||||
with:
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
init-shell: >-
|
||||
bash
|
||||
- name: pip install cadquery CQ-editor ... etc
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba info
|
||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
pip install https://github.com/CadQuery/ocp-build-system/releases/download/7.7.2.0/cadquery_ocp-7.7.2-cp311-cp311-macosx_11_0_arm64.whl
|
||||
pip install https://github.com/jdegenstein/nlopt-python/releases/download/2.7.1.3/nlopt-2.7.1-cp311-cp311-macosx_11_0_arm64.whl
|
||||
pip install --pre git+https://github.com/cadquery/cadquery casadi
|
||||
pip install pyinstaller>=5.6
|
||||
pip install path
|
||||
pip uninstall -y PyQt5
|
||||
pip install PyQt5==5.15.10
|
||||
pip install PyQtWebEngine==5.15.6
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/gumyr/bd_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
pip list
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba activate test
|
||||
micromamba info
|
||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor-mac.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/CQ-editor.sh
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CQ-editor-MacOS-arm64
|
||||
name: CQ-editor-MacOS
|
||||
path: dist
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- uses: mamba-org/setup-micromamba@v1
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
init-shell: >-
|
||||
bash
|
||||
powershell
|
||||
create-args: >-
|
||||
python=3.10
|
||||
- name: pip install cadquery CQ-editor ... etc
|
||||
shell: bash --login {0}
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba info
|
||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
pip install --pre git+https://github.com/cadquery/cadquery casadi
|
||||
pip install pyinstaller>=5.6
|
||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
||||
pip install path
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/gumyr/bd_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
pip list
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba activate test
|
||||
micromamba info
|
||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
cp D:/a/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.cmd D:/a/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
|
||||
- name: 7zip artifact (workaround for too many files during artifact upload)
|
||||
shell: bash --login {0}
|
||||
run: 7z a release.zip ./dist/*
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||
- uses: alehechka/upload-tartifact@v2
|
||||
with:
|
||||
name: CQ-editor-Windows
|
||||
path: release.zip
|
||||
path: dist
|
||||
|
||||
126
.github/workflows/pyinstaller-builds-actions-build-PIP-TAR-pyinst5-6p.yml
vendored
Normal file
126
.github/workflows/pyinstaller-builds-actions-build-PIP-TAR-pyinst5-6p.yml
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
name: build-PIP-TAR-pyinst5-6p
|
||||
on:
|
||||
# schedule:
|
||||
# - cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||
required: true
|
||||
default: 'dir'
|
||||
jobs:
|
||||
# build-linux:
|
||||
# runs-on: ubuntu-20.04
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: mamba-org/provision-with-micromamba@main
|
||||
# with:
|
||||
# #miniconda-version: "latest"
|
||||
# #auto-update-conda: true
|
||||
# environment-name: test
|
||||
# environment-file: environment.yml
|
||||
# extra-specs:
|
||||
# python=3.9
|
||||
# - name: Mamba install CadQuery and pyinstaller
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||
# sudo apt install -y libxkbcommon0
|
||||
# sudo apt install -y libxkbcommon-x11-0
|
||||
# sudo apt install -y libxcb-xinerama0
|
||||
# micromamba info
|
||||
# pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
# pip install -vvv --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||
# pip install pyinstaller==4.10
|
||||
# pip install path
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# pip install git+https://github.com/JustinSDK/cqMore
|
||||
# pip list
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
# cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# - uses: alehechka/upload-tartifact@v1
|
||||
# with:
|
||||
# name: CQ-editor-Linux-x86_64
|
||||
# path: dist
|
||||
# build-macos:
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: mamba-org/provision-with-micromamba@main
|
||||
# with:
|
||||
# #miniconda-version: "latest"
|
||||
# #auto-update-conda: true
|
||||
# environment-name: test
|
||||
# environment-file: environment.yml
|
||||
# extra-specs:
|
||||
# python=3.9
|
||||
# - name: Mamba install CadQuery and pyinstaller
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
# pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||
# pip install pyinstaller==4.10
|
||||
# pip install path
|
||||
# pip uninstall -y PyQt5
|
||||
# pip install PyQt5==5.15.7
|
||||
# pip install PyQtWebEngine==5.15.6
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# pip install git+https://github.com/JustinSDK/cqMore
|
||||
# pip list
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
# cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# - uses: alehechka/upload-tartifact@v1
|
||||
# with:
|
||||
# name: CQ-editor-MacOS
|
||||
# path: dist
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mamba-org/provision-with-micromamba@main
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
extra-specs:
|
||||
python=3.9
|
||||
- name: pip install cadquery CQ-editor ... etc
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba info
|
||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||
pip install pyinstaller>=5.6
|
||||
pip install path
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
pip list
|
||||
- name: Run build
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba info
|
||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||
- uses: alehechka/upload-tartifact@v1
|
||||
with:
|
||||
name: CQ-editor-Windows
|
||||
path: dist
|
||||
122
.github/workflows/pyinstaller-builds-actions-mmamba-TAR.yml
vendored
Normal file
122
.github/workflows/pyinstaller-builds-actions-mmamba-TAR.yml
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
name: build-micromamba-DEV
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||
required: true
|
||||
default: 'dir'
|
||||
jobs:
|
||||
# build-linux:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: mamba-org/provision-with-micromamba@main
|
||||
# with:
|
||||
# #miniconda-version: "latest"
|
||||
# #auto-update-conda: true
|
||||
# environment-name: test
|
||||
# environment-file: environment.yml
|
||||
# extra-specs:
|
||||
# python=3.9
|
||||
# - name: Mamba install CadQuery and pyinstaller
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||
# sudo apt install -y libxkbcommon0
|
||||
# sudo apt install -y libxkbcommon-x11-0
|
||||
# sudo apt install -y libxcb-xinerama0
|
||||
# micromamba info
|
||||
# micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
# micromamba install -c conda-forge pyinstaller=4.10
|
||||
# pip install path
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# pip install git+https://github.com/JustinSDK/cqMore
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
# cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# - uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: CQ-editor-Linux-x86_64
|
||||
# path: dist
|
||||
# build-macos:
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: mamba-org/provision-with-micromamba@main
|
||||
# with:
|
||||
# #miniconda-version: "latest"
|
||||
# #auto-update-conda: true
|
||||
# environment-name: test
|
||||
# environment-file: environment.yml
|
||||
# extra-specs:
|
||||
# python=3.9
|
||||
# - name: Mamba install CadQuery and pyinstaller
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
# micromamba install -c conda-forge pyinstaller
|
||||
# pip install path
|
||||
# pip uninstall -y PyQt5
|
||||
# pip install PyQt5==5.15.7
|
||||
# pip install PyQtWebEngine==5.15.6
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# pip install git+https://github.com/JustinSDK/cqMore
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# micromamba info
|
||||
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
# cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# - uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: CQ-editor-MacOS
|
||||
# path: dist
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mamba-org/provision-with-micromamba@main
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
extra-specs:
|
||||
python=3.9
|
||||
- name: Mamba install CadQuery and pyinstaller
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
micromamba install -c conda-forge pyinstaller=4.10 casadi ipopt
|
||||
pip install path
|
||||
pip install pipwin
|
||||
pipwin install numpy
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
- name: Run build
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba info
|
||||
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
Copy-Item C:\Users\runneradmin\micromamba-root\envs\test\Library\bin\casadi_nlpsol_ipopt.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||
- uses: alehechka/upload-tartifact@v1
|
||||
with:
|
||||
name: CQ-editor-Windows
|
||||
path: dist
|
||||
121
.github/workflows/pyinstaller-builds-actions-mmamba.yml
vendored
Normal file
121
.github/workflows/pyinstaller-builds-actions-mmamba.yml
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
name: build-micromamba
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||
required: true
|
||||
default: 'dir'
|
||||
jobs:
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mamba-org/provision-with-micromamba@main
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
extra-specs:
|
||||
python=3.9
|
||||
- name: Mamba install CadQuery and pyinstaller
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||
sudo apt install -y libxkbcommon0
|
||||
sudo apt install -y libxkbcommon-x11-0
|
||||
sudo apt install -y libxcb-xinerama0
|
||||
micromamba info
|
||||
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
micromamba install -c conda-forge pyinstaller=4.10
|
||||
pip install path
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba info
|
||||
pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: CQ-editor-Linux-x86_64
|
||||
path: dist
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mamba-org/provision-with-micromamba@main
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
extra-specs:
|
||||
python=3.9
|
||||
- name: Mamba install CadQuery and pyinstaller
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba info
|
||||
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
micromamba install -c conda-forge pyinstaller
|
||||
pip install path
|
||||
pip uninstall -y PyQt5
|
||||
pip install PyQt5==5.15.7
|
||||
pip install PyQtWebEngine==5.15.6
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
- name: Run build
|
||||
shell: bash --login {0}
|
||||
run: |
|
||||
micromamba info
|
||||
pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: CQ-editor-MacOS
|
||||
path: dist
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mamba-org/provision-with-micromamba@main
|
||||
with:
|
||||
#miniconda-version: "latest"
|
||||
#auto-update-conda: true
|
||||
environment-name: test
|
||||
environment-file: environment.yml
|
||||
extra-specs:
|
||||
python=3.9
|
||||
- name: Mamba install CadQuery and pyinstaller
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||
micromamba install -c conda-forge pyinstaller=4.10
|
||||
pip install path
|
||||
pip install pipwin
|
||||
pipwin install numpy
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
pip install git+https://github.com/JustinSDK/cqMore
|
||||
- name: Run build
|
||||
shell: powershell
|
||||
run: |
|
||||
micromamba info
|
||||
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: CQ-editor-Windows
|
||||
path: dist
|
||||
120
.github/workflows/pyinstaller-builds-actions.yml
vendored
Normal file
120
.github/workflows/pyinstaller-builds-actions.yml
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
name: build
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 1'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||
required: true
|
||||
default: 'dir'
|
||||
jobs:
|
||||
# build-linux:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: conda-incubator/setup-miniconda@v2
|
||||
# with:
|
||||
# mamba-version: "*"
|
||||
# channels: conda-forge,defaults
|
||||
# channel-priority: true
|
||||
# # auto-update-conda: true
|
||||
# python-version: 3.9
|
||||
# activate-environment: test
|
||||
# - name: Install CadQuery, CQ-editor and pyinstaller
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||
# sudo apt install -y libxkbcommon0
|
||||
# sudo apt install -y libxkbcommon-x11-0
|
||||
# sudo apt install -y libxcb-xinerama0
|
||||
# conda info
|
||||
# conda install -c cadquery -c conda-forge cq-editor=master cadquery=master python=3.9
|
||||
# conda install -c conda-forge pyinstaller=4.10
|
||||
# conda uninstall --force -y importlib_resources
|
||||
# pip install path
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# conda info
|
||||
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
# cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# rm /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/CQ-editor/libstdc++.so.6
|
||||
# - uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: CQ-editor-Linux-x86_64
|
||||
# path: dist
|
||||
# build-macos:
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: conda-incubator/setup-miniconda@v2
|
||||
# with:
|
||||
# mamba-version: "*"
|
||||
# channels: conda-forge,defaults
|
||||
# # auto-update-conda: true
|
||||
# python-version: 3.9
|
||||
# activate-environment: test
|
||||
# - name: Install CadQuery, CQ-editor and pyinstaller=4.10
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# conda info
|
||||
# conda install -c cadquery -c conda-forge cq-editor=master cadquery=master python=3.9
|
||||
# conda install -c conda-forge pyinstaller
|
||||
# conda uninstall --force -y importlib_resources
|
||||
# pip install path
|
||||
# pip uninstall -y PyQt5
|
||||
# pip install PyQt5==5.15.7
|
||||
# pip install PyQtWebEngine==5.15.6
|
||||
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
# - name: Run build
|
||||
# shell: bash --login {0}
|
||||
# run: |
|
||||
# conda info
|
||||
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
# cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||
# - uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: CQ-editor-MacOS
|
||||
# path: dist
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: conda-incubator/setup-miniconda@v2
|
||||
with:
|
||||
miniconda-version: "latest"
|
||||
auto-update-conda: true
|
||||
python-version: 3.9
|
||||
activate-environment: test
|
||||
- name: Install CadQuery and pyinstaller
|
||||
shell: powershell
|
||||
run: |
|
||||
conda install -c cadquery -c conda-forge cq-editor=master cadquery=master ipython=7.20 python=3.9
|
||||
conda install -c conda-forge pyinstaller=4.10
|
||||
pip install pipwin
|
||||
pipwin install numpy
|
||||
pip install path
|
||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||
- name: Run build
|
||||
shell: powershell
|
||||
run: |
|
||||
conda info
|
||||
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||
Copy-Item C:\Miniconda3\Library\bin\libssl-1_1-x64.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||
Copy-Item C:\Miniconda3\Library\bin\libcrypto-1_1-x64.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: CQ-editor-Windows
|
||||
path: dist
|
||||
@@ -1,6 +1,6 @@
|
||||
# CadQuery editor
|
||||
|
||||
This is a fork of [jmwright's fork](https://github.com/jmwright/CQ-editor) of [CadQuery/CQ-editor](https://github.com/CadQuery/CQ-editor). This fork includes changes that enable dark mode for CQ-editor (see screenshot below). Under the GitHub Actions menu this fork also contains static builds of CQ-editor for Linux/MacOS/Windows that include the [cq_gears](https://github.com/meadiode/cq_gears), [cq_cache](https://github.com/CadQuery/cadquery-plugins/tree/main/plugins/cq_cache), [cq_more](https://github.com/JustinSDK/cqMore), [cq_warehouse](https://github.com/gumyr/cq_warehouse), [bd_warehouse](https://github.com/gumyr/bd_warehouse), and [build123d](https://github.com/gumyr/build123d) libraries. Note you need to change color preferences to enable dark mode for all panes (see Edit -> Preferences).
|
||||
This is a fork of [jmwright's fork](https://github.com/jmwright/CQ-editor) of [CadQuery/CQ-editor](https://github.com/CadQuery/CQ-editor). This fork includes changes that enable dark mode for CQ-editor (see screenshot below). Under the GitHub Actions menu this fork also contains static builds of CQ-editor for Linux/MacOS/Windows that include the [cq_gears](https://github.com/meadiode/cq_gears), [cq_cache](https://github.com/CadQuery/cadquery-plugins/tree/main/plugins/cq_cache), [cq_more](https://github.com/JustinSDK/cqMore), [cq_warehouse](https://github.com/gumyr/cq_warehouse), and [build123d](https://github.com/gumyr/build123d) libraries. Note you need to change color preferences to enable dark mode for all panes (see Edit -> Preferences).
|
||||
|
||||
This fork also contains additional changes to the `show_object` function in CQ-editor that make it easier to display and export build123d objects and object lists.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
NAME = 'CQ-editor'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from OCP.Quantity import (
|
||||
)
|
||||
from OCP.Graphic3d import Graphic3d_NOM_JADE, Graphic3d_MaterialAspect
|
||||
|
||||
from PyQt5.QtGui import QColor
|
||||
from PySide6.QtGui import QColor
|
||||
|
||||
DEFAULT_FACE_COLOR = Quantity_Color(GOLD)
|
||||
DEFAULT_MATERIAL = Graphic3d_MaterialAspect(Graphic3d_NOM_JADE)
|
||||
|
||||
@@ -3,9 +3,9 @@ import spyder.utils.encoding
|
||||
from modulefinder import ModuleFinder
|
||||
|
||||
from spyder.plugins.editor.widgets.codeeditor import CodeEditor
|
||||
from PyQt5.QtCore import pyqtSignal, QFileSystemWatcher, QTimer
|
||||
from PyQt5.QtWidgets import QAction, QFileDialog
|
||||
from PyQt5.QtGui import QFontDatabase
|
||||
from PySide6.QtCore import Signal as pyqtSignal, QFileSystemWatcher, QTimer
|
||||
from PySide6.QtWidgets import QAction, QFileDialog
|
||||
from PySide6.QtGui import QFontDatabase
|
||||
from path import Path
|
||||
|
||||
import sys
|
||||
@@ -17,91 +17,104 @@ from ..utils import get_save_filename, get_open_filename, confirm
|
||||
|
||||
from ..icons import icon
|
||||
|
||||
class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
name = 'Code Editor'
|
||||
class Editor(CodeEditor, ComponentMixin):
|
||||
name = "Code Editor"
|
||||
|
||||
# This signal is emitted whenever the currently-open file changes and
|
||||
# autoreload is enabled.
|
||||
triggerRerender = pyqtSignal(bool)
|
||||
sigFilenameChanged = pyqtSignal(str)
|
||||
|
||||
preferences = Parameter.create(name='Preferences',children=[
|
||||
{'name': 'Font size', 'type': 'int', 'value': 12},
|
||||
{'name': 'Autoreload', 'type': 'bool', 'value': False},
|
||||
{'name': 'Autoreload delay', 'type': 'int', 'value': 50},
|
||||
{'name': 'Autoreload: watch imported modules', 'type': 'bool', 'value': False},
|
||||
{'name': 'Line wrap', 'type': 'bool', 'value': False},
|
||||
{'name': 'Color scheme', 'type': 'list',
|
||||
'values': ['Spyder','Monokai','Zenburn'], 'value': 'Spyder'}])
|
||||
preferences = Parameter.create(
|
||||
name="Preferences",
|
||||
children=[
|
||||
{"name": "Font size", "type": "int", "value": 12},
|
||||
{"name": "Autoreload", "type": "bool", "value": False},
|
||||
{"name": "Autoreload delay", "type": "int", "value": 50},
|
||||
{
|
||||
"name": "Autoreload: watch imported modules",
|
||||
"type": "bool",
|
||||
"value": False,
|
||||
},
|
||||
{"name": "Line wrap", "type": "bool", "value": False},
|
||||
{
|
||||
"name": "Color scheme",
|
||||
"type": "list",
|
||||
"values": ["Spyder", "Monokai", "Zenburn"],
|
||||
"value": "Spyder",
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
EXTENSIONS = 'py'
|
||||
|
||||
def __init__(self,parent=None):
|
||||
EXTENSIONS = "py"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
self._watched_file = None
|
||||
|
||||
super(Editor,self).__init__(parent)
|
||||
super(Editor, self).__init__(parent)
|
||||
ComponentMixin.__init__(self)
|
||||
|
||||
self.setup_editor(linenumbers=True,
|
||||
self.setup_editor(
|
||||
linenumbers=True,
|
||||
markers=True,
|
||||
edge_line=False,
|
||||
tab_mode=False,
|
||||
show_blanks=True,
|
||||
font=QFontDatabase.systemFont(QFontDatabase.FixedFont),
|
||||
language='Python',
|
||||
filename='')
|
||||
language="Python",
|
||||
filename="",
|
||||
)
|
||||
|
||||
self._actions = \
|
||||
{'File' : [QAction(icon('new'),
|
||||
'New',
|
||||
self._actions = {
|
||||
"File": [
|
||||
QAction(
|
||||
icon("new"), "New", self, shortcut="ctrl+N", triggered=self.new
|
||||
),
|
||||
QAction(
|
||||
icon("open"), "Open", self, shortcut="ctrl+O", triggered=self.open
|
||||
),
|
||||
QAction(
|
||||
icon("save"), "Save", self, shortcut="ctrl+S", triggered=self.save
|
||||
),
|
||||
QAction(
|
||||
icon("save_as"),
|
||||
"Save as",
|
||||
self,
|
||||
shortcut='ctrl+N',
|
||||
triggered=self.new),
|
||||
QAction(icon('open'),
|
||||
'Open',
|
||||
shortcut="ctrl+shift+S",
|
||||
triggered=self.save_as,
|
||||
),
|
||||
QAction(
|
||||
icon("autoreload"),
|
||||
"Automatic reload and preview",
|
||||
self,
|
||||
shortcut='ctrl+O',
|
||||
triggered=self.open),
|
||||
QAction(icon('save'),
|
||||
'Save',
|
||||
self,
|
||||
shortcut='ctrl+S',
|
||||
triggered=self.save),
|
||||
QAction(icon('save_as'),
|
||||
'Save as',
|
||||
self,
|
||||
shortcut='ctrl+shift+S',
|
||||
triggered=self.save_as),
|
||||
QAction(icon('autoreload'),
|
||||
'Automatic reload and preview',
|
||||
self,triggered=self.autoreload,
|
||||
triggered=self.autoreload,
|
||||
checkable=True,
|
||||
checked=False,
|
||||
objectName='autoreload'),
|
||||
]}
|
||||
objectName="autoreload",
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
for a in self._actions.values():
|
||||
self.addActions(a)
|
||||
|
||||
|
||||
self._fixContextMenu()
|
||||
|
||||
# autoreload support
|
||||
self._file_watcher = QFileSystemWatcher(self)
|
||||
# we wait for 50ms after a file change for the file to be written completely
|
||||
self._file_watch_timer = QTimer(self)
|
||||
self._file_watch_timer.setInterval(self.preferences['Autoreload delay'])
|
||||
self._file_watch_timer.setInterval(self.preferences["Autoreload delay"])
|
||||
self._file_watch_timer.setSingleShot(True)
|
||||
self._file_watcher.fileChanged.connect(
|
||||
lambda val: self._file_watch_timer.start())
|
||||
lambda val: self._file_watch_timer.start()
|
||||
)
|
||||
self._file_watch_timer.timeout.connect(self._file_changed)
|
||||
|
||||
self.updatePreferences()
|
||||
|
||||
def _fixContextMenu(self):
|
||||
|
||||
menu = self.menu
|
||||
|
||||
menu.removeAction(self.run_cell_action)
|
||||
@@ -109,52 +122,52 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
menu.removeAction(self.run_selection_action)
|
||||
menu.removeAction(self.re_run_last_cell_action)
|
||||
|
||||
def updatePreferences(self,*args):
|
||||
|
||||
self.set_color_scheme(self.preferences['Color scheme'])
|
||||
def updatePreferences(self, *args):
|
||||
self.set_color_scheme(self.preferences["Color scheme"])
|
||||
|
||||
font = self.font()
|
||||
font.setPointSize(self.preferences['Font size'])
|
||||
font.setPointSize(self.preferences["Font size"])
|
||||
self.set_font(font)
|
||||
|
||||
self.findChild(QAction, 'autoreload') \
|
||||
.setChecked(self.preferences['Autoreload'])
|
||||
self.findChild(QAction, "autoreload").setChecked(self.preferences["Autoreload"])
|
||||
|
||||
self._file_watch_timer.setInterval(self.preferences['Autoreload delay'])
|
||||
self._file_watch_timer.setInterval(self.preferences["Autoreload delay"])
|
||||
|
||||
self.toggle_wrap_mode(self.preferences['Line wrap'])
|
||||
self.toggle_wrap_mode(self.preferences["Line wrap"])
|
||||
|
||||
self._clear_watched_paths()
|
||||
self._watch_paths()
|
||||
|
||||
def confirm_discard(self):
|
||||
|
||||
if self.modified:
|
||||
rv = confirm(self,'Please confirm','Current document is not saved - do you want to continue?')
|
||||
rv = confirm(
|
||||
self,
|
||||
"Please confirm",
|
||||
"Current document is not saved - do you want to continue?",
|
||||
)
|
||||
else:
|
||||
rv = True
|
||||
|
||||
return rv
|
||||
|
||||
def new(self):
|
||||
if not self.confirm_discard():
|
||||
return
|
||||
|
||||
if not self.confirm_discard(): return
|
||||
|
||||
self.set_text('')
|
||||
self.filename = ''
|
||||
self.set_text("")
|
||||
self.filename = ""
|
||||
self.reset_modified()
|
||||
|
||||
def open(self):
|
||||
if not self.confirm_discard():
|
||||
return
|
||||
|
||||
if not self.confirm_discard(): return
|
||||
|
||||
curr_dir = Path(self.filename).absolute().dirname()
|
||||
curr_dir = Path(self.filename).abspath().dirname()
|
||||
fname = get_open_filename(self.EXTENSIONS, curr_dir)
|
||||
if fname != '':
|
||||
if fname != "":
|
||||
self.load_from_file(fname)
|
||||
|
||||
def load_from_file(self,fname):
|
||||
|
||||
def load_from_file(self, fname):
|
||||
self.set_text_from_file(fname)
|
||||
self.filename = fname
|
||||
self.reset_modified()
|
||||
@@ -164,24 +177,22 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
# this function returns the encoding spyder used to read the file
|
||||
_, encoding = spyder.utils.encoding.read(fname)
|
||||
# spyder returns a -guessed suffix in some cases
|
||||
return encoding.replace('-guessed', '')
|
||||
return encoding.replace("-guessed", "")
|
||||
else:
|
||||
return 'utf-8'
|
||||
return "utf-8"
|
||||
|
||||
def save(self):
|
||||
|
||||
if self._filename != '':
|
||||
|
||||
if self.preferences['Autoreload']:
|
||||
if self._filename != "":
|
||||
if self.preferences["Autoreload"]:
|
||||
self._file_watcher.blockSignals(True)
|
||||
self._file_watch_timer.stop()
|
||||
|
||||
encoding = self.determine_encoding(self._filename)
|
||||
encoded = self.toPlainText().encode(encoding)
|
||||
with open(self._filename, 'wb') as f:
|
||||
with open(self._filename, "wb") as f:
|
||||
f.write(encoded)
|
||||
|
||||
if self.preferences['Autoreload']:
|
||||
if self.preferences["Autoreload"]:
|
||||
self._file_watcher.blockSignals(False)
|
||||
self.triggerRerender.emit(True)
|
||||
|
||||
@@ -191,21 +202,26 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
self.save_as()
|
||||
|
||||
def save_as(self):
|
||||
|
||||
fname = get_save_filename(self.EXTENSIONS)
|
||||
if fname != '':
|
||||
encoded = self.toPlainText().encode('utf-8')
|
||||
with open(fname, 'wb') as f:
|
||||
if fname != "":
|
||||
encoded = self.toPlainText().encode("utf-8")
|
||||
with open(fname, "wb") as f:
|
||||
f.write(encoded)
|
||||
self.filename = fname
|
||||
|
||||
self.reset_modified()
|
||||
|
||||
def _update_filewatcher(self):
|
||||
if self._watched_file and (self._watched_file != self.filename or not self.preferences['Autoreload']):
|
||||
if self._watched_file and (
|
||||
self._watched_file != self.filename or not self.preferences["Autoreload"]
|
||||
):
|
||||
self._clear_watched_paths()
|
||||
self._watched_file = None
|
||||
if self.preferences['Autoreload'] and self.filename and self.filename != self._watched_file:
|
||||
if (
|
||||
self.preferences["Autoreload"]
|
||||
and self.filename
|
||||
and self.filename != self._watched_file
|
||||
):
|
||||
self._watched_file = self._filename
|
||||
self._watch_paths()
|
||||
|
||||
@@ -227,7 +243,7 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
def _watch_paths(self):
|
||||
if Path(self._filename).exists():
|
||||
self._file_watcher.addPath(self._filename)
|
||||
if self.preferences['Autoreload: watch imported modules']:
|
||||
if self.preferences["Autoreload: watch imported modules"]:
|
||||
module_paths = self.get_imported_module_paths(self._filename)
|
||||
if module_paths:
|
||||
self._file_watcher.addPaths(module_paths)
|
||||
@@ -241,51 +257,45 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
# Turn autoreload on/off.
|
||||
def autoreload(self, enabled):
|
||||
self.preferences['Autoreload'] = enabled
|
||||
self.preferences["Autoreload"] = enabled
|
||||
self._update_filewatcher()
|
||||
|
||||
def reset_modified(self):
|
||||
|
||||
self.document().setModified(False)
|
||||
|
||||
@property
|
||||
def modified(self):
|
||||
|
||||
return self.document().isModified()
|
||||
|
||||
def saveComponentState(self,store):
|
||||
def saveComponentState(self, store):
|
||||
if self.filename != "":
|
||||
store.setValue(self.name + "/state", self.filename)
|
||||
|
||||
if self.filename != '':
|
||||
store.setValue(self.name+'/state',self.filename)
|
||||
def restoreComponentState(self, store):
|
||||
filename = store.value(self.name + "/state")
|
||||
|
||||
def restoreComponentState(self,store):
|
||||
|
||||
filename = store.value(self.name+'/state')
|
||||
|
||||
if filename and self.filename == '':
|
||||
if filename and self.filename == "":
|
||||
try:
|
||||
self.load_from_file(filename)
|
||||
except IOError:
|
||||
self._logger.warning(f'could not open {filename}')
|
||||
|
||||
self._logger.warning(f"could not open {filename}")
|
||||
|
||||
def get_imported_module_paths(self, module_path):
|
||||
|
||||
finder = ModuleFinder([os.path.dirname(module_path)])
|
||||
imported_modules = []
|
||||
|
||||
try:
|
||||
finder.run_script(module_path)
|
||||
except SyntaxError as err:
|
||||
self._logger.warning(f'Syntax error in {module_path}: {err}')
|
||||
self._logger.warning(f"Syntax error in {module_path}: {err}")
|
||||
except Exception as err:
|
||||
self._logger.warning(
|
||||
f'Cannot determine imported modules in {module_path}: {type(err).__name__} {err}'
|
||||
f"Cannot determine imported modules in {module_path}: {type(err).__name__} {err}"
|
||||
)
|
||||
else:
|
||||
for module_name, module in finder.modules.items():
|
||||
if module_name != '__main__':
|
||||
path = getattr(module, '__file__', None)
|
||||
if module_name != "__main__":
|
||||
path = getattr(module, "__file__", None)
|
||||
if path is not None and os.path.isfile(path):
|
||||
imported_modules.append(path)
|
||||
|
||||
@@ -293,8 +303,7 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
editor = Editor()
|
||||
|
||||
@@ -6,7 +6,7 @@ Created on Fri May 25 14:47:10 2018
|
||||
@author: adam
|
||||
"""
|
||||
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PySide6.QtGui import QIcon
|
||||
|
||||
from . import icons_res
|
||||
_icons = {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from PySide6 import QtCore
|
||||
|
||||
qt_resource_data = b"\
|
||||
\x00\x00\x4e\x4c\
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import sys
|
||||
|
||||
from PyQt5.QtWidgets import (QLabel, QMainWindow, QToolBar, QDockWidget, QAction)
|
||||
from PySide6.QtWidgets import QLabel, QMainWindow, QToolBar, QDockWidget
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtCore import Signal as pyqtSignal
|
||||
from logbook import Logger
|
||||
import cadquery as cq
|
||||
|
||||
@@ -14,16 +16,26 @@ from .widgets.cq_object_inspector import CQObjectInspector
|
||||
from .widgets.log import LogViewer
|
||||
|
||||
from . import __version__
|
||||
from .utils import dock, add_actions, open_url, about_dialog, check_gtihub_for_updates, confirm
|
||||
from .utils import (
|
||||
dock,
|
||||
add_actions,
|
||||
open_url,
|
||||
about_dialog,
|
||||
check_gtihub_for_updates,
|
||||
confirm,
|
||||
)
|
||||
from .mixins import MainMixin
|
||||
from .icons import icon
|
||||
from .preferences import PreferencesWidget
|
||||
|
||||
#DARKMODE edits: https://stackoverflow.com/questions/48256772/dark-theme-for-qt-widgets
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtGui import QPalette, QColor
|
||||
app = QApplication([])
|
||||
# DARKMODE edits: https://stackoverflow.com/questions/48256772/dark-theme-for-qt-widgets
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtGui import QPalette, QColor
|
||||
|
||||
app = QApplication.instance()
|
||||
if app == None:
|
||||
app = QApplication([])
|
||||
# Force the style to be the same on all OSs:
|
||||
app.setStyle("Fusion")
|
||||
# Now use a palette to switch to dark colors:
|
||||
@@ -43,141 +55,131 @@ palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
|
||||
palette.setColor(QPalette.HighlightedText, Qt.black)
|
||||
app.setPalette(palette)
|
||||
|
||||
class MainWindow(QMainWindow,MainMixin):
|
||||
|
||||
name = 'CQ-Editor'
|
||||
org = 'CadQuery'
|
||||
class MainWindow(QMainWindow, MainMixin):
|
||||
name = "CQ-Editor"
|
||||
org = "CadQuery"
|
||||
|
||||
def __init__(self,parent=None, filename=None):
|
||||
|
||||
super(MainWindow,self).__init__(parent)
|
||||
def __init__(self, parent=None, filename=None):
|
||||
super(MainWindow, self).__init__(parent)
|
||||
MainMixin.__init__(self)
|
||||
|
||||
self.setWindowIcon(icon('app'))
|
||||
self.setWindowIcon(icon("app"))
|
||||
|
||||
self.viewer = OCCViewer(self)
|
||||
self.setCentralWidget(self.viewer.canvas)
|
||||
# self.setCentralWidget(self.viewer.canvas)
|
||||
|
||||
self.prepare_panes()
|
||||
self.registerComponent('viewer',self.viewer)
|
||||
self.prepare_toolbar()
|
||||
self.prepare_menubar()
|
||||
# self.prepare_panes()
|
||||
# self.registerComponent("viewer", self.viewer)
|
||||
# self.prepare_toolbar()
|
||||
# self.prepare_menubar()
|
||||
|
||||
self.prepare_statusbar()
|
||||
self.prepare_actions()
|
||||
# self.prepare_statusbar()
|
||||
# self.prepare_actions()
|
||||
|
||||
self.components['object_tree'].addLines()
|
||||
# self.components["object_tree"].addLines()
|
||||
|
||||
self.prepare_console()
|
||||
# self.prepare_console()
|
||||
|
||||
self.fill_dummy()
|
||||
# self.fill_dummy()
|
||||
|
||||
self.setup_logging()
|
||||
# self.setup_logging()
|
||||
|
||||
self.restorePreferences()
|
||||
self.restoreWindow()
|
||||
# self.restorePreferences()
|
||||
# self.restoreWindow()
|
||||
|
||||
if filename:
|
||||
self.components['editor'].load_from_file(filename)
|
||||
# if filename:
|
||||
# self.components["editor"].load_from_file(filename)
|
||||
|
||||
self.restoreComponentState()
|
||||
|
||||
def closeEvent(self,event):
|
||||
# self.restoreComponentState()
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.saveWindow()
|
||||
self.savePreferences()
|
||||
self.saveComponentState()
|
||||
|
||||
if self.components['editor'].document().isModified():
|
||||
|
||||
rv = confirm(self, 'Confirm close', 'Close without saving?')
|
||||
if self.components["editor"].document().isModified():
|
||||
rv = confirm(self, "Confirm close", "Close without saving?")
|
||||
|
||||
if rv:
|
||||
event.accept()
|
||||
super(MainWindow,self).closeEvent(event)
|
||||
super(MainWindow, self).closeEvent(event)
|
||||
else:
|
||||
event.ignore()
|
||||
else:
|
||||
super(MainWindow,self).closeEvent(event)
|
||||
super(MainWindow, self).closeEvent(event)
|
||||
|
||||
def prepare_panes(self):
|
||||
|
||||
self.registerComponent('editor',
|
||||
self.registerComponent(
|
||||
"editor",
|
||||
Editor(self),
|
||||
lambda c : dock(c,
|
||||
'Editor',
|
||||
self,
|
||||
defaultArea='left'))
|
||||
lambda c: dock(c, "Editor", self, defaultArea="left"),
|
||||
)
|
||||
|
||||
self.registerComponent('object_tree',
|
||||
self.registerComponent(
|
||||
"object_tree",
|
||||
ObjectTree(self),
|
||||
lambda c: dock(c,
|
||||
'Objects',
|
||||
self,
|
||||
defaultArea='right'))
|
||||
lambda c: dock(c, "Objects", self, defaultArea="right"),
|
||||
)
|
||||
|
||||
self.registerComponent('console',
|
||||
self.registerComponent(
|
||||
"console",
|
||||
ConsoleWidget(self),
|
||||
lambda c: dock(c,
|
||||
'Console',
|
||||
self,
|
||||
defaultArea='bottom'))
|
||||
lambda c: dock(c, "Console", self, defaultArea="bottom"),
|
||||
)
|
||||
|
||||
self.registerComponent('traceback_viewer',
|
||||
self.registerComponent(
|
||||
"traceback_viewer",
|
||||
TracebackPane(self),
|
||||
lambda c: dock(c,
|
||||
'Current traceback',
|
||||
self,
|
||||
defaultArea='bottom'))
|
||||
lambda c: dock(c, "Current traceback", self, defaultArea="bottom"),
|
||||
)
|
||||
|
||||
self.registerComponent('debugger',Debugger(self))
|
||||
self.registerComponent("debugger", Debugger(self))
|
||||
|
||||
self.registerComponent('variables_viewer',LocalsView(self),
|
||||
lambda c: dock(c,
|
||||
'Variables',
|
||||
self,
|
||||
defaultArea='right'))
|
||||
self.registerComponent(
|
||||
"variables_viewer",
|
||||
LocalsView(self),
|
||||
lambda c: dock(c, "Variables", self, defaultArea="right"),
|
||||
)
|
||||
|
||||
self.registerComponent('cq_object_inspector',
|
||||
self.registerComponent(
|
||||
"cq_object_inspector",
|
||||
CQObjectInspector(self),
|
||||
lambda c: dock(c,
|
||||
'CQ object inspector',
|
||||
self,
|
||||
defaultArea='right'))
|
||||
self.registerComponent('log',
|
||||
lambda c: dock(c, "CQ object inspector", self, defaultArea="right"),
|
||||
)
|
||||
self.registerComponent(
|
||||
"log",
|
||||
LogViewer(self),
|
||||
lambda c: dock(c,
|
||||
'Log viewer',
|
||||
self,
|
||||
defaultArea='bottom'))
|
||||
lambda c: dock(c, "Log viewer", self, defaultArea="bottom"),
|
||||
)
|
||||
|
||||
for d in self.docks.values():
|
||||
d.show()
|
||||
|
||||
def prepare_menubar(self):
|
||||
|
||||
menu = self.menuBar()
|
||||
|
||||
menu_file = menu.addMenu('&File')
|
||||
menu_edit = menu.addMenu('&Edit')
|
||||
menu_tools = menu.addMenu('&Tools')
|
||||
menu_run = menu.addMenu('&Run')
|
||||
menu_view = menu.addMenu('&View')
|
||||
menu_help = menu.addMenu('&Help')
|
||||
menu_file = menu.addMenu("&File")
|
||||
menu_edit = menu.addMenu("&Edit")
|
||||
menu_tools = menu.addMenu("&Tools")
|
||||
menu_run = menu.addMenu("&Run")
|
||||
menu_view = menu.addMenu("&View")
|
||||
menu_help = menu.addMenu("&Help")
|
||||
|
||||
#per component menu elements
|
||||
menus = {'File' : menu_file,
|
||||
'Edit' : menu_edit,
|
||||
'Run' : menu_run,
|
||||
'Tools': menu_tools,
|
||||
'View' : menu_view,
|
||||
'Help' : menu_help}
|
||||
# per component menu elements
|
||||
menus = {
|
||||
"File": menu_file,
|
||||
"Edit": menu_edit,
|
||||
"Run": menu_run,
|
||||
"Tools": menu_tools,
|
||||
"View": menu_view,
|
||||
"Help": menu_help,
|
||||
}
|
||||
|
||||
for comp in self.components.values():
|
||||
self.prepare_menubar_component(menus,
|
||||
comp.menuActions())
|
||||
self.prepare_menubar_component(menus, comp.menuActions())
|
||||
|
||||
#global menu elements
|
||||
# global menu elements
|
||||
menu_view.addSeparator()
|
||||
for d in self.findChildren(QDockWidget):
|
||||
menu_view.addAction(d.toggleViewAction())
|
||||
@@ -186,181 +188,200 @@ class MainWindow(QMainWindow,MainMixin):
|
||||
for t in self.findChildren(QToolBar):
|
||||
menu_view.addAction(t.toggleViewAction())
|
||||
|
||||
menu_edit.addAction( \
|
||||
QAction(icon('preferences'),
|
||||
'Preferences',
|
||||
self,triggered=self.edit_preferences))
|
||||
menu_edit.addAction(
|
||||
QAction(
|
||||
icon("preferences"),
|
||||
"Preferences",
|
||||
self,
|
||||
triggered=self.edit_preferences,
|
||||
)
|
||||
)
|
||||
|
||||
menu_help.addAction( \
|
||||
QAction(icon('help'),
|
||||
'Documentation',
|
||||
self,triggered=self.documentation))
|
||||
menu_help.addAction(
|
||||
QAction(icon("help"), "Documentation", self, triggered=self.documentation)
|
||||
)
|
||||
|
||||
menu_help.addAction( \
|
||||
QAction('CQ documentation',
|
||||
self,triggered=self.cq_documentation))
|
||||
menu_help.addAction(
|
||||
QAction("CQ documentation", self, triggered=self.cq_documentation)
|
||||
)
|
||||
|
||||
menu_help.addAction( \
|
||||
QAction(icon('about'),
|
||||
'About',
|
||||
self,triggered=self.about))
|
||||
menu_help.addAction(QAction(icon("about"), "About", self, triggered=self.about))
|
||||
|
||||
menu_help.addAction( \
|
||||
QAction('Check for CadQuery updates',
|
||||
self,triggered=self.check_for_cq_updates))
|
||||
menu_help.addAction(
|
||||
QAction(
|
||||
"Check for CadQuery updates", self, triggered=self.check_for_cq_updates
|
||||
)
|
||||
)
|
||||
|
||||
def prepare_menubar_component(self,menus,comp_menu_dict):
|
||||
|
||||
for name,action in comp_menu_dict.items():
|
||||
def prepare_menubar_component(self, menus, comp_menu_dict):
|
||||
for name, action in comp_menu_dict.items():
|
||||
menus[name].addActions(action)
|
||||
|
||||
def prepare_toolbar(self):
|
||||
|
||||
self.toolbar = QToolBar('Main toolbar',self,objectName='Main toolbar')
|
||||
self.toolbar = QToolBar("Main toolbar", self, objectName="Main toolbar")
|
||||
|
||||
for c in self.components.values():
|
||||
add_actions(self.toolbar,c.toolbarActions())
|
||||
add_actions(self.toolbar, c.toolbarActions())
|
||||
|
||||
self.addToolBar(self.toolbar)
|
||||
|
||||
def prepare_statusbar(self):
|
||||
|
||||
self.status_label = QLabel('',parent=self)
|
||||
self.status_label = QLabel("", parent=self)
|
||||
self.statusBar().insertPermanentWidget(0, self.status_label)
|
||||
|
||||
def prepare_actions(self):
|
||||
self.components["debugger"].sigRendered.connect(
|
||||
self.components["object_tree"].addObjects
|
||||
)
|
||||
self.components["debugger"].sigTraceback.connect(
|
||||
self.components["traceback_viewer"].addTraceback
|
||||
)
|
||||
self.components["debugger"].sigLocals.connect(
|
||||
self.components["variables_viewer"].update_frame
|
||||
)
|
||||
self.components["debugger"].sigLocals.connect(
|
||||
self.components["console"].push_vars
|
||||
)
|
||||
|
||||
self.components['debugger'].sigRendered\
|
||||
.connect(self.components['object_tree'].addObjects)
|
||||
self.components['debugger'].sigTraceback\
|
||||
.connect(self.components['traceback_viewer'].addTraceback)
|
||||
self.components['debugger'].sigLocals\
|
||||
.connect(self.components['variables_viewer'].update_frame)
|
||||
self.components['debugger'].sigLocals\
|
||||
.connect(self.components['console'].push_vars)
|
||||
self.components["object_tree"].sigObjectsAdded[list].connect(
|
||||
self.components["viewer"].display_many
|
||||
)
|
||||
self.components["object_tree"].sigObjectsAdded2[list, bool].connect(
|
||||
self.components["viewer"].display_many
|
||||
)
|
||||
self.components["object_tree"].sigItemChanged.connect(
|
||||
self.components["viewer"].update_item
|
||||
)
|
||||
self.components["object_tree"].sigObjectsRemoved.connect(
|
||||
self.components["viewer"].remove_items
|
||||
)
|
||||
self.components["object_tree"].sigCQObjectSelected.connect(
|
||||
self.components["cq_object_inspector"].setObject
|
||||
)
|
||||
self.components["object_tree"].sigObjectPropertiesChanged.connect(
|
||||
self.components["viewer"].redraw
|
||||
)
|
||||
self.components["object_tree"].sigAISObjectsSelected.connect(
|
||||
self.components["viewer"].set_selected
|
||||
)
|
||||
|
||||
self.components['object_tree'].sigObjectsAdded[list]\
|
||||
.connect(self.components['viewer'].display_many)
|
||||
self.components['object_tree'].sigObjectsAdded[list,bool]\
|
||||
.connect(self.components['viewer'].display_many)
|
||||
self.components['object_tree'].sigItemChanged.\
|
||||
connect(self.components['viewer'].update_item)
|
||||
self.components['object_tree'].sigObjectsRemoved\
|
||||
.connect(self.components['viewer'].remove_items)
|
||||
self.components['object_tree'].sigCQObjectSelected\
|
||||
.connect(self.components['cq_object_inspector'].setObject)
|
||||
self.components['object_tree'].sigObjectPropertiesChanged\
|
||||
.connect(self.components['viewer'].redraw)
|
||||
self.components['object_tree'].sigAISObjectsSelected\
|
||||
.connect(self.components['viewer'].set_selected)
|
||||
self.components["viewer"].sigObjectSelected.connect(
|
||||
self.components["object_tree"].handleGraphicalSelection
|
||||
)
|
||||
|
||||
self.components['viewer'].sigObjectSelected\
|
||||
.connect(self.components['object_tree'].handleGraphicalSelection)
|
||||
self.components["traceback_viewer"].sigHighlightLine.connect(
|
||||
self.components["editor"].go_to_line
|
||||
)
|
||||
|
||||
self.components['traceback_viewer'].sigHighlightLine\
|
||||
.connect(self.components['editor'].go_to_line)
|
||||
self.components["cq_object_inspector"].sigDisplayObjects.connect(
|
||||
self.components["viewer"].display_many
|
||||
)
|
||||
self.components["cq_object_inspector"].sigRemoveObjects.connect(
|
||||
self.components["viewer"].remove_items
|
||||
)
|
||||
self.components["cq_object_inspector"].sigShowPlane.connect(
|
||||
self.components["viewer"].toggle_grid
|
||||
)
|
||||
self.components["cq_object_inspector"].sigShowPlane2[bool, float].connect(
|
||||
self.components["viewer"].toggle_grid
|
||||
)
|
||||
self.components["cq_object_inspector"].sigChangePlane.connect(
|
||||
self.components["viewer"].set_grid_orientation
|
||||
)
|
||||
|
||||
self.components['cq_object_inspector'].sigDisplayObjects\
|
||||
.connect(self.components['viewer'].display_many)
|
||||
self.components['cq_object_inspector'].sigRemoveObjects\
|
||||
.connect(self.components['viewer'].remove_items)
|
||||
self.components['cq_object_inspector'].sigShowPlane\
|
||||
.connect(self.components['viewer'].toggle_grid)
|
||||
self.components['cq_object_inspector'].sigShowPlane[bool,float]\
|
||||
.connect(self.components['viewer'].toggle_grid)
|
||||
self.components['cq_object_inspector'].sigChangePlane\
|
||||
.connect(self.components['viewer'].set_grid_orientation)
|
||||
|
||||
self.components['debugger'].sigLocalsChanged\
|
||||
.connect(self.components['variables_viewer'].update_frame)
|
||||
self.components['debugger'].sigLineChanged\
|
||||
.connect(self.components['editor'].go_to_line)
|
||||
self.components['debugger'].sigDebugging\
|
||||
.connect(self.components['object_tree'].stashObjects)
|
||||
self.components['debugger'].sigCQChanged\
|
||||
.connect(self.components['object_tree'].addObjects)
|
||||
self.components['debugger'].sigTraceback\
|
||||
.connect(self.components['traceback_viewer'].addTraceback)
|
||||
self.components["debugger"].sigLocalsChanged.connect(
|
||||
self.components["variables_viewer"].update_frame
|
||||
)
|
||||
self.components["debugger"].sigLineChanged.connect(
|
||||
self.components["editor"].go_to_line
|
||||
)
|
||||
self.components["debugger"].sigDebugging.connect(
|
||||
self.components["object_tree"].stashObjects
|
||||
)
|
||||
self.components["debugger"].sigCQChanged.connect(
|
||||
self.components["object_tree"].addObjects
|
||||
)
|
||||
self.components["debugger"].sigTraceback.connect(
|
||||
self.components["traceback_viewer"].addTraceback
|
||||
)
|
||||
|
||||
# trigger re-render when file is modified externally or saved
|
||||
self.components['editor'].triggerRerender \
|
||||
.connect(self.components['debugger'].render)
|
||||
self.components['editor'].sigFilenameChanged\
|
||||
.connect(self.handle_filename_change)
|
||||
self.components["editor"].triggerRerender.connect(
|
||||
self.components["debugger"].render
|
||||
)
|
||||
self.components["editor"].sigFilenameChanged.connect(
|
||||
self.handle_filename_change
|
||||
)
|
||||
|
||||
def prepare_console(self):
|
||||
console = self.components["console"]
|
||||
obj_tree = self.components["object_tree"]
|
||||
|
||||
console = self.components['console']
|
||||
obj_tree = self.components['object_tree']
|
||||
# application related items
|
||||
console.push_vars({"self": self})
|
||||
|
||||
#application related items
|
||||
console.push_vars({'self' : self})
|
||||
|
||||
#CQ related items
|
||||
console.push_vars({'show' : obj_tree.addObject,
|
||||
'show_object' : obj_tree.addObject,
|
||||
'rand_color' : self.components['debugger']._rand_color,
|
||||
'cq' : cq,
|
||||
'log' : Logger(self.name).info})
|
||||
# CQ related items
|
||||
console.push_vars(
|
||||
{
|
||||
"show": obj_tree.addObject,
|
||||
"show_object": obj_tree.addObject,
|
||||
"rand_color": self.components["debugger"]._rand_color,
|
||||
"cq": cq,
|
||||
"log": Logger(self.name).info,
|
||||
}
|
||||
)
|
||||
|
||||
def fill_dummy(self):
|
||||
|
||||
self.components['editor']\
|
||||
.set_text('import cadquery as cq\nresult = cq.Workplane("XY" ).box(3, 3, 0.5).edges("|Z").fillet(0.125)')
|
||||
self.components["editor"].set_text(
|
||||
'import cadquery as cq\nresult = cq.Workplane("XY" ).box(3, 3, 0.5).edges("|Z").fillet(0.125)'
|
||||
)
|
||||
|
||||
def setup_logging(self):
|
||||
|
||||
from logbook.compat import redirect_logging
|
||||
from logbook import INFO, Logger
|
||||
|
||||
redirect_logging()
|
||||
self.components['log'].handler.level = INFO
|
||||
self.components['log'].handler.push_application()
|
||||
self.components["log"].handler.level = INFO
|
||||
self.components["log"].handler.push_application()
|
||||
|
||||
self._logger = Logger(self.name)
|
||||
|
||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
||||
|
||||
if issubclass(exc_type, KeyboardInterrupt):
|
||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||
return
|
||||
|
||||
self._logger.error("Uncaught exception occurred",
|
||||
exc_info=(exc_type, exc_value, exc_traceback))
|
||||
self._logger.error(
|
||||
"Uncaught exception occurred",
|
||||
exc_info=(exc_type, exc_value, exc_traceback),
|
||||
)
|
||||
|
||||
sys.excepthook = handle_exception
|
||||
|
||||
|
||||
def edit_preferences(self):
|
||||
|
||||
prefs = PreferencesWidget(self,self.components)
|
||||
prefs = PreferencesWidget(self, self.components)
|
||||
prefs.exec_()
|
||||
|
||||
def about(self):
|
||||
|
||||
about_dialog(
|
||||
self,
|
||||
f'About CQ-editor',
|
||||
f'PyQt GUI for CadQuery.\nVersion: {__version__}.\nSource Code: https://github.com/CadQuery/CQ-editor',
|
||||
f"About CQ-editor",
|
||||
f"PyQt GUI for CadQuery.\nVersion: {__version__}.\nSource Code: https://github.com/CadQuery/CQ-editor",
|
||||
)
|
||||
|
||||
def check_for_cq_updates(self):
|
||||
|
||||
check_gtihub_for_updates(self,cq)
|
||||
check_gtihub_for_updates(self, cq)
|
||||
|
||||
def documentation(self):
|
||||
|
||||
open_url('https://github.com/CadQuery')
|
||||
open_url("https://github.com/CadQuery")
|
||||
|
||||
def cq_documentation(self):
|
||||
|
||||
open_url('https://cadquery.readthedocs.io/en/latest/')
|
||||
open_url("https://cadquery.readthedocs.io/en/latest/")
|
||||
|
||||
def handle_filename_change(self, fname):
|
||||
|
||||
new_title = fname if fname else "*"
|
||||
self.setWindowTitle(f"{self.name}: {new_title}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
@@ -10,72 +10,67 @@ from functools import reduce
|
||||
from operator import add
|
||||
from logbook import Logger
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QSettings
|
||||
from PySide6.QtCore import QSettings
|
||||
from PySide6.QtCore import Slot as pyqtSlot
|
||||
|
||||
|
||||
class MainMixin(object):
|
||||
|
||||
name = 'Main'
|
||||
org = 'Unknown'
|
||||
name = "Main"
|
||||
org = "Unknown"
|
||||
|
||||
components = {}
|
||||
docks = {}
|
||||
preferences = None
|
||||
|
||||
def __init__(self):
|
||||
self.settings = QSettings(self.org, self.name)
|
||||
|
||||
self.settings = QSettings(self.org,self.name)
|
||||
|
||||
def registerComponent(self,name,component,dock=None):
|
||||
|
||||
def registerComponent(self, name, component, dock=None):
|
||||
self.components[name] = component
|
||||
|
||||
if dock:
|
||||
self.docks[name] = dock(component)
|
||||
|
||||
def saveWindow(self):
|
||||
|
||||
self.settings.setValue('geometry',self.saveGeometry())
|
||||
self.settings.setValue('windowState',self.saveState())
|
||||
self.settings.setValue("geometry", self.saveGeometry())
|
||||
self.settings.setValue("windowState", self.saveState())
|
||||
|
||||
def restoreWindow(self):
|
||||
|
||||
if self.settings.value('geometry'):
|
||||
self.restoreGeometry(self.settings.value('geometry'))
|
||||
if self.settings.value('windowState'):
|
||||
self.restoreState(self.settings.value('windowState'))
|
||||
if self.settings.value("geometry"):
|
||||
self.restoreGeometry(self.settings.value("geometry"))
|
||||
if self.settings.value("windowState"):
|
||||
self.restoreState(self.settings.value("windowState"))
|
||||
|
||||
def savePreferences(self):
|
||||
|
||||
settings = self.settings
|
||||
|
||||
if self.preferences:
|
||||
settings.setValue('General',self.preferences.saveState())
|
||||
settings.setValue("General", self.preferences.saveState())
|
||||
|
||||
for comp in (c for c in self.components.values() if c.preferences):
|
||||
settings.setValue(comp.name,comp.preferences.saveState())
|
||||
settings.setValue(comp.name, comp.preferences.saveState())
|
||||
|
||||
def restorePreferences(self):
|
||||
|
||||
settings = self.settings
|
||||
|
||||
if self.preferences and settings.value('General'):
|
||||
self.preferences.restoreState(settings.value('General'),
|
||||
removeChildren=False)
|
||||
if self.preferences and settings.value("General"):
|
||||
self.preferences.restoreState(
|
||||
settings.value("General"), removeChildren=False
|
||||
)
|
||||
|
||||
for comp in (c for c in self.components.values() if c.preferences):
|
||||
if settings.value(comp.name):
|
||||
comp.preferences.restoreState(settings.value(comp.name),
|
||||
removeChildren=False)
|
||||
comp.preferences.restoreState(
|
||||
settings.value(comp.name), removeChildren=False
|
||||
)
|
||||
|
||||
def saveComponentState(self):
|
||||
|
||||
settings = self.settings
|
||||
|
||||
for comp in self.components.values():
|
||||
comp.saveComponentState(settings)
|
||||
|
||||
def restoreComponentState(self):
|
||||
|
||||
settings = self.settings
|
||||
|
||||
for comp in self.components.values():
|
||||
@@ -83,42 +78,32 @@ class MainMixin(object):
|
||||
|
||||
|
||||
class ComponentMixin(object):
|
||||
|
||||
|
||||
name = 'Component'
|
||||
name = "Component"
|
||||
preferences = None
|
||||
|
||||
_actions = {}
|
||||
|
||||
|
||||
def __init__(self):
|
||||
|
||||
if self.preferences:
|
||||
self.preferences.sigTreeStateChanged.\
|
||||
connect(self.updatePreferences)
|
||||
self.preferences.sigTreeStateChanged.connect(self.updatePreferences)
|
||||
|
||||
self._logger = Logger(self.name)
|
||||
|
||||
def menuActions(self):
|
||||
|
||||
return self._actions
|
||||
|
||||
def toolbarActions(self):
|
||||
|
||||
if len(self._actions) > 0:
|
||||
return reduce(add,[a for a in self._actions.values()])
|
||||
return reduce(add, [a for a in self._actions.values()])
|
||||
else:
|
||||
return []
|
||||
|
||||
@pyqtSlot(object,object)
|
||||
def updatePreferences(self,*args):
|
||||
|
||||
@pyqtSlot(object, object)
|
||||
def updatePreferences(self, *args):
|
||||
pass
|
||||
|
||||
def saveComponentState(self,store):
|
||||
|
||||
def saveComponentState(self, store):
|
||||
pass
|
||||
|
||||
def restoreComponentState(self,store):
|
||||
|
||||
def restoreComponentState(self, store):
|
||||
pass
|
||||
@@ -1,6 +1,5 @@
|
||||
from PyQt5.QtWidgets import (QTreeWidget, QTreeWidgetItem,
|
||||
QStackedWidget, QDialog)
|
||||
from PyQt5.QtCore import pyqtSlot, Qt
|
||||
from PySide6.QtWidgets import QTreeWidget, QTreeWidgetItem, QStackedWidget, QDialog
|
||||
from PySide6.QtCore import Slot as pyqtSlot, Qt
|
||||
|
||||
from pyqtgraph.parametertree import ParameterTree
|
||||
|
||||
@@ -8,55 +7,54 @@ from .utils import splitter, layout
|
||||
|
||||
|
||||
class PreferencesTreeItem(QTreeWidgetItem):
|
||||
|
||||
def __init__(self,name,widget,):
|
||||
|
||||
super(PreferencesTreeItem,self).__init__(name)
|
||||
def __init__(
|
||||
self,
|
||||
name,
|
||||
widget,
|
||||
):
|
||||
super(PreferencesTreeItem, self).__init__(name)
|
||||
self.widget = widget
|
||||
|
||||
|
||||
class PreferencesWidget(QDialog):
|
||||
|
||||
def __init__(self,parent,components):
|
||||
|
||||
super(PreferencesWidget,self).__init__(
|
||||
def __init__(self, parent, components):
|
||||
super(PreferencesWidget, self).__init__(
|
||||
parent,
|
||||
Qt.Window | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint,
|
||||
windowTitle='Preferences')
|
||||
windowTitle="Preferences",
|
||||
)
|
||||
|
||||
self.stacked = QStackedWidget(self)
|
||||
self.preferences_tree = QTreeWidget(self,
|
||||
self.preferences_tree = QTreeWidget(
|
||||
self,
|
||||
headerHidden=True,
|
||||
itemsExpandable=False,
|
||||
rootIsDecorated=False,
|
||||
columnCount=1)
|
||||
columnCount=1,
|
||||
)
|
||||
|
||||
self.root = self.preferences_tree.invisibleRootItem()
|
||||
|
||||
self.add('General',
|
||||
parent)
|
||||
self.add("General", parent)
|
||||
|
||||
for v in parent.components.values():
|
||||
self.add(v.name,v)
|
||||
self.add(v.name, v)
|
||||
|
||||
self.splitter = splitter((self.preferences_tree,self.stacked),(2,5))
|
||||
layout(self,(self.splitter,),self)
|
||||
self.splitter = splitter((self.preferences_tree, self.stacked), (2, 5))
|
||||
layout(self, (self.splitter,), self)
|
||||
|
||||
self.preferences_tree.currentItemChanged.connect(self.handleSelection)
|
||||
|
||||
def add(self,name,component):
|
||||
|
||||
def add(self, name, component):
|
||||
if component.preferences:
|
||||
widget = ParameterTree()
|
||||
widget.setHeaderHidden(True)
|
||||
widget.setParameters(component.preferences,showTop=False)
|
||||
self.root.addChild(PreferencesTreeItem((name,),
|
||||
widget))
|
||||
widget.setParameters(component.preferences, showTop=False)
|
||||
self.root.addChild(PreferencesTreeItem((name,), widget))
|
||||
|
||||
self.stacked.addWidget(widget)
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem,QTreeWidgetItem)
|
||||
def handleSelection(self,item,*args):
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
|
||||
def handleSelection(self, item, *args):
|
||||
if item:
|
||||
self.stacked.setCurrentWidget(item.widget)
|
||||
|
||||
|
||||
@@ -2,22 +2,27 @@ import requests
|
||||
|
||||
from pkg_resources import parse_version
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtWidgets import QFileDialog, QMessageBox
|
||||
from PySide6 import QtCore, QtWidgets
|
||||
from PySide6.QtGui import QDesktopServices
|
||||
from PySide6.QtCore import QUrl
|
||||
from PySide6.QtWidgets import QFileDialog, QMessageBox
|
||||
|
||||
DOCK_POSITIONS = {'right' : QtCore.Qt.RightDockWidgetArea,
|
||||
'left' : QtCore.Qt.LeftDockWidgetArea,
|
||||
'top' : QtCore.Qt.TopDockWidgetArea,
|
||||
'bottom' : QtCore.Qt.BottomDockWidgetArea}
|
||||
DOCK_POSITIONS = {
|
||||
"right": QtCore.Qt.RightDockWidgetArea,
|
||||
"left": QtCore.Qt.LeftDockWidgetArea,
|
||||
"top": QtCore.Qt.TopDockWidgetArea,
|
||||
"bottom": QtCore.Qt.BottomDockWidgetArea,
|
||||
}
|
||||
|
||||
def layout(parent,items,
|
||||
top_widget = None,
|
||||
layout_type = QtWidgets.QVBoxLayout,
|
||||
margin = 2,
|
||||
spacing = 0):
|
||||
|
||||
def layout(
|
||||
parent,
|
||||
items,
|
||||
top_widget=None,
|
||||
layout_type=QtWidgets.QVBoxLayout,
|
||||
margin=2,
|
||||
spacing=0,
|
||||
):
|
||||
if not top_widget:
|
||||
top_widget = QtWidgets.QWidget(parent)
|
||||
top_widget_was_none = True
|
||||
@@ -26,109 +31,123 @@ def layout(parent,items,
|
||||
layout = layout_type(top_widget)
|
||||
top_widget.setLayout(layout)
|
||||
|
||||
for item in items: layout.addWidget(item)
|
||||
for item in items:
|
||||
layout.addWidget(item)
|
||||
|
||||
layout.setSpacing(spacing)
|
||||
layout.setContentsMargins(margin,margin,margin,margin)
|
||||
layout.setContentsMargins(margin, margin, margin, margin)
|
||||
|
||||
if top_widget_was_none:
|
||||
return top_widget
|
||||
else:
|
||||
return layout
|
||||
|
||||
def splitter(items,
|
||||
stretch_factors = None,
|
||||
orientation=QtCore.Qt.Horizontal):
|
||||
|
||||
def splitter(items, stretch_factors=None, orientation=QtCore.Qt.Horizontal):
|
||||
sp = QtWidgets.QSplitter(orientation)
|
||||
|
||||
for item in items: sp.addWidget(item)
|
||||
for item in items:
|
||||
sp.addWidget(item)
|
||||
|
||||
if stretch_factors:
|
||||
for i,s in enumerate(stretch_factors):
|
||||
sp.setStretchFactor(i,s)
|
||||
|
||||
for i, s in enumerate(stretch_factors):
|
||||
sp.setStretchFactor(i, s)
|
||||
|
||||
return sp
|
||||
|
||||
def dock(widget,
|
||||
|
||||
def dock(
|
||||
widget,
|
||||
title,
|
||||
parent,
|
||||
allowedAreas = QtCore.Qt.AllDockWidgetAreas,
|
||||
defaultArea = 'right',
|
||||
allowedAreas=QtCore.Qt.AllDockWidgetAreas,
|
||||
defaultArea="right",
|
||||
name=None,
|
||||
icon = None):
|
||||
icon=None,
|
||||
):
|
||||
dock = QtWidgets.QDockWidget(title, parent, objectName=title)
|
||||
|
||||
dock = QtWidgets.QDockWidget(title,parent,objectName=title)
|
||||
|
||||
if name: dock.setObjectName(name)
|
||||
if icon: dock.toggleViewAction().setIcon(icon)
|
||||
if name:
|
||||
dock.setObjectName(name)
|
||||
if icon:
|
||||
dock.toggleViewAction().setIcon(icon)
|
||||
|
||||
dock.setAllowedAreas(allowedAreas)
|
||||
dock.setWidget(widget)
|
||||
action = dock.toggleViewAction()
|
||||
action.setText(title)
|
||||
|
||||
dock.setFeatures(QtWidgets.QDockWidget.DockWidgetFeatures(\
|
||||
QtWidgets.QDockWidget.AllDockWidgetFeatures))
|
||||
dock.setFeatures(
|
||||
QtWidgets.QDockWidget.DockWidgetFeatures(
|
||||
QtWidgets.QDockWidget.DockWidgetFloatable
|
||||
)
|
||||
)
|
||||
|
||||
parent.addDockWidget(DOCK_POSITIONS[defaultArea],
|
||||
dock)
|
||||
parent.addDockWidget(DOCK_POSITIONS[defaultArea], dock)
|
||||
|
||||
return dock
|
||||
|
||||
def add_actions(menu,actions):
|
||||
|
||||
def add_actions(menu, actions):
|
||||
if len(actions) > 0:
|
||||
menu.addActions(actions)
|
||||
menu.addSeparator()
|
||||
|
||||
def open_url(url):
|
||||
|
||||
def open_url(url):
|
||||
QDesktopServices.openUrl(QUrl(url))
|
||||
|
||||
def about_dialog(parent,title,text):
|
||||
|
||||
QtWidgets.QMessageBox.about(parent,title,text)
|
||||
def about_dialog(parent, title, text):
|
||||
QtWidgets.QMessageBox.about(parent, title, text)
|
||||
|
||||
|
||||
def get_save_filename(suffix):
|
||||
|
||||
rv,_ = QFileDialog.getSaveFileName(filter='*.{}'.format(suffix))
|
||||
if rv != '' and not rv.endswith(suffix): rv += '.'+suffix
|
||||
rv, _ = QFileDialog.getSaveFileName(filter="*.{}".format(suffix))
|
||||
if rv != "" and not rv.endswith(suffix):
|
||||
rv += "." + suffix
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def get_open_filename(suffix, curr_dir):
|
||||
|
||||
rv,_ = QFileDialog.getOpenFileName(directory=curr_dir, filter='*.{}'.format(suffix))
|
||||
if rv != '' and not rv.endswith(suffix): rv += '.'+suffix
|
||||
rv, _ = QFileDialog.getOpenFileName(
|
||||
directory=curr_dir, filter="*.{}".format(suffix)
|
||||
)
|
||||
if rv != "" and not rv.endswith(suffix):
|
||||
rv += "." + suffix
|
||||
|
||||
return rv
|
||||
|
||||
def check_gtihub_for_updates(parent,
|
||||
mod,
|
||||
github_org='cadquery',
|
||||
github_proj='cadquery'):
|
||||
|
||||
url = f'https://api.github.com/repos/{github_org}/{github_proj}/releases'
|
||||
def check_gtihub_for_updates(
|
||||
parent, mod, github_org="cadquery", github_proj="cadquery"
|
||||
):
|
||||
url = f"https://api.github.com/repos/{github_org}/{github_proj}/releases"
|
||||
resp = requests.get(url).json()
|
||||
|
||||
newer = [el['tag_name'] for el in resp if not el['draft'] and \
|
||||
parse_version(el['tag_name']) > parse_version(mod.__version__)]
|
||||
newer = [
|
||||
el["tag_name"]
|
||||
for el in resp
|
||||
if not el["draft"]
|
||||
and parse_version(el["tag_name"]) > parse_version(mod.__version__)
|
||||
]
|
||||
|
||||
if newer:
|
||||
title='Updates available'
|
||||
text=f'There are newer versions of {github_proj} ' \
|
||||
f'available on github:\n' + '\n'.join(newer)
|
||||
title = "Updates available"
|
||||
text = (
|
||||
f"There are newer versions of {github_proj} "
|
||||
f"available on github:\n" + "\n".join(newer)
|
||||
)
|
||||
|
||||
else:
|
||||
title='No updates available'
|
||||
text=f'You are already using the latest version of {github_proj}'
|
||||
title = "No updates available"
|
||||
text = f"You are already using the latest version of {github_proj}"
|
||||
|
||||
QtWidgets.QMessageBox.about(parent,title,text)
|
||||
QtWidgets.QMessageBox.about(parent, title, text)
|
||||
|
||||
def confirm(parent,title,msg):
|
||||
|
||||
def confirm(parent, title, msg):
|
||||
rv = QMessageBox.question(parent, title, msg, QMessageBox.Yes, QMessageBox.No)
|
||||
|
||||
return True if rv == QMessageBox.Yes else False
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtCore import Slot as pyqtSlot
|
||||
|
||||
from qtconsole.rich_jupyter_widget import RichJupyterWidget
|
||||
from qtconsole.inprocess import QtInProcessKernelManager
|
||||
|
||||
from ..mixins import ComponentMixin
|
||||
|
||||
class ConsoleWidget(RichJupyterWidget,ComponentMixin):
|
||||
|
||||
name = 'Console'
|
||||
class ConsoleWidget(RichJupyterWidget, ComponentMixin):
|
||||
name = "Console"
|
||||
|
||||
def __init__(self, customBanner=None, namespace=dict(), *args, **kwargs):
|
||||
super(ConsoleWidget, self).__init__(*args, **kwargs)
|
||||
|
||||
# if not customBanner is None:
|
||||
# self.banner = customBanner
|
||||
# if not customBanner is None:
|
||||
# self.banner = customBanner
|
||||
|
||||
self.font_size = 6
|
||||
self.style_sheet = '''<style>
|
||||
self.style_sheet = """<style>
|
||||
QPlainTextEdit, QTextEdit {
|
||||
background-color: #3f3f3f;
|
||||
background-clip: padding;
|
||||
@@ -34,12 +34,12 @@ class ConsoleWidget(RichJupyterWidget,ComponentMixin):
|
||||
.in-prompt { color: navy; }
|
||||
.out-prompt { color: darkred; }
|
||||
</style>
|
||||
'''
|
||||
self.syntax_style = 'zenburn' #CHANGES FOR DARKMODE
|
||||
"""
|
||||
self.syntax_style = "zenburn" # CHANGES FOR DARKMODE
|
||||
|
||||
self.kernel_manager = kernel_manager = QtInProcessKernelManager()
|
||||
kernel_manager.start_kernel(show_banner=False)
|
||||
kernel_manager.kernel.gui = 'qt'
|
||||
kernel_manager.kernel.gui = "qt"
|
||||
kernel_manager.kernel.shell.banner1 = ""
|
||||
|
||||
self.kernel_client = kernel_client = self._kernel_manager.client()
|
||||
@@ -70,7 +70,6 @@ class ConsoleWidget(RichJupyterWidget,ComponentMixin):
|
||||
"""
|
||||
self._control.clear()
|
||||
|
||||
|
||||
def print_text(self, text):
|
||||
"""
|
||||
Prints some plain text to the console
|
||||
@@ -84,18 +83,15 @@ class ConsoleWidget(RichJupyterWidget,ComponentMixin):
|
||||
self._execute(command, False)
|
||||
|
||||
def _banner_default(self):
|
||||
|
||||
return ''
|
||||
return ""
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
console = ConsoleWidget(customBanner='IPython console test')
|
||||
console = ConsoleWidget(customBanner="IPython console test")
|
||||
console.show()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAction
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||
|
||||
from PySide6.QtWidgets import QTreeWidget, QTreeWidgetItem
|
||||
from PySide6.QtCore import Qt, Slot as pyqtSlot, Signal as pyqtSignal
|
||||
from PySide6.QtGui import QAction
|
||||
from OCP.AIS import AIS_ColoredShape
|
||||
from OCP.gp import gp_Ax3
|
||||
|
||||
@@ -10,63 +10,62 @@ from ..mixins import ComponentMixin
|
||||
from ..icons import icon
|
||||
|
||||
|
||||
|
||||
class CQChildItem(QTreeWidgetItem):
|
||||
|
||||
def __init__(self,cq_item,**kwargs):
|
||||
|
||||
super(CQChildItem,self).\
|
||||
__init__([type(cq_item).__name__,str(cq_item)],**kwargs)
|
||||
def __init__(self, cq_item, **kwargs):
|
||||
super(CQChildItem, self).__init__(
|
||||
[type(cq_item).__name__, str(cq_item)], **kwargs
|
||||
)
|
||||
|
||||
self.cq_item = cq_item
|
||||
|
||||
|
||||
class CQStackItem(QTreeWidgetItem):
|
||||
|
||||
def __init__(self,name,workplane=None,**kwargs):
|
||||
|
||||
super(CQStackItem,self).__init__([name,''],**kwargs)
|
||||
def __init__(self, name, workplane=None, **kwargs):
|
||||
super(CQStackItem, self).__init__([name, ""], **kwargs)
|
||||
|
||||
self.workplane = workplane
|
||||
|
||||
|
||||
class CQObjectInspector(QTreeWidget,ComponentMixin):
|
||||
|
||||
name = 'CQ Object Inspector'
|
||||
class CQObjectInspector(QTreeWidget, ComponentMixin):
|
||||
name = "CQ Object Inspector"
|
||||
|
||||
sigRemoveObjects = pyqtSignal(list)
|
||||
sigDisplayObjects = pyqtSignal(list,bool)
|
||||
sigShowPlane = pyqtSignal([bool],[bool,float])
|
||||
sigDisplayObjects = pyqtSignal(list, bool)
|
||||
sigShowPlane = pyqtSignal(bool)
|
||||
sigShowPlane2 = pyqtSignal(bool, float)
|
||||
sigChangePlane = pyqtSignal(gp_Ax3)
|
||||
|
||||
def __init__(self,parent):
|
||||
|
||||
super(CQObjectInspector,self).__init__(parent)
|
||||
def __init__(self, parent):
|
||||
super(CQObjectInspector, self).__init__(parent)
|
||||
self.setHeaderHidden(False)
|
||||
self.setRootIsDecorated(True)
|
||||
self.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||
self.setColumnCount(2)
|
||||
self.setHeaderLabels(['Type','Value'])
|
||||
self.setHeaderLabels(["Type", "Value"])
|
||||
|
||||
self.root = self.invisibleRootItem()
|
||||
self.inspected_items = []
|
||||
|
||||
self._toolbar_actions = \
|
||||
[QAction(icon('inspect'),'Inspect CQ object',self,\
|
||||
toggled=self.inspect,checkable=True)]
|
||||
self._toolbar_actions = [
|
||||
QAction(
|
||||
icon("inspect"),
|
||||
"Inspect CQ object",
|
||||
self,
|
||||
toggled=self.inspect,
|
||||
checkable=True,
|
||||
)
|
||||
]
|
||||
|
||||
self.addActions(self._toolbar_actions)
|
||||
|
||||
def menuActions(self):
|
||||
|
||||
return {'Tools' : self._toolbar_actions}
|
||||
return {"Tools": self._toolbar_actions}
|
||||
|
||||
def toolbarActions(self):
|
||||
|
||||
return self._toolbar_actions
|
||||
|
||||
@pyqtSlot(bool)
|
||||
def inspect(self,value):
|
||||
|
||||
def inspect(self, value):
|
||||
if value:
|
||||
self.itemSelectionChanged.connect(self.handleSelection)
|
||||
self.itemSelectionChanged.emit()
|
||||
@@ -77,7 +76,6 @@ class CQObjectInspector(QTreeWidget,ComponentMixin):
|
||||
|
||||
@pyqtSlot()
|
||||
def handleSelection(self):
|
||||
|
||||
inspected_items = self.inspected_items
|
||||
self.sigRemoveObjects.emit(inspected_items)
|
||||
inspected_items.clear()
|
||||
@@ -90,40 +88,37 @@ class CQObjectInspector(QTreeWidget,ComponentMixin):
|
||||
if type(item) is CQStackItem:
|
||||
cq_plane = item.workplane.plane
|
||||
dim = item.workplane.largestDimension()
|
||||
plane = gp_Ax3(cq_plane.origin.toPnt(),
|
||||
cq_plane.zDir.toDir(),
|
||||
cq_plane.xDir.toDir())
|
||||
plane = gp_Ax3(
|
||||
cq_plane.origin.toPnt(), cq_plane.zDir.toDir(), cq_plane.xDir.toDir()
|
||||
)
|
||||
self.sigChangePlane.emit(plane)
|
||||
self.sigShowPlane[bool,float].emit(True,dim)
|
||||
self.sigShowPlane[bool, float].emit(True, dim)
|
||||
|
||||
for child in (item.child(i) for i in range(item.childCount())):
|
||||
obj = child.cq_item
|
||||
if hasattr(obj,'wrapped') and type(obj) != Vector:
|
||||
if hasattr(obj, "wrapped") and type(obj) != Vector:
|
||||
ais = AIS_ColoredShape(obj.wrapped)
|
||||
inspected_items.append(ais)
|
||||
|
||||
else:
|
||||
self.sigShowPlane.emit(False)
|
||||
obj = item.cq_item
|
||||
if hasattr(obj,'wrapped') and type(obj) != Vector:
|
||||
if hasattr(obj, "wrapped") and type(obj) != Vector:
|
||||
ais = AIS_ColoredShape(obj.wrapped)
|
||||
inspected_items.append(ais)
|
||||
|
||||
self.sigDisplayObjects.emit(inspected_items,False)
|
||||
self.sigDisplayObjects.emit(inspected_items, False)
|
||||
|
||||
@pyqtSlot(object)
|
||||
def setObject(self,cq_obj):
|
||||
|
||||
def setObject(self, cq_obj):
|
||||
self.root.takeChildren()
|
||||
|
||||
# iterate through parent objects if they exist
|
||||
while getattr(cq_obj, 'parent', None):
|
||||
current_frame = CQStackItem(str(cq_obj.plane.origin),workplane=cq_obj)
|
||||
while getattr(cq_obj, "parent", None):
|
||||
current_frame = CQStackItem(str(cq_obj.plane.origin), workplane=cq_obj)
|
||||
self.root.addChild(current_frame)
|
||||
|
||||
for obj in cq_obj.objects:
|
||||
current_frame.addChild(CQChildItem(obj))
|
||||
|
||||
cq_obj = cq_obj.parent
|
||||
|
||||
|
||||
@@ -5,16 +5,17 @@ from types import SimpleNamespace, FrameType, ModuleType
|
||||
from typing import List
|
||||
|
||||
import cadquery as cq
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import (
|
||||
from PySide6 import QtCore
|
||||
from PySide6.QtCore import (
|
||||
Qt,
|
||||
QObject,
|
||||
pyqtSlot,
|
||||
pyqtSignal,
|
||||
Slot as pyqtSlot,
|
||||
Signal as pyqtSignal,
|
||||
QEventLoop,
|
||||
QAbstractTableModel,
|
||||
)
|
||||
from PyQt5.QtWidgets import QAction, QTableView
|
||||
from PySide6.QtWidgets import QTableView
|
||||
from PySide6.QtGui import QAction
|
||||
from logbook import info
|
||||
from path import Path
|
||||
from pyqtgraph.parametertree import Parameter
|
||||
@@ -186,7 +187,7 @@ class Debugger(QObject, ComponentMixin):
|
||||
def _exec(self, code, locals_dict, globals_dict):
|
||||
with ExitStack() as stack:
|
||||
fname = self.parent().components["editor"].filename
|
||||
p = Path(fname if fname else "").absolute().dirname()
|
||||
p = Path(fname if fname else "").abspath().dirname()
|
||||
|
||||
if self.preferences["Add script dir to path"] and p.exists():
|
||||
sys.path.insert(0, p)
|
||||
|
||||
@@ -2,9 +2,11 @@ import os
|
||||
from modulefinder import ModuleFinder
|
||||
|
||||
from spyder.plugins.editor.widgets.codeeditor import CodeEditor
|
||||
from PyQt5.QtCore import pyqtSignal, QFileSystemWatcher, QTimer
|
||||
from PyQt5.QtWidgets import QAction, QFileDialog
|
||||
from PyQt5.QtGui import QFontDatabase
|
||||
from PySide6.QtCore import Signal as pyqtSignal
|
||||
from PySide6.QtCore import QFileSystemWatcher, QTimerEvent, QTimer
|
||||
|
||||
from PySide6.QtWidgets import QFileDialog
|
||||
from PySide6.QtGui import QFontDatabase, QAction
|
||||
from path import Path
|
||||
|
||||
import sys
|
||||
@@ -16,91 +18,104 @@ from ..utils import get_save_filename, get_open_filename, confirm
|
||||
|
||||
from ..icons import icon
|
||||
|
||||
class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
name = 'Code Editor'
|
||||
class Editor(CodeEditor, ComponentMixin):
|
||||
name = "Code Editor"
|
||||
|
||||
# This signal is emitted whenever the currently-open file changes and
|
||||
# autoreload is enabled.
|
||||
triggerRerender = pyqtSignal(bool)
|
||||
sigFilenameChanged = pyqtSignal(str)
|
||||
|
||||
preferences = Parameter.create(name='Preferences',children=[
|
||||
{'name': 'Font size', 'type': 'int', 'value': 12},
|
||||
{'name': 'Autoreload', 'type': 'bool', 'value': False},
|
||||
{'name': 'Autoreload delay', 'type': 'int', 'value': 50},
|
||||
{'name': 'Autoreload: watch imported modules', 'type': 'bool', 'value': False},
|
||||
{'name': 'Line wrap', 'type': 'bool', 'value': False},
|
||||
{'name': 'Color scheme', 'type': 'list',
|
||||
'values': ['Spyder','Monokai','Zenburn'], 'value': 'Spyder'}])
|
||||
preferences = Parameter.create(
|
||||
name="Preferences",
|
||||
children=[
|
||||
{"name": "Font size", "type": "int", "value": 12},
|
||||
{"name": "Autoreload", "type": "bool", "value": False},
|
||||
{"name": "Autoreload delay", "type": "int", "value": 50},
|
||||
{
|
||||
"name": "Autoreload: watch imported modules",
|
||||
"type": "bool",
|
||||
"value": False,
|
||||
},
|
||||
{"name": "Line wrap", "type": "bool", "value": False},
|
||||
{
|
||||
"name": "Color scheme",
|
||||
"type": "list",
|
||||
"values": ["Spyder", "Monokai", "Zenburn"],
|
||||
"value": "Spyder",
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
EXTENSIONS = 'py'
|
||||
|
||||
def __init__(self,parent=None):
|
||||
EXTENSIONS = "py"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
self._watched_file = None
|
||||
|
||||
super(Editor,self).__init__(parent)
|
||||
super(Editor, self).__init__(parent)
|
||||
ComponentMixin.__init__(self)
|
||||
|
||||
self.setup_editor(linenumbers=True,
|
||||
self.setup_editor(
|
||||
linenumbers=True,
|
||||
markers=True,
|
||||
edge_line=False,
|
||||
tab_mode=False,
|
||||
show_blanks=True,
|
||||
font=QFontDatabase.systemFont(QFontDatabase.FixedFont),
|
||||
language='Python',
|
||||
filename='')
|
||||
language="Python",
|
||||
filename="",
|
||||
)
|
||||
|
||||
self._actions = \
|
||||
{'File' : [QAction(icon('new'),
|
||||
'New',
|
||||
self._actions = {
|
||||
"File": [
|
||||
QAction(
|
||||
icon("new"), "New", self, shortcut="ctrl+N", triggered=self.new
|
||||
),
|
||||
QAction(
|
||||
icon("open"), "Open", self, shortcut="ctrl+O", triggered=self.open
|
||||
),
|
||||
QAction(
|
||||
icon("save"), "Save", self, shortcut="ctrl+S", triggered=self.save
|
||||
),
|
||||
QAction(
|
||||
icon("save_as"),
|
||||
"Save as",
|
||||
self,
|
||||
shortcut='ctrl+N',
|
||||
triggered=self.new),
|
||||
QAction(icon('open'),
|
||||
'Open',
|
||||
shortcut="ctrl+shift+S",
|
||||
triggered=self.save_as,
|
||||
),
|
||||
QAction(
|
||||
icon("autoreload"),
|
||||
"Automatic reload and preview",
|
||||
self,
|
||||
shortcut='ctrl+O',
|
||||
triggered=self.open),
|
||||
QAction(icon('save'),
|
||||
'Save',
|
||||
self,
|
||||
shortcut='ctrl+S',
|
||||
triggered=self.save),
|
||||
QAction(icon('save_as'),
|
||||
'Save as',
|
||||
self,
|
||||
shortcut='ctrl+shift+S',
|
||||
triggered=self.save_as),
|
||||
QAction(icon('autoreload'),
|
||||
'Automatic reload and preview',
|
||||
self,triggered=self.autoreload,
|
||||
triggered=self.autoreload,
|
||||
checkable=True,
|
||||
checked=False,
|
||||
objectName='autoreload'),
|
||||
]}
|
||||
objectName="autoreload",
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
for a in self._actions.values():
|
||||
self.addActions(a)
|
||||
|
||||
|
||||
self._fixContextMenu()
|
||||
|
||||
# autoreload support
|
||||
self._file_watcher = QFileSystemWatcher(self)
|
||||
# we wait for 50ms after a file change for the file to be written completely
|
||||
self._file_watch_timer = QTimer(self)
|
||||
self._file_watch_timer.setInterval(self.preferences['Autoreload delay'])
|
||||
self._file_watch_timer.setInterval(self.preferences["Autoreload delay"])
|
||||
self._file_watch_timer.setSingleShot(True)
|
||||
self._file_watcher.fileChanged.connect(
|
||||
lambda val: self._file_watch_timer.start())
|
||||
lambda val: self._file_watch_timer.start()
|
||||
)
|
||||
self._file_watch_timer.timeout.connect(self._file_changed)
|
||||
|
||||
self.updatePreferences()
|
||||
|
||||
def _fixContextMenu(self):
|
||||
|
||||
menu = self.menu
|
||||
|
||||
menu.removeAction(self.run_cell_action)
|
||||
@@ -108,68 +123,66 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
menu.removeAction(self.run_selection_action)
|
||||
menu.removeAction(self.re_run_last_cell_action)
|
||||
|
||||
def updatePreferences(self,*args):
|
||||
|
||||
self.set_color_scheme(self.preferences['Color scheme'])
|
||||
def updatePreferences(self, *args):
|
||||
self.set_color_scheme(self.preferences["Color scheme"])
|
||||
|
||||
font = self.font()
|
||||
font.setPointSize(self.preferences['Font size'])
|
||||
font.setPointSize(self.preferences["Font size"])
|
||||
self.set_font(font)
|
||||
|
||||
self.findChild(QAction, 'autoreload') \
|
||||
.setChecked(self.preferences['Autoreload'])
|
||||
self.findChild(QAction, "autoreload").setChecked(self.preferences["Autoreload"])
|
||||
|
||||
self._file_watch_timer.setInterval(self.preferences['Autoreload delay'])
|
||||
self._file_watch_timer.setInterval(self.preferences["Autoreload delay"])
|
||||
|
||||
self.toggle_wrap_mode(self.preferences['Line wrap'])
|
||||
self.toggle_wrap_mode(self.preferences["Line wrap"])
|
||||
|
||||
self._clear_watched_paths()
|
||||
self._watch_paths()
|
||||
|
||||
def confirm_discard(self):
|
||||
|
||||
if self.modified:
|
||||
rv = confirm(self,'Please confirm','Current document is not saved - do you want to continue?')
|
||||
rv = confirm(
|
||||
self,
|
||||
"Please confirm",
|
||||
"Current document is not saved - do you want to continue?",
|
||||
)
|
||||
else:
|
||||
rv = True
|
||||
|
||||
return rv
|
||||
|
||||
def new(self):
|
||||
if not self.confirm_discard():
|
||||
return
|
||||
|
||||
if not self.confirm_discard(): return
|
||||
|
||||
self.set_text('')
|
||||
self.filename = ''
|
||||
self.set_text("")
|
||||
self.filename = ""
|
||||
self.reset_modified()
|
||||
|
||||
def open(self):
|
||||
if not self.confirm_discard():
|
||||
return
|
||||
|
||||
if not self.confirm_discard(): return
|
||||
|
||||
curr_dir = Path(self.filename).absolute().dirname()
|
||||
curr_dir = Path(self.filename).abspath().dirname()
|
||||
fname = get_open_filename(self.EXTENSIONS, curr_dir)
|
||||
if fname != '':
|
||||
if fname != "":
|
||||
self.load_from_file(fname)
|
||||
|
||||
def load_from_file(self,fname):
|
||||
|
||||
def load_from_file(self, fname):
|
||||
self.set_text_from_file(fname)
|
||||
self.filename = fname
|
||||
self.reset_modified()
|
||||
|
||||
def save(self):
|
||||
|
||||
if self._filename != '':
|
||||
|
||||
if self.preferences['Autoreload']:
|
||||
if self._filename != "":
|
||||
if self.preferences["Autoreload"]:
|
||||
self._file_watcher.blockSignals(True)
|
||||
self._file_watch_timer.stop()
|
||||
|
||||
with open(self._filename, 'w') as f:
|
||||
with open(self._filename, "w") as f:
|
||||
f.write(self.toPlainText())
|
||||
|
||||
if self.preferences['Autoreload']:
|
||||
if self.preferences["Autoreload"]:
|
||||
self._file_watcher.blockSignals(False)
|
||||
self.triggerRerender.emit(True)
|
||||
|
||||
@@ -179,20 +192,25 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
self.save_as()
|
||||
|
||||
def save_as(self):
|
||||
|
||||
fname = get_save_filename(self.EXTENSIONS)
|
||||
if fname != '':
|
||||
with open(fname,'w') as f:
|
||||
if fname != "":
|
||||
with open(fname, "w") as f:
|
||||
f.write(self.toPlainText())
|
||||
self.filename = fname
|
||||
|
||||
self.reset_modified()
|
||||
|
||||
def _update_filewatcher(self):
|
||||
if self._watched_file and (self._watched_file != self.filename or not self.preferences['Autoreload']):
|
||||
if self._watched_file and (
|
||||
self._watched_file != self.filename or not self.preferences["Autoreload"]
|
||||
):
|
||||
self._clear_watched_paths()
|
||||
self._watched_file = None
|
||||
if self.preferences['Autoreload'] and self.filename and self.filename != self._watched_file:
|
||||
if (
|
||||
self.preferences["Autoreload"]
|
||||
and self.filename
|
||||
and self.filename != self._watched_file
|
||||
):
|
||||
self._watched_file = self._filename
|
||||
self._watch_paths()
|
||||
|
||||
@@ -214,7 +232,7 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
def _watch_paths(self):
|
||||
if Path(self._filename).exists():
|
||||
self._file_watcher.addPath(self._filename)
|
||||
if self.preferences['Autoreload: watch imported modules']:
|
||||
if self.preferences["Autoreload: watch imported modules"]:
|
||||
module_paths = self.get_imported_module_paths(self._filename)
|
||||
if module_paths:
|
||||
self._file_watcher.addPaths(module_paths)
|
||||
@@ -228,51 +246,45 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
# Turn autoreload on/off.
|
||||
def autoreload(self, enabled):
|
||||
self.preferences['Autoreload'] = enabled
|
||||
self.preferences["Autoreload"] = enabled
|
||||
self._update_filewatcher()
|
||||
|
||||
def reset_modified(self):
|
||||
|
||||
self.document().setModified(False)
|
||||
|
||||
@property
|
||||
def modified(self):
|
||||
|
||||
return self.document().isModified()
|
||||
|
||||
def saveComponentState(self,store):
|
||||
def saveComponentState(self, store):
|
||||
if self.filename != "":
|
||||
store.setValue(self.name + "/state", self.filename)
|
||||
|
||||
if self.filename != '':
|
||||
store.setValue(self.name+'/state',self.filename)
|
||||
def restoreComponentState(self, store):
|
||||
filename = store.value(self.name + "/state")
|
||||
|
||||
def restoreComponentState(self,store):
|
||||
|
||||
filename = store.value(self.name+'/state')
|
||||
|
||||
if filename and self.filename == '':
|
||||
if filename and self.filename == "":
|
||||
try:
|
||||
self.load_from_file(filename)
|
||||
except IOError:
|
||||
self._logger.warning(f'could not open {filename}')
|
||||
|
||||
self._logger.warning(f"could not open {filename}")
|
||||
|
||||
def get_imported_module_paths(self, module_path):
|
||||
|
||||
finder = ModuleFinder([os.path.dirname(module_path)])
|
||||
imported_modules = []
|
||||
|
||||
try:
|
||||
finder.run_script(module_path)
|
||||
except SyntaxError as err:
|
||||
self._logger.warning(f'Syntax error in {module_path}: {err}')
|
||||
self._logger.warning(f"Syntax error in {module_path}: {err}")
|
||||
except Exception as err:
|
||||
self._logger.warning(
|
||||
f'Cannot determine imported modules in {module_path}: {type(err).__name__} {err}'
|
||||
f"Cannot determine imported modules in {module_path}: {type(err).__name__} {err}"
|
||||
)
|
||||
else:
|
||||
for module_name, module in finder.modules.items():
|
||||
if module_name != '__main__':
|
||||
path = getattr(module, '__file__', None)
|
||||
if module_name != "__main__":
|
||||
path = getattr(module, "__file__", None)
|
||||
if path is not None and os.path.isfile(path):
|
||||
imported_modules.append(path)
|
||||
|
||||
@@ -280,8 +292,7 @@ class Editor(CodeEditor,ComponentMixin):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
editor = Editor()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logbook as logging
|
||||
|
||||
from PyQt5.QtWidgets import QPlainTextEdit
|
||||
from PyQt5 import QtCore
|
||||
from PySide6.QtWidgets import QPlainTextEdit
|
||||
from PySide6 import QtCore
|
||||
|
||||
from ..mixins import ComponentMixin
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from PyQt5.QtWidgets import (
|
||||
from PySide6.QtWidgets import (
|
||||
QTreeWidget,
|
||||
QTreeWidgetItem,
|
||||
QAction,
|
||||
QMenu,
|
||||
QWidget,
|
||||
QAbstractItemView,
|
||||
)
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtCore import Qt, Slot as pyqtSlot, Signal as pyqtSignal
|
||||
from pyqtgraph.parametertree import Parameter, ParameterTree
|
||||
|
||||
from OCP.AIS import AIS_Line
|
||||
@@ -114,7 +114,8 @@ class ObjectTree(QWidget, ComponentMixin):
|
||||
],
|
||||
)
|
||||
|
||||
sigObjectsAdded = pyqtSignal([list], [list, bool])
|
||||
sigObjectsAdded = pyqtSignal(list)
|
||||
sigObjectsAdded2 = pyqtSignal(list, bool)
|
||||
sigObjectsRemoved = pyqtSignal(list)
|
||||
sigCQObjectSelected = pyqtSignal(object)
|
||||
sigAISObjectsSelected = pyqtSignal(list)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from sys import platform
|
||||
|
||||
|
||||
from PyQt5.QtWidgets import QWidget, QApplication
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QEvent
|
||||
from PySide6.QtWidgets import QWidget, QApplication
|
||||
from PySide6.QtCore import Slot as pyqtSlot, Signal as pyqtSignal, Qt, QEvent
|
||||
|
||||
import OCP
|
||||
|
||||
@@ -17,12 +17,10 @@ ZOOM_STEP = 0.9
|
||||
|
||||
|
||||
class OCCTWidget(QWidget):
|
||||
|
||||
sigObjectSelected = pyqtSignal(list)
|
||||
|
||||
def __init__(self,parent=None):
|
||||
|
||||
super(OCCTWidget,self).__init__(parent)
|
||||
def __init__(self, parent=None):
|
||||
super(OCCTWidget, self).__init__(parent)
|
||||
|
||||
self.setAttribute(Qt.WA_NativeWindow)
|
||||
self.setAttribute(Qt.WA_PaintOnScreen)
|
||||
@@ -31,7 +29,7 @@ class OCCTWidget(QWidget):
|
||||
self._initialized = False
|
||||
self._needs_update = False
|
||||
|
||||
#OCCT secific things
|
||||
# OCCT secific things
|
||||
self.display_connection = Aspect_DisplayConnection()
|
||||
self.graphics_driver = OpenGl_GraphicDriver(self.display_connection)
|
||||
|
||||
@@ -39,11 +37,10 @@ class OCCTWidget(QWidget):
|
||||
self.view = self.viewer.CreateView()
|
||||
self.context = AIS_InteractiveContext(self.viewer)
|
||||
|
||||
#Trihedorn, lights, etc
|
||||
# Trihedorn, lights, etc
|
||||
self.prepare_display()
|
||||
|
||||
def prepare_display(self):
|
||||
|
||||
view = self.view
|
||||
|
||||
params = view.ChangeRenderingParams()
|
||||
@@ -51,8 +48,8 @@ class OCCTWidget(QWidget):
|
||||
params.IsAntialiasingEnabled = True
|
||||
|
||||
view.TriedronDisplay(
|
||||
Aspect_TypeOfTriedronPosition.Aspect_TOTP_RIGHT_LOWER,
|
||||
Quantity_Color(), 0.1)
|
||||
Aspect_TypeOfTriedronPosition.Aspect_TOTP_RIGHT_LOWER, Quantity_Color(), 0.1
|
||||
)
|
||||
|
||||
view.ZBufferTriedronSetup(Quantity_Color(*(0.2, 0.0, 0.0), TOC_RGB))
|
||||
|
||||
@@ -67,14 +64,12 @@ class OCCTWidget(QWidget):
|
||||
ctx.DefaultDrawer().SetFaceBoundaryDraw(True)
|
||||
|
||||
def wheelEvent(self, event):
|
||||
|
||||
delta = event.angleDelta().y()
|
||||
factor = ZOOM_STEP if delta<0 else 1/ZOOM_STEP
|
||||
factor = ZOOM_STEP if delta < 0 else 1 / ZOOM_STEP
|
||||
|
||||
self.view.SetZoom(factor)
|
||||
|
||||
def mousePressEvent(self,event):
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
pos = event.pos()
|
||||
|
||||
if event.button() == Qt.LeftButton:
|
||||
@@ -84,36 +79,31 @@ class OCCTWidget(QWidget):
|
||||
|
||||
self.old_pos = pos
|
||||
|
||||
def mouseMoveEvent(self,event):
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
pos = event.pos()
|
||||
x,y = pos.x(),pos.y()
|
||||
x, y = pos.x(), pos.y()
|
||||
|
||||
if event.buttons() == Qt.LeftButton:
|
||||
self.view.Rotation(x,y)
|
||||
self.view.Rotation(x, y)
|
||||
|
||||
elif event.buttons() == Qt.MiddleButton:
|
||||
self.view.Pan(x - self.old_pos.x(),
|
||||
self.old_pos.y() - y, theToStart=True)
|
||||
self.view.Pan(x - self.old_pos.x(), self.old_pos.y() - y, theToStart=True)
|
||||
|
||||
elif event.buttons() == Qt.RightButton:
|
||||
self.view.Pan(x - self.old_pos.x(),
|
||||
self.old_pos.y() - y, theToStart=True)
|
||||
self.view.Pan(x - self.old_pos.x(), self.old_pos.y() - y, theToStart=True)
|
||||
|
||||
self.old_pos = pos
|
||||
|
||||
def mouseReleaseEvent(self,event):
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
pos = event.pos()
|
||||
x,y = pos.x(),pos.y()
|
||||
x, y = pos.x(), pos.y()
|
||||
|
||||
self.context.MoveTo(x,y,self.view,True)
|
||||
self.context.MoveTo(x, y, self.view, True)
|
||||
|
||||
self._handle_selection()
|
||||
|
||||
def _handle_selection(self):
|
||||
|
||||
self.context.Select(True)
|
||||
self.context.InitSelected()
|
||||
|
||||
@@ -124,52 +114,45 @@ class OCCTWidget(QWidget):
|
||||
self.sigObjectSelected.emit(selected)
|
||||
|
||||
def paintEngine(self):
|
||||
|
||||
return None
|
||||
|
||||
def paintEvent(self, event):
|
||||
|
||||
if not self._initialized:
|
||||
self._initialize()
|
||||
else:
|
||||
self.view.Redraw()
|
||||
|
||||
def showEvent(self, event):
|
||||
|
||||
super(OCCTWidget,self).showEvent(event)
|
||||
super(OCCTWidget, self).showEvent(event)
|
||||
|
||||
def resizeEvent(self, event):
|
||||
|
||||
super(OCCTWidget,self).resizeEvent(event)
|
||||
super(OCCTWidget, self).resizeEvent(event)
|
||||
|
||||
self.view.MustBeResized()
|
||||
|
||||
def _initialize(self):
|
||||
|
||||
wins = {
|
||||
'darwin' : self._get_window_osx,
|
||||
'linux' : self._get_window_linux,
|
||||
'win32': self._get_window_win
|
||||
"darwin": self._get_window_osx,
|
||||
"linux": self._get_window_linux,
|
||||
"win32": self._get_window_win,
|
||||
}
|
||||
|
||||
self.view.SetWindow(wins.get(platform,self._get_window_linux)(self.winId()))
|
||||
self.view.SetWindow(wins.get(platform, self._get_window_linux)(self.winId()))
|
||||
|
||||
self._initialized = True
|
||||
|
||||
def _get_window_win(self,wid):
|
||||
|
||||
def _get_window_win(self, wid):
|
||||
from OCP.WNT import WNT_Window
|
||||
|
||||
print(wid)
|
||||
return WNT_Window(wid.ascapsule())
|
||||
|
||||
def _get_window_linux(self,wid):
|
||||
|
||||
def _get_window_linux(self, wid):
|
||||
from OCP.Xw import Xw_Window
|
||||
|
||||
return Xw_Window(self.display_connection,int(wid))
|
||||
|
||||
def _get_window_osx(self,wid):
|
||||
return Xw_Window(self.display_connection, int(wid))
|
||||
|
||||
def _get_window_osx(self, wid):
|
||||
from OCP.Cocoa import Cocoa_Window
|
||||
|
||||
return Cocoa_Window(wid.ascapsule())
|
||||
|
||||
@@ -1,97 +1,89 @@
|
||||
from traceback import extract_tb, format_exception_only
|
||||
|
||||
from PyQt5.QtWidgets import (QWidget, QTreeWidget, QTreeWidgetItem, QAction,
|
||||
QLabel)
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||
from PySide6.QtWidgets import QWidget, QTreeWidget, QTreeWidgetItem, QLabel
|
||||
from PySide6.QtGui import QAction
|
||||
from PySide6.QtCore import Qt, Slot as pyqtSlot, Signal as pyqtSignal
|
||||
|
||||
from ..mixins import ComponentMixin
|
||||
from ..utils import layout
|
||||
|
||||
|
||||
class TracebackTree(QTreeWidget):
|
||||
name = "Traceback Viewer"
|
||||
|
||||
name = 'Traceback Viewer'
|
||||
|
||||
def __init__(self,parent):
|
||||
|
||||
super(TracebackTree,self).__init__(parent)
|
||||
def __init__(self, parent):
|
||||
super(TracebackTree, self).__init__(parent)
|
||||
self.setHeaderHidden(False)
|
||||
self.setItemsExpandable(False)
|
||||
self.setRootIsDecorated(False)
|
||||
self.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||
|
||||
self.setColumnCount(3)
|
||||
self.setHeaderLabels(['File','Line','Code'])
|
||||
|
||||
self.setHeaderLabels(["File", "Line", "Code"])
|
||||
|
||||
self.root = self.invisibleRootItem()
|
||||
|
||||
class TracebackPane(QWidget,ComponentMixin):
|
||||
|
||||
class TracebackPane(QWidget, ComponentMixin):
|
||||
sigHighlightLine = pyqtSignal(int)
|
||||
|
||||
def __init__(self,parent):
|
||||
|
||||
super(TracebackPane,self).__init__(parent)
|
||||
def __init__(self, parent):
|
||||
super(TracebackPane, self).__init__(parent)
|
||||
|
||||
self.tree = TracebackTree(self)
|
||||
self.current_exception = QLabel(self)
|
||||
self.current_exception.setStyleSheet(\
|
||||
"QLabel {color : red; }");
|
||||
self.current_exception.setStyleSheet("QLabel {color : red; }")
|
||||
|
||||
layout(self,
|
||||
(self.current_exception,
|
||||
self.tree),
|
||||
self)
|
||||
layout(self, (self.current_exception, self.tree), self)
|
||||
|
||||
self.tree.currentItemChanged.connect(self.handleSelection)
|
||||
|
||||
@pyqtSlot(object,str)
|
||||
def addTraceback(self,exc_info,code):
|
||||
|
||||
@pyqtSlot(object, str)
|
||||
def addTraceback(self, exc_info, code):
|
||||
self.tree.clear()
|
||||
|
||||
if exc_info:
|
||||
t,exc,tb = exc_info
|
||||
t, exc, tb = exc_info
|
||||
|
||||
root = self.tree.root
|
||||
code = code.splitlines()
|
||||
tb = [t for t in extract_tb(tb) if '<string>' in t.filename] #ignore highest frames (debug, exec)
|
||||
tb = [
|
||||
t for t in extract_tb(tb) if "<string>" in t.filename
|
||||
] # ignore highest frames (debug, exec)
|
||||
|
||||
for el in tb:
|
||||
#workaround of the traceback module
|
||||
if el.line == '':
|
||||
line = code[el.lineno-1].strip()
|
||||
# workaround of the traceback module
|
||||
if el.line == "":
|
||||
line = code[el.lineno - 1].strip()
|
||||
else:
|
||||
line = el.line
|
||||
|
||||
root.addChild(QTreeWidgetItem([el.filename,
|
||||
str(el.lineno),
|
||||
line]))
|
||||
root.addChild(QTreeWidgetItem([el.filename, str(el.lineno), line]))
|
||||
|
||||
exc_name = t.__name__
|
||||
exc_msg = str(exc)
|
||||
exc_msg = exc_msg.replace('<', '<').replace('>', '>') #replace <>
|
||||
exc_msg = exc_msg.replace("<", "<").replace(">", ">") # replace <>
|
||||
|
||||
self.current_exception.\
|
||||
setText('<b>{}</b>: {}'.format(exc_name,exc_msg))
|
||||
self.current_exception.setText("<b>{}</b>: {}".format(exc_name, exc_msg))
|
||||
|
||||
# handle the special case of a SyntaxError
|
||||
if t is SyntaxError:
|
||||
root.addChild(QTreeWidgetItem(
|
||||
[exc.filename,
|
||||
root.addChild(
|
||||
QTreeWidgetItem(
|
||||
[
|
||||
exc.filename,
|
||||
str(exc.lineno),
|
||||
exc.text.strip() if exc.text else '']
|
||||
))
|
||||
exc.text.strip() if exc.text else "",
|
||||
]
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.current_exception.setText('')
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem,QTreeWidgetItem)
|
||||
def handleSelection(self,item,*args):
|
||||
self.current_exception.setText("")
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
|
||||
def handleSelection(self, item, *args):
|
||||
if item:
|
||||
f,line = item.data(0,0),int(item.data(1,0))
|
||||
f, line = item.data(0, 0), int(item.data(1, 0))
|
||||
|
||||
if '<string>' in f:
|
||||
if "<string>" in f:
|
||||
self.sigHighlightLine.emit(line)
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
from PyQt5.QtWidgets import QWidget, QDialog, QTreeWidgetItem, QApplication, QAction
|
||||
from PySide6.QtWidgets import QWidget, QDialog, QTreeWidgetItem, QApplication
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PySide6.QtCore import Slot as pyqtSlot, Signal as pyqtSignal
|
||||
from PySide6.QtGui import QIcon, QAction
|
||||
|
||||
from OCP.Graphic3d import Graphic3d_Camera, Graphic3d_StereoMode, Graphic3d_NOM_JADE,\
|
||||
Graphic3d_MaterialAspect
|
||||
from OCP.AIS import AIS_Shaded,AIS_WireFrame, AIS_ColoredShape, AIS_Axis
|
||||
from OCP.Graphic3d import (
|
||||
Graphic3d_Camera,
|
||||
Graphic3d_StereoMode,
|
||||
Graphic3d_NOM_JADE,
|
||||
Graphic3d_MaterialAspect,
|
||||
)
|
||||
from OCP.AIS import AIS_Shaded, AIS_WireFrame, AIS_ColoredShape, AIS_Axis
|
||||
from OCP.Aspect import Aspect_GDM_Lines, Aspect_GT_Rectangular
|
||||
from OCP.Quantity import Quantity_NOC_BLACK as BLACK, Quantity_TOC_RGB as TOC_RGB,\
|
||||
Quantity_Color
|
||||
from OCP.Quantity import (
|
||||
Quantity_NOC_BLACK as BLACK,
|
||||
Quantity_TOC_RGB as TOC_RGB,
|
||||
Quantity_Color,
|
||||
)
|
||||
from OCP.Geom import Geom_Axis1Placement
|
||||
from OCP.gp import gp_Ax3, gp_Dir, gp_Pnt, gp_Ax1
|
||||
|
||||
@@ -25,30 +32,66 @@ import qtawesome as qta
|
||||
DEFAULT_EDGE_COLOR = Quantity_Color(BLACK)
|
||||
DEFAULT_EDGE_WIDTH = 2
|
||||
|
||||
class OCCViewer(QWidget,ComponentMixin):
|
||||
|
||||
name = '3D Viewer'
|
||||
class OCCViewer(QWidget, ComponentMixin):
|
||||
name = "3D Viewer"
|
||||
|
||||
preferences = Parameter.create(name='Pref',children=[
|
||||
{'name': 'Fit automatically', 'type': 'bool', 'value': True},
|
||||
{'name': 'Use gradient', 'type': 'bool', 'value': False},
|
||||
{'name': 'Background color', 'type': 'color', 'value': (95,95,95)},
|
||||
{'name': 'Background color (aux)', 'type': 'color', 'value': (30,30,30)},
|
||||
{'name': 'Default object color', 'type': 'color', 'value': "#FF0"},
|
||||
{'name': 'Deviation', 'type': 'float', 'value': 1e-5, 'dec': True, 'step': 1},
|
||||
{'name': 'Angular deviation', 'type': 'float', 'value': 0.1, 'dec': True, 'step': 1},
|
||||
{'name': 'Projection Type', 'type': 'list', 'value': 'Orthographic',
|
||||
'values': ['Orthographic', 'Perspective', 'Stereo', 'MonoLeftEye', 'MonoRightEye']},
|
||||
{'name': 'Stereo Mode', 'type': 'list', 'value': 'QuadBuffer',
|
||||
'values': ['QuadBuffer', 'Anaglyph', 'RowInterlaced', 'ColumnInterlaced',
|
||||
'ChessBoard', 'SideBySide', 'OverUnder']}])
|
||||
IMAGE_EXTENSIONS = 'png'
|
||||
preferences = Parameter.create(
|
||||
name="Pref",
|
||||
children=[
|
||||
{"name": "Fit automatically", "type": "bool", "value": True},
|
||||
{"name": "Use gradient", "type": "bool", "value": False},
|
||||
{"name": "Background color", "type": "color", "value": (95, 95, 95)},
|
||||
{"name": "Background color (aux)", "type": "color", "value": (30, 30, 30)},
|
||||
{"name": "Default object color", "type": "color", "value": "#FF0"},
|
||||
{
|
||||
"name": "Deviation",
|
||||
"type": "float",
|
||||
"value": 1e-5,
|
||||
"dec": True,
|
||||
"step": 1,
|
||||
},
|
||||
{
|
||||
"name": "Angular deviation",
|
||||
"type": "float",
|
||||
"value": 0.1,
|
||||
"dec": True,
|
||||
"step": 1,
|
||||
},
|
||||
{
|
||||
"name": "Projection Type",
|
||||
"type": "list",
|
||||
"value": "Orthographic",
|
||||
"values": [
|
||||
"Orthographic",
|
||||
"Perspective",
|
||||
"Stereo",
|
||||
"MonoLeftEye",
|
||||
"MonoRightEye",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Stereo Mode",
|
||||
"type": "list",
|
||||
"value": "QuadBuffer",
|
||||
"values": [
|
||||
"QuadBuffer",
|
||||
"Anaglyph",
|
||||
"RowInterlaced",
|
||||
"ColumnInterlaced",
|
||||
"ChessBoard",
|
||||
"SideBySide",
|
||||
"OverUnder",
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
IMAGE_EXTENSIONS = "png"
|
||||
|
||||
sigObjectSelected = pyqtSignal(list)
|
||||
|
||||
def __init__(self,parent=None):
|
||||
|
||||
super(OCCViewer,self).__init__(parent)
|
||||
def __init__(self, parent=None):
|
||||
super(OCCViewer, self).__init__(parent)
|
||||
ComponentMixin.__init__(self)
|
||||
|
||||
self.canvas = OCCTWidget()
|
||||
@@ -56,15 +99,18 @@ class OCCViewer(QWidget,ComponentMixin):
|
||||
|
||||
self.create_actions(self)
|
||||
|
||||
self.layout_ = layout(self,
|
||||
[self.canvas,],
|
||||
self.layout_ = layout(
|
||||
self,
|
||||
[
|
||||
self.canvas,
|
||||
],
|
||||
top_widget=self,
|
||||
margin=0)
|
||||
self.setup_default_drawer() #misspelled in original
|
||||
margin=0,
|
||||
)
|
||||
self.setup_default_drawer() # misspelled in original
|
||||
self.updatePreferences()
|
||||
|
||||
def setup_default_drawer(self):
|
||||
|
||||
# set the default color and material
|
||||
material = Graphic3d_MaterialAspect(Graphic3d_NOM_JADE)
|
||||
|
||||
@@ -77,98 +123,128 @@ class OCCViewer(QWidget,ComponentMixin):
|
||||
line_aspect.SetWidth(DEFAULT_EDGE_WIDTH)
|
||||
line_aspect.SetColor(DEFAULT_EDGE_COLOR)
|
||||
|
||||
def updatePreferences(self,*args):
|
||||
def updatePreferences(self, *args):
|
||||
color1 = to_occ_color(self.preferences["Background color"])
|
||||
color2 = to_occ_color(self.preferences["Background color (aux)"])
|
||||
|
||||
color1 = to_occ_color(self.preferences['Background color'])
|
||||
color2 = to_occ_color(self.preferences['Background color (aux)'])
|
||||
|
||||
if not self.preferences['Use gradient']:
|
||||
if not self.preferences["Use gradient"]:
|
||||
color2 = color1
|
||||
self.canvas.view.SetBgGradientColors(color1,color2,theToUpdate=True)
|
||||
self.canvas.view.SetBgGradientColors(color1, color2, theToUpdate=True)
|
||||
|
||||
self.canvas.update()
|
||||
|
||||
ctx = self.canvas.context
|
||||
ctx.SetDeviationCoefficient(self.preferences['Deviation'])
|
||||
ctx.SetDeviationAngle(self.preferences['Angular deviation'])
|
||||
ctx.SetDeviationCoefficient(self.preferences["Deviation"])
|
||||
ctx.SetDeviationAngle(self.preferences["Angular deviation"])
|
||||
|
||||
v = self._get_view()
|
||||
camera = v.Camera()
|
||||
projection_type = self.preferences['Projection Type']
|
||||
camera.SetProjectionType(getattr(Graphic3d_Camera, f'Projection_{projection_type}',
|
||||
Graphic3d_Camera.Projection_Orthographic))
|
||||
projection_type = self.preferences["Projection Type"]
|
||||
camera.SetProjectionType(
|
||||
getattr(
|
||||
Graphic3d_Camera,
|
||||
f"Projection_{projection_type}",
|
||||
Graphic3d_Camera.Projection_Orthographic,
|
||||
)
|
||||
)
|
||||
|
||||
# onle relevant for stereo projection
|
||||
stereo_mode = self.preferences['Stereo Mode']
|
||||
stereo_mode = self.preferences["Stereo Mode"]
|
||||
params = v.ChangeRenderingParams()
|
||||
params.StereoMode = getattr(Graphic3d_StereoMode, f'Graphic3d_StereoMode_{stereo_mode}',
|
||||
Graphic3d_StereoMode.Graphic3d_StereoMode_QuadBuffer)
|
||||
params.StereoMode = getattr(
|
||||
Graphic3d_StereoMode,
|
||||
f"Graphic3d_StereoMode_{stereo_mode}",
|
||||
Graphic3d_StereoMode.Graphic3d_StereoMode_QuadBuffer,
|
||||
)
|
||||
|
||||
def create_actions(self,parent):
|
||||
|
||||
self._actions = \
|
||||
{'View' : [QAction(qta.icon('fa.arrows-alt'),
|
||||
'Fit (Shift+F1)',
|
||||
def create_actions(self, parent):
|
||||
self._actions = {
|
||||
"View": [
|
||||
QAction(
|
||||
qta.icon("fa.arrows-alt"),
|
||||
"Fit (Shift+F1)",
|
||||
parent,
|
||||
shortcut='shift+F1',
|
||||
triggered=self.fit),
|
||||
QAction(QIcon(':/images/icons/isometric_view.svg'),
|
||||
'Iso (Shift+F2)',
|
||||
shortcut="shift+F1",
|
||||
triggered=self.fit,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/isometric_view.svg"),
|
||||
"Iso (Shift+F2)",
|
||||
parent,
|
||||
shortcut='shift+F2',
|
||||
triggered=self.iso_view),
|
||||
QAction(QIcon(':/images/icons/top_view.svg'),
|
||||
'Top (Shift+F3)',
|
||||
shortcut="shift+F2",
|
||||
triggered=self.iso_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/top_view.svg"),
|
||||
"Top (Shift+F3)",
|
||||
parent,
|
||||
shortcut='shift+F3',
|
||||
triggered=self.top_view),
|
||||
QAction(QIcon(':/images/icons/bottom_view.svg'),
|
||||
'Bottom (Shift+F4)',
|
||||
shortcut="shift+F3",
|
||||
triggered=self.top_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/bottom_view.svg"),
|
||||
"Bottom (Shift+F4)",
|
||||
parent,
|
||||
shortcut='shift+F4',
|
||||
triggered=self.bottom_view),
|
||||
QAction(QIcon(':/images/icons/front_view.svg'),
|
||||
'Front (Shift+F5)',
|
||||
shortcut="shift+F4",
|
||||
triggered=self.bottom_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/front_view.svg"),
|
||||
"Front (Shift+F5)",
|
||||
parent,
|
||||
shortcut='shift+F5',
|
||||
triggered=self.front_view),
|
||||
QAction(QIcon(':/images/icons/back_view.svg'),
|
||||
'Back (Shift+F6)',
|
||||
shortcut="shift+F5",
|
||||
triggered=self.front_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/back_view.svg"),
|
||||
"Back (Shift+F6)",
|
||||
parent,
|
||||
shortcut='shift+F6',
|
||||
triggered=self.back_view),
|
||||
QAction(QIcon(':/images/icons/left_side_view.svg'),
|
||||
'Left (Shift+F7)',
|
||||
shortcut="shift+F6",
|
||||
triggered=self.back_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/left_side_view.svg"),
|
||||
"Left (Shift+F7)",
|
||||
parent,
|
||||
shortcut='shift+F7',
|
||||
triggered=self.left_view),
|
||||
QAction(QIcon(':/images/icons/right_side_view.svg'),
|
||||
'Right (Shift+F8)',
|
||||
shortcut="shift+F7",
|
||||
triggered=self.left_view,
|
||||
),
|
||||
QAction(
|
||||
QIcon(":/images/icons/right_side_view.svg"),
|
||||
"Right (Shift+F8)",
|
||||
parent,
|
||||
shortcut='shift+F8',
|
||||
triggered=self.right_view),
|
||||
QAction(qta.icon('fa.square-o'),
|
||||
'Wireframe (Shift+F9)',
|
||||
shortcut="shift+F8",
|
||||
triggered=self.right_view,
|
||||
),
|
||||
QAction(
|
||||
qta.icon("fa.square-o"),
|
||||
"Wireframe (Shift+F9)",
|
||||
parent,
|
||||
shortcut='shift+F9',
|
||||
triggered=self.wireframe_view),
|
||||
QAction(qta.icon('fa.square'),
|
||||
'Shaded (Shift+F10)',
|
||||
shortcut="shift+F9",
|
||||
triggered=self.wireframe_view,
|
||||
),
|
||||
QAction(
|
||||
qta.icon("fa.square"),
|
||||
"Shaded (Shift+F10)",
|
||||
parent,
|
||||
shortcut='shift+F10',
|
||||
triggered=self.shaded_view)],
|
||||
'Tools' : [QAction(icon('screenshot'),
|
||||
'Screenshot',
|
||||
shortcut="shift+F10",
|
||||
triggered=self.shaded_view,
|
||||
),
|
||||
],
|
||||
"Tools": [
|
||||
QAction(
|
||||
icon("screenshot"),
|
||||
"Screenshot",
|
||||
parent,
|
||||
triggered=self.save_screenshot)]}
|
||||
triggered=self.save_screenshot,
|
||||
)
|
||||
],
|
||||
}
|
||||
|
||||
def toolbarActions(self):
|
||||
|
||||
return self._actions['View']
|
||||
|
||||
return self._actions["View"]
|
||||
|
||||
def clear(self):
|
||||
|
||||
self.displayed_shapes = []
|
||||
self.displayed_ais = []
|
||||
self.canvas.context.EraseAll(True)
|
||||
@@ -176,199 +252,167 @@ class OCCViewer(QWidget,ComponentMixin):
|
||||
context.PurgeDisplay()
|
||||
context.RemoveAll(True)
|
||||
|
||||
def _display(self,shape):
|
||||
|
||||
def _display(self, shape):
|
||||
ais = make_AIS(shape)
|
||||
self.canvas.context.Display(shape,True)
|
||||
self.canvas.context.Display(shape, True)
|
||||
|
||||
self.displayed_shapes.append(shape)
|
||||
self.displayed_ais.append(ais)
|
||||
|
||||
#self.canvas._display.Repaint()
|
||||
# self.canvas._display.Repaint()
|
||||
|
||||
@pyqtSlot(object)
|
||||
def display(self,ais):
|
||||
|
||||
def display(self, ais):
|
||||
context = self._get_context()
|
||||
context.Display(ais,True)
|
||||
context.Display(ais, True)
|
||||
|
||||
if self.preferences['Fit automatically']: self.fit()
|
||||
if self.preferences["Fit automatically"]:
|
||||
self.fit()
|
||||
|
||||
@pyqtSlot(list)
|
||||
@pyqtSlot(list,bool)
|
||||
def display_many(self,ais_list,fit=None):
|
||||
|
||||
@pyqtSlot(list, bool)
|
||||
def display_many(self, ais_list, fit=None):
|
||||
context = self._get_context()
|
||||
for ais in ais_list:
|
||||
context.Display(ais,True)
|
||||
context.Display(ais, True)
|
||||
|
||||
if self.preferences['Fit automatically'] and fit is None:
|
||||
if self.preferences["Fit automatically"] and fit is None:
|
||||
self.fit()
|
||||
elif fit:
|
||||
self.fit()
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem,int)
|
||||
def update_item(self,item,col):
|
||||
|
||||
@pyqtSlot(QTreeWidgetItem, int)
|
||||
def update_item(self, item, col):
|
||||
ctx = self._get_context()
|
||||
if item.checkState(0):
|
||||
ctx.Display(item.ais,True)
|
||||
ctx.Display(item.ais, True)
|
||||
else:
|
||||
ctx.Erase(item.ais,True)
|
||||
ctx.Erase(item.ais, True)
|
||||
|
||||
@pyqtSlot(list)
|
||||
def remove_items(self,ais_items):
|
||||
|
||||
def remove_items(self, ais_items):
|
||||
ctx = self._get_context()
|
||||
for ais in ais_items: ctx.Erase(ais,True)
|
||||
for ais in ais_items:
|
||||
ctx.Erase(ais, True)
|
||||
|
||||
@pyqtSlot()
|
||||
def redraw(self):
|
||||
|
||||
self._get_viewer().Redraw()
|
||||
|
||||
def fit(self):
|
||||
|
||||
self.canvas.view.FitAll()
|
||||
|
||||
def iso_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(1,-1,1)
|
||||
v.SetProj(1, -1, 1)
|
||||
v.SetTwist(0)
|
||||
|
||||
def bottom_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(0,0,-1)
|
||||
v.SetProj(0, 0, -1)
|
||||
v.SetTwist(0)
|
||||
|
||||
def top_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(0,0,1)
|
||||
v.SetProj(0, 0, 1)
|
||||
v.SetTwist(0)
|
||||
|
||||
def front_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(0,-1,0)
|
||||
v.SetProj(0, -1, 0)
|
||||
v.SetTwist(0)
|
||||
|
||||
def back_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(0,1,0)
|
||||
v.SetProj(0, 1, 0)
|
||||
v.SetTwist(0)
|
||||
|
||||
def left_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(-1,0,0)
|
||||
v.SetProj(-1, 0, 0)
|
||||
v.SetTwist(0)
|
||||
|
||||
def right_view(self):
|
||||
|
||||
v = self._get_view()
|
||||
v.SetProj(1,0,0)
|
||||
v.SetProj(1, 0, 0)
|
||||
v.SetTwist(0)
|
||||
|
||||
def shaded_view(self):
|
||||
|
||||
c = self._get_context()
|
||||
c.SetDisplayMode(AIS_Shaded, True)
|
||||
|
||||
def wireframe_view(self):
|
||||
|
||||
c = self._get_context()
|
||||
c.SetDisplayMode(AIS_WireFrame, True)
|
||||
|
||||
def show_grid(self,
|
||||
step=1.,
|
||||
size=10.+1e-6,
|
||||
color1=(.7,.7,.7),
|
||||
color2=(0,0,0)):
|
||||
|
||||
def show_grid(
|
||||
self, step=1.0, size=10.0 + 1e-6, color1=(0.7, 0.7, 0.7), color2=(0, 0, 0)
|
||||
):
|
||||
viewer = self._get_viewer()
|
||||
viewer.ActivateGrid(Aspect_GT_Rectangular,
|
||||
Aspect_GDM_Lines)
|
||||
viewer.ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines)
|
||||
viewer.SetRectangularGridGraphicValues(size, size, 0)
|
||||
viewer.SetRectangularGridValues(0, 0, step, step, 0)
|
||||
grid = viewer.Grid()
|
||||
grid.SetColors(Quantity_Color(*color1,TOC_RGB),
|
||||
Quantity_Color(*color2,TOC_RGB))
|
||||
grid.SetColors(
|
||||
Quantity_Color(*color1, TOC_RGB), Quantity_Color(*color2, TOC_RGB)
|
||||
)
|
||||
|
||||
def hide_grid(self):
|
||||
|
||||
viewer = self._get_viewer()
|
||||
viewer.DeactivateGrid()
|
||||
|
||||
@pyqtSlot(bool,float)
|
||||
@pyqtSlot(bool, float)
|
||||
@pyqtSlot(bool)
|
||||
def toggle_grid(self,
|
||||
value : bool,
|
||||
dim : float = 10.):
|
||||
|
||||
def toggle_grid(self, value: bool, dim: float = 10.0):
|
||||
if value:
|
||||
self.show_grid(step=dim/20,size=dim+1e-9)
|
||||
self.show_grid(step=dim / 20, size=dim + 1e-9)
|
||||
else:
|
||||
self.hide_grid()
|
||||
|
||||
@pyqtSlot(gp_Ax3)
|
||||
def set_grid_orientation(self,orientation : gp_Ax3):
|
||||
|
||||
def set_grid_orientation(self, orientation: gp_Ax3):
|
||||
viewer = self._get_viewer()
|
||||
viewer.SetPrivilegedPlane(orientation)
|
||||
|
||||
def show_axis(self,origin = (0,0,0), direction=(0,0,1)):
|
||||
|
||||
ax_placement = Geom_Axis1Placement(gp_Ax1(gp_Pnt(*origin),
|
||||
gp_Dir(*direction)))
|
||||
def show_axis(self, origin=(0, 0, 0), direction=(0, 0, 1)):
|
||||
ax_placement = Geom_Axis1Placement(gp_Ax1(gp_Pnt(*origin), gp_Dir(*direction)))
|
||||
ax = AIS_Axis(ax_placement)
|
||||
self._display_ais(ax)
|
||||
|
||||
def save_screenshot(self):
|
||||
|
||||
fname = get_save_filename(self.IMAGE_EXTENSIONS)
|
||||
if fname != '':
|
||||
if fname != "":
|
||||
self._get_view().Dump(fname)
|
||||
|
||||
def _display_ais(self,ais):
|
||||
|
||||
def _display_ais(self, ais):
|
||||
self._get_context().Display(ais)
|
||||
|
||||
|
||||
def _get_view(self):
|
||||
|
||||
return self.canvas.view
|
||||
|
||||
def _get_viewer(self):
|
||||
|
||||
return self.canvas.viewer
|
||||
|
||||
def _get_context(self):
|
||||
|
||||
return self.canvas.context
|
||||
|
||||
@pyqtSlot(list)
|
||||
def handle_selection(self,obj):
|
||||
|
||||
def handle_selection(self, obj):
|
||||
self.sigObjectSelected.emit(obj)
|
||||
|
||||
@pyqtSlot(list)
|
||||
def set_selected(self,ais):
|
||||
|
||||
def set_selected(self, ais):
|
||||
ctx = self._get_context()
|
||||
ctx.ClearSelected(False)
|
||||
|
||||
for obj in ais:
|
||||
ctx.AddOrRemoveSelected(obj,False)
|
||||
ctx.AddOrRemoveSelected(obj, False)
|
||||
|
||||
self.redraw()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# pass
|
||||
import sys
|
||||
from OCP.BRepPrimAPI import BRepPrimAPI_MakeBox
|
||||
|
||||
@@ -379,10 +423,10 @@ if __name__ == "__main__":
|
||||
dlg.setFixedHeight(400)
|
||||
dlg.setFixedWidth(600)
|
||||
|
||||
layout(dlg,(viewer,),dlg)
|
||||
layout(dlg, (viewer,), dlg)
|
||||
dlg.show()
|
||||
|
||||
box = BRepPrimAPI_MakeBox(20,20,30)
|
||||
box = BRepPrimAPI_MakeBox(20, 20, 30)
|
||||
box_ais = AIS_ColoredShape(box.Shape())
|
||||
viewer.display(box_ais)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ channels:
|
||||
dependencies:
|
||||
- pyqt=5
|
||||
- pyqtgraph
|
||||
- python=3.11
|
||||
- python=3.10
|
||||
- spyder=5
|
||||
- path
|
||||
- logbook
|
||||
|
||||
@@ -3,4 +3,4 @@ channels:
|
||||
- conda-forge
|
||||
- defaults
|
||||
dependencies:
|
||||
- python=3.11
|
||||
- python=3.10
|
||||
|
||||
98
pyinstaller.spec
Normal file
98
pyinstaller.spec
Normal file
@@ -0,0 +1,98 @@
|
||||
# -*- mode: python -*-
|
||||
|
||||
import sys, site, os
|
||||
from path import Path
|
||||
from PyInstaller.utils.hooks import collect_all, collect_submodules
|
||||
|
||||
block_cipher = None
|
||||
|
||||
spyder_data = Path(site.getsitepackages()[-1]) / 'spyder'
|
||||
parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*')
|
||||
cqw_path = Path(site.getsitepackages()[-1]) / 'cq_warehouse'
|
||||
cq_path = Path(site.getsitepackages()[-1]) / 'cadquery'
|
||||
|
||||
if sys.platform == 'linux':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-39-x86_64-linux-gnu.so'), '.')
|
||||
elif sys.platform == 'darwin':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-39-darwin.so'), '.')
|
||||
elif sys.platform == 'win32':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp39-win_amd64.pyd'), '.')]
|
||||
cas_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'casadi_nlpsol_ipopt.dll'), '.')]
|
||||
ipo_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'ipopt-3.dll'), '.')]
|
||||
bla_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'libblas.dll'), '.')]
|
||||
lap_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'liblapack.dll'), '.')]
|
||||
mum_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'dmumps.dll'), '.')]
|
||||
fla_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'flang.dll'), '.')]
|
||||
flr_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'flangrti.dll'), '.')]
|
||||
omp_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'libomp.dll'), '.')]
|
||||
mkl_DLLs = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'mkl*.dll'), '.')]
|
||||
#cas_dllA = os.path.join(HOMEPATH, 'casadi', 'libcasadi.dll')
|
||||
#cas_dllB = os.path.join(HOMEPATH, 'casadi', 'libcasadi_nlpsol_ipopt.dll')
|
||||
|
||||
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
|
||||
hiddenimports2 = collect_submodules('xmlrpc')
|
||||
|
||||
a = Analysis(['run.py'],
|
||||
pathex=['.'],
|
||||
binaries=ocp_path + cas_DLL + ipo_DLL + bla_DLL + lap_DLL + mum_DLL + fla_DLL + flr_DLL + omp_DLL + mkl_DLLs + binaries1,
|
||||
datas=[(spyder_data, 'spyder'),
|
||||
(occt_dir, 'opencascade'),
|
||||
(cqw_path, 'cq_warehouse'),
|
||||
(cq_path, 'cadquery')] +
|
||||
[(p, 'parso/python') for p in parso_grammar] + datas1,
|
||||
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
|
||||
'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5',
|
||||
'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5',
|
||||
'pyqtgraph.imageview.ImageViewTemplate_pyqt5', 'xmlrpc', 'ipopt', 'casadi',
|
||||
'zmq.backend', 'cq_warehouse', 'cq_warehouse.bearing', 'cq_warehouse.chain',
|
||||
'cq_warehouse.drafting', 'cq_warehouse.extensions', 'cq_warehouse.fastener',
|
||||
'cq_warehouse.sprocket', 'cq_warehouse.thread', 'cq_gears', 'cq_cache',
|
||||
'build123d', 'cqmore'] + hiddenimports1 + hiddenimports2,
|
||||
hookspath=[],
|
||||
runtime_hooks=['pyinstaller/pyi_rth_occ.py',
|
||||
'pyinstaller/pyi_rth_fontconfig.py'],
|
||||
excludes=['_tkinter'],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
|
||||
# There is an issue that keeps the OpenSSL libraries from being copied to the output directory.
|
||||
# This should work if nothing else, but does not with GitHub Actions
|
||||
if sys.platform == 'win32':
|
||||
from PyInstaller.depend.bindepend import getfullnameof
|
||||
rel_data_path = ['PyQt5', 'Qt', 'bin']
|
||||
a.datas += [
|
||||
(getfullnameof('libssl-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||
(getfullnameof('libcrypto-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||
]
|
||||
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='CQ-editor',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=True,
|
||||
icon='icons/cadquery_logo_dark.ico')
|
||||
|
||||
exclude = ()
|
||||
#exclude = ('libGL','libEGL','libbsd')
|
||||
a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)])
|
||||
|
||||
coll = COLLECT(exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
name='CQ-editor')
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
export QT_MAC_WANTS_LAYER=1
|
||||
chmod u+x ./CQ-editor/CQ-editor
|
||||
QT_QPA_PLATFORM=cocoa PYOPENGL_PLATFORM=x11 ./CQ-editor/CQ-editor
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
export QT_MAC_WANTS_LAYER=1
|
||||
chmod u+x ./CQ-editor/CQ-editor
|
||||
QT_QPA_PLATFORM=xcb PYOPENGL_PLATFORM=x11 ./CQ-editor/CQ-editor
|
||||
./CQ-editor/CQ-editor
|
||||
@@ -1,4 +0,0 @@
|
||||
# hook-py_lib3mf.py
|
||||
from PyInstaller.utils.hooks import collect_dynamic_libs
|
||||
|
||||
binaries = collect_dynamic_libs('py_lib3mf')
|
||||
@@ -9,18 +9,17 @@ block_cipher = None
|
||||
spyder_data = Path(site.getsitepackages()[-1]) / 'spyder'
|
||||
parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*')
|
||||
cqw_path = Path(site.getsitepackages()[-1]) / 'cq_warehouse'
|
||||
bdw_path = Path(site.getsitepackages()[-1]) / 'bd_warehouse'
|
||||
cq_path = Path(site.getsitepackages()[-1]) / 'cadquery'
|
||||
|
||||
if sys.platform == 'linux':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-311-x86_64-linux-gnu.so'), '.')]
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-310-x86_64-linux-gnu.so'), '.')]
|
||||
elif sys.platform == 'darwin':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-311-darwin.so'), '.')]
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-310-darwin.so'), '.')]
|
||||
elif sys.platform == 'win32':
|
||||
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp311-win_amd64.pyd'), '.')]
|
||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp310-win_amd64.pyd'), '.')]
|
||||
|
||||
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
|
||||
hiddenimports2 = collect_submodules('xmlrpc')
|
||||
@@ -30,7 +29,6 @@ a = Analysis(['run.py'],
|
||||
binaries=ocp_path + binaries1,
|
||||
datas=[(spyder_data, 'spyder'),
|
||||
(cqw_path, 'cq_warehouse'),
|
||||
(bdw_path, 'bd_warehouse'),
|
||||
(cq_path, 'cadquery')] +
|
||||
[(p, 'parso/python') for p in parso_grammar] + datas1,
|
||||
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
|
||||
@@ -40,8 +38,7 @@ a = Analysis(['run.py'],
|
||||
'zmq.backend', 'cq_warehouse', 'cq_warehouse.bearing', 'cq_warehouse.chain',
|
||||
'cq_warehouse.drafting', 'cq_warehouse.extensions', 'cq_warehouse.fastener',
|
||||
'cq_warehouse.sprocket', 'cq_warehouse.thread', 'cq_gears', 'cq_cache',
|
||||
'build123d', 'cqmore', 'bd_warehouse', 'bd_warehouse.pipe', 'bd_warehouse.flange',
|
||||
'bd_warehouse.thread', 'bd_warehouse.gears'] + hiddenimports1 + hiddenimports2,
|
||||
'build123d', 'cqmore'] + hiddenimports1 + hiddenimports2,
|
||||
hookspath=['pyinstaller/extrahooks/'],
|
||||
runtime_hooks=['pyinstaller/pyi_rth_occ.py',
|
||||
'pyinstaller/pyi_rth_fontconfig.py'],
|
||||
|
||||
5
setup.py
5
setup.py
@@ -26,15 +26,14 @@ setup(
|
||||
"CQ-editor = cq_editor.__main__:main",
|
||||
]
|
||||
},
|
||||
python_requires=">=3.8,<3.13",
|
||||
python_requires=">=3.8,<3.12",
|
||||
install_requires=[
|
||||
"logbook>=1",
|
||||
"ipython",
|
||||
"path>=16",
|
||||
"PyQt5>=5",
|
||||
"PySide6",
|
||||
"requests>=2,<3",
|
||||
"spyder>=5,<6",
|
||||
"pyqtgraph",
|
||||
"numpy >= 1.24.1, <2",
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user