Skip to content

Commit

Permalink
Examples updates. Added programmatic maintenance tool passthru args d…
Browse files Browse the repository at this point in the history
…emo to Dynamic Finish Example to tweak custom uninstall on upgrade context. Added a new UI Example, demoing component selection and enabling / disabling per the internet status (with plans to expand to other UI demos).
  • Loading branch information
BuvinJ committed Jan 15, 2021
1 parent 35ae18d commit ada03b7
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 4 deletions.
12 changes: 10 additions & 2 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ TODO: FILL IN!

TODO: FILL IN!

## Hello Installer UI Example
## Hello Installer UI Examples

### Custom Interactions Examples

TODO: FILL IN!

### Custom Pages Examples

A QtIwf installer is extremely customizable. In addition to simply copying
files to another machine, it can perform extended operations on that target
Expand Down Expand Up @@ -329,7 +335,9 @@ In concert with altering these visual dimensions of the user experience, you may
revise the logic via [Installer Scripting](LowLevel.md#installer-scripting), or call upon the higher level script abstraction classes [QtIfwControlScript](ConfigClasses.md#qtifwcontrolscript) or
[QtIfwPackageScript](ConfigClasses.md#qtifwpackagescript).

TODO: Expand to demo custom widgets injected on built-in pages.
### Widget Injections Example

TODO: FILL IN!

## Hello Dynamic Finish Example

Expand Down
28 changes: 28 additions & 0 deletions examples/hello_dynamic_finish/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ def onQtIfwConfig( self, cfg ):
IS_CLI_APP_INSTALLED_KEY = "isCliAppInstalled"
IS_TK_APP_INSTALLED_KEY = "isTkAppInstalled"

def reviseControllerConstructor( cfg ):
# When running the installer (not the maintenance tool), and not
# using "remove all mode" (e.g. via silent installer -u),
# define additional arguments for the maintenance tool
# (unless a manual override was provided for that...)
# so it will skip the custom uninstallation detached execution
# during an a forced uninstall, i.e. an "update" context.
Script = QtIfwControlScript
TAB = Script.TAB
EBLK = Script.END_BLOCK
NOT_EQUAL_TO = Script.NOT_EQUAL_TO
ASSIGN = Script.ASSIGN
FALSE = Script.FALSE
cfg.controlScript.controllerConstructorInjection =(
Script.ifInstalling( isMultiLine=True ) +
TAB + Script.ifCondition( Script.cmdLineArg(
Script.MAINTAIN_MODE_CMD_ARG ) + NOT_EQUAL_TO +
Script.quote( Script.MAINTAIN_MODE_OPT_REMOVE_ALL ),
isMultiLine=True ) +
(2*TAB) + Script.ifCmdLineArg( Script.MAINTAIN_PASSTHRU_CMD_ARG,
isNegated=True ) +
(3*TAB) + Script.setValue( Script.MAINTAIN_PASSTHRU_CMD_ARG,
IS_TK_APP_INSTALLED_KEY + ASSIGN + FALSE ) +
TAB + EBLK +
EBLK
)

def customizeReadyForInstallPage( cfg, tkPkg, cliPkg ):
# Unfortunately, there is no built-in QtIFW means to determine
# which components were installed via QtScript from an uninstaller.
Expand Down Expand Up @@ -287,6 +314,7 @@ def showIfInstalled( checkbox, pkg, isChecked=True ):
pkgs = cfg.packages
tkPkg = findQtIfwPackage( pkgs, TK_CONFIG_KEY )
cliPkg = findQtIfwPackage( pkgs, CLI_CONFIG_KEY )
reviseControllerConstructor( cfg )
customizeReadyForInstallPage( cfg, tkPkg, cliPkg )
customizeFinishedPage( cfg, tkPkg, cliPkg )

Expand Down
82 changes: 82 additions & 0 deletions examples/hello_qtiwf_ui/custom_interactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from distbuilder import( RobustInstallerProcess, ConfigFactory,
QtIfwControlScript, findQtIfwPackage )

f = masterConfigFactory = ConfigFactory()
f.productName = "Hello Custom UI Interactions Example"
f.companyTradeName = "Some Company"
f.companyLegalName = "Some Company Inc."
f.iconFilePath = "../hello_world_tk/demo.ico"
f.version = (1,0,0,0)
f.setupName = "HelloUiInteractionsSetup"

# Define a "Package Factory Dictionary"
# Note: None values for a ConfigFactory results in making a clone of the
# master, which can then be customization from that "base" within
# RobustInstallerProcess.onConfigFactory
TK_CONFIG_KEY = "tk"
CLI_CONFIG_KEY = "cli"
pkgFactories={ TK_CONFIG_KEY:None, CLI_CONFIG_KEY:None }

licenseName = "LICENSE.TXT"

class BuildProcess( RobustInstallerProcess ):

def onConfigFactory( self, key, f ):
if key==TK_CONFIG_KEY:
f.productName = "Hello World Tk Example"
f.description = "Tk Example"
f.binaryName = "HelloWorldTk"
f.version = (1,0,0,0)
f.isGui = True
f.sourceDir = "../hello_world_tk"
f.entryPointPy = "hello.py"
f.iconFilePath = "demo.ico"
elif key==CLI_CONFIG_KEY:
f.productName = "Hello World CLI Example"
f.description = "CLI Example"
f.binaryName = "HelloWorld"
f.version = (1,0,0,0)
f.isGui = False
f.sourceDir = "../hello_world"
f.entryPointPy = "hello.py"
f.iconFilePath = None
f.distResources = [licenseName]

def onQtIfwConfig( self, cfg ):

def reviseComponentSelectionPage( cfg, tkPkg ):
Script = QtIfwControlScript
TAB = Script.TAB
ELSE = Script.ELSE
SBLK = Script.START_BLOCK
EBLK = Script.END_BLOCK
NET_ERR_MSG="The Tk Example requires an internet connection"
cfg.controlScript.componentSelectionPageInjection =(
Script.ifAutoPilot( isMultiLine=True ) +
TAB + Script.ifComponentSelected( tkPkg,
isMultiLine=True ) +
(2*TAB) + Script.assertInternetConnected(
errMsg=NET_ERR_MSG ) +
TAB + EBLK +
EBLK + ELSE + SBLK +
TAB + Script.ifInternetConnected( isRefresh=True,
isMultiLine=True ) +
(2*TAB) + QtIfwControlScript.enableComponent( tkPkg, True ) +
TAB + EBLK +
TAB + ELSE + SBLK +
(2*TAB) + QtIfwControlScript.warningPopup( NET_ERR_MSG ) +
(2*TAB) + QtIfwControlScript.selectComponent( tkPkg, False ) +
(2*TAB) + QtIfwControlScript.enableComponent( tkPkg, False ) +
TAB + EBLK +
EBLK
)

pkgs = cfg.packages
tkPkg = findQtIfwPackage( pkgs, TK_CONFIG_KEY )
cliPkg = findQtIfwPackage( pkgs, CLI_CONFIG_KEY )
reviseComponentSelectionPage( cfg, tkPkg )

p = BuildProcess( masterConfigFactory, pyPkgConfigFactoryDict=pkgFactories,
isDesktopTarget=True )
p.isInstallTest = True
p.run()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
QtIfwSimpleTextPage, QT_IFW_TARGET_DIR_PAGE, QtIfwControlScript as Script

f = configFactory = ConfigFactory()
f.productName = "Hello Custom Installer UI Example"
f.productName = "Hello Custom Pages Example"
f.description = "A Distribution Builder Example"
f.companyTradeName = "Some Company"
f.companyLegalName = "Some Company Inc."
Expand All @@ -11,7 +11,7 @@
f.entryPointPy = "../hello_world_tk/hello.py"
f.iconFilePath = "../hello_world_tk/demo.ico"
f.version = (1,0,0,0)
f.setupName = "HelloIfwUiSetup"
f.setupName = "HelloIfwPagesSetup"

f.ifwUiPages = QtIfwSimpleTextPage( "Example", QT_IFW_TARGET_DIR_PAGE,
title="Custom Page",
Expand Down
1 change: 1 addition & 0 deletions examples/hello_qtiwf_ui/widget_injections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO!

0 comments on commit ada03b7

Please sign in to comment.