2020년 12월 5일 토요일

[IronPython] WPF Check Box

WPF Check Box


import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore");
clr.AddReference('System.Data')
clr.AddReference('System.Windows.Forms')

import System
from System import *
from System.Data import *
from System.Type import GetType
from System.Threading.Tasks import Task
from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Controls.Primitives import *
from System.Windows.Media import *
from System.Windows.Media.Imaging import *
from System.Windows.Media.Effects import *
from System.Windows.Shapes import Rectangle
from System.Windows.Data import Binding
from System.Windows.Ink import Stroke
from System.Windows.Forms import ( FolderBrowserDialog, DialogResult )
from Microsoft.Win32 import ( OpenFileDialog, SaveFileDialog )

import ctrl

class WpfCheck(ctrl.WpfCtrl):
    def __init__(self,text=None,handler=None,**kwargs):
        self.ctrl = CheckBox()
        self.ctrl.VerticalAlignment = VerticalAlignment.Center
        self.ctrl.VerticalContentAlignment = VerticalAlignment.Center
        self.init(**kwargs)
        if text: self.ctrl.Content = text
        if handler: self.ctrl.Click += handler        
    def get_value(self): return self.ctrl.IsChecked

if __name__ == "__main__":
    def check_handler(s,e):
        print( s.IsChecked )
    import win
    app = win.Win("Check Demo",320,240)
    b = WpfCheck("Exit", handler=check_handler)
    app.set_content(b.ctrl)
    app.run()
    
    

댓글 없음:

댓글 쓰기