2020년 8월 17일 월요일

[IronPython] WPF Control - Button

 1. WPF Control Button

import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore")

from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Media.Effects import *

def GetToolTip(title):
    tip = ToolTip()
    tip.Content = title
    return tip
    
def GetButton(title,size,handler):
    l = Button()
    l.Content = title
    l.FontSize = size
    l.Margin  = Thickness(5)
    l.Padding = Thickness(5)
    l.HorizontalAlignment = HorizontalAlignment.Center;
    l.VerticalAlignment = VerticalAlignment.Center;
    l.BitmapEffect = DropShadowBitmapEffect()
    l.ToolTip = GetToolTip(title)
    l.Click += ClickEvent
    return l

def ClickEvent(sender,args):
    MessageBox.Show("Label Clicked","Alert")
    
if __name__ == "__main__":     
    w = Window()
    w.Title = "Hello World"
    w.Width = 320
    w.Height = 240
    w.Content = GetButton("Hello World",30,ClickEvent)
    Application().Run(w)   




댓글 없음:

댓글 쓰기