/
DefaultButtons1.py
137 lines (108 loc) · 4.07 KB
/
DefaultButtons1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# encoding: utf-8
# Advanced example of using the Wizard widget.
#
# Note: YCP applications are discouraged from using the Wizard widget directly.
# Use the Wizard module instead.
from yast import import_module
import_module('UI')
from yast import *
class DefaultButtons1Client:
def main(self):
base_installation_steps = [
{ "id" : "language", "label" : "Language" },
{ "id" : "proposal", "label" : "Installation Settings" },
{ "id" : "do_resize", "label" : "Perform Installation" },
{ "id" : "prepdisk", "label" : "Perform Installation" },
{ "id" : "kickoff", "label" : "Perform Installation" },
{ "id" : "rpmcopy", "label" : "Perform Installation" },
{ "id" : "finish", "label" : "Perform Installation" }
]
config_steps = [
{ "id" : "root", "label" : "Root Password" },
{ "id" : "proposal_net", "label" : "Network" },
{ "id" : "ask_net_test", "label" : "Network" },
{ "id" : "do_net_test", "label" : "Network" },
{ "id" : "you", "label" : "Online Update" },
{ "id" : "auth", "label" : "Users" },
{ "id" : "user", "label" : "Users" },
{ "id" : "suseconfig", "label" : "Clean Up" },
{ "id" : "release_notes", "label" : "Release Notes" },
{ "id" : "proposal_hw", "label" : "Device Configuration" }
]
self.steps = ycpbuiltins.flatten([base_installation_steps, config_steps])
if not UI.HasSpecialWidget("Wizard"):
ycpbuiltins.y2error(
"This works only with UIs that provide the wizard widget!"
)
return
help_text = "<p>This is a help text.</p>" + "<p>It should be helpful.</p>" + "<p>If it isn't helpful, it should rather not be called a <i>help text</i>.</p>" + "<p>Help texts may contain the product name (&product;) with a macro that will " + "automatically be expanded - multiple times (&product;) if needed.</p>"
UI.OpenDialog(
Opt("defaultsize"),
Wizard(
Opt("stepsEnabled"),
Symbol("back"),
"&Back",
Symbol("abort"),
"Ab&ort",
Symbol("next"),
"&Next"
)
)
# UI::DumpWidgetTree();
UI.WizardCommand(
Term(
"SetDialogIcon",
"/usr/share/YaST2/theme/current/icons/22x22/apps/YaST.png"
)
)
UI.WizardCommand(
Term("SetDialogHeading", "Welcome to the YaST2 installation")
)
UI.WizardCommand(Term("SetHelpText", help_text))
UI.WizardCommand(Term("AddStepHeading", "Base Installation"))
UI.ReplaceWidget(
Id("contents"),
VBox(
Heading("Current workflow step:"),
VSpacing(0.5),
HSquash(InputField(Id("stepName"), "Step &Name: ")),
PushButton(Id("doit"), Opt("default"), "&Do something!")
)
)
for step in ycpbuiltins.foreach(base_installation_steps):
UI.WizardCommand(
Term(
"AddStep",
step.get("label", ""),
step.get("id", "")
)
)
UI.WizardCommand(Term("AddStepHeading", "Configuration"))
for step in ycpbuiltins.foreach(config_steps):
UI.WizardCommand(
Term(
"AddStep",
step.get("label", ""),
step.get("id", "")
)
)
current_step = 0
self.show_step(0)
while True:
button = UI.UserInput()
if button == "abort":
break
if button == "next" or button == "back":
if button == "next" and ((current_step + 1) < ycpbuiltins.size(self.steps)):
current_step = current_step + 1
if button == "back" and current_step > 0:
current_step = current_step - 1
self.show_step(current_step)
if button == "doit":
ycpbuiltins.y2milestone("Doing something")
UI.CloseDialog()
def show_step(self, no):
current_id = self.steps[no].get("id", "")
UI.ChangeWidget("stepName", "Value", current_id)
UI.WizardCommand(Term("SetCurrentStep", current_id))
DefaultButtons1Client().main()