Skip to content

Commit

Permalink
table contents loading fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KubiV committed Sep 2, 2024
1 parent 9248a31 commit e517253
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
Empty file added .gitignore
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

Use the pyinstaller command insiode the "pyinstaller" folder (cd `version2/pyinstaller`)

macOS: `pyinstaller --onefile --add-data "Settings.json:." --windowed --name "3D print Multi-color Molecules" --icon=../../graphical/default_icon.icns --debug=all ../src/main.py`
macOS: `pyinstaller --onefile --windowed --add-data "Settings.json:." --name "3D print Multi-color Molecules" --icon=../../graphical/default_icon.icns --debug=all --noconsole --exclude=PyQt6 --clean --noupx --strip --optimize=2 ../src/main.py`

Windows: `pyinstaller --onefile --add-data "Settings.json;." --windowed --name "3D print Multi-color Molecules" --icon=..\..\graphical\default_icon.ico --debug=all ..\src\main.py`

Expand Down
Binary file modified version2/.DS_Store
Binary file not shown.
Binary file modified version2/pyinstaller/.DS_Store
Binary file not shown.
29 changes: 18 additions & 11 deletions version2/pyinstaller/3D print Multi-color Molecules.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ a = Analysis(
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
excludes=['PyQt6'],
noarchive=True,
optimize=2,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[('v', None, 'OPTION')],
name='3D Print Multi-Color Molecules',
[('O', None, 'OPTION'), ('O', None, 'OPTION'), ('v', None, 'OPTION')],
exclude_binaries=True,
name='3D print Multi-color Molecules',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
strip=True,
upx=False,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
Expand All @@ -36,9 +34,18 @@ exe = EXE(
entitlements_file=None,
icon=['../../graphical/default_icon.icns'],
)
app = BUNDLE(
coll = COLLECT(
exe,
name='3D Print Multi-Color Molecules.app',
a.binaries,
a.datas,
strip=True,
upx=False,
upx_exclude=[],
name='3D print Multi-color Molecules',
)
app = BUNDLE(
coll,
name='3D print Multi-color Molecules.app',
icon='../../graphical/default_icon.icns',
bundle_identifier=None,
)
2 changes: 1 addition & 1 deletion version2/src/Settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"large_c_chain_protection": 100,
"large_c_chain_protection": 20,
"resolution_limit": 8,
"radius_factor": 70
}
14 changes: 4 additions & 10 deletions version2/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,17 @@ def download_and_display_image(self, image_url):
image_data = BytesIO(response.content)
pixmap = QPixmap()
pixmap.loadFromData(image_data.getvalue())

# Display the image
#self.image_label.setPixmap(pixmap)
self.set_image(pixmap)
pixmap = pixmap.scaled(self.main_window.image_label.width(), self.main_window.image_label.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.main_window.image_label.setPixmap(pixmap)
else:
self.show_error("Error", "Can not load the image")

def set_image(self, image_path):
pixmap = QPixmap(image_path)
pixmap = pixmap.scaled(self.main_window.image_label.width(), self.main_window.image_label.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.main_window.image_label.setPixmap(pixmap)

def set_table_info(self, first_item, second_item, third_item):
# Update the labels with the fetched data
self.main_window.table.setItem(0, 1, QTableWidgetItem(first_item))
self.main_window.table.setItem(1, 1, QTableWidgetItem(second_item))
self.main_window.table.setItem(2, 1, QTableWidgetItem(third_item))
self.main_window.table.viewport().update()

def show_error(self, title, message):
error_box = QMessageBox()
Expand Down Expand Up @@ -311,7 +305,7 @@ def change_variable(self):
# Write updated settings back to the JSON file
with open(self.settings_file_path, 'w') as file:
json.dump(self.settings, file, indent=4)

print("Variables changed")

def keyPressEvent(self, event):
if event.key() == Qt.Key_W and event.modifiers() & Qt.ControlModifier:
Expand Down
25 changes: 25 additions & 0 deletions version2/src/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""

from setuptools import setup
import sys

sys.setrecursionlimit(2000)
print(sys.getrecursionlimit())

APP = ['main.py']
DATA_FILES = ["Settings.json"]
OPTIONS = {
'argv_emulation': True
}

setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

0 comments on commit e517253

Please sign in to comment.