source: drbl_ui/menus/Main.py @ 110

Last change on this file since 110 was 20, checked in by chris, 17 years ago
File size: 4.9 KB
Line 
1import  wx, sys, os, gettext, string, time
2import  wx.wizard as wiz
3import  wx.lib.layoutf as layoutf
4
5from config import main_functions,remote_functions
6from remoteLinuxWizard import remoteLinuxPage, setAllClientsPage,selectClientsPage,remoteLinuxFinalPage
7
8cat = gettext.GNUTranslations(open('../langs/%s.mo' % os.getenv('LANG')))
9_ = cat.gettext
10
11
12#----------------------------------------------------------------------
13class MainFrame(wx.Frame):
14    def __init__(self):
15        wx.Frame.__init__(self, parent=None, title=_('msg_nchc_title'), pos=wx.DefaultPosition, size=(400,400))
16
17        mainlist = []
18        for i in range(0, len(main_functions)):
19            mainlist.append(main_functions[i][0] + '  ' + ' --- ' + '  ' + main_functions[i][1])
20
21        self.SetAutoLayout(True)
22
23        self.panelA = wx.Panel(self)
24        #self.panelA.SetBackgroundColour(wx.RED)
25        self.panelA.SetConstraints(layoutf.Layoutf('t=t#1;l=l10#1;b%b35#1;r=r10#1',(self,)))
26
27        self.panelB = wx.Panel(self)
28        #self.panelB.SetBackgroundColour(wx.BLUE)
29        self.panelB.SetConstraints(layoutf.Layoutf('t_5#2;l=l10#1;b%b85#1;r=r10#1',(self,self.panelA)))
30
31        self.panelC = wx.Panel(self)
32        #self.panelC.SetBackgroundColour(wx.GREEN)
33        self.panelC.SetConstraints(layoutf.Layoutf('t_10#2;l=l10#1;b=b10#1;r=r10#1',(self,self.panelB)))
34
35        gif = wx.Image('../images/drbl-logo.gif', wx.BITMAP_TYPE_GIF).ConvertToBitmap()
36        image = wx.StaticBitmap(self.panelA, -1, gif, wx.DefaultPosition, (gif.GetWidth(), gif.GetHeight()))
37        #text = wx.StaticText(self.panelA, -1, _('msg_warnning_content'), wx.DefaultPosition, (375,65), style=wx.TE_MULTILINE)
38        #font = wx.Font(10, wx.SWISS, wx.BOLD, wx.NORMAL)
39        #text.SetFont(font)
40        #image.SetConstraints(layoutf.Layoutf('X%X50#1;Y=Y#1;h*;w%w50#1', (self.panelA,)))
41        image.SetConstraints(layoutf.Layoutf('X=X#1;Y=Y#1;h*;w*', (self.panelA,)))
42
43        rb = wx.RadioBox(self.panelB, -1, _('msg_choose_action'), wx.DefaultPosition, wx.DefaultSize, mainlist, 1, wx.RA_SPECIFY_COLS)
44        rb.SetConstraints(layoutf.Layoutf('X=X#1;Y=Y#1;h*;w*', (self.panelB,)))
45        self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, rb)
46        rb.SetSelection(0)
47
48        self.b_ok = wx.Button(self.panelC, wx.ID_OK)
49        self.b_ok.SetSize(self.b_ok.GetBestSize())
50        self.b_ok.SetConstraints(layoutf.Layoutf('X%X150#1;Y=Y#1;h*;w*', (self.panelC,)))
51        self.b_exit = wx.Button(self.panelC, wx.ID_EXIT)
52        self.b_exit.SetSize(self.b_exit.GetBestSize())
53        self.b_exit.SetConstraints(layoutf.Layoutf('X%X50#1;Y=Y#1;h*;w*', (self.panelC,)))
54
55        #self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnWizPageChanged)
56        self.Bind(wx.EVT_BUTTON, self.remoteLinuxWizard, self.b_ok)
57        self.Bind(wx.EVT_BUTTON, self.OnCloseWindow, self.b_exit)
58        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
59
60        #warnning = wx.MessageDialog(self, _('msg_warnning_content'), _('msg_warnning'), wx.OK|wx.ICON_INFORMATION)
61        #warnning.Centre()
62        #warnning.SetFocus()
63        #warnning.ShowModal()
64        #warnning.Destroy()
65
66    def EvtRadioBox(self, event):
67        if event.GetSelection() == 0:
68            self.Bind(wx.EVT_BUTTON, self.remoteLinuxWizard, self.b_ok)
69        #if event.GetSelection() == 1:
70            #self.Bind(wx.EVT_BUTTON, self.clonezillaSaveWizard, self.b_ok)
71        #if event.GetSelection() == 2:
72            #self.Bind(wx.EVT_BUTTON, self.clonezillaRestoreWizard, self.b_ok)
73        #if event.GetSelection() == 3:
74            #self.Bind(wx.EVT_BUTTON, self.TDWDemoWizard, self.b_ok)
75        #if event.GetSelection() == 4:
76            #self.Bind(wx.EVT_BUTTON, self.StreamDemoWizard, self.b_ok)
77        #if event.GetSelection() == 5:
78            #self.Bind(wx.EVT_BUTTON, self.RunWizard, self.b_ok)
79        #if event.GetSelection() == 6:
80            #self.Bind(wx.EVT_BUTTON, self.HelpWizard, self.b_ok)
81
82#----------------------------------------------------------------------
83    def OnCloseWindow(self, event):
84        self.Destroy()
85
86
87#------------------------------Wizard Modules--------------------------
88    def remoteLinuxWizard(self,evt):
89        wizard = wiz.Wizard(self, -1, _('msg_remote_linux'))
90
91        page1 = remoteLinuxPage(wizard, _('msg_choose'))
92        page2 = setAllClientsPage(wizard, _('msg_title_set_all_clients'))
93        page3 = selectClientsPage(wizard, _('msg_select_clients'))
94        page4 = remoteLinuxFinalPage(wizard, _('msg_done'))
95
96        self.page1 = page1
97        wizard.SetPageSize((500, 320))
98        #wizard.FitToPage(page1)
99
100        page1.SetNext(page2)
101        page2.SetPrev(page1)
102        page2.SetNext(page3)
103        page3.SetPrev(page2)
104        page3.SetNext(page4)
105
106        #wizard.GetPageAreaSizer().Add(page1)
107        wizard.RunWizard(page1)
108
109#------------------------------------------------------------------------
110if __name__ == '__main__':
111    app = wx.PySimpleApp()
112    frame = MainFrame()
113    frame.Centre()
114    frame.Show()
115    app.MainLoop()
116
Note: See TracBrowser for help on using the repository browser.