forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicGrid.py
More file actions
23 lines (19 loc) · 712 Bytes
/
DynamicGrid.py
File metadata and controls
23 lines (19 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()