Skip to content

Instantly share code, notes, and snippets.

@MomenFathi
Forked from SteveGilham/gist:335e15f5aa4bbf579184
Last active September 5, 2017 13:54
Show Gist options
  • Select an option

  • Save MomenFathi/fdd000704e40969895d75db2423aea0c to your computer and use it in GitHub Desktop.

Select an option

Save MomenFathi/fdd000704e40969895d75db2423aea0c to your computer and use it in GitHub Desktop.
WPF for Python Example
from wpf import *
# Create window
my_window = Window()
my_window.Title = 'Welcome to IronPython'
# Create StackPanel to Layout UI elements
my_stack = StackPanel()
my_stack.Margin = Thickness(15)
my_window.Content = my_stack
# Create Button and add a Button Click event handler
my_button = Button()
my_button.Content = 'Push Me'
my_button.FontSize = 24
my_button.BitmapEffect = DropShadowBitmapEffect()
def clicker(sender, args):
# Create new label
my_message = Label()
my_message.FontSize = 48
my_message.Content = 'Welcome to IronPython!'
# Add label into stack panel of controls
my_stack.Children.Add (my_message)
my_button.Click += clicker
my_stack.Children.Add (my_button)
# Run application
my_app = Application()
my_app.Run (my_window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment