ich möchte gerne in einer BitmapComboBox Bilder anzeigen, die ich selbst über DC erstellt habe. Leider bekomme ich es nicht hin. Es wird nichts angezeigt. Hier ein Code-Beispiel:
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
import wx
import wx.combo
class MainFrame(wx.Frame):
def __init__(self, ):
wx.Frame.__init__(self, None, -1, 'Test BitmapComboBox')
panel = wx.Panel(self)
self.bcb = wx.combo.BitmapComboBox(panel, -1, size=(250, 21))
size = (40, 23)
self.bmp = self.getBitmap(size)
self.Bind(wx.EVT_PAINT, self.on_paint)
self.drawFigure()
self.setBitmap()
def setBitmap(self):
self.bcb.Append('Eintrag1', self.bmp)
def getBitmap(self, size):
bmp = wx.EmptyBitmap(*size)
self.dc = wx.MemoryDC(bmp)
self.dc.SetBackground(wx.WHITE_BRUSH)
self.dc.Clear()
self.dc.SelectObject(wx.NullBitmap)
return bmp
def on_paint(self, event=None):
wx.BufferedPaintDC(self, self.bmp, style=wx.BUFFER_VIRTUAL_AREA)
def drawFigure(self):
color = 'black'
brush = wx.Brush(color)
brush.SetStyle(wx.BDIAGONAL_HATCH)
self.dc.SetBrush(brush)
pen = wx.Pen(color, 1, wx.DOT)
self.dc.SetPen(pen)
self.dc.DrawRectangle(2, 2, 22, 14)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MainFrame()
frame.Center()
frame.Show()
app.MainLoop()
Grüße
Mawilo