# soui4py **Repository Path**: setoutsoft/soui4py ## Basic Information - **Project Name**: soui4py - **Description**: soui for python - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-02-07 - **Last Updated**: 2025-09-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # soui4py Python bindings for SOUI4+ (Simple Direct UI for Windows). This project provides Python interface to the SOUI4 C++ UI framework. ## Features - Complete Python bindings for SOUI4 UI framework - Support for all SOUI4 controls and widgets - Event handling system - Resource management - Window and dialog management - Menu system support - ListView and other container controls ## Requirements - Python 3.10+ (64-bit recommended) - Windows operating system - Visual Studio 2019 or later (for compilation) ## Building from Source 1. Clone the repository: ```bash git clone cd soui4py ``` 2. Set up the build environment: - Install Visual Studio 2019 or later with C++ development tools - Install Python 3.10 or later - Install required Python packages: ```bash pip install cython ``` 3. Build the extension: ```bash pip install -r requirement.txt python build-pyd.py ``` ## Usage Example ```python from soui4py import * from events import * from message import * from helper import * souiRootDir = os.path.dirname(os.path.abspath(__file__)) result = setup_soui_dll_path(souiRootDir) class MainWindow(SHostWnd): events = EventHandler() messages = MessageHandler() def __init__(self): super().__init__(soui_factory.CreateHostWnd('LAYOUT:XML_MAINWND')) self.SetEventHandler(self.events) self.SetMsgHandler(self.messages) @messages.MSG_WM_INITDIALOG def OnInitDialog(self, hWnd, lParam): print('Window initialized') def main(): # Initialize SOUI factory and resources soui_factory = SouiFactory(sys.dllhandle) # Create and show main window window = MainWindow() window.Create() window.ShowWindow(1) # Run message loop app.Run(window.GetHwnd()) if __name__ == '__main__': main() ``` ## Project Structure - `soui4py.pyx` - Main Cython source file - `ctrls.pxd` - Control interface definitions - `events.py` - Event handling system - `message.py` - Window message handling - `helper.py` - Utility functions - `build-pyd.py` - Build script - `test.py` - Example usage and test cases ## Debugging 1. Setup Visual Studio Code for debugging: - Install Python extension - Configure launch.json for Python debugging - Set breakpoints in Python code 2. Debug build: ```bash python build-pyd.py --debug ``` 3. Common debugging tips: - Use print statements for tracking COM interface calls - Check reference counting with AddRef/Release calls - Monitor DLL loading with Process Monitor - Use Visual Studio debugger for native code debugging ## Known Issues - Make sure SOUI DLLs are in the correct path before importing soui4py - COM interface reference counting needs careful management - Some complex controls might need special handling ## Contributing Contributions are welcome! Please feel free to submit pull requests. 1. Fork the repository 2. Create your feature branch 3. Commit your changes 4. Push to the branch 5. Create a new Pull Request ## License This project is licensed under the MIT License - see the LICENSE file for details.