Up | Example 01 - ComboBox | Example 02 - ListBox | Example 03 - Labels class derived from Winforms.Panel | Example 04 - Button with Resize Event | Example 05 - CheckBox | Example 06 - GroupBox | Example 07 - Modeless Status Dialog | Example 08 -Timer | Example 09 -TextBox | Example 10 - Custom Button Class | Example 11 - Product Selection ComboBox | Example 12 - Simple ListView

 

  

 
Example 04 - Button with Resize Event
The following defines the creation of a Button in a Panel or Form derived class.
 # Create the command button
self.resetButton = WinForms.Button()
self.resetButton.Parent = self
self.resetButton.Size = Size(80,25)
self.resetButton.Location = Point((self.Width-self.resetButton.Width)/2,(self.Height-self.resetButton.Height*3/2))
self.resetButton.Text = "Reset"

# Register event handler for Button.Click
self.resetButton.Click += self.ResetButton_ClickHandler
# Register event handler for Resize
self.Resize += self.ResizeHandler
def ResizeHandler(self, sender, args):
  # Handles the Resize event

  print 'Resize Left: ',self.Left
  print 'Resize Top: ',self.Top
  print 'Resize Width: ',self.Width
  print 'Resize Height: ',self.Height

  self.resetButton.Location = Point((self.Width-self.resetButton.Width)/2,(self.Height - self.resetButton.Height*3/2))
 
def ResetButton_ClickHandler(self, sender, args):
  # Handles the command button Click event
  print 'Button Click'

Example 1: Change Font

self.resetButton.ForeColor = Color.Yellow
self.resetButton.Font = Font(r"Arial",20.0,FontStyle.Bold)

Example 2: Set Image

# handle the exception no image available
try :
  self.resetButton.Image = Bitmap(r'\video.jpg')
except :
  print ' no \video.jpg present '

 

 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.