(圖一) WPF視窗介面 |
template.py 檔案代碼
import os, sys, re, clr
import math, cmath
import collections
win64_dir = oDesktop.GetExeDir()
dll_dir = os.path.join(win64_dir, 'common/IronPython/DLLs')
sys.path.append(dll_dir)
clr.AddReference('IronPython.Wpf')
import wpf
from System.Windows import Window
from System.Windows.Controls import ListBoxItem
from System.Windows.Forms import OpenFileDialog, SaveFileDialog, DialogResult, FolderBrowserDialog
os.chdir(os.path.dirname(__file__))
#Functions---------------------------------------------------------------------|
#GUI---------------------------------------------------------------------------|
class MyWindow(Window):
def __init__(self):
wpf.LoadComponent(self, 'template.xaml')
oDesktop.ClearMessages("","",2)
def Button_Click(self, sender, e):
AddWarningMessage(self.input_tb.Text)
#Code End----------------------------------------------------------------------|
MyWindow().ShowDialog()
template.xaml 檔案代碼
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Template Window" Height="144.165" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Background="#FFEAEBFF">
<Grid>
<Button Content="Execute" HorizontalAlignment="Right" Height="36" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="93" Click="Button_Click"/>
<TextBox x:Name="input_tb" HorizontalAlignment="Right" Height="27" Margin="0,10,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="214" VerticalContentAlignment="Center"/>
<Label Content="Value:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="55"/>
</Grid>
</Window>
沒有留言:
張貼留言