Skip to content

[WIP] WPF DynamicGrid python and XAML layout files #280

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

Merged
merged 2 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions demo/DynamicGrid.py
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()
34 changes: 34 additions & 0 deletions demo/DynamicGrid.xaml
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>