1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 from pyanaconda.constants import *
22 from snack import *
23 from constants_text import *
24 from pyanaconda.iutil import strip_markup
25
26 import gettext
27 _ = lambda x: gettext.ldgettext("anaconda", x)
28
29 import logging
30 log = logging.getLogger("anaconda")
31
34 self.screen = screen
35 self.drawn = False
36
37 self.pct = 0
38
40 if self.drawn:
41 self.screen.popWindow ()
42
44 screen = self.screen
45
46 self.grid = GridForm(self.screen, _("Package Installation"), 1, 6)
47
48 self.width = 65
49 self.progress = Scale(self.width, 100)
50 self.grid.add (self.progress, 0, 1, (0, 1, 0, 0))
51
52 self.label = Label("")
53 self.grid.add(self.label, 0, 2, (0, 1, 0, 0), anchorLeft = 1)
54
55 self.info = Textbox(self.width, 4, "", wrap = 1)
56 self.grid.add(self.info, 0, 3, (0, 1, 0, 0))
57
58 self.grid.draw()
59 screen.refresh()
60 self.drawn = True
61
63 if not self.drawn:
64 return
65 self.grid.draw()
66 self.screen.refresh()
67
70
73
75 if not self.drawn:
76 self._setupScreen()
77
78 if pct > 1.0:
79 pct = 1.0
80
81 self.progress.set(int(pct * 100))
82 self.pct = pct
83 self.processEvents()
84
91
92 - def set_text(self, txt):
93 if not self.drawn:
94 self._setupScreen()
95
96 if len(txt) > self.width:
97 txt = txt[:self.width]
98 else:
99 spaces = (self.width - len(txt)) / 2
100 txt = (" " * spaces) + txt
101
102 self.label.setText(strip_markup(txt))
103 self.processEvents()
104
114
115 if __name__ == "__main__":
116 screen = SnackScreen()
117 ipw = InstallProgressWindow(screen)
118
119 import time
120 ipw._setupScreen()
121 time.sleep(2)
122
123 ipw.set_label("testing blah\n<b>blahblahb</b>lahbl ahalsdfkj")
124 ipw.set_text("blah blah blah")
125 ipw.set_fraction(0.25)
126 time.sleep(2)
127
128 p = ipw.get_fraction()
129
130 screen.finish()
131 print(p)
132