Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Add capability to use external python packages in apps #38

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
3ffc08f
Created external folder with simple pyqt5 app using pyyaml and update…
achille-martin Mar 18, 2024
c5e6781
Created external python pkg to test integration of pyyaml into androi…
achille-martin Mar 19, 2024
d1f503b
Updated imports in pyqt5 app example with pyyaml
achille-martin Mar 20, 2024
8ccbf43
Started from basic operation pyqt5 app to later try pyyaml integration
achille-martin Mar 20, 2024
2eff693
Deleted simple pyqt5 script with yaml because distracting
achille-martin Mar 20, 2024
134cf57
Added logging capability and yaml initialisation to pyqt5 app with ya…
achille-martin Mar 20, 2024
4b8312c
Added complementary sections to setup your own sysroot
achille-martin Apr 14, 2024
ffc1fe8
Split up Sysroot creation into various package case sections
achille-martin Apr 15, 2024
f83499b
Fixed typos in create sysroot section of README
achille-martin Apr 15, 2024
0de0933
Fixed typos and updated paths in create pdt file in README
achille-martin Apr 15, 2024
d5410fe
Fixed grammatical imprecision in create your python package in README
achille-martin Apr 15, 2024
33e4113
Fixed typo in description for pdt config in README
achille-martin Apr 15, 2024
243a688
Fixed typo in custom pyqt crom env variable in README
achille-martin Apr 15, 2024
db87c81
Merge branch 'main' into 32-bug-cannot-add-python-packages-from-site-…
achille-martin Apr 16, 2024
8b20c01
Fixed typos and imprecisions in README related to own sysroot configu…
achille-martin Apr 17, 2024
ad134b5
Fixed merge conflicts
achille-martin Apr 18, 2024
36c2e0d
Added precision around order of sysroot modules in README
achille-martin Apr 18, 2024
422d5a5
Fixed shebang in download_sources script
achille-martin Apr 18, 2024
feeb0cb
Moved and renamed path_setup script and added script to get wheel for…
achille-martin Apr 18, 2024
7a5a844
Added first steps of guide to add non-standard python module to outpu…
achille-martin Apr 18, 2024
8b7fc38
Used variable aliases in get_wheel_for_python_package script for clarity
achille-martin Apr 18, 2024
c7fc759
Improved get wheel for python package script by using path variables …
achille-martin Apr 20, 2024
25d635c
Added first draft of script to get source OS information for debuggin…
achille-martin Apr 20, 2024
992085d
Added MIT licence 2024 to bash scripts
achille-martin Apr 20, 2024
ddd0110
Replaced echo with printf for control on output format in get wheel f…
achille-martin Apr 20, 2024
c976532
Added usage function for modularity in get wheel for python package
achille-martin Apr 20, 2024
0c698d5
Updated usage function name in get wheel for python package for consi…
achille-martin Apr 20, 2024
b42e2eb
Moved download_sources script to bash folder for consistency, upgrade…
achille-martin Apr 20, 2024
f654c29
Added instruction to make setup_path script executable in README for …
achille-martin Apr 20, 2024
b08a1c1
Added overview comment to get_wheel_for_python_package script
achille-martin Apr 20, 2024
9415ba8
Removed download_sources script from utils/resources folder
achille-martin Apr 20, 2024
428c61d
Removed get_source_os_info script since created another version more …
achille-martin Apr 20, 2024
d4fe02e
Updated overview comment of setup_path script
achille-martin Apr 20, 2024
15789b7
Moved python utils into utils/python sub-folder for organisational pu…
achille-martin Apr 20, 2024
1d9c9ec
Updated README to reflect move of python utils
achille-martin Apr 20, 2024
85cf733
Added executable instruction for get_wheel_for_python_package script …
achille-martin Apr 20, 2024
aee30a4
Renamed script to get wheel from python package and adapted instructi…
achille-martin Apr 20, 2024
9d1d1ff
Updated conditional to check required arguments in get_python_package…
achille-martin Apr 20, 2024
3dc99e2
Created get_command_output_help script to collect information around …
achille-martin Apr 20, 2024
1641289
Added log/ folder to gitignore so that all logs generated by the repo…
achille-martin Apr 20, 2024
73f5b99
Updated snippet sequential commands to prevent issues when copy-pasti…
achille-martin Apr 21, 2024
6f003b2
Split up the build_app command into multiple lines for clarity in README
achille-martin Apr 21, 2024
a4b0798
Clarified needed zlib component in README
achille-martin Apr 21, 2024
7af1a9c
Improved build_app script organisation and methods used for devs
achille-martin Apr 21, 2024
b1c245b
Improved get_command_output_help script organisation and methods for …
achille-martin Apr 21, 2024
7ae7b2b
Added capture of all output stdout and stderr to md log file for comp…
achille-martin Apr 21, 2024
a5c0925
Added list of python site packages to get_command_output_help script
achille-martin Apr 21, 2024
98327d8
Added precision around zlib being considered a non-python module in R…
achille-martin Apr 21, 2024
f8992b2
Added a series of tests with external python packages and non-python …
achille-martin Apr 22, 2024
6ad8b55
Improved process of getting app config data through importlib.resourc…
achille-martin May 2, 2024
c255d38
Removed all external_python_project folder attempts and kept attempt_…
achille-martin May 2, 2024
5502775
Adjusted config and sysroot to match folder organisation of external_…
achille-martin May 2, 2024
58d4494
Converted externalpy into externalpy_pkg which is a package readable …
achille-martin May 11, 2024
f11becc
Removed __init__.py in externalpy_pkg config because not needed due t…
achille-martin May 11, 2024
cfbeafe
Toggled off the non-root debugging in externalpy_pkg because not needed
achille-martin May 12, 2024
122c235
Added init file back to externalpy config folder to identify as pytho…
achille-martin May 12, 2024
f4f331b
Added a tools directory to externalpy_pkg and moved in the validate_p…
achille-martin May 12, 2024
81e527d
Added instructions to README on how to build applications with advanc…
achille-martin May 12, 2024
2c02e95
Fixed stylistic typos in main README
achille-martin May 12, 2024
ee32633
Added instructions to README to include non-python modules to the pyq…
achille-martin May 13, 2024
aa7c5bf
Added list-imports module to requirements.txt to facilitate inclusion…
achille-martin May 13, 2024
87bf120
Create a python package dependency collector script to collect depend…
achille-martin May 15, 2024
ffe2653
Experimented block highlight for WARNING and TIP in README
achille-martin May 15, 2024
93d09a2
Experimented with INFO TARGET and IMPORTANT and added table for condi…
achille-martin May 15, 2024
4d66811
Experimented with other IMPORTANT block and removed unnecessary INFO …
achille-martin May 15, 2024
a13fb43
Experimented code snippet within block quote in README
achille-martin May 15, 2024
4d5d493
Updated all highlighted blockquotes in README
achille-martin May 15, 2024
22a92bf
Updated emojis in Credits section of README
achille-martin May 15, 2024
ba91caa
Updated block quotes in all docs
achille-martin May 15, 2024
3414e0a
Fixed emojis for TARGET and REWARD in README
achille-martin May 15, 2024
69f494e
Added functionality to collect deps from installed python package nam…
achille-martin May 15, 2024
f312a70
Added method to make deps list unique in py_package_dependency_collec…
achille-martin May 15, 2024
981f8c4
Replaced importlib.metadata with importlib_metadata because of issue …
achille-martin May 15, 2024
b3bf283
Moved making deps collected list unique and sorted to within method o…
achille-martin May 15, 2024
c58ac6a
Added exclusion tip to non-standard python module addition to sysroot…
achille-martin May 15, 2024
532cddc
Added capability to filter modules by top-level and adjust format for…
achille-martin May 15, 2024
9343152
Added dep stdlib-list to collect list of python standard libraries
achille-martin May 15, 2024
28fc7b7
Specified handy script py_package_dependency_collector in README to c…
achille-martin May 15, 2024
41b3d55
Simplified command to use py_package_dependency_collector in README
achille-martin May 15, 2024
c2c4009
Added exclusion of directories and files starting with unique undersc…
achille-martin May 15, 2024
a377bd2
Added capability to exclude file names and directory names and added …
achille-martin May 16, 2024
8c24e47
Re-formatted output of py_package_dependency_collector script for use…
achille-martin May 16, 2024
bd3d10a
Clarified process to add non-standard python modules to the sysroot i…
achille-martin May 16, 2024
c5fa17a
Added instructions to download github repo with specific release for …
achille-martin May 17, 2024
b571849
Fixed backticks display in code snippet in README
achille-martin May 17, 2024
bf7ebe6
Fixed get_python_package_wheel script by downloading the wheels into …
achille-martin May 19, 2024
fceba1b
Added module error logging at the top of pyqt5_app_with_yaml script
achille-martin May 20, 2024
3d446ab
Fixed py_package_dependency_collector script by selecting line indexe…
achille-martin May 20, 2024
c9f2a0e
Added list sorting and updated the outputs of py_package_dependency_c…
achille-martin May 24, 2024
ff10fa9
Created a module finder project to help identify the python dependenc…
achille-martin May 27, 2024
0310cd6
Updated list of dependencies in yaml component of sysroot for externa…
achille-martin May 27, 2024
9de151b
Removed reference to numpy in pyqt5_app_with_yaml and removed python …
achille-martin May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated repos
venv/
log/
sysroot-android-64/
build-android-64/

Expand Down
446 changes: 332 additions & 114 deletions README.md

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions docs/features/pyqt5_features.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyQt5 Features

:mag: This section introduces the main PyQt5 features needed to create a custom standard app.
> :mag: **Info**: This section introduces the main PyQt5 features needed to create a custom standard app.

<a id="toc"></a>
## Table of Contents
Expand Down Expand Up @@ -36,7 +36,7 @@ PyQt5 lets you work with many other database engines as shown on [tutorialspoint
<a id="database-management-setup"></a>
#### 1.2. Setup for database management

Before attempting to run any `SQLite`-related actions, make sure that the library is available on your machine:
> :triangular_flag_on_post: **Important**: Before attempting to run any `SQLite`-related actions, make sure that the library is available on your machine with the following command.

```
sudo apt-get install sqlite3
Expand All @@ -58,7 +58,7 @@ A dialog window will pop up in which you can perform the following:
- Add a row to the database
- Remove a row from the database

You can view the content of the generated and edited database at any time outside of the application with:
> :bulb: **Tip**: You can view the content of the generated and edited database at any time outside of the application with the following command.

```
cd $PYQT_CROM_DIR/examples/database
Expand All @@ -81,7 +81,7 @@ This demo app is built on the one highlighted in the [Getting started](../../REA
- Once the pop-up has been acknowledged, a database (called `sportsdatabase.db`) is created in the `home` folder as shown in the alert window, if not already existing
- In the dialog window displaying the content of the database, rows can be added, removed or edited

:bulb: _You can view the content of `sportsdatabase.db` at any time by following the instructions in [Example PyQt5 app with database](#database-pyqt5-demo-app) after ensuring that your [Database manager](#database-management-setup) is correctly setup._
> :bulb: **Tip**: You can view the content of `sportsdatabase.db` at any time by following the instructions in [Example PyQt5 app with database](#database-pyqt5-demo-app) after ensuring that your [Database manager](#database-management-setup) is correctly setup.

<a id="pyqt5-database-management-app-android-video"></a>

Expand Down Expand Up @@ -110,7 +110,6 @@ As we are showcasing a prototyping tool for mobile apps, we have decided to expl

To visualise a basic example of 2D Graphics in a PyQt app, run the following:


```
cd $PYQT_CROM_DIR/examples/graphics
python3 pyqt5_app_with_graphics.py
Expand Down Expand Up @@ -177,7 +176,7 @@ cd $PYQT_CROM_DIR/examples/network
python3 pyqt5_app_with_bluetooth.py
```

:bulb: _If you encounter issues with Bluetooth, please refer to the [Bluetooth troubleshooting](../troubleshooting/common_issues.md#virtual-machine-bluetooth)._
> :bulb: **Tip**: If you encounter issues with Bluetooth, please refer to the [Bluetooth troubleshooting](../troubleshooting/common_issues.md#virtual-machine-bluetooth).

The example Bluetooth app provides the following experience:
- A window appears on the screen with 2 buttons: Search for Bluetooth devices and EXIT
Expand All @@ -186,8 +185,6 @@ The example Bluetooth app provides the following experience:
- Once your Bluetooth is ON, click again on Search for Bluetooth devices so that the app can search for nearby devices for 5 seconds
- The app displays the list of found nearby devices on the main window



<a id="operational-bluetooth-pyqt5-demo-app"></a>
#### 3.3. Example operational PyQt5 Bluetooth app

Expand All @@ -198,9 +195,9 @@ cd $PYQT_CROM_DIR/examples/network/bluetooth_scanner_project/bluetooth_scanner_p
python3 operational_pyqt5_app_with_bluetooth.py
```

:bulb: _If you encounter issues with Bluetooth, please refer to the [Bluetooth troubleshooting](../troubleshooting/common_issues.md#virtual-machine-bluetooth)._
> :bulb: **Tip**: If you encounter issues with Bluetooth, please refer to the [Bluetooth troubleshooting](../troubleshooting/common_issues.md#virtual-machine-bluetooth).

The operational example Bluetooth app has a similar behaviour to the [example Bluetooth app](#bluetooth-pyqt5-demo-app).
> :bulb: **Tip**: The operational example Bluetooth app has a similar behaviour to the [example Bluetooth app](#bluetooth-pyqt5-demo-app).

<a id="pyqt5-bluetooth-scanner-app-android-video"></a>

Expand Down
2 changes: 1 addition & 1 deletion docs/licencing/licencing_information.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Licencing information

:mag: This section gathers the licences of the main dependencies.
> :mag: **Info**: This section gathers the licences of the main dependencies.

| Dependency | Version | Licence |
| --- | --- | --- |
Expand Down
39 changes: 29 additions & 10 deletions docs/troubleshooting/common_issues.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Common issues

:mag: This section walks you through tips and fixes for the main challenges you might encounter while setting up the repo or running the scripts.
> :mag: **Info**: This section walks you through tips and fixes for the main challenges you might encounter while setting up the repo or running the scripts.

<a id="toc"></a>
## Table of Contents
Expand Down Expand Up @@ -61,13 +61,32 @@ sudo apt-get install libxcb-xinerama0
<a id="virtual-machine-setup"></a>
### 4. Setup repo with a Virtual Machine

To setup a Linux Virtual Machine on Windows via VirtualBox, follow [It's FOSS virtualbox setup tutorial](https://itsfoss.com/install-linux-in-virtualbox/).

If you would prefer to setup a Linux Virtual Machine on MacOS via VirtualBox, follow [TecAdmin virtualbox setup tutorial](https://tecadmin.net/how-to-install-virtualbox-on-macos/).

It is also recommended to install the VirtualBox Guest Additions. Follow the [LinuxTechi guest addition setup tutorial](https://www.linuxtechi.com/install-virtualbox-guest-additions-on-ubuntu/) for more information.

:bulb: _It is also recommended to set the size of the Virtual Machine to at least 50GB so that there is enough space to download and install all dependencies._
Follow the relevant tutorial to setup a Virtual Machine on your machine.

<table style="width:100%">
<!-- Headers -->
<tr>
<th align="center" style="width:30%"> HOST </th> <!-- Col 1 -->
<th align="center" style="width:30%"> GUEST </th> <!-- Col 2 -->
<th align="center"> TUTORIAL </th> <!-- Col 3 -->
</tr>
<!-- Row 1 -->
<tr>
<td>You have Windows OS installed on your machine</td>
<td>You want a Linux Virtual Machine</td>
<td><a href="https://itsfoss.com/install-linux-in-virtualbox">It's FOSS virtualbox setup tutorial</a> </td>
</tr>
<!-- Row 2 -->
<tr>
<td>You have Mac OS installed on your machine</td>
<td>You want a Linux Virtual Machine</td>
<td><a href="https://tecadmin.net/how-to-install-virtualbox-on-macos/">TecAdmin virtualbox setup tutorial</a> </td>
</tr>
</table>

> :bulb: **Tip**: It is recommended to install the VirtualBox Guest Additions. Follow the [LinuxTechi guest addition setup tutorial](https://www.linuxtechi.com/install-virtualbox-guest-additions-on-ubuntu/) for more information.

> :bulb: **Tip**: It is also recommended to set the size of the Virtual Machine to at least 50GB so that there is enough space to download and install all dependencies.

<a id="virtual-machine-bluetooth"></a>
### 5. Setup Bluetooth in a Virtual Machine
Expand All @@ -88,7 +107,7 @@ If you are using VirtualBox (Virtual Machine) and you want to run a pyqt5 app re

To setup an Android Emulator, it is recommended to use Android Studio.

_If you want to set up the Android Emulator in VirtualBox, please refer to [this issue](https://github.com/achille-martin/pyqt-crom/issues/12)._
> :bulb: **Tip**: If you want to set up the Android Emulator in VirtualBox, please refer to [this issue](https://github.com/achille-martin/pyqt-crom/issues/12).

To setup the Android Emulator in Ubuntu, make sure that you have:
* Android Studio installed (refer to [External dependencies setup](../../README.md#external-dependency-installation) if needed)
Expand All @@ -112,7 +131,7 @@ sudo chown <username> /dev/kvm

Once the Android Emulator is set up and running, you can drag and drop your `.apk` to install it and run it.

If you wish to access more Android logs, please refer to [this issue](https://github.com/achille-martin/pyqt-crom/issues/12), which mentions tips for `adb`, the Android Debug Bridge.
> :bulb: **Tip**: If you wish to access more Android logs, please refer to [this issue](https://github.com/achille-martin/pyqt-crom/issues/12), which mentions tips for `adb`, the Android Debug Bridge.

[:arrow_heading_up: Back to TOP](#toc)

Expand Down
27 changes: 27 additions & 0 deletions examples/demo/module_finder_project/config.pdt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version = 0
sysroot = "sysroot.toml"
sysroots_dir = ""
parts = [ "PyQt:PyQt5.QtWidgets", "Python:logging",]

[Application]
entry_point = "modfinder_pkg.modfinder_app:main"
is_console = false
is_bundle = false
name = "ModFinderApp"
qmake_configuration = ""
script = ""
syspath = ""

[Application.Package]
name = "modfinder_pkg"
exclude = [ "*.pyc", "*.pyd", "*.pyo", "*.pyx", "*.pxi", "__pycache__", "*-info", "EGG_INFO", "*.so",]
[[Application.Package.Content]]
name = "__init__.py"
included = true
is_directory = false

[[Application.Package.Content]]
name = "modfinder_app.py"
included = true
is_directory = false

File renamed without changes.
195 changes: 195 additions & 0 deletions examples/demo/module_finder_project/modfinder_pkg/modfinder_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#!/usr/bin/env python3

# MIT License

# Copyright (c) 2024 Achille MARTIN

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Module Finder PyQt5 app
# Inspired by Martin Fitzpatrick from https://www.pythonguis.com/tutorials/creating-your-first-pyqt-window/
#
# This app helps you identify
# the python module dependencies
# related to specific non-standard python libraries


## Imports

import sys
sys_modules = dict(sorted(sys.modules.items()))
sys_modules_base = list(sys_modules.keys())
sys_modules_base.sort()

import_error_msg = ""
sys_modules_base_with_pkg = None
sys_modules_pkg = None
try:
# Import your non-standard python pkg
import numpy
sys_modules = dict(sorted(sys.modules.items()))
sys_modules_base_with_pkg = list(sys_modules.keys())
sys_modules_base_with_pkg.sort()
sys_modules_pkg = list(
set(
sys_modules_base_with_pkg
).difference(
set(sys_modules_base)
)
)
sys_modules_pkg.sort()
except Exception as e:
import_error_msg = f"Exception caught: {e}"

import os
import logging as log_tool # The logging library for debugging
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QMessageBox
from PyQt5.QtCore import QStandardPaths

built_in_modules = list(sys.stdlib_module_names)
built_in_modules.sort()

## Main variables and objects

# Retrieve app data folder path reference
std_app_data_folder_path_list = QStandardPaths.writableLocation(
QStandardPaths.AppDataLocation
)

# Define custom app data folder path
std_app_data_folder_path = ""
if isinstance(std_app_data_folder_path_list, list):
std_app_data_folder_path = std_app_data_folder_path_list[0]
else:
std_app_data_folder_path = str(std_app_data_folder_path_list)
app_data_folder_path = os.path.join(
std_app_data_folder_path,
'pyqt5_app_data',
)

# Generate custom app data folder at convenient writable location
os.makedirs(app_data_folder_path, exist_ok = True)

# Set logger config and instantiate object
logger_logging_level = "DEBUG"
logger_output_file_name = "modfinder_app.log"
logger_output_prefix_format = "[%(asctime)s] [%(levelname)s] - %(message)s"
logger = log_tool.getLogger(__name__)
logger.setLevel(logger_logging_level)
logger_output_file_path = os.path.join(app_data_folder_path, str(logger_output_file_name))
file_handler = log_tool.FileHandler(logger_output_file_path)
formatter = log_tool.Formatter(logger_output_prefix_format)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)

# Set additional log output location
# for non-root debugging
# when flag is_non_root_debug_active is set to True
is_non_root_debug_active = True
# WARNING: this feature might require
# to allow storage access permission before launching the app
if is_non_root_debug_active:
# Retrieve documents folder path reference
# to save logs at a location accessible by non-root users
std_documents_folder_path_list = QStandardPaths.writableLocation(
QStandardPaths.DocumentsLocation
)
# Define custom alternative app data folder path
std_documents_folder_path = ""
if isinstance(std_documents_folder_path_list, list):
std_documents_folder_path = std_documents_folder_path_list[0]
else:
std_documents_folder_path = str(std_documents_folder_path_list)
alternative_app_data_folder_path = os.path.join(
std_documents_folder_path,
'pyqt5_app_data',
)
# Generate alternative app data folder at convenient writable location
os.makedirs(alternative_app_data_folder_path, exist_ok = True)
# Add log file output alternative to logger
logger_output_file_path_alternative = os.path.join(
alternative_app_data_folder_path,
str(logger_output_file_name)
)
file_handler_alternative = log_tool.FileHandler(
logger_output_file_path_alternative
)
formatter_alternative = log_tool.Formatter(logger_output_prefix_format)
file_handler_alternative.setFormatter(formatter_alternative)
logger.addHandler(file_handler_alternative)

## Investigating the imports
logger.debug("---- SYS MODULES BASE ----")
logger.debug(sys_modules_base)
logger.debug("---- SYS MODULES BASE WITH PKG ----")
logger.debug(sys_modules_base_with_pkg)
logger.debug("---- SYS MODULES NUMPY ----")
logger.debug(sys_modules_pkg)
logger.debug("---- PYTHON BUILT-IN MODULES ----")
logger.debug(built_in_modules)
logger.debug("---- IMPORT ERRORS ----")
logger.debug(import_error_msg)


## Class definition

# Subclass QMainWindow to customize your application's main window
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()

self.setWindowTitle("Module Finder PyQt5 app")

button = QPushButton("Press Here for the magic")

button.setCheckable(True)
button.clicked.connect(self.on_button_clicked)

# Set properties of the widget in the Window.
self.setCentralWidget(button)


def on_button_clicked(self):
print("Button has been clicked!")
alert = QMessageBox()
alert.setText('You clicked the button!')
alert.exec()


## Application definition

def main():
# Only one QApplication instance is needed per application.
# Pass in sys.argv to allow command line arguments for the app: `QApplication(sys.argv)`
# If command line arguments are not needed, use: `QApplication([])`
app = QApplication([])

# Create a QMainWindow object which represents the Main Window.
main_window = MainWindow()
main_window.showMaximized() # This line will show windows that are normally hidden. Plus, it will maximise the main window.

# Start the application event loop.
app.exec()

# The application will only reach here when exiting or event loop has stopped.

if __name__ == "__main__":
# This section needs to only define main
# due to how pyqtdeploy is implemented to build packages
main()
Loading