::AddButtonToActionFrame
This command adds a button to the specified frame. Normally it is used to add “Back” and “Next” buttons to the buttons frame of the wizard dialog, but can be used to add any button which can perform any task to any frame.
Syntax
::model::mdlWizardDlg::AddButtonToActionFrame frame button position text callback
Application
MotionView Tcl GUI
Description
This command adds a button to the specified frame. Normally it is used to add “Back” and “Next” buttons to the buttons frame of the wizard dialog, but can be used to add any button which can perform any task to any frame.
Inputs
- frame
- The full path to the action frame of the wizard dialog. This path is usually returned by the ::model::mdlWizardDlg::GetButtonFrame procedure.
- button
- The name that will be used for the button widget being added.
- position
- This position is the “column” that the button is to be added in the specified frame.
- text
- The text that is to be displayed in this button in the specified frame.
- callback
- The procedure that is to be executed when this button is pressed.
Example
namespace eval ::my_wizard {
variable p_dlg ""
variable panel_list {}
variable current_panel 0
}
proc ::my_wizard::Run {} {
set mangle [::model::GetMangle my_wizard_Run]
variable p_dlg
variable current_panel 0
set p_dlg [::model::mdlWizardDlg wiz$mangle -width 600 -height 400 \
-title "My Wizard" -showExport false -callback "::my_wizard::OnClose"]
set frm [::model::mdlWizardDlg::GetButtonFrame $p_dlg]
::model::mdlWizardDlg::AddButtonToActionFrame $frm btnBack 4 "< Back" ::my_wizard::OnBack
::model::mdlWizardDlg::AddButtonToActionFrame $frm btnNext 6 "Next >" ::my_wizard::OnNext
::model::mdlWizardDlg::SetCloseButtonText "Finish"
variable panel_list [InitializePanelList]
DisplayPanel
::model::mdlWizardDlg::ShowDialog
}
proc ::my_wizard::InitializePanelList {} {
hwi GetSessionHandle sess1
sess1 GetProjectHandle pro1
sess1 ReleaseHandle
pro1 GetPageHandle pa1 [pro1 GetActivePage]
pro1 ReleaseHandle
pa1 GetWindowHandle win1 [pa1 GetActiveWindow]
pa1 ReleaseHandle
win1 GetClientHandle mcl
win1 ReleaseHandle
mcl GetRootObjectHandle mo
mcl ReleaseHandle
mo InterpretEntity en1 Point p_abtaf_1 "\"Point 1\""
mo InterpretEntity en2 Point p_abtaf_2 "\"Point 2\""
mo InterpretEntity en3 Point p_abtaf_3 "\"Point 3\""
mo ReleaseHandle
return { en1 en2 en3 }
}
proc ::my_wizard::DisplayPanel {} {
set mangle [::model::GetMangle my_wizard_DisplayPanel]
variable current_panel
variable panel_list
set tmp [lindex $panel_list $current_panel]
$tmp GetObjectHandle pCurPoint$mangle
set lbl "My Wizard - [pCurPoint$mangle GetLabel]"
pCurPoint$mangle ReleaseHandle
::model::mdlWizardDlg::ChangeTitle "$lbl"
set frmParent [::model::mdlWizardDlg::GetDialogFrame]
grid rowconfigure $frmParent 0 -weight 1
grid columnconfigure $frmParent 0 -weight 1
catch { destroy $frmParent.frmPanel }
set frm [frame $frmParent.frmPanel]
grid rowconfigure $frm 0 -weight 1
grid columnconfigure $frm 0 -weight 1
set txt "Point: $lbl"
set wLbl [label $frm.lbl -text $txt]
grid $wLbl -row 0 -column 0
grid $frm -row 0 -column 0 -sticky nesw
UpdateBackNextButtonStates
}
proc ::my_wizard::UpdateBackNextButtonStates {} {
variable p_dlg
variable current_panel
variable panel_list
set nLastIndex [ expr { [llength $panel_list] - 1 } ]
set frm [::model::mdlWizardDlg::GetButtonFrame $p_dlg]
set bEnableBack [ expr { $current_panel > 0 && $nLastIndex > 0} ]
set bEnableNext [ expr { $current_panel < $nLastIndex } ]
if { $bEnableBack } { ::hwt::EnableCanvasButton $frm.btnBack } else { ::hwt::DisableCanvasButton $frm.btnBack }
if { $bEnableNext } { ::hwt::EnableCanvasButton $frm.btnNext } else { ::hwt::DisableCanvasButton $frm.btnNext }
}
proc ::my_wizard::OnNext { args } {
variable current_panel
incr current_panel 1
DisplayPanel
UpdateBackNextButtonStates
}
proc ::my_wizard::OnBack { args } {
variable current_panel
incr current_panel -1
DisplayPanel
UpdateBackNextButtonStates
}
proc ::my_wizard::OnClose { args } {
variable p_dlg
hwt::UnpostWindow $p_dlg
return 1
}
::my_wizard::Run
Errors
None.