PacDessert1436.PythonNetTemplateVB
1.0.0
See the version list below for details.
dotnet new install PacDessert1436.PythonNetTemplateVB@1.0.0
Python.NET Templates for VB.NET, by Pac-Dessert1436
A comprehensive set of VB.NET templates for creating desktop applications with Python integration using Python.NET, including both general-purpose Python templates and specialized bioinformatics templates using Biopython.
This template package is designed to enable VB.NET developers to leverage the power of Python.NET, and create robust desktop applications with Python integration.
Templates Included
1. Python Console Application (VB.NET)
A general-purpose console application template with Python.NET integration for seamless Python interop.
Short Name: pyappvb
Identity: PacDessert1436.PythonNetTemplateVB.Python.Console
Features:
- Python runtime initialization and management
- Direct Python expression evaluation
- Execute Python code blocks from VB.NET
- Proper GIL (Global Interpreter Lock) handling
- Example Python integration scenarios
- Cross-platform console application support
2. Python WPF Desktop Application (VB.NET)
A modern WPF desktop application template with Python.NET integration.
Short Name: pywpfvb
Identity: PacDessert1436.PythonNetTemplateVB.Python.WPF
Features:
- Python runtime integration in WPF applications
- Interactive UI with Python backend processing
- Thread-safe Python calls from WPF UI thread
- Example Python integration patterns
- Modern MVVM-ready WPF architecture
3. BioPython Console Application (VB.NET)
A console-based bioinformatics application template leveraging Python's Biopython library.
Short Name: biopyappvb
Identity: PacDessert1436.PythonNetTemplateVB.BioPython.Console
Features:
- DNA/RNA/Protein sequence analysis
- Reverse complement, transcription, translation
- GC/AU content calculation
- Sequence record formatting (FASTA)
- Biopython object wrappers for type-safe access
- Comprehensive bioinformatics workflows
4. BioPython WPF Desktop Application (VB.NET)
A feature-rich WPF desktop application for bioinformatics sequence analysis.
Short Name: biopywpfvb
Identity: PacDessert1436.PythonNetTemplateVB.BioPython.WPF
Features:
- Interactive sequence analysis interface
- Support for DNA, RNA, and protein sequences
- Real-time sequence validation
- Visual display of analysis results
- GC/AU content calculation
- Nucleotide/amino acid frequency analysis
- FASTA format support
- Professional WPF UI with modern styling
Prerequisites
- .NET SDK 10: Download from dotnet.microsoft.com
- Python 3.11 or later: Download from python.org
- Biopython Library: Install via pip:
pip install biopython - Python.NET: Install via NuGet (automatically included in templates)
Installation
Install Templates
dotnet new install PacDessert1436.PythonNetTemplateVB
Verify Installation
dotnet new --list
You should see all four templates listed:
| Template Name | Short Name |
|---|---|
| Python Console Application (VB.NET) | pyappvb |
| Python WPF Desktop Application (VB.NET) | pywpfvb |
| BioPython Console Application (VB.NET) | biopyappvb |
| BioPython WPF Desktop Application (VB.NET) | biopywpfvb |
Usage
Create a Python Console Application
dotnet new pyappvb -n MyPythonConsoleApp
cd MyPythonConsoleApp
dotnet run
Create a Python WPF Desktop Application
dotnet new pywpfvb -n MyPythonWPFApp
cd MyPythonWPFApp
dotnet run
Create a BioPython Console Application
dotnet new biopyappvb -n MyBioConsoleApp
cd MyBioConsoleApp
dotnet run
Create a BioPython WPF Desktop Application
dotnet new biopywpfvb -n MyBioWPFApp
cd MyBioWPFApp
dotnet run
Project Structure
Python Console Application Structure
MyPythonConsoleApp/
├── PythonBridge.vb ' Python runtime management utilities
├── Program.vb ' Main application entry point
└── PythonAppVB.vbproj ' Project file
Python WPF Application Structure
MyPythonWPFApp/
├── PythonBridge.vb ' Python runtime management utilities
├── MainWindow.xaml ' Main UI window
├── MainWindow.xaml.vb ' UI event handlers and logic
├── App.xaml ' Application definition
└── PythonWPFVB.vbproj ' Project file
BioPython Console Application Structure
MyBioConsoleApp/
├── BioPyWrappers/
│ ├── BioPyObject.vb ' Base wrapper class for Python objects
│ ├── Seq.vb ' Wrapper for Biopython Seq objects
│ ├── MutableSeq.vb ' Wrapper for Biopython MutableSeq objects
│ └── SeqRecord.vb ' Wrapper for Biopython SeqRecord objects
├── PythonBridge.vb ' Python runtime management utilities
├── Program.vb ' Main application entry point
└── BioPythonAppVB.vbproj ' Project file
BioPython WPF Application Structure
MyBioWPFApp/
├── BioPyWrappers/
│ ├── BioPyObject.vb ' Base wrapper class for Python objects
│ ├── Seq.vb ' Wrapper for Biopython Seq objects
│ ├── MutableSeq.vb ' Wrapper for Biopython MutableSeq objects
│ └── SeqRecord.vb ' Wrapper for Biopython SeqRecord objects
├── PythonBridge.vb ' Python runtime management utilities
├── MainWindow.xaml ' Main UI window
├── MainWindow.xaml.vb ' UI event handlers and logic
├── App.xaml ' Application definition
└── BioPythonWPFVB.vbproj ' Project file
Key Features
Python.NET Integration (All Templates)
All templates provide seamless Python integration using Python.NET:
- Automatic Python runtime initialization and cleanup
- Proper GIL (Global Interpreter Lock) management
- Direct evaluation of Python expressions from VB.NET
- Execute Python code blocks within VB.NET applications
- Thread-safe Python calls for multi-threaded environments
- Comprehensive error handling for Python operations
Bioinformatics Capabilities (BioPython Templates)
Specialized bioinformatics functionality using Biopython:
- DNA Analysis: Reverse complement, transcription, translation, GC content
- RNA Analysis: Reverse complement, translation, AU content
- Protein Analysis: Sequence validation, amino acid property analysis
- Sequence Records: FASTA format support and manipulation
- Type-Safe Wrappers: VB.NET wrapper classes for Biopython objects
- Comprehensive Workflows: Pre-built bioinformatics analysis pipelines
General-Purpose Python Templates
Flexible Python integration for any type of application:
- Console Applications: Cross-platform console apps with Python logic
- WPF Applications: Modern desktop apps with Python backend processing
- MVVM-Ready: WPF templates designed for MVVM architecture
- Example Patterns: Pre-built Python integration examples
- Extensible Architecture: Easy to add custom Python functionality
Best Practices
All templates follow .NET and Python best practices:
- Resource Management: Proper use of
Usingstatements for Python objects - Error Handling: Comprehensive try-catch blocks and user-friendly error messages
- Thread Safety: GIL handling for multi-threaded WPF applications
- Clean Architecture: Separation of concerns between Python interop and application logic
- Maintainable Code: Consistent coding style and documentation
Customization
Adding New Biopython Wrappers
- Create a new class in the
BioPyWrappersdirectory - Inherit from
BioPyObject(Of T) - Implement wrapper methods for Biopython functionality
Example:
Public Class MyBioWrapper
Inherits BioPyObject(Of Object)
Public Sub New(pyObj As IntPtr)
MyBase.New(pyObj)
End Sub
Public Sub MyMethod()
InvokeMethod("my_method")
End Sub
End Class
Extending Functionality
Use the provided helper methods in PythonBridge.vb:
EvalPyExpr(Of T): Evaluate Python expressions and return strongly-typed resultsExecPyCode: Execute Python code blocksStartPythonRuntime: Initialize Python environmentStopPythonRuntime: Clean up Python environment
Troubleshooting
Python Runtime Errors
- Ensure Python is installed and available in PATH
- Verify Biopython is installed:
pip install biopython - Check that the Python version matches the template's pythonVersion parameter
Interop Errors
- Make sure Python.NET is compatible with your Python version
- Check for architecture mismatches (x86 vs x64)
- Verify that all required Python libraries are installed
WPF UI Issues
- Ensure .NET Desktop Runtime is installed
- Check for missing NuGet packages
- Verify that the project builds correctly before running
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Support
For support, please open an issue in the repository or contact the maintainer.
License
BSD 3-Clause License. See the LICENSE file for details.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.