forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPF DynamicGrid python and XAML layout files (pythonnet#280)
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import clr | ||
import sys | ||
if sys.platform.lower() not in ['cli','win32']: | ||
print("only windows is supported for wpf") | ||
clr.AddReference(r"wpf\PresentationFramework") | ||
from System.IO import StreamReader | ||
from System.Windows.Markup import XamlReader | ||
from System.Threading import Thread, ThreadStart, ApartmentState | ||
from System.Windows import Application, Window | ||
|
||
|
||
class MyWindow(Window): | ||
def __init__(self): | ||
stream = StreamReader("DynamicGrid.xaml") | ||
window = XamlReader.Load(stream.BaseStream) | ||
Application().Run(window) | ||
|
||
|
||
if __name__ == '__main__': | ||
thread = Thread(ThreadStart(MyWindow)) | ||
thread.SetApartmentState(ApartmentState.STA) | ||
thread.Start() | ||
thread.Join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Window | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Title="WpfApplication1" Height="300" Width="300"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Label Content="Left" Grid.Column="0" Background="LightBlue" /> | ||
<GridSplitter | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
Grid.Column="1" | ||
Width="5" | ||
Grid.RowSpan="3"/> | ||
<Label Content="Right" Grid.Column="2" Grid.Row="2" Background="LightBlue" /> | ||
<Label Content="Top" Grid.Column="2" Background="LightGreen"/> | ||
<GridSplitter | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Grid.Row="1" | ||
Width="Auto" | ||
Height="5" | ||
Grid.ColumnSpan="3"/> | ||
<Label Content="Bottom" Grid.Column="0" Grid.Row="2" Background="LightGreen" /> | ||
</Grid> | ||
</Window> |