Skip to content

Commit 41f2329

Browse files
author
falldog
committed
[What] Add Preference setting function
[Why] New feature to change the style of SudokuBoxer [How] 1. Generate the XRC file by wxFormBuilder (*.fbp & *.xrc) save it in resource\xrc\ 2. Add XRCBase for XrcFrame, XrcPanel, XrcDialog to inherit it, implement the basic function OnCreate(), PostInit( interface ) and __getattr__( auto generate the XRCCTRL ) 3. Implement PreferenceDialog to inherit XrcDialog, and add PreferenceDialog.xrc( the attribute @subclass="ui.PreferenceDialog" ) 4. Modify SudokuBoxer.py for add the option 'Preference' 5. Modify build_util.py, Add _GenerateXRCTranslateString() for generate the translate string saved in XRC file via pywxrc.py Temporary save the string into 'xrc_string.py', and write it into py_list.txt for xgettext can parse it. [TODO] 1. Add style.xml to record the style 2. Apply the style into NumberBoard
1 parent c2432a8 commit 41f2329

File tree

10 files changed

+1901
-95
lines changed

10 files changed

+1901
-95
lines changed

App.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
VERSION_DATE = vd
1616
#-----------------------------------------------------------------------#
1717

18+
XRC_PATH = r'.\resource\xrc'
19+
1820
nCellSize = eval(util.config.get('APP', 'CellSize', '50'))
1921
nAnswerCellSize = nCellSize*0.6
2022
nLINE = 9
2123
nGRID = 3
2224
rgLINE = range(nLINE)
2325
rgGRID = range(nGRID)
2426

27+
clBgFocus = '#C1DEA3'
28+
clBgOver = '#8FD6FF'
29+
clBgNormal = '#EEEEEE'
30+
clBgDefault = '#E3EDFF'
31+
clTextNormal = '#000000'
32+
clTextDefault = '#000000'
33+
2534
locale = wx.Locale()
2635
puzzleLoader = PuzzleLoaderDB()
2736

Build/MUI.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ python build_util.py generate_py_list %PY_LIST_FILE%
1111
%GETTEXT_DIR%\msgfmt --output-file "..\lang\CHT.mo" "..\lang\CHT.po"
1212

1313
del %PY_LIST_FILE%
14+
del xrc_string.py

Build/build.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ python .\build_util.py generate_version %VERSION%
1717
md %DIST_DIR%\img
1818
md %DIST_DIR%\lang
1919
md %DIST_DIR%\puzzle
20+
md %DIST_DIR%\resource
2021
xcopy ..\img %DIST_DIR%\img /e /y
2122
xcopy ..\lang %DIST_DIR%\lang /e /y
23+
xcopy ..\resource %DIST_DIR%\resource /e /y
2224
copy %PUZZLE_DIR%\PuzzleDB-1000 %DIST_DIR%\puzzle\PuzzleDB
2325

2426
del %DIST_DIR%\lang\*.po

Build/build_util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ def GeneratePyList(output_file):
88
for fname in files:
99
if os.path.splitext(fname)[1] != '.py' : continue
1010
f.write(PY_DIR+fname+'\n')
11+
12+
_GenerateXRCTranslateString('.\\xrc_string.py')
13+
f.write('xrc_string.py')
1114
f.close()
15+
16+
def _GenerateXRCTranslateString(filename=''):
17+
XRC_Folder = r'..\resource\xrc'
18+
xrcList = os.listdir(XRC_Folder)
19+
strFiles = ''
20+
for xrc in xrcList:
21+
strFiles += ' ' + os.path.join(XRC_Folder, xrc)
22+
os.system('python pywxrc.py -o %s -g %s' % (filename, strFiles))
1223

1324
def GenerateVersion(version_path):
1425
import datetime

SudokuBoxer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ def setPuzzle(self, default, answer):
747747
ID_MENU_OPT_RECORD_LAST_PUZZLE = wx.NewId()
748748
ID_MENU_OPT_SHOW_AUTOTIP = wx.NewId()
749749
ID_MENU_OPT_SHOW_USERTIP = wx.NewId()
750+
ID_MENU_OPT_PREFERENCE = wx.NewId()
750751

751752
MODE_STR_MAP = { ID_MENU_MODE_EASY: 'easy',
752753
ID_MENU_MODE_MEDIUM: 'medium',
@@ -835,6 +836,8 @@ def initMenubar(self):
835836
self.menuOpt.Append(ID_MENU_OPT_SHOW_USERTIP, _('Show UserTip'), kind=wx.ITEM_RADIO)
836837
self.menuOpt.AppendSeparator()
837838
self.menuOpt.Append(ID_MENU_OPT_RECORD_LAST_PUZZLE, _('Record Last Puzzle'), kind=wx.ITEM_CHECK)
839+
self.menuOpt.Append(ID_MENU_OPT_PREFERENCE, _('Preference'))
840+
838841
#About
839842
_help = wx.Menu()
840843
_help.Append(ID_MENU_HELP_ABOUT, _('About'))
@@ -861,6 +864,7 @@ def initMenubar(self):
861864
self.Bind(wx.EVT_MENU, self.about, id=ID_MENU_HELP_ABOUT)
862865
self.Bind(wx.EVT_MENU, self.linkProject, id=ID_MENU_HELP_LINKPROJECT)
863866
self.Bind(wx.EVT_MENU, self.onRecordLastPuzzle, id=ID_MENU_OPT_RECORD_LAST_PUZZLE)
867+
self.Bind(wx.EVT_MENU, self.onPreference, id=ID_MENU_OPT_PREFERENCE)
864868

865869
_clickTip = lambda evt: self.changeTipMode(evt.GetId())
866870
self.Bind(wx.EVT_MENU, _clickTip, id=ID_MENU_OPT_SHOW_AUTOTIP)
@@ -970,6 +974,15 @@ def onRecordLastPuzzle(self, evt):
970974
App.bRecordLastPuzzle = not App.bRecordLastPuzzle
971975
self.menuOpt.Check(ID_MENU_OPT_RECORD_LAST_PUZZLE, App.bRecordLastPuzzle)
972976

977+
def onPreference(self, evt):
978+
from wx import xrc
979+
res = xrc.XmlResource( os.path.join(App.XRC_PATH, "PreferenceDialog.xrc") )
980+
dlg = res.LoadDialog(None, 'PreferenceDialog')
981+
if dlg:
982+
dlg.ShowModal()
983+
dlg.Destroy()
984+
pass
985+
973986
def changeTipMode(self, _id):
974987
if _id == ID_MENU_OPT_SHOW_USERTIP:
975988
autoTip = False

lang/CHT.po

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,63 @@
33
# This file is distributed under the same license as the PACKAGE package.
44
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55
#
6-
#, fuzzy
76
msgid ""
87
msgstr ""
98
"Project-Id-Version: PACKAGE VERSION\n"
109
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2010-05-18 00:14+0800\n"
12-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
10+
"POT-Creation-Date: 2010-06-03 00:37+0800\n"
11+
"PO-Revision-Date: 2010-06-03 00:36+0800\n"
12+
"Last-Translator: Falldog <falldog7@gmail.com>\n"
1413
"Language-Team: LANGUAGE <LL@li.org>\n"
1514
"MIME-Version: 1.0\n"
1615
"Content-Type: text/plain; charset=utf-8\n"
1716
"Content-Transfer-Encoding: 8bit\n"
1817

19-
#: ..\SudokuBoxer.py:841
18+
#: ..\SudokuBoxer.py:843
2019
msgid "About"
2120
msgstr "關於"
2221

23-
#: ..\SudokuBoxer.py:1047
22+
#: ..\SudokuBoxer.py:1059
2423
msgid "Answer"
2524
msgstr "答案"
2625

27-
#: ..\SudokuBoxer.py:925
26+
#: ..\SudokuBoxer.py:928
2827
msgid "Best Time:"
2928
msgstr "最佳時間 :"
3029

31-
#: ..\SudokuBoxer.py:831
30+
#: ..\SudokuBoxer.py:832
3231
msgid "CHT"
3332
msgstr "中文"
3433

35-
#: ..\SudokuBoxer.py:842
34+
#: ..\SudokuBoxer.py:844
3635
msgid "Check New Version"
3736
msgstr "檢查新版本"
3837

39-
#: ..\SudokuBoxer.py:894
38+
#: ..\SudokuBoxer.py:897
4039
msgid "Check Valid"
4140
msgstr "檢查正確"
4241

43-
#: ..\SudokuBoxer.py:1071
42+
#: ..\SudokuBoxer.py:1083
4443
msgid "Check Valid : Correctly!"
4544
msgstr "檢查是否正確 : 正確無誤!"
4645

47-
#: ..\SudokuBoxer.py:1073
46+
#: ..\SudokuBoxer.py:1085
4847
msgid "Check Valid : Wrong!"
4948
msgstr "檢查是否正確 : 錯了啦~大哥~"
5049

51-
#: ..\root.py:20
50+
#: ..\root.py:19
5251
msgid "Choice Language"
5352
msgstr "選擇語言"
5453

55-
#: ..\SudokuBoxer.py:897
54+
#: ..\SudokuBoxer.py:900
5655
msgid "Choice User"
5756
msgstr "選擇使用者"
5857

59-
#: ..\SudokuBoxer.py:889
58+
#: ..\SudokuBoxer.py:892
6059
msgid "Clear All"
6160
msgstr "全部清除"
6261

63-
#: ..\SudokuBoxer.py:1084
62+
#: ..\SudokuBoxer.py:1096
6463
msgid "Congratulations! You had finish this Sudoku!"
6564
msgstr "恭喜恭喜! 你已經完成了這個Sudoku"
6665

@@ -72,144 +71,151 @@ msgstr "建立使用者"
7271
msgid "Create a new user"
7372
msgstr "建立一名新的使用者"
7473

75-
#: ..\SudokuBoxer.py:830
74+
#: ..\SudokuBoxer.py:831
7675
msgid "ENU"
7776
msgstr "英文"
7877

79-
#: ..\SudokuBoxer.py:824
78+
#: ..\SudokuBoxer.py:825
8079
msgid "Easy"
8180
msgstr "簡單"
8281

83-
#: ..\SudokuBoxer.py:827
82+
#: ..\SudokuBoxer.py:828
8483
msgid "Evil"
8584
msgstr "真他馬的難"
8685

87-
#: ..\SudokuBoxer.py:892
86+
#: ..\SudokuBoxer.py:895
8887
msgid "Guess Next"
8988
msgstr "猜下一步"
9089

91-
#: ..\SudokuBoxer.py:826
90+
#: ..\SudokuBoxer.py:827
9291
msgid "Hard"
9392
msgstr "困難"
9493

95-
#: ..\SudokuBoxer.py:847
94+
#: ..\SudokuBoxer.py:849
9695
msgid "Help"
9796
msgstr "幫助"
9897

99-
#: ..\SudokuBoxer.py:1090
98+
#: ..\SudokuBoxer.py:1102
10099
msgid "Hey man! Your answer is wrong... try again!"
101100
msgstr "嘿~大哥~ 你的答案錯了啦~ 再試一下~"
102101

103-
#: ..\SudokuBoxer.py:958 ..\SudokuBoxer.py:1028 ..\SudokuBoxer.py:1074
104-
#: ..\SudokuBoxer.py:1095
102+
#: ..\SudokuBoxer.py:961 ..\SudokuBoxer.py:1040 ..\SudokuBoxer.py:1086
103+
#: ..\SudokuBoxer.py:1107
105104
msgid "Information"
106105
msgstr "訊息"
107106

108-
#: ..\SudokuBoxer.py:845
107+
#: ..\SudokuBoxer.py:847
109108
msgid "Language"
110109
msgstr "語言"
111110

112-
#: ..\SudokuBoxer.py:825
111+
#: ..\SudokuBoxer.py:826
113112
msgid "Medium"
114113
msgstr "中等"
115114

116-
#: ..\SudokuBoxer.py:844
115+
#: ..\SudokuBoxer.py:846
117116
msgid "Mode"
118117
msgstr "等級"
119118

120-
#: ..\SudokuBoxer.py:883
119+
#: ..\SudokuBoxer.py:886
121120
msgid "New Null Puzzle"
122121
msgstr "開啟空的Sudoku"
123122

124-
#: ..\SudokuBoxer.py:882
123+
#: ..\SudokuBoxer.py:885
125124
msgid "New Puzzle"
126125
msgstr "開啟新的Sudoku"
127126

128127
#: ..\user.py:119
129128
msgid "OK"
130129
msgstr "確定"
131130

132-
#: ..\SudokuBoxer.py:846
131+
#: ..\SudokuBoxer.py:848
133132
msgid "Options"
134133
msgstr "選項"
135134

136-
#: ..\SudokuBoxer.py:1016
135+
#: ..\SudokuBoxer.py:1028
137136
#, python-format
138137
msgid "Please input a ID number : (1~%d)"
139138
msgstr "請輸入ID號碼:(1~%d)"
140139

141-
#: ..\SudokuBoxer.py:1028
140+
#: ..\SudokuBoxer.py:1040
142141
msgid "Please input a correctly number!"
143142
msgstr "請輸入正確的數字"
144143

145144
#: ..\user.py:143
146145
msgid "Please input a user name"
147146
msgstr "請輸入一個使用者名稱"
148147

149-
#: ..\SudokuBoxer.py:958
148+
#: ..\SudokuBoxer.py:961
150149
msgid "Please relaunch SudokuBoxer to load correctly Language"
151150
msgstr "請重新開啟SudokuBoxer 新的語言才會生效!"
152151

153-
#: ..\SudokuBoxer.py:928
152+
#: ..\SudokuBoxer.py:839
153+
msgid "Preference"
154+
msgstr "外觀設定"
155+
156+
#: ..\SudokuBoxer.py:931
154157
msgid "Puzzle ID :"
155158
msgstr "Sudoku ID :"
156159

157160
#: ..\user.py:170
158161
msgid "PuzzleID"
159162
msgstr "Puzzle ID"
160163

161-
#: ..\SudokuBoxer.py:837
164+
#: ..\SudokuBoxer.py:838
162165
msgid "Record Last Puzzle"
163166
msgstr "結束時記錄最後Puzzle"
164167

165-
#: ..\SudokuBoxer.py:1134
168+
#: ..\SudokuBoxer.py:1146
166169
msgid "Record List"
167170
msgstr "記錄清單"
168171

169-
#: ..\SudokuBoxer.py:898
172+
#: ..\SudokuBoxer.py:901
170173
msgid "Record Time"
171174
msgstr "花費時間 :"
172175

173-
#: ..\SudokuBoxer.py:888
176+
#: ..\SudokuBoxer.py:891
174177
msgid "Redo"
175178
msgstr "下一步"
176179

177-
#: ..\SudokuBoxer.py:884
180+
#: ..\SudokuBoxer.py:887
178181
msgid "Select Puzzle By ID"
179182
msgstr "輸入ID選擇Sudoku"
180183

181-
#: ..\SudokuBoxer.py:1108
184+
#: ..\SudokuBoxer.py:1120
182185
msgid "Select User"
183186
msgstr "選擇使用者"
184187

185-
#: ..\SudokuBoxer.py:893
188+
#: ..\SudokuBoxer.py:896
186189
msgid "Show Answer"
187190
msgstr "秀出答案"
188191

189-
#: ..\SudokuBoxer.py:834
192+
#: ..\SudokuBoxer.py:835
190193
msgid "Show AutoTip"
191194
msgstr "每一格秀出提示"
192195

193-
#: ..\SudokuBoxer.py:835
196+
#: ..\SudokuBoxer.py:836
194197
msgid "Show UserTip"
195198
msgstr "自行填入可能提示"
196199

197-
#: ..\SudokuBoxer.py:931
200+
#: ..\SudokuBoxer.py:934
198201
msgid "Spend Time :"
199202
msgstr "花費時間 :"
200203

201204
#: ..\user.py:171
202205
msgid "Time"
203206
msgstr "時間"
204207

205-
#: ..\SudokuBoxer.py:887
208+
#: ..\SudokuBoxer.py:890
206209
msgid "Undo"
207210
msgstr "上一步"
208211

209-
#: ..\SudokuBoxer.py:922
212+
#: ..\SudokuBoxer.py:925
210213
msgid "User Name :"
211214
msgstr "使用者:"
212215

216+
#~ msgid "Cancel"
217+
#~ msgstr "取消"
218+
213219
#~ msgid "Guess Easy"
214220
#~ msgstr "猜1"
215221

@@ -222,3 +228,24 @@ msgstr "使用者:"
222228
#~ msgstr ""
223229
#~ "抱歉! 目前無法解決此Puzzle.\n"
224230
#~ "請等待新的加強版..."
231+
232+
#~ msgid "[BG] Default"
233+
#~ msgstr "[背景] 預設"
234+
235+
#~ msgid "[BG] Focus"
236+
#~ msgstr "[背景] 焦點"
237+
238+
#~ msgid "[BG] Mouse Over"
239+
#~ msgstr "[背景] 滑鼠所在"
240+
241+
#~ msgid "[BG] Normal"
242+
#~ msgstr "[背景] 正常"
243+
244+
#~ msgid "[Text] Default"
245+
#~ msgstr "[數字] 預設字"
246+
247+
#~ msgid "[Text] Invalid"
248+
#~ msgstr "[數字] 不正確"
249+
250+
#~ msgid "[Text] Normal"
251+
#~ msgstr "[數字] 正常"

0 commit comments

Comments
 (0)