Up | Button | BitBtn | SpeedButton | CheckBox | ComboBox | Control | Edit | Memo | Font | GroupBox | Label | ListBox | PageControl | Panel | RadioButton | Bevel | ScrollBox | TabSheet | WinControl | Callback | Frame | WinControl | Form | Release Notes

 

  

 
Control

The Control class is base class for Windows controls.

access function: GetControl(name)  / GetControlByHandle(hwnd)

Attribute Access Type Description
name R string the name of the control
iName R string internal name of control (full path of control)
pName R string the python wrapper class name, normally same as iName
type R string the control type
bound R bool returns boolean if the python instance contains a wrapped control
visible R/W bool the visibility of the panel. Changing the visibility property may cause unexpected results in the UI due to other child controls alignments
enabled R/W bool whether a control is enabled or not
align R/W int 0=None, 1=Top, 2=Bottom, 3=Left, 4=Right, 5=Client. Note the anchors property using align.
anchors R/W int anchors the individual corners ogf the control. bit0=Left, bit1=Top, bit2=Right, bit3=Bottom. Note the align property using anchors.
left R/W int left position of the control relative to the controls parent client area
top R/W int top position of the control relative to the controls parent client area
width R/W int width of the control
height R/W int height of the control
right R/W int right position of the control relative to the controls parent client area
bottom R/W int bottom position of the control relative to the controls parent client area
topLeft R int,int returns upper left position as tuple, (left, top)
bottomRight R int,int returns bottom right position as tuple (right, bottom)
size R int,int returns size of control as tuple (width,height)
clientWidth R/W int the controls client width, useful when populating new controls from python
clientHeight R/W int the controls client height, useful when populating new controls from python
controlCount R int number of owned controls
controls R tuple returns a tuple with sets of type and name as strings for all owned controls which can be used for browsing
parent R WinControl returns the parent WinControl
tag R/W integer user defined value
hint R/W string the controls hint when mouse hooves over
showHint R/W bool hint visibility
config R/W string configuration for special controls, rarely used


Method Returns Description
get(index) Control returns a control by index
getControl(name) Control returns the named child control. Returns None if not found. The name is not case sensitive but it is recommended to use the exact case found when browsing controls.
assigned() bool returns true if the object is assigend to the windows control, else it draws an exception
addControl(type [,left,top]) Control returns a control of given type (classname), left and top are optinal, defalts to 0

Available standard controls:
Label,GroupBox,Panel,ScrollBox,Button,CheckBox,RadioButton,Edit,ListBox,ComboBox,
PageControl,TabSheet

Additional controls:
CaptionPanel,TrendView,CurveView
addMenuItem([caption,onClick] MenuItem adds a menu item to the controls popupmenu. Applies to Panel, ListBox, GroupBox, Frame and Form
addTimer([name,interval,enabled,onTimer] MenuItem adds local timer to the control. NOTE: local timers is not included in timers added by GetTimerList().addTimer and is not calling 'System.OnTimer' event. The timer's 'onTimer' property or the owners control 'onTimer ' property has to be set.
addComponent(type) component adds a Control, Timer or MenuItem to the control with default properties
deleteControl(name) bool deletes named control if found
deleteControls() None deletes all controls added by python
update() None forces GUI update

Note: Special care must be taken if changing the position/size of a control since a control very often is aligned to its parent boundaries and changes may cause misbehaviour (or may not be editable).

Example 1: Find all PageControls of Main form

def FindControls(name,type):
  ctrl=GetControl(name)
  for iter in ctrl.controls:
    if iter[0]==type:                 #check for equal type, first item is type
      c=ctrl.getControl(iter[1])   #get the control, second item is name
      print c.type,c.name           #print found control

FindControls('','PageControl')   #find all page controls directly owned by main form

Console output:

PageControl pcMain
PageControl pcOperation
PageControl pcSettings
PageControl pcService
PageControl pcServiceGeneral
PageControl pcServiceTdvCmd
PageControl pcServiceAdvanced

Note: The names of controls are defined by the Scorpion Program at compile-time and may change from one version to another.

Example 2: Find all controls of Main form

def Browse(name):
  ctrl=GetControl(name)
  if ctrl.assigned():
    print 'Control %s of type %s' % (ctrl.name,ctrl.type)
    if ctrl.type=='PageControl':
      pc=GetPageControl(ctrl.name)
      for ts in pc.pages:
        print ts
    else:
      for c in ctrl.controls:
        print c

Browse('')   #browses all controls owned by the main form

Console output:

Control of type Main
('Label', '')
('Splitter', 'SplitterVertical')
('StatusBar', 'StatusBar')
('PageControl', 'pcMain')
('TabSheet', 'tsOperation')
('PageControl', 'pcOperation')
('TabSheet', 'tsOperationImageBuffer')
('ImageBuffer', 'ImageBuffer')
('TabSheet', 'tsOperationTrendView')
('TrendView', 'TrendView')
('TabSheet', 'tsOperationStatistics')
('StatisticsView', 'StatisticsView')
('TabSheet', 'tsSettings')
('PageControl', 'pcSettings')
('TabSheet', 'tsSettingsReferences')
('ReferenceView', 'ReferenceView')
('TabSheet', 'tsService')
('PageControl', 'pcService')
('TabSheet', 'tsServiceGeneral')
('PageControl', 'pcServiceGeneral')
('TabSheet', 'tsServiceGeneralProfile')
('GroupBox', 'gbIdentification')
('Label', 'LabelApplicationName')
('Label', 'LabelProject')
('Label', 'Label5')
('Label', 'Label10')
('Label', 'Label2')
('Edit', 'eApplicationName')
('Edit', 'eProject')
('Edit', 'eProfileVersion')
('CheckBox', 'cbModifiedProfile')
....
....
....

 

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