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 10 - Custom Button Class
The example defines a special Button Class - that opens and closes the Central tab in Scorpion.

#The bitmap shows the buttom placed on a OverlayPanel connected to a custompage with name Demo.

import CLR
import CLR.System.Windows.Forms as WinForms


class OpenCentralButton(WinForms.Button):
  def __init__(self):

    # Create the button
    self.Text = "Open Central Start"
    # Register event handler for button.Click
    self.Click += self.button_ClickHandler

  def button_ClickHandler(self, sender, args):
  # Handles the button Click event

    if self.Text == "Open Central Start":
     self.Text = "Close Central Start"
     # open service
     ExecuteCmd('AccessControl','Service=1')
     #activate Service
     mp = GetPageControl('pcMain')
     mp.activePage = 'Service'

     #activate Advanced
     sp = GetPageControl('pcService')
     sp.activePage = 'Advanced'

     # activate Central
     sap = GetPageControl('pcServiceAdvanced')
     sap.activePage = 'Central'

  elif self.Text == "Close Central Start":
     self.Text = "Open Central Start"
     # open service
     ExecuteCmd('AccessControl','Service=0')
     mp = GetPageControl('pcMain')
     mp.activePage = 'Operation'
 

 
 

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