1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
|
"""
PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
This file is part of PyColourChooser.
This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program 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.
"""
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatibility update.
#
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o wxPyColorChooser -> PyColorChooser
# o wxPyColourChooser -> PyColourChooser
# o Added wx.InitAllImageHandlers() to test code since
# that's where it belongs.
#
# Tags: phoenix-port
import wx
import wx.lib.newevent as newevent
from . import pycolourbox
from . import pypalette
from . import pycolourslider
import colorsys
from . import intl
from .intl import _ # _
ColourChangedEventBase, EVT_COLOUR_CHANGED = newevent.NewEvent()
class ColourChangedEvent(ColourChangedEventBase):
"""Adds GetColour()/GetValue() for compatibility with ColourPickerCtrl and colourselect"""
def __init__(self, newColour):
super(ColourChangedEvent, self).__init__(newColour = newColour)
def GetColour(self):
return self.newColour
def GetValue(self):
return self.newColour
class PyColourChooser(wx.Panel):
"""A Pure-Python implementation of the colour chooser dialog.
The PyColourChooser is a pure python implementation of the colour
chooser dialog. It's useful for embedding the colour choosing functionality
inside other widgets, when the pop-up dialog is undesirable. It can also
be used as a drop-in replacement on the GTK platform, as the native
dialog is kind of ugly.
"""
colour_names = [
'ORANGE',
'GOLDENROD',
'WHEAT',
'SPRING GREEN',
'SKY BLUE',
'SLATE BLUE',
'MEDIUM VIOLET RED',
'PURPLE',
'RED',
'YELLOW',
'MEDIUM SPRING GREEN',
'PALE GREEN',
'CYAN',
'LIGHT STEEL BLUE',
'ORCHID',
'LIGHT MAGENTA',
'BROWN',
'YELLOW',
'GREEN',
'CADET BLUE',
'MEDIUM BLUE',
'MAGENTA',
'MAROON',
'ORANGE RED',
'FIREBRICK',
'CORAL',
'FOREST GREEN',
'AQUAMARINE',
'BLUE',
'NAVY',
'THISTLE',
'MEDIUM VIOLET RED',
'INDIAN RED',
'GOLD',
'MEDIUM SEA GREEN',
'MEDIUM BLUE',
'MIDNIGHT BLUE',
'GREY',
'PURPLE',
'KHAKI',
'BLACK',
'MEDIUM FOREST GREEN',
'KHAKI',
'DARK GREY',
'SEA GREEN',
'LIGHT GREY',
'MEDIUM SLATE BLUE',
'WHITE',
]
# Generate the custom colours. These colours are shared across
# all instances of the colour chooser
NO_CUSTOM_COLOURS = 16
custom_colours = [ (wx.WHITE,
pycolourslider.PyColourSlider.HEIGHT / 2)
] * NO_CUSTOM_COLOURS
last_custom = 0
idADD_CUSTOM = wx.NewIdRef()
idSCROLL = wx.NewIdRef()
def __init__(self, parent, id):
"""Creates an instance of the colour chooser. Note that it is best to
accept the given size of the colour chooser as it is currently not
resizeable."""
wx.Panel.__init__(self, parent, id)
self.basic_label = wx.StaticText(self, -1, _("Basic Colours:"))
self.custom_label = wx.StaticText(self, -1, _("Custom Colours:"))
self.add_button = wx.Button(self, self.idADD_CUSTOM, _("Add to Custom Colours"))
self.Bind(wx.EVT_BUTTON, self.onAddCustom, self.add_button)
# Since we're going to be constructing widgets that require some serious
# computation, let's process any events (like redraws) right now
wx.Yield()
# Create the basic colours palette
self.colour_boxs = [ ]
colour_grid = wx.GridSizer(rows=6, cols=8, vgap=0, hgap=0)
for name in self.colour_names:
new_id = wx.NewIdRef()
box = pycolourbox.PyColourBox(self, new_id)
box.GetColourBox().Bind(wx.EVT_LEFT_DOWN, lambda x, b=box: self.onBasicClick(x, b))
self.colour_boxs.append(box)
colour_grid.Add(box, 0, wx.EXPAND)
# Create the custom colours palette
self.custom_boxs = [ ]
custom_grid = wx.GridSizer(rows=2, cols=8, vgap=0, hgap=0)
for wxcolour, slidepos in self.custom_colours:
new_id = wx.NewIdRef()
custom = pycolourbox.PyColourBox(self, new_id)
custom.GetColourBox().Bind(wx.EVT_LEFT_DOWN, lambda x, b=custom: self.onCustomClick(x, b))
custom.SetColour(wxcolour)
custom_grid.Add(custom, 0, wx.EXPAND)
self.custom_boxs.append(custom)
csizer = wx.BoxSizer(wx.VERTICAL)
csizer.Add((1, 25))
csizer.Add(self.basic_label, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(colour_grid, 0, wx.EXPAND)
csizer.Add((1, 25))
csizer.Add(self.custom_label, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(custom_grid, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(self.add_button, 0, wx.EXPAND)
self.palette = pypalette.PyPalette(self, -1)
self.colour_slider = pycolourslider.PyColourSlider(self, -1)
self.colour_slider.Bind(wx.EVT_LEFT_DOWN, self.onSliderDown)
self.colour_slider.Bind(wx.EVT_LEFT_UP, self.onSliderUp)
self.colour_slider.Bind(wx.EVT_MOTION, self.onSliderMotion)
self.slider = wx.Slider(
self, self.idSCROLL, 86, 0, self.colour_slider.HEIGHT - 1,
style=wx.SL_VERTICAL, size=(-1, self.colour_slider.HEIGHT)
)
self.Bind(wx.EVT_COMMAND_SCROLL, self.onScroll, self.slider)
psizer = wx.BoxSizer(wx.HORIZONTAL)
psizer.Add(self.palette, 0, 0)
psizer.Add((10, 1))
psizer.Add(self.colour_slider, 0, wx.ALIGN_CENTER_VERTICAL)
psizer.Add(self.slider, 0, wx.ALIGN_CENTER_VERTICAL)
# Register mouse events for dragging across the palette
self.palette.Bind(wx.EVT_LEFT_DOWN, self.onPaletteDown)
self.palette.Bind(wx.EVT_LEFT_UP, self.onPaletteUp)
self.palette.Bind(wx.EVT_MOTION, self.onPaletteMotion)
self.solid = pycolourbox.PyColourBox(self, -1, size=(75, 50))
slabel = wx.StaticText(self, -1, _("Solid Colour"))
ssizer = wx.BoxSizer(wx.VERTICAL)
ssizer.Add(self.solid, 0, 0)
ssizer.Add((1, 2))
ssizer.Add(slabel, 0, wx.ALIGN_CENTER_HORIZONTAL)
hlabel = wx.StaticText(self, -1, _("H:"))
self.hentry = wx.TextCtrl(self, -1)
self.hentry.SetSize((40, -1))
slabel = wx.StaticText(self, -1, _("S:"))
self.sentry = wx.TextCtrl(self, -1)
self.sentry.SetSize((40, -1))
vlabel = wx.StaticText(self, -1, _("V:"))
self.ventry = wx.TextCtrl(self, -1)
self.ventry.SetSize((40, -1))
hsvgrid = wx.FlexGridSizer(rows=1, cols=6, vgap=2, hgap=2)
hsvgrid.AddMany ([
(hlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.hentry, 0, wx.FIXED_MINSIZE),
(slabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.sentry, 0, wx.FIXED_MINSIZE),
(vlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.ventry, 0, wx.FIXED_MINSIZE),
])
self.hentry.Bind(wx.EVT_KILL_FOCUS, self.onHSVKillFocus)
self.sentry.Bind(wx.EVT_KILL_FOCUS, self.onHSVKillFocus)
self.ventry.Bind(wx.EVT_KILL_FOCUS, self.onHSVKillFocus)
rlabel = wx.StaticText(self, -1, _("R:"))
self.rentry = wx.TextCtrl(self, -1)
self.rentry.SetSize((40, -1))
glabel = wx.StaticText(self, -1, _("G:"))
self.gentry = wx.TextCtrl(self, -1)
self.gentry.SetSize((40, -1))
blabel = wx.StaticText(self, -1, _("B:"))
self.bentry = wx.TextCtrl(self, -1)
self.bentry.SetSize((40, -1))
lgrid = wx.FlexGridSizer(rows=1, cols=6, vgap=2, hgap=2)
lgrid.AddMany([
(rlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.rentry, 0, wx.FIXED_MINSIZE),
(glabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.gentry, 0, wx.FIXED_MINSIZE),
(blabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.bentry, 0, wx.FIXED_MINSIZE),
])
self.rentry.Bind(wx.EVT_KILL_FOCUS, self.onRGBKillFocus)
self.gentry.Bind(wx.EVT_KILL_FOCUS, self.onRGBKillFocus)
self.bentry.Bind(wx.EVT_KILL_FOCUS, self.onRGBKillFocus)
gsizer = wx.GridSizer(rows=2, cols=1, vgap=0, hgap=0)
gsizer.SetVGap (10)
gsizer.SetHGap (2)
gsizer.Add(hsvgrid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
gsizer.Add(lgrid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
hsizer.Add(ssizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
hsizer.Add(gsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
vsizer = wx.BoxSizer(wx.VERTICAL)
vsizer.Add((1, 5))
vsizer.Add(psizer, 0, 0)
vsizer.Add((1, 15))
vsizer.Add(hsizer, 0, wx.EXPAND)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add((5, 1))
sizer.Add(csizer, 0, wx.EXPAND)
sizer.Add((10, 1))
sizer.Add(vsizer, 0, wx.EXPAND)
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
self.InitColours()
self.UpdateColour(self.solid.GetColour())
def InitColours(self):
"""Initializes the pre-set palette colours."""
for i in range(len(self.colour_names)):
colour = wx.TheColourDatabase.FindColour(self.colour_names[i])
self.colour_boxs[i].SetColourTuple((colour.Red(),
colour.Green(),
colour.Blue()))
def onBasicClick(self, event, box):
"""Highlights the selected colour box and updates the solid colour
display and colour slider to reflect the choice."""
if hasattr(self, '_old_custom_highlight'):
self._old_custom_highlight.SetHighlight(False)
if hasattr(self, '_old_colour_highlight'):
self._old_colour_highlight.SetHighlight(False)
box.SetHighlight(True)
self._old_colour_highlight = box
self.UpdateColour(box.GetColour())
def onCustomClick(self, event, box):
"""Highlights the selected custom colour box and updates the solid
colour display and colour slider to reflect the choice."""
if hasattr(self, '_old_colour_highlight'):
self._old_colour_highlight.SetHighlight(False)
if hasattr(self, '_old_custom_highlight'):
self._old_custom_highlight.SetHighlight(False)
box.SetHighlight(True)
self._old_custom_highlight = box
# Update the colour panel and then the slider accordingly
box_index = self.custom_boxs.index(box)
base_colour, slidepos = self.custom_colours[box_index]
self.UpdateColour(box.GetColour())
self.slider.SetValue(slidepos)
def onAddCustom(self, event):
"""Adds a custom colour to the custom colour box set. Boxes are
chosen in a round-robin fashion, eventually overwriting previously
added colours."""
# Store the colour and slider position so we can restore the
# custom colours just as they were
self.setCustomColour(self.last_custom,
self.solid.GetColour(),
self.colour_slider.GetBaseColour(),
self.slider.GetValue())
self.last_custom = (self.last_custom + 1) % self.NO_CUSTOM_COLOURS
def setCustomColour (self, index, true_colour, base_colour, slidepos):
"""Sets the custom colour at the given index. true_colour is wxColour
object containing the actual rgb value of the custom colour.
base_colour (wxColour) and slidepos (int) are used to configure the
colour slider and set everything to its original position."""
self.custom_boxs[index].SetColour(true_colour)
self.custom_colours[index] = (base_colour, slidepos)
def setSliderToV(self, v):
"""Set a new HSV value for the v slider. Does not update displayed colour."""
min = self.slider.GetMin()
max = self.slider.GetMax()
val = (1 - v) * max
self.slider.SetValue(int(val))
def getVFromSlider(self):
"""Get the current value of "V" from the v slider."""
val = self.slider.GetValue()
min = self.slider.GetMin()
max = self.slider.GetMax()
# Snap to exact min/max values
if val == 0:
return 1
if val == max - 1:
return 0
return 1 - (val / max)
def colourToHSV(self, colour):
"""Convert wx.Colour to hsv triplet"""
return colorsys.rgb_to_hsv(colour.Red() / 255.0, colour.Green() / 255.0, colour.Blue() / 255.0)
def hsvToColour(self, hsv):
"""Convert hsv triplet to wx.Colour"""
# Allow values to go full range from 0 to 255
r, g, b = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2])
round_tenths = lambda x: int(x + 0.5)
r = round_tenths(r * 255.0)
g = round_tenths(g * 255.0)
b = round_tenths(b * 255.0)
return wx.Colour(r, g, b)
def getColourFromControls(self):
"""
Calculate current colour from HS box position and V slider.
return - wx.Colour
"""
# This allows colours to be exactly 0,0,0 or 255, 255, 255
baseColour = self.colour_slider.GetBaseColour()
h,s,v = self.colourToHSV(baseColour)
v = self.getVFromSlider()
if s < 0.04: # Allow pure white
s = 0
return self.hsvToColour((h, s, v))
def updateDisplayColour(self, colour):
"""Update the displayed color box (solid) and send the EVT_COLOUR_CHANGED"""
self.solid.SetColour(colour)
evt = ColourChangedEvent(newColour=colour)
wx.PostEvent(self, evt)
def UpdateColour(self, colour):
"""Updates displayed colour and HSV controls with the new colour"""
# Set the color info
self.updateDisplayColour(colour)
self.colour_slider.SetBaseColour(colour)
self.colour_slider.ReDraw()
# Update the Vslider and the HS current selection dot
h,s,v = self.colourToHSV(colour)
self.setSliderToV(v)
# Convert RGB to (x,y) == (hue, saturation)
width, height = self.palette.GetSize()
x = width * h
y = height * (1 - s)
self.palette.HighlightPoint(x, y)
self.UpdateEntries(colour)
def UpdateEntries(self, colour):
"""Updates the color levels to display the new values."""
# Temporary bindings
r = colour.Red()
g = colour.Green()
b = colour.Blue()
# Update the RGB entries
self.rentry.SetValue(str(r))
self.gentry.SetValue(str(g))
self.bentry.SetValue(str(b))
# Convert to HSV
h,s,v = colorsys.rgb_to_hsv(r / 255.0, g / 255.0, b / 255.0)
self.hentry.SetValue("%.2f" % (h))
self.sentry.SetValue("%.2f" % (s))
self.ventry.SetValue("%.2f" % (v))
def onColourSliderClick(self, y):
"""Shared helper for onSliderDown()/onSliderMotion()"""
v = self.colour_slider.GetVFromClick(y)
self.setSliderToV(v)
# Now with the slider updated, update all controls
colour = self.getColourFromControls()
self.updateDisplayColour(colour) # Update display
self.UpdateEntries(colour)
# We don't move on the palette...
# width, height = self.palette.GetSize()
# x = width * h
# y = height * (1 - s)
# self.palette.HighlightPoint(x, y)
def onSliderDown(self, event):
"""Handle mouse click on the colour slider palette"""
self.onColourSliderClick(event.GetY())
self.colour_slider.CaptureMouse()
def onSliderUp(self, event):
if self.colour_slider.HasCapture():
self.colour_slider.ReleaseMouse()
def onSliderMotion(self, event):
"""Handle mouse-down drag on the colour slider palette"""
if event.LeftIsDown():
self.onColourSliderClick(event.GetY())
def onPaletteDown(self, event):
"""Stores state that the mouse has been pressed and updates
the selected colour values."""
self.doPaletteClick(event.GetX(), event.GetY())
# Prevent mouse from leaving window, so that we will also get events
# when mouse is dragged along the edges of the rectangle.
self.palette.CaptureMouse()
def onPaletteUp(self, event):
"""Stores state that the mouse is no longer depressed."""
if self.palette.HasCapture():
self.palette.ReleaseMouse() # Must call once for each CaputreMouse()
def onPaletteMotion(self, event):
"""Updates the colour values during mouse motion while the
mouse button is depressed."""
if event.LeftIsDown():
self.doPaletteClick(event.GetX(), event.GetY())
def onPaletteCaptureLost(self, event):
pass # I don't think we have to call ReleaseMouse in this event
def doPaletteClick(self, m_x, m_y):
"""Updates the colour values based on the mouse location
over the palette."""
# Get the colour value, combine with H slider value, and update
colour = self.palette.GetValue(m_x, m_y)
# Update colour, but do not move V slider
self.colour_slider.SetBaseColour(colour)
self.colour_slider.ReDraw()
colour = self.getColourFromControls()
self.updateDisplayColour(colour) # Update display
self.UpdateEntries(colour)
# Highlight a fresh selected area
self.palette.HighlightPoint(m_x, m_y)
def onScroll(self, event):
"""Updates the display to reflect the new "Value"."""
value = self.slider.GetValue()
colour = self.getColourFromControls()
self.updateDisplayColour(colour)
self.UpdateEntries(colour)
def getValueAsFloat(self, textctrl):
"""If you type garbage, you get, literally, nothing (0)"""
try:
return float(textctrl.GetValue())
except ValueError:
return 0
def onHSVKillFocus(self, event):
h = self.getValueAsFloat(self.hentry)
s = self.getValueAsFloat(self.sentry)
v = self.getValueAsFloat(self.ventry)
if h > 0.9999:
h = 0.9999
if s > 0.9999:
s = 0.9999
if v > 0.9999:
v = 0.9999
if h < 0:
h = 0
if s < 0:
s = 0
if v < 0:
v = 0
colour = self.hsvToColour((h, s, v))
self.SetValue(colour) # infinite loop?
def onRGBKillFocus(self, event):
r = self.getValueAsFloat(self.rentry)
g = self.getValueAsFloat(self.gentry)
b = self.getValueAsFloat(self.bentry)
if r > 255:
r = 255
if g > 255:
g = 255
if b > 255:
b = 255
if r < 0:
r = 0
if g < 0:
g = 0
if b < 0:
b = 0
self.SetValue(wx.Colour((r, g, b)))
def SetValue(self, colour):
"""Updates the colour chooser to reflect the given wxColour."""
self.UpdateColour(colour)
def GetValue(self):
"""Returns a wxColour object indicating the current colour choice."""
return self.solid.GetColour()
def main():
"""Simple test display."""
class CCTestDialog(wx.Dialog):
def __init__(self, parent, initColour):
super(CCTestDialog, self).__init__(parent, title="Pick A Colo(u)r")
sizer = wx.BoxSizer(wx.VERTICAL)
self.chooser = PyColourChooser(self, wx.ID_ANY)
self.chooser.SetValue(initColour)
sizer.Add(self.chooser)
self.SetSizer(sizer)
sizer.Fit(self)
class CCTestFrame(wx.Frame):
def __init__(self):
super(CCTestFrame, self).__init__(None, -1, 'PyColourChooser Test')
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(wx.StaticText(self, label="CLICK ME"), 0, wx.CENTER)
self.box = pycolourbox.PyColourBox(self, id=wx.ID_ANY, size=(100,100))
sizer.Add(self.box, 0, wx.EXPAND)
self.box.SetColour(wx.Colour((0x7f, 0x90, 0x21)))
self.box.colour_box.Bind(wx.EVT_LEFT_DOWN, self.onClick) # should be an event. :(
self.SetSizer(sizer)
sizer.Fit(self)
def onClick(self, cmdEvt):
with CCTestDialog(self, self.box.GetColour()) as dialog:
dialog.chooser.Bind(EVT_COLOUR_CHANGED, self.onColourChanged)
dialog.ShowModal()
self.box.SetColour(dialog.chooser.GetValue())
def onColourChanged(self, event):
self.box.SetColour(event.GetValue())
class App(wx.App):
def OnInit(self):
frame = CCTestFrame()
# Added here because that's where it's supposed to be,
# not embedded in the library. If it's embedded in the
# library, debug messages will be generated for duplicate
# handlers.
wx.InitAllImageHandlers()
frame.Show(True)
self.SetTopWindow(frame)
return True
app = App(False)
app.MainLoop()
if __name__ == '__main__':
main()
|