Metadata-Version: 2.1
Name: GUISpices
Version: 1.2.0
Summary: A wrapper module for various GUI usages
Home-page: UNKNOWN
Author: Leon Wiesen
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.5
Description-Content-Type: text/markdown
Requires-Dist: PySide2

# Weasel's GUI Spices
This is the one and only GUI module you really need...

## Features
- Helper functions for PyInstaller builds
- Tray icons with custom sub-menus
- Windows Messages
- Qt Creator windows
- Windows Explorer extensions
- Borderless *and* draggable windows
- Easy custom CSS Styling

# Helper functions for PyInstaller
These helper functions provide excellent support for building applications 
with PyInstaller, fixing some major problems which usually occur at runtime.
I highly suggest you to build all windowed and one-file applications with 
PyInstaller with these functions. This will save you **A LOT** of debugging time.

### One-file build (-F option)
If you build a .exe with the -F option, the whole app gets bundled into a single 
executable with all resource files included. These are unpacked on execution. 
But where? Use this function to refer to resource files whenever you plan to 
use the -w option.
```python
from GUISpices.Utility import resource_path

# opening a "text.txt" in the same directory
f = open(resource_path("text.txt"),"r")
print(f.read())
f.close()
```
Make sure you attach your resource files upon build via `--add-data <src;dst>` 
when running PyInstaller! In this case: `pyinstaller -F --add-data "text.txt;text.txt" main.py`

### Windowed build (-w option)
If you build a .exe with the -w option, the app will execute without a terminal
window. We usually want this for GUI-only applications. However, if your app 
needs to fetch the output of a terminal command, your app either opens up a 
terminal or gets stuck because it is prohibited to do so. This function will 
execute your terminal command and return the output as string (based on `subprocess.Popen`).
```python
from GUISpices.Utility import popen

print(popen("pwd")) # Output -> "C:\Users\User\Desktop"
```

# Code examples

### Tray Icons
This example creates a classic icon in the bottom right tray.
```python
from PySide2.QtWidgets import QApplication, QMenu
from GUISpices import TrayIcon
import sys

# create main application (if not present)
app = QApplication([])
app.setQuitOnLastWindowClosed(False)

# configure basic tray actions
tray = TrayIcon(app, "examples/icon.png", "Test Program", click_action=lambda :print("Clicked"))
tray.add_menu_feature("Change Icon", lambda: tray.set_icon("examples/icon2.png"))
tray.add_menu_feature("Show a message from tray", lambda: tray.show_tray_message("Hello", "Hello my friend"))
tray.add_separator()
tray.add_menu_feature("Exit", app.exit)

# Include a custom sub-menu
menu_ = QMenu(title="Sub Menu")
menu_.addAction("Egg sit (sub-action)", lambda: sys.exit(0))
tray.add_menu(menu_)

sys.exit(app.exec_())
```

### Windows Messages
This shows a tray icon and creates a windows tray message with a custom icon and action.
```python
from PySide2.QtWidgets import QApplication, QMenu
from GUISpices import TrayIcon
import sys

# create main application (if not present)
app = QApplication([])
app.setQuitOnLastWindowClosed(False)

# configure basic tray
tray = TrayIcon(app, "examples/icon.png", "Test Program")

# Show message
tray.show_tray_message("Title","This is the message body",
                        icon="examples/icon.png",
                        on_click=lambda:print("Message clicked"))

sys.exit(app.exec_())
```

### Qt Windows
The whole module lets you build all windows and popups with
[Qt Designer](https://www.qt.io/), a powerful and easy-to-use environment for 
drag & drop GUI building. This creates a `.ui` file which can be directly loaded 
to create the desired window with full compatibility.
```python
from PySide2.QtWidgets import QApplication
from GUISpices import UIWindow
import sys

app = QApplication()
main_form = UIWindow('examples/wizard.ui', "examples/icon.png")
main_form.window.show()
sys.exit(app.exec_())
```

### Windows Explorer extensions
This creates a new entry in the explorers context menu. 
So a right-click in any folder or on the user's desktop 
will show your custom action, as well. This example creates 
a custom action "Run CMD", which opens up a terminal.
```python
from GUISpices import ExplorerContextManager
ExplorerContextManager.register_entry("Run CMD", "C:\\Windows\\System32\\cmd.exe", "C:\\Windows\\System32\\cmd.exe")
```

### Borderless and draggable windows
This creates a new entry in the explorers context menu. 
So a right-click in any folder or on the user's desktop 
will show your custom action, as well. This example creates 
a custom action "Run CMD", which opens up a terminal.
```python

from PySide2.QtWidgets import QApplication
from PySide2.QtCore import Qt
import sys
from GUISpices import UIWindow, DragBar

app = QApplication()
main_form = UIWindow('examples/wizard.ui', "examples/icon.png")

# This line makes your window borderless
main_form.window.setWindowFlags(Qt.FramelessWindowHint)

# This adds a special Class to it, making it movable (via drag)
DragBar(main_form.window)

main_form.window.show()
sys.exit(app.exec_())


```


