- Page 1 and 2: wxPython in Action —— 1 / 565
- Page 3 and 4: 2.5.2 wxPythonID 37 ID 38 NewID() 3
- Page 5 and 6: 4.5 Py 96 4.5.1 GUI 97 4.5.2 97 bu
- Page 7 and 8: 7.1.1 175 176 178 178 7.1.2 17
- Page 9 and 10: 234 8.3 235 8.3.1 MDI 235 8.7 236
- Page 11 and 12: 10.4 320 10.4.1 321 10.4.2 321
- Page 13 and 14: 12.3.3 390 12.3.4 392 12.4 392
- Page 15 and 16: 14.4 462 14.4.1 462 14.4.2 465 1
- Page 17 and 18: 538 wx.Printer 538 wx.PrinterPrin
- Page 19 and 20: Part1 wxPython 1. wxPython #!/bin
- Page 21 and 22: wxPython wxPython 1wxPython 2wxPyth
- Page 23 and 24: wx.App class MyApp(wx.App): def OnI
- Page 25 and 26: % spare.py #2 __doc__ Python >>>
- Page 27: if __name__ == ’__main__’: main
- Page 31 and 32: wx.PySimpleAppwxPython wx.PySimple
- Page 33 and 34: print ”OnExit” if __name__ ==
- Page 35 and 36: 2.4.1 wxPython wx.AppOnExit()wxPy
- Page 37 and 38: parentNone idwxPython ID-1 wxPyth
- Page 39 and 40: y = point.y wx.PointPython a = wx.
- Page 41 and 42: 2.4wx.DEFAULT_STYLE 2.5 wx.DEFAULT_
- Page 43 and 44: frame.Show() app.MainLoop() InsertF
- Page 45 and 46: menu2.Append(wx.NewId(), ”Paste
- Page 47 and 48: ShowModal() ShowModal() wx.MessageD
- Page 49 and 50: wx.AppwxPython wx.App wx.AppMai
- Page 51 and 52: 3 wxPython GUI wxPython wxPyth
- Page 53 and 54: 1 wxPythonwx.App.MainLoop() 2 wxP
- Page 55 and 56: wxPython wx.App.MainLoop()MainLoop(
- Page 57 and 58: wx.EVT_MIDDLE_DOWN wx.EVT_MIDDLE_UP
- Page 59 and 60: #!/usr/bin/env python import wx cla
- Page 61 and 62: 3.4 wxPython wxPython 3.2 3.3 wxP
- Page 63 and 64: 3.3 wxPython wxPython wxPython wx
- Page 65 and 66: ProcessEvent()True wx.EventSkip() w
- Page 67 and 68: 3.8 wxPython Skip()wxPython wx.A
- Page 69 and 70: 3.4 #!/usr/bin/env python import w
- Page 71 and 72: 3.6 wxPython 3.6.1 3.9(pane
- Page 73 and 74: def OnRightClick(self, event): self
- Page 75 and 76: wxPython wxPython 3.7 1wxPython
- Page 77 and 78: ... print n * 9 ... 0 9 18 27 36 >>
- Page 79 and 80:
wxPythonPython shellwxPython Python
- Page 81 and 82:
4.4 4.2.3 shellPyCrust Python 4.2
- Page 83 and 84:
Ctrl+ Alt+P Ctrl+ Alt+N Shift+ Shif
- Page 85 and 86:
KeyboardInterrupt >>> GUIPyCrust sh
- Page 87 and 88:
4.7 4.7PyCrust 4.3 PyCrust notebook
- Page 89 and 90:
PyCrust shellPyCrustlocale locale/e
- Page 91 and 92:
4.9 Dispatcherwx.Notebook Dispatche
- Page 93 and 94:
windows F:\>python pywrap.py spare.
- Page 95 and 96:
4.10 >>> app.frame.panel.Refresh
- Page 97 and 98:
wxPython shell Py Py GUIPyCrust,Py
- Page 99 and 100:
text = text.replace(‘\r’, ’\n
- Page 101 and 102:
command we keep appending the piece
- Page 103 and 104:
interpreterInterpreterPythoncode In
- Page 105 and 106:
4.11 4.7 105 / 565
- Page 107 and 108:
self.Bind(wx.EVT_MENU, self.OnShell
- Page 109 and 110:
5 GUI UI UIMVCModełView/Controlle
- Page 111 and 112:
self.Bind(wx.EVT_BUTTON, self.OnNex
- Page 113 and 114:
5.1.2 5.2 5.25.1 5.2 def createBu
- Page 115 and 116:
createButtonBar()buttonData() x
- Page 117 and 118:
eturn button def textFieldData(self
- Page 119 and 120:
ViewControllerwebView Controller 5.
- Page 121 and 122:
class SimpleGrid(wx.grid.Grid): def
- Page 123 and 124:
SetValue(row, col,value)(row,col) p
- Page 125 and 126:
5.7PyGridTableBase GetColLabelValue
- Page 127 and 128:
size=(275, 275)) grid = SimpleGrid(
- Page 129 and 130:
.Python gridwxPython wxPython 5.2.
- Page 131 and 132:
self.last = last self.update() #1
- Page 133 and 134:
#1 #2OnUpdate() listenerOnUpdate()
- Page 135 and 136:
5.3.2 unittest 5.13unittest5.12 5.
- Page 137 and 138:
OKOK Python #5 self.assertEqual(
- Page 139 and 140:
wx.WindowC(Controller)wx.EvtHandler
- Page 141 and 142:
6.1 GUI wxPython 6.1.1 device c
- Page 143 and 144:
self.Bind(wx.EVT_IDLE, self.OnIdle)
- Page 145 and 146:
class SketchFrame(wx.Frame): def __
- Page 147 and 148:
wx.DC wxPythonwx.BufferDC wx.Cl
- Page 149 and 150:
GetSizeTuple()wx.SizePython 6.2
- Page 151 and 152:
class SketchFrame(wx.Frame): def __
- Page 153 and 154:
wx.MenuCheck(id,bool)id wxPython ID
- Page 155 and 156:
def OnNew(self, event): pass def On
- Page 157 and 158:
6.6 wx.FileDialog parentNone messag
- Page 159 and 160:
def OnSave(self, event):#4 if not
- Page 161 and 162:
dlg.Destroy() SetChooseFull() wx.C
- Page 163 and 164:
6.8control panelsketch sizer 6.8 de
- Page 165 and 166:
6.9 ControlPanel class ControlPanel
- Page 167 and 168:
if color != self.sketch.color: self
- Page 169 and 170:
6.10 wx.html.HtmlWindowabout class
- Page 171 and 172:
wx.SplashScreen wx.SplashScreen w
- Page 173 and 174:
wx.BoxSizersizersizer 7aboutwx.htm
- Page 175 and 176:
7 wxPython wxPython API 7.1 7
- Page 177 and 178:
text.SetFont(font) # wx.StaticText
- Page 179 and 180:
GenStaticText6 12 7.1.2 wxPythonw
- Page 181 and 182:
wx.TE_PROCESS_ENTER wx.TE_PROCESS
- Page 183 and 184:
7.37.3 wx.TE_MULTILINE 7.3 import
- Page 185 and 186:
wxPythonRGB (, , )wx.NullColorfont
- Page 187 and 188:
wx.NORMAL, wx.LIGHT,wx.BOLD underli
- Page 189 and 190:
frame.Bind(wx.EVT_TEXT, frame.OnTex
- Page 191 and 192:
wx.Button EVT_BUTTON 7.2.2 7.5 wx
- Page 193 and 194:
wx.ToggleButtonwx.Button 1wx.Toggle
- Page 195 and 196:
= buttons.GenButton(panel, -1, ’d
- Page 197 and 198:
7.77.7 7.7 import wx class SliderF
- Page 199 and 200:
GetValue() SetValue(value) 7.3.2
- Page 201 and 202:
7.3.3 wxPythonwx.Gauge 7.9 7.9 7.
- Page 203 and 204:
7.10 wxPythonwx.CheckBox 7.10 7.10
- Page 205 and 206:
7.117.11 7.11 wx.RadioButton import
- Page 207 and 208:
7.12 wx.RadioBox7.12 7.12 7.12 imp
- Page 209 and 210:
SetStringSelection()set*() EVT_RADI
- Page 211 and 212:
wx.LB_SINGLE wx.ListBox7.13 7.13
- Page 213 and 214:
7.4.5 7.157.16 7.15 7.16 7.14 7
- Page 215 and 216:
wx.ComboBoxwx.Choice7.157.17 7.15 i
- Page 217 and 218:
217 / 565
- Page 219 and 220:
8.1 wx.Frame7 wx.Frame(parent, id=
- Page 221 and 222:
panel tab 8.1.2 wx.Frame —— 8
- Page 223 and 224:
wx.CLOSE_BOX wx.RESIZE_BORDER wx.SI
- Page 225 and 226:
pre = preClass() preInitFunc(pre) p
- Page 227 and 228:
Destroy() wx.App EVT_QUERY_END_S
- Page 229 and 230:
IsShown()True IsTopLevel()True Fals
- Page 231 and 232:
parent FindFindWindowByName() nameF
- Page 233 and 234:
8.1 SetScrollBars SetScrollbars(pix
- Page 235 and 236:
EVT_SCROLL*EVT_SCROLLWIN* wx.Scroll
- Page 237 and 238:
self.Bind(wx.EVT_MENU, self.OnNewWi
- Page 239 and 240:
app.MainLoop() wx.MiniFramewx.Frame
- Page 241 and 242:
self.SetWindowShape() self.Bind(wx.
- Page 243 and 244:
self.Bind(wx.EVT_LEFT_DCLICK, self.
- Page 245 and 246:
Mac OS X Finder 8.4.1 wxPythonwx.
- Page 247 and 248:
self.p2 = wx.Panel(self.sp, style=w
- Page 249 and 250:
def OnExit(self, evt): self.Close()
- Page 251 and 252:
SetSplitMode(mode)mode wx.SPLIT_VER
- Page 253 and 254:
9 9.1 wxPython 9.1.1 9.1 wxP
- Page 255 and 256:
9.1 if wx.ID_OK C+ +Python ShowM
- Page 257 and 258:
9.1 wx.MessageDialog wx.CANCELcance
- Page 259 and 260:
9.3 import wx if __name__ == ”__m
- Page 261 and 262:
9.1.4 wx.SingleChoiceDialog9.4 9
- Page 263 and 264:
9.5 9.59.5 9.5 import wx if __name
- Page 265 and 266:
9.6 9.6 9.6 wx.FileDialog import w
- Page 267 and 268:
wx.OK GetPath() wx.MULTIPLEGetPaths
- Page 269 and 270:
9.2.2 wxPython 9.8Windows 9.8 9.8
- Page 271 and 272:
wx.FontData wx.GetFontFromUser(pare
- Page 273 and 274:
colInitwx.Colour wx.ColourOK wx.Col
- Page 275 and 276:
wx.wizard.WizardPageSimple 9.119.11
- Page 277 and 278:
RunWizard()9.11#4 9.5 wx.wizard.Wiz
- Page 279 and 280:
filenamecurrentTip 0 # You can do
- Page 281 and 282:
””” Note that every validator
- Page 283 and 284:
app.MainLoop() #1 9.13 #2 9.13
- Page 285 and 286:
def __init__(self, data, key): wx.P
- Page 287 and 288:
app.MainLoop() TransDataFromWindow
- Page 289 and 290:
wx.Dialog.__init__(self, None, -1,
- Page 291 and 292:
wx.DirDialog 5wx.FontDialogwx.Colo
- Page 293 and 294:
5 10.1.1 wx.MenuBar wx.MenuBar()
- Page 295 and 296:
wx.Menuwx.MenuBar 10.1wx.MenuBar 10
- Page 297 and 298:
if __name__ == ”__main__”: app
- Page 299 and 300:
10.3 import wx class MyFrame(wx.Fr
- Page 301 and 302:
wx.EVT_MENU_RANGE self.Bind(wx.EVT_
- Page 303 and 304:
self.Bind(wx.EVT_MENU, self.OnNewIt
- Page 305 and 306:
10.5 IsEnabled()Enable() 10.5 impor
- Page 307 and 308:
10.3 10.6 10.6 import wx class My
- Page 309 and 310:
wxPython \t\tAlt, Ctrl, Shift +-
- Page 311 and 312:
10.4 10.7 10.7 import wx class
- Page 313 and 314:
wx.MenuItem kind AppendItem(), Prep
- Page 315 and 316:
def OnExit(self, event): self.Close
- Page 317 and 318:
item = self.popupmenu.Append(-1, te
- Page 319 and 320:
wx.Frame.__init__(self, None, -1,
- Page 321 and 322:
10.4.1 1015 10.4.2 —— F
- Page 323 and 324:
10.5 ·wxPython wx.MenuBar wx.Menu
- Page 325 and 326:
11 sizer ·sizer ·sizer ·sizergr
- Page 327 and 328:
sizer 11.2 sizergrid sizer sizer11
- Page 329 and 330:
class GridSizerFrame(wx.Frame): def
- Page 331 and 332:
sizerinsert() Insert(index, window
- Page 333 and 334:
11.4 11.311.4sizer 11.3 grid sizer
- Page 335 and 336:
sizer GetSize() GetPosition()sizer
- Page 337 and 338:
windowsizersizer sizerindexsizer si
- Page 339 and 340:
11.3 sizer sizersizer flex grid siz
- Page 341 and 342:
wx.FlexGridSizer(rows, cols, vgap,
- Page 343 and 344:
11.3 wx.FLEX_GROWMODE_ALLflex gridS
- Page 345 and 346:
grid bag sizerwx.GridBagSizerwx.Gri
- Page 347 and 348:
GetItemPosition()GetItemSpan()grid
- Page 349 and 350:
11.9 box sizer import wx from block
- Page 351 and 352:
ox sizerwx.BoxSizerwx.BoxSizerwx.Si
- Page 353 and 354:
def MakeStaticBoxSizer(self, boxlab
- Page 355 and 356:
nameLbl = wx.StaticText(panel, -1,
- Page 357 and 358:
# Fit the frame to the needs of the
- Page 359 and 360:
sizer 2wxPythonsizerwx.Sizer sizer
- Page 361 and 362:
12.1.1 wxPython wx.Imagewx.Bitmap
- Page 363 and 364:
wx.ImageHandler wxPython12.1 12.
- Page 365 and 366:
wx.Image wx.Bitmap wx.EmptyBitmap(w
- Page 367 and 368:
Replace(r1, g1, b1, r2, g2, b2)r1,
- Page 369 and 370:
wx.CURSOR_HAND wx.CURSOR_IBEAMI wx.
- Page 371 and 372:
wxPython wxPython wx.DCwx.DCAPIAP
- Page 373 and 374:
wx.PrinterDC wx.MemoryDC wx.MemoryD
- Page 375 and 376:
12.4 CrossHair(x, y)——y x(x,y)
- Page 377 and 378:
12.20-100 12.2 import wx import
- Page 379 and 380:
dc.Clear() dw, dh = dc.GetSize() #
- Page 381 and 382:
self.Bind(wx.EVT_TIMER, self.OnTime
- Page 383 and 384:
12.3 12.3 12.3 12.3 12.3 # This on
- Page 385 and 386:
12.2.4 DrawText(text, x, y) textxy
- Page 387 and 388:
wx.SHORT_DASH wx.SOLID wx.STIPPLE w
- Page 389 and 390:
wx.NOR~ & ~ wx.NO_OP wx.OR | wx.OR
- Page 391 and 392:
wx.MM_TEXT 1() wx.MM_TWIPS 1/20 Ge
- Page 393 and 394:
alpha 2wx.Image 3 4wx.DC APIwx.DC
- Page 395 and 396:
13 wxPython HTML 8 13.1
- Page 397 and 398:
self.list.InsertImageStringItem(x,
- Page 399 and 400:
# assign the image list to it self.
- Page 401 and 402:
13.1.4 13.4 13.4 13.213.4 13.2 #!
- Page 403 and 404:
13.1.5 wxPythonwx.ListCtrl wx.Lis
- Page 405 and 406:
widthheight maskTrue initialCount
- Page 407 and 408:
13.2.2 / API InsertItem()
- Page 409 and 410:
GetItemState(item,stateMask) SetIte
- Page 411 and 412:
EVT_LIST_BEGIN_RDRAG EVT_LIST_Dele
- Page 413 and 414:
self.list.AssignImageList(il, wx.IM
- Page 415 and 416:
def OnItemSelected(self, evt): item
- Page 417 and 418:
def OnEditItem(self, evt): index =
- Page 419 and 420:
wx.LC_SORT_ASCENDING wx.LC_SORT_DES
- Page 421 and 422:
def __init__(self): wx.Frame.__init
- Page 423 and 424:
4ColumnSorterMixinDemoFrame itemDat
- Page 425 and 426:
GetNextItem(item, geometry=wx.LIST_
- Page 427 and 428:
wxPython 13.6 13.6 13.5 13.5 #!
- Page 429 and 430:
evt.GetCacheFrom(), evt.GetCacheTo(
- Page 431 and 432:
2 3InsertStringItem(index,label)
- Page 433 and 434:
* (grid table) 5MVC 14.1.1 14
- Page 435 and 436:
def __init__(self): wx.Frame.__init
- Page 437 and 438:
self.even=wx.grid.GridCellAttr() se
- Page 439 and 440:
SetTableCreateGrid() Clear()ClearG
- Page 441 and 442:
14.3 import wx import wx.grid clas
- Page 443 and 444:
grid = wx.grid.Grid(self) table = T
- Page 445 and 446:
HTML rowspancolspanwxPython SetCell
- Page 447 and 448:
* EnableDragRowSize(enable=True) *
- Page 449 and 450:
GetGridCursorCol()GetGridCursorRow(
- Page 451 and 452:
grid.SetAttr(5, 1, attr) grid.SetRo
- Page 453 and 454:
wx.grid.GridCellRenderer wx.grid.Gr
- Page 455 and 456:
g = grid.GetSelectionBackground() f
- Page 457 and 458:
SetReadOnlySetRowAttr()SetColAttr()
- Page 459 and 460:
Create(parent, id, evtHandler)paren
- Page 461 and 462:
def EndEdit(self, row, col, grid):
- Page 463 and 464:
14.8 wx.grid.GridEvent AltDown()alt
- Page 465 and 466:
14.4.2 14.10 expandSelectionexpan
- Page 467 and 468:
wx.grid.GridCellEditor 7 467 / 56
- Page 469 and 470:
15.1 15.115.1 data.py 15.1 import
- Page 471 and 472:
def OnSelChanged(self, evt): print
- Page 473 and 474:
”wx.lib.gridmovers.GridColMoveEve
- Page 475 and 476:
[“wx.BitmapButton”,[ ”wx.lib.
- Page 477 and 478:
”wx.lib.multisash.MultiCreator”
- Page 479 and 480:
”wx.py.crust.CrustFrame”, [“w
- Page 481 and 482:
] ”wx.html.HtmlPrintout”, ”wx
- Page 483 and 484:
DeleteChildren(item) itemwx.TreeIte
- Page 485 and 486:
15.3 SortChildren(item) itemwx.Tre
- Page 487 and 488:
wx.Frame.__init__(self, None, title
- Page 489 and 490:
GetRootItem() wx.TreeItemIdGetItemT
- Page 491 and 492:
CollapseAndReset(item) Toggle(item)
- Page 493 and 494:
wx.TreeItemIcon_Normal) self.tree.S
- Page 495 and 496:
15.5 wx.TREE_HITTEST_ABOVE wx.TREE
- Page 497 and 498:
15.7 wx.EVT_TREE_BEGIN_DRAG Allow
- Page 499 and 500:
wx.ArtProvider.GetBitmap(wx.ART_FIL
- Page 501 and 502:
def OnItemCollapsed(self, evt): pri
- Page 503 and 504:
16 HTML * wxPythonHTML * HTML * HTM
- Page 505 and 506:
name=”htmlWindow”) wx.html.HW_
- Page 507 and 508:
16.2HTML 16.2 16.216.2 16.2 webHTML
- Page 509 and 510:
OnOpeningURL(type, url)URL type wx.
- Page 511 and 512:
16.316.3 16.3 HTML 16.3 webHTMLWind
- Page 513 and 514:
wx.PrintDataGetPageSetupData()wx.Pa
- Page 515 and 516:
wndwxPythonww 01100wnd w% HTML wxWi
- Page 517 and 518:
self.GetParser().SetActualColor(clr
- Page 519 and 520:
—— parser = self.GetParser()
- Page 521 and 522:
16.4 1HTMLInternetwxPythonHTML HTM
- Page 523 and 524:
17.1 17.1.1 wx.Printer wx.Printer
- Page 525 and 526:
17.1 17.1 17.1 import wx import o
- Page 527 and 528:
self.x1 = topLeft.x * self.logUnits
- Page 529 and 530:
item = menu.Append(-1, ”E&xit”,
- Page 531 and 532:
”Printing Error”, wx.OK) else:
- Page 533 and 534:
wx.PrintDialog wx.PrintDialog(pare
- Page 535 and 536:
SetPaperId(paperId) GetPaperId() wx
- Page 537 and 538:
EnablePrinter(flag) GetEnablePrinte
- Page 539 and 540:
17.5 wx.PrintPreview wx.Print
- Page 541 and 542:
18 wxPython * * * * wx.Timer *
- Page 543 and 544:
18.1.3 GetData(data)datawx.DataOb
- Page 545 and 546:
size=(500,300)) p = wx.Panel(self)
- Page 547 and 548:
wxPythonwx.DataObject 1 2wx
- Page 549 and 550:
18.2 18.2 #-*- encoding:UTF-8 -*-
- Page 551 and 552:
app = wx.PySimpleApp() frm = MyFram
- Page 553 and 554:
wx.DragNone(drop)OnDrop() OnData()O
- Page 555 and 556:
wxPython 18.4 wxPython wxPython
- Page 557 and 558:
wx.DataObjectComposite()Add(data, p
- Page 559 and 560:
def Draw(self, dc):# t = time.local
- Page 561 and 562:
wxPython wx.CallAfter() Python 18.
- Page 563 and 564:
style=wx.TE_RICH|wx.TE_MULTILINE) i
- Page 565:
wx.CallAfter() 18.7 1wx.DataObjec