1- # ===========================================================================
2- # This software is subject to the provisions of the Zope Public License,
3- # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4- # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5- # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6- # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7- # FOR A PARTICULAR PURPOSE.
8- # ===========================================================================
9-
101import clr
112import System .Windows .Forms as WinForms
123from System .Threading import Thread , ThreadStart , ApartmentState
@@ -60,18 +51,16 @@ def InitializeComponent(self):
6051 self .aboutMenu = WinForms .MenuItem ()
6152 self .menuHelpAbout = WinForms .MenuItem ()
6253
63-
6454 self .richTextBox = WinForms .RichTextBox ()
6555 self .statusBarPanel1 = WinForms .StatusBarPanel ()
6656 self .statusBar = WinForms .StatusBar ()
6757 self .fontDialog = WinForms .FontDialog ()
6858 self .statusBarPanel1 .BeginInit ()
6959
70-
7160 # ===================================================================
7261 # File Menu
7362 # ===================================================================
74-
63+
7564 self .menuFileNew .Text = "&New"
7665 self .menuFileNew .Shortcut = WinForms .Shortcut .CtrlN
7766 self .menuFileNew .ShowShortcut = False
@@ -83,7 +72,7 @@ def InitializeComponent(self):
8372 self .menuFileOpen .ShowShortcut = False
8473 self .menuFileOpen .Index = 1
8574 self .menuFileOpen .Click += self .OnClickFileOpen
86-
75+
8776 self .menuFileSave .Text = "&Save"
8877 self .menuFileSave .Shortcut = WinForms .Shortcut .CtrlS
8978 self .menuFileSave .ShowShortcut = False
@@ -112,7 +101,6 @@ def InitializeComponent(self):
112101
113102 self .fileMenu .MenuItems .AddRange (items )
114103
115-
116104 # ===================================================================
117105 # Edit menu
118106 # ===================================================================
@@ -134,7 +122,7 @@ def InitializeComponent(self):
134122 self .menuEditCut .Shortcut = WinForms .Shortcut .CtrlX
135123 self .menuEditCut .Index = 3
136124 self .menuEditCut .Click += self .OnClickEditCut
137-
125+
138126 self .menuEditCopy .Text = "Copy"
139127 self .menuEditCopy .Shortcut = WinForms .Shortcut .CtrlC
140128 self .menuEditCopy .Index = 4
@@ -163,7 +151,6 @@ def InitializeComponent(self):
163151
164152 self .editMenu .MenuItems .AddRange (items )
165153
166-
167154 # ===================================================================
168155 # Format Menu
169156 # ===================================================================
@@ -184,11 +171,10 @@ def InitializeComponent(self):
184171
185172 self .formatMenu .MenuItems .AddRange (items )
186173
187-
188174 # ===================================================================
189175 # About menu
190176 # ===================================================================
191-
177+
192178 self .menuHelpAbout .Text = "&About"
193179 self .menuHelpAbout .Index = 0
194180 self .menuHelpAbout .Click += self .OnClickHelpAbout
@@ -210,19 +196,16 @@ def InitializeComponent(self):
210196 self .richTextBox .AcceptsTab = 1
211197 self .richTextBox .Location = System .Drawing .Point (0 , 0 )
212198
213-
214199 self .statusBar .BackColor = System .Drawing .SystemColors .Control
215200 self .statusBar .Location = System .Drawing .Point (0 , 518 )
216201 self .statusBar .Size = System .Drawing .Size (775 , 19 )
217202 self .statusBar .TabIndex = 1
218203 self .statusBar .ShowPanels = True
219204 self .statusBar .Panels .Add (self .statusBarPanel1 )
220205
221-
222206 items = (self .fileMenu , self .editMenu , self .formatMenu , self .aboutMenu )
223207 self .mainMenu .MenuItems .AddRange (items )
224208
225-
226209 self .openFileDialog .Filter = "Text documents|*.txt|RTF document|*.rtf"
227210 self .openFileDialog .Title = "Open document"
228211
@@ -231,7 +214,6 @@ def InitializeComponent(self):
231214 self .saveFileDialog .Title = "Save document"
232215 self .saveFileDialog .FileName = "Untitled"
233216
234-
235217 self .AutoScaleBaseSize = System .Drawing .Size (5 , 13 )
236218 self .ClientSize = System .Drawing .Size (775 , 537 )
237219 self .Menu = self .mainMenu
@@ -244,7 +226,6 @@ def InitializeComponent(self):
244226 def Dispose (self ):
245227 self .components .Dispose ()
246228 WinForms .Form .Dispose (self )
247-
248229
249230 def OnClickFileNew (self , sender , args ):
250231 self .SaveChangesDialog ()
@@ -265,7 +246,6 @@ def OnClickFileExit(self, sender, args):
265246 self .SaveChangesDialog ()
266247 self .Close ()
267248
268-
269249 def OnClickEditUndo (self , sender , args ):
270250 self .richTextBox .Undo ()
271251
@@ -284,7 +264,6 @@ def OnClickEditPaste(self, sender, args):
284264 def OnClickEditSelectAll (self , sender , args ):
285265 self .richTextBox .SelectAll ()
286266
287-
288267 def OnClickFormatWordWrap (self , sender , args ):
289268 value = not self .word_wrap
290269 self .richTextBox .WordWrap = value
@@ -298,7 +277,6 @@ def OnClickFormatFont(self, sender, args):
298277 def OnClickHelpAbout (self , sender , args ):
299278 AboutForm ().ShowDialog (self )
300279
301-
302280 def NewDocument (self ):
303281 self .doctype = 1
304282 self .richTextBox .Rtf = ''
@@ -327,7 +305,7 @@ def OpenDocument(self):
327305 stream .Close ()
328306
329307 filename = self .filename = filename .lower ()
330-
308+
331309 if filename .endswith ('.rtf' ):
332310 self .richTextBox .Rtf = data
333311 self .doctype = 2
@@ -345,10 +323,10 @@ def SaveDocument(self):
345323 if self .saveFileDialog .ShowDialog () != WinForms .DialogResult .OK :
346324 return
347325 filename = self .saveFileDialog .FileName
348-
326+
349327 filename = self .filename = filename .lower ()
350328 self .Text = 'Python Wordpad - %s' % filename
351-
329+
352330 self .richTextBox .Select (0 , 0 )
353331
354332 stream = File .OpenWrite (filename )
@@ -366,17 +344,16 @@ def SaveDocument(self):
366344 def SaveChangesDialog (self ):
367345 if self .richTextBox .Modified :
368346 if WinForms .MessageBox .Show (
369- "Save changes?" , "Word Pad" ,
370- WinForms .MessageBoxButtons .OK |
371- WinForms .MessageBoxButtons .YesNo
372- ) == WinForms .DialogResult .Yes :
347+ "Save changes?" , "Word Pad" ,
348+ WinForms .MessageBoxButtons .OK |
349+ WinForms .MessageBoxButtons .YesNo
350+ ) == WinForms .DialogResult .Yes :
373351 self .SaveDocument ()
374352 return 1
375353 return 0
376354
377355
378356class AboutForm (WinForms .Form ):
379-
380357 def __init__ (self ):
381358 self .InitializeComponent ()
382359
@@ -406,7 +383,7 @@ def InitializeComponent(self):
406383 self .ClientSize = System .Drawing .Size (300 , 150 )
407384
408385 self .Controls .AddRange ((self .label1 , self .btnClose ))
409-
386+
410387 self .FormBorderStyle = WinForms .FormBorderStyle .FixedDialog
411388 self .MaximizeBox = 0
412389 self .MinimizeBox = 0
@@ -435,4 +412,3 @@ def main():
435412
436413if __name__ == '__main__' :
437414 main ()
438-
0 commit comments