|
11 | 11 | @package manatools
|
12 | 12 | '''
|
13 | 13 |
|
14 |
| -import manatools.ui.basedialog as basedialog |
| 14 | +import manatools.basehelpinfo as helpdata |
| 15 | +import manatools.ui.helpdialog as helpdialog |
| 16 | + |
15 | 17 | import yui
|
16 | 18 | import time
|
17 | 19 |
|
|
21 | 23 | ##
|
22 | 24 | ######################################################################
|
23 | 25 |
|
24 |
| -class HelpInfoBase: |
25 |
| - def __init__(self): |
26 |
| - pass |
27 | 26 |
|
28 |
| - def show(self, info_to_show): |
29 |
| - ''' |
30 |
| - super class must implement show to return the right string to show |
31 |
| - into dialog |
32 |
| - @param info_to_show: a kind of index of what to show, it depends on implementation |
33 |
| - ''' |
34 |
| - raise NotImplementedError("show is not implemented") |
35 | 27 |
|
36 |
| - def home(self): |
37 |
| - ''' |
38 |
| - super class must implement show to return the very first info to show |
39 |
| - into dialog, such as index for instance. Than index could be anchored and anchors passed |
40 |
| - to show() to display related content |
41 |
| - ''' |
42 |
| - raise NotImplementedError("home is not implemented") |
43 |
| - |
44 |
| -class HelpInfo(HelpInfoBase): |
| 28 | +class HelpInfo(helpdata.HelpInfoBase): |
45 | 29 | def __init__(self):
|
46 |
| - HelpInfoBase.__init__(self) |
| 30 | + helpdata.HelpInfoBase.__init__(self) |
47 | 31 | index1 = '<b>%s</b>'%self._formatLink("Title 1", 'title1')
|
48 | 32 | index2 = '<b>%s</b>'%self._formatLink("Title 2", 'titleindex2')
|
49 | 33 | self.text = { 'home': "This text explain how to use manatools Help Dialog. <br><br>%s <br>%s"%(index1, index2),
|
@@ -76,61 +60,10 @@ def home(self):
|
76 | 60 | return self.text['home']
|
77 | 61 |
|
78 | 62 |
|
79 |
| -class HelpDialog(basedialog.BaseDialog): |
80 |
| - def __init__(self, info): |
81 |
| - basedialog.BaseDialog.__init__(self, "Help dialog", "", basedialog.DialogType.POPUP, 80, 10) |
82 |
| - #### TODO check instance of HelpInfoBase |
83 |
| - self.info = info |
84 |
| - |
85 |
| - def UIlayout(self, layout): |
86 |
| - ''' |
87 |
| - layout implementation called in base class to setup UI |
88 |
| - ''' |
89 |
| - |
90 |
| - # Let's test a Menu widget |
91 |
| - menu = self.factory.createMenuButton(self.factory.createLeft(layout), "Test &menu") |
92 |
| - qm = yui.YMenuItem("&Quit") |
93 |
| - menu.addItem(qm) |
94 |
| - menu.rebuildMenuTree() |
95 |
| - sendObjOnEvent=True |
96 |
| - self.eventManager.addMenuEvent(qm, self.onQuitEvent, sendObjOnEvent) |
97 |
| - # URL events are sent as YMenuEvent by libyui |
98 |
| - self.eventManager.addMenuEvent(None, self.onURLEvent, False) |
99 |
| - |
100 |
| - self.text = self.factory.createRichText(layout, "", False) |
101 |
| - self.text.setValue(self.info.home()) |
102 |
| - |
103 |
| - #let's test some buttons |
104 |
| - align = self.factory.createRight(layout) |
105 |
| - |
106 |
| - # Let's test a quitbutton (same handle as Quit menu) |
107 |
| - self.quitButton = self.factory.createPushButton(align, "&Quit") |
108 |
| - self.eventManager.addWidgetEvent(self.quitButton, self.onQuitEvent, sendObjOnEvent) |
109 |
| - |
110 |
| - # Let's test a cancel event |
111 |
| - self.eventManager.addCancelEvent(self.onCancelEvent) |
112 |
| - |
113 |
| - def onCancelEvent(self) : |
114 |
| - print ("Got a cancel event") |
115 |
| - |
116 |
| - def onQuitEvent(self, obj) : |
117 |
| - if isinstance(obj, yui.YItem): |
118 |
| - print ("Quit menu pressed") |
119 |
| - else: |
120 |
| - print ("Quit button pressed") |
121 |
| - # BaseDialog needs to force to exit the handle event loop |
122 |
| - self.ExitLoop() |
123 |
| - |
124 |
| - def onURLEvent(self, mEvent): |
125 |
| - print("onURLEvent") |
126 |
| - url = mEvent.id() |
127 |
| - if url: |
128 |
| - self.text.setValue(self.info.show(url)) |
129 |
| - |
130 | 63 | if __name__ == '__main__':
|
131 | 64 |
|
132 | 65 | info = HelpInfo()
|
133 |
| - td = HelpDialog(info) |
| 66 | + td = helpdialog.HelpDialog(info) |
134 | 67 | td.run()
|
135 | 68 |
|
136 | 69 |
|
0 commit comments