~lorzeteam/lorze/trunk

« back to all changes in this revision

Viewing changes to Modules/lrzdlghelp.py

  • Committer: Andreas Ulrich
  • Date: 2012-12-13 20:54:19 UTC
  • Revision ID: ulrich3110@gmail.com-20121213205419-aucgdskqtqmyrj10
new file structure, new object structure, about dialogue, help dialogue, hep pages in english and german, german translation, ponton5h installer, documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# LORZE erasandcad, a 2D CAD with an intuitive user interface, simple and easy.
 
5
# http://erasand.jimdo.com/python-programme/lorze/
 
6
# (C) 2012, Andreas Ulrich
 
7
 
 
8
# This file is part of “LORZE erasandcad“
 
9
 
 
10
# “LORZE erasandcad“ is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 
11
 
 
12
# “LORZE erasandcad“ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License along with LORZE erasandcad.  If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
import wx, locale
 
17
import wx.html as html
 
18
 
 
19
# name for translations texts
 
20
_= wx.GetTranslation
 
21
 
 
22
 
 
23
class LorzeHelp(wx.Dialog):
 
24
    # Lorze help dialogue
 
25
 
 
26
    def __init__(self, parent, options):
 
27
        # parent class
 
28
        self.__parent= parent
 
29
 
 
30
        # LorzeOptions() of parent class
 
31
        self.__options= options
 
32
 
 
33
        # get settings for dialog from options
 
34
        dlgborder= self.__options.GetDlgBorder()
 
35
        wdlg, hdlg= self.DialogueSize()
 
36
 
 
37
        # subclass
 
38
        wx.Dialog.__init__(self, self.__parent, wx.ID_ANY, _(u'LORZE erasandcad HELP'), size= (wdlg, hdlg), style= wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
 
39
 
 
40
        # help window
 
41
        htmlhelp= html.HtmlWindow(self, wx.ID_ANY, style=wx.NO_BORDER)
 
42
 
 
43
        # select language
 
44
        wxlang= locale.getdefaultlocale()
 
45
        wxlang= wxlang[0][:2]
 
46
        if wxlang== 'de':
 
47
            htmlhelp.LoadFile('../Documentation/HTML/DE_hilfe.html')
 
48
        else:
 
49
            htmlhelp.LoadPage('../Documentation/HTML/EN_help.html')
 
50
 
 
51
        # buttons
 
52
        buttonok= wx.Button(self, label= _(u'OK'))
 
53
 
 
54
        # dialog bindings
 
55
        buttonok.Bind(wx.EVT_BUTTON, self.OnExit)
 
56
        self.Bind(wx.EVT_CLOSE, self.OnDialogueClose)
 
57
 
 
58
        # layout
 
59
        vbox= wx.BoxSizer(wx.VERTICAL)
 
60
        vbox.Add(htmlhelp, 2, wx.EXPAND|wx.ALL, dlgborder)
 
61
        vbox.Add(buttonok, 0, wx.ALIGN_RIGHT|wx.ALL, dlgborder)
 
62
 
 
63
        self.SetSizer(vbox)
 
64
        self.Centre()
 
65
 
 
66
 
 
67
    def DialogueSize(self):
 
68
        wdlg, hdlg= self.__options.GetDlgHelpSize()
 
69
 
 
70
        # get size from parent
 
71
        wparent, hparent= self.__parent.GetSize()
 
72
 
 
73
        # dialog size control
 
74
        if hdlg> hparent:
 
75
            # correct height to parent size
 
76
            hdlg= hparent
 
77
 
 
78
        if wdlg> wparent:
 
79
            # correct width to parent size
 
80
            wdlg= wparent
 
81
 
 
82
        return(wdlg, hdlg)
 
83
 
 
84
 
 
85
    def OnDialogueClose(self, event):
 
86
        # last commando before close the dialogue, read dialogue size
 
87
        wdlg, hdlg= self.GetSize()
 
88
 
 
89
        # set sizes to options
 
90
        self.__options.SetDlgHelpSize(wdlg, hdlg)
 
91
 
 
92
        event.Skip()
 
93
 
 
94
 
 
95
    def OnExit(self, event):
 
96
        self.Close()
 
97
 
 
98
 
 
99
class TestFrame(wx.Frame):
 
100
    # object for testing
 
101
    def __init__(self):
 
102
        wx.Frame.__init__(self, None, title= u'Test Dialog Load/ Save Object')
 
103
 
 
104
        self.__options= LorzeOptions()
 
105
 
 
106
        buttontest= wx.Button(self, label= u'Help')
 
107
        buttonexit= wx.Button(self, label= u'Exit')
 
108
        buttontest.Bind(wx.EVT_BUTTON, self.OnTest)
 
109
        buttonexit.Bind(wx.EVT_BUTTON, self.OnExit)
 
110
 
 
111
        vbox= wx.BoxSizer(wx.VERTICAL)
 
112
        vbox.Add(buttontest)
 
113
        vbox.Add(buttonexit)
 
114
 
 
115
        self.SetSizer(vbox)
 
116
        self.Center()
 
117
        self.Show()
 
118
 
 
119
 
 
120
    def OnTest(self, event):
 
121
        dlg= LorzeHelp(self, self.__options)
 
122
        dlg.ShowModal()
 
123
        dlg.Destroy()
 
124
 
 
125
 
 
126
    def OnExit(self, event):
 
127
        self.Close()
 
128
 
 
129
 
 
130
if __name__== '__main__':
 
131
    from lrzoptions import LorzeOptions
 
132
 
 
133
    app= wx.App()
 
134
 
 
135
    # internationalization
 
136
    wxloc= wx.Locale()
 
137
    wxloc.AddCatalogLookupPathPrefix('./in18')
 
138
    # get system language ('xx_XX', 'CHARSET')
 
139
    wxlang= locale.getdefaultlocale()
 
140
    wxlang= wxlang[0][:2]
 
141
    # select translations
 
142
    if wxlang== 'de':
 
143
        wxloc.AddCatalog('lorze_de')
 
144
 
 
145
    frame= TestFrame()
 
146
    app.MainLoop()