~ubuntu-branches/ubuntu/oneiric/phatch/oneiric

« back to all changes in this revision

Viewing changes to phatch/pyWx/lib/about.py

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2008-02-13 23:48:47 UTC
  • Revision ID: james.westby@ubuntu.com-20080213234847-mp6vc4y88a9rz5qz
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: UTF-8 -*-
 
2
 
 
3
# Copyright (C) 2007-2008 www.stani.be
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation, either version 3 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program.  If not, see http://www.gnu.org/licenses/
 
17
 
 
18
# generated by wxGlade 0.4.1cvs on Thu Jun  7 21:24:31 2007 from /home/stani/sync/python/convert/trunk/about.wxg
 
19
 
 
20
import wx
 
21
import wx.lib.hyperlink as hl
 
22
 
 
23
class wxgAboutDialog(wx.Dialog):
 
24
    def __init__(self, *args, **kwds):
 
25
        # begin wxGlade: wxgAboutDialog.__init__
 
26
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
 
27
        wx.Dialog.__init__(self, *args, **kwds)
 
28
        self.logo = wx.StaticBitmap(self, -1, wx.NullBitmap)
 
29
        self.title = wx.StaticText(self, -1, _("Phatch Version"), style=wx.ALIGN_CENTRE)
 
30
        self.description = wx.StaticText(self, -1, _("Photo Batch Processor"))
 
31
        self.website = hl.HyperLinkCtrl(self, -1, label = 'http://www.stani.be', URL = 'http://www.stani.be')
 
32
        self.credits = wx.Button(self, -1, _("C&redits"))
 
33
        self.license = wx.Button(self, -1, _("&License"))
 
34
        self.close = wx.Button(self, wx.ID_CLOSE, _("&Close"))
 
35
 
 
36
        self.__set_properties()
 
37
        self.__do_layout()
 
38
 
 
39
        self.Bind(wx.EVT_BUTTON, self.OnCredits, self.credits)
 
40
        self.Bind(wx.EVT_BUTTON, self.OnLicense, self.license)
 
41
        self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
 
42
        # end wxGlade
 
43
 
 
44
    def __set_properties(self):
 
45
        # begin wxGlade: wxgAboutDialog.__set_properties
 
46
        self.SetTitle(_("About"))
 
47
        self.license.SetDefault()
 
48
        # end wxGlade
 
49
 
 
50
    def __do_layout(self):
 
51
        # begin wxGlade: wxgAboutDialog.__do_layout
 
52
        sizer_7 = wx.BoxSizer(wx.VERTICAL)
 
53
        sizer_9 = wx.BoxSizer(wx.HORIZONTAL)
 
54
        sizer_7.Add(self.logo, 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
 
55
        sizer_7.Add(self.title, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 4)
 
56
        sizer_7.Add(self.description, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 4)
 
57
        sizer_7.Add(self.website, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 4)
 
58
        sizer_9.Add(self.credits, 0, wx.ALL|wx.EXPAND, 4)
 
59
        sizer_9.Add(self.license, 0, wx.ALL|wx.EXPAND, 3)
 
60
        sizer_9.Add(self.close, 0, wx.ALL|wx.EXPAND, 4)
 
61
        sizer_7.Add(sizer_9, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 10)
 
62
        self.SetSizer(sizer_7)
 
63
        sizer_7.Fit(self)
 
64
        self.Layout()
 
65
        # end wxGlade
 
66
 
 
67
    def OnCredits(self, event): # wxGlade: wxgAboutDialog.<event_handler>
 
68
        print "Event handler `OnCredits' not implemented!"
 
69
        event.Skip()
 
70
 
 
71
    def OnLicense(self, event): # wxGlade: wxgAboutDialog.<event_handler>
 
72
        print "Event handler `OnLicense' not implemented!"
 
73
        event.Skip()
 
74
 
 
75
    def OnClose(self, event): # wxGlade: wxgAboutDialog.<event_handler>
 
76
        print "Event handler `OnClose' not implemented!"
 
77
        event.Skip()
 
78
 
 
79
# end of class wxgAboutDialog
 
80
 
 
81
 
 
82
class wxgCreditsDialog(wx.Dialog):
 
83
    def __init__(self, *args, **kwds):
 
84
        # begin wxGlade: wxgCreditsDialog.__init__
 
85
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
 
86
        wx.Dialog.__init__(self, *args, **kwds)
 
87
        self.notebook = wx.Notebook(self, -1, style=0)
 
88
        self.notebook_pane_6 = wx.Panel(self.notebook, -1)
 
89
        self.notebook_1_pane_5 = wx.Panel(self.notebook, -1)
 
90
        self.notebook_1_pane_4 = wx.Panel(self.notebook, -1)
 
91
        self.notebook_1_pane_3 = wx.Panel(self.notebook, -1)
 
92
        self.notebook_1_pane_2 = wx.Panel(self.notebook, -1)
 
93
        self.notebook_1_pane_1 = wx.Panel(self.notebook, -1)
 
94
        self.credits_code = wx.TextCtrl(self.notebook_1_pane_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
95
        self.credits_documentation = wx.TextCtrl(self.notebook_1_pane_2, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
96
        self.credits_translation = wx.TextCtrl(self.notebook_1_pane_3, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
97
        self.credits_graphics = wx.TextCtrl(self.notebook_1_pane_4, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
98
        self.credits_libraries = wx.TextCtrl(self.notebook_1_pane_5, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
99
        self.credits_sponsors = wx.TextCtrl(self.notebook_pane_6, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
 
100
        self.close = wx.Button(self, wx.ID_CLOSE, _("&Close"))
 
101
 
 
102
        self.__set_properties()
 
103
        self.__do_layout()
 
104
 
 
105
        self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
 
106
        # end wxGlade
 
107
 
 
108
    def __set_properties(self):
 
109
        # begin wxGlade: wxgCreditsDialog.__set_properties
 
110
        self.SetTitle(_("Credits"))
 
111
        # end wxGlade
 
112
 
 
113
    def __do_layout(self):
 
114
        # begin wxGlade: wxgCreditsDialog.__do_layout
 
115
        sizer_100 = wx.BoxSizer(wx.VERTICAL)
 
116
        sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
 
117
        sizer_11_copy_3 = wx.BoxSizer(wx.HORIZONTAL)
 
118
        sizer_11_copy_2 = wx.BoxSizer(wx.HORIZONTAL)
 
119
        sizer_11_copy_1 = wx.BoxSizer(wx.HORIZONTAL)
 
120
        sizer_11_copy = wx.BoxSizer(wx.HORIZONTAL)
 
121
        sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
 
122
        sizer_11.Add(self.credits_code, 1, wx.EXPAND, 0)
 
123
        self.notebook_1_pane_1.SetSizer(sizer_11)
 
124
        sizer_11_copy.Add(self.credits_documentation, 1, wx.EXPAND, 0)
 
125
        self.notebook_1_pane_2.SetSizer(sizer_11_copy)
 
126
        sizer_11_copy_1.Add(self.credits_translation, 1, wx.EXPAND, 0)
 
127
        self.notebook_1_pane_3.SetSizer(sizer_11_copy_1)
 
128
        sizer_11_copy_2.Add(self.credits_graphics, 1, wx.EXPAND, 0)
 
129
        self.notebook_1_pane_4.SetSizer(sizer_11_copy_2)
 
130
        sizer_11_copy_3.Add(self.credits_libraries, 1, wx.EXPAND, 0)
 
131
        self.notebook_1_pane_5.SetSizer(sizer_11_copy_3)
 
132
        sizer_1.Add(self.credits_sponsors, 1, wx.EXPAND, 0)
 
133
        self.notebook_pane_6.SetSizer(sizer_1)
 
134
        self.notebook.AddPage(self.notebook_1_pane_1, _("Code"))
 
135
        self.notebook.AddPage(self.notebook_1_pane_2, _("Documentation"))
 
136
        self.notebook.AddPage(self.notebook_1_pane_3, _("Translation"))
 
137
        self.notebook.AddPage(self.notebook_1_pane_4, _("Artwork"))
 
138
        self.notebook.AddPage(self.notebook_1_pane_5, _("Libraries"))
 
139
        self.notebook.AddPage(self.notebook_pane_6, _("Sponsors"))
 
140
        sizer_100.Add(self.notebook, 1, wx.EXPAND, 0)
 
141
        sizer_100.Add(self.close, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
 
142
        self.SetSizer(sizer_100)
 
143
        sizer_100.Fit(self)
 
144
        self.Layout()
 
145
        # end wxGlade
 
146
 
 
147
    def OnClose(self, event): # wxGlade: wxgCreditsDialog.<event_handler>
 
148
        print "Event handler `OnClose' not implemented!"
 
149
        event.Skip()
 
150
 
 
151
# end of class wxgCreditsDialog
 
152
 
 
153
class CreditsDialog(wxgCreditsDialog):
 
154
    def __init__(self,parent,credits):
 
155
        super(CreditsDialog,self).__init__(parent,-1)
 
156
        for attr, all in credits.items():
 
157
            ctrl    = getattr(self,'credits_%s'%attr)
 
158
            ctrl.SetValue('\n'.join([' - '.join(x.values()) for x in all]))
 
159
        w, h    = parent.GetSize()
 
160
        self.SetSize((int(2*w),int(h/1.5)))
 
161
        
 
162
    def OnClose(self,event):
 
163
        self.EndModal(wx.ID_CLOSE)
 
164
            
 
165
class Dialog(wxgAboutDialog):
 
166
    def __init__(self,parent,title,logo,description,website, credits, license):
 
167
        super(Dialog,self).__init__(parent,-1)
 
168
        #title
 
169
        self.title.SetLabel(title)
 
170
        title_font  = self.title.GetFont()
 
171
        title_font.SetPointSize(title_font.GetPointSize()*3)
 
172
        self.title.SetFont(title_font)
 
173
        #logo
 
174
        self.logo.SetBitmap(logo)
 
175
        #description
 
176
        self.description.SetLabel(description.replace('&','&&'))
 
177
        #website
 
178
        self.website.SetLabel(website)
 
179
        self.website.SetURL(website)
 
180
        #save other parameters
 
181
        self.credits    = credits
 
182
        self.license    = license
 
183
        #layout
 
184
        self.GetSizer().Fit(self)
 
185
        self.Layout()
 
186
        
 
187
    def OnCredits(self,event):
 
188
        dlg = CreditsDialog(self,self.credits)
 
189
        dlg.ShowModal()
 
190
        dlg.Destroy()
 
191
        
 
192
    def OnLicense(self,event):
 
193
        import wx.lib.dialogs
 
194
        dlg = wx.lib.dialogs.ScrolledMessageDialog(self, self.license, 
 
195
                _('License'))
 
196
        dlg.ShowModal()
 
197
 
 
198
    
 
199
    def OnClose(self,event):
 
200
        self.Destroy()
 
201
 
 
202
def test():
 
203
    import gettext, random
 
204
    gettext.install("test") # replace with the appropriate catalog name
 
205
    
 
206
    def create_credits(*args):
 
207
        result  = {}
 
208
        for arg in args:
 
209
            result[arg] = [{
 
210
                            'name':'%s %d'%(arg,x),
 
211
                            'email':'info@%s%d.com'%(arg,x)} 
 
212
                            for x in range(random.randint(1,9))]
 
213
        return result
 
214
    
 
215
    app         = wx.PySimpleApp(0)
 
216
    logo        = wx.ArtProvider_GetBitmap(wx.ART_GO_HOME,wx.ART_OTHER,(128,128))
 
217
    credits     = create_credits('code','documentation','translation',
 
218
                    'libraries','graphics')
 
219
    aboutDialog = Dialog(None, 'title', logo, 'description', 'website', 
 
220
                    credits, 'license (latest GPL)')
 
221
    app.SetTopWindow(aboutDialog)
 
222
    aboutDialog.Show()
 
223
    app.MainLoop()
 
224
    
 
225
if __name__ == "__main__":
 
226
    test()