Scott Frankel:
======= 2005-03-30 10:38:34 Scott Frankel wrote: =======
I'm trying to display a bitmap image in my app. This is a thumbnail
image, a little larger than an icon, that I want to add to a panel (not
a control). I'm looking at the API docs, the demo app, and the wiki,
but still have several questions.In the demo app, opj is imported from Main.
1) What/where is the importable module, Main?
2) What is opj?
Main and opj is something in the demo, not part of the wx and wx.lib, so of course you cannot import them.
Unable to load opj, because my system can't find a module
called Main, I'm following the docs in the API.3) How should I call the image handler? This line spits errors.
wx.Image_AddHandler(wx.JPEGHandler)TypeError: argument number 1: a 'wxImageHandler *' is expected,
'type(<class 'wx._core.JPEGHandler'>)' is received
In your case, I don't think you need to deal with image handler yourself.
4) Should I be using wx.StaticBitmap at all? The docs say this class
is meant for small icons.
I think wx.StaticBitmap is Ok. You can load the file to a wx.Bitmap or wx.Image and display it using the wx.Staticbitmap, you can also call image.scale() to change image size.
I feel like the approaches I've been hammering at are barking up the
wrong tree. I'm sure there's a simple solution out there.Thanks in advance!
ScottSample code follows ...
#!/usr/bin/env pythonw
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):# frame specs
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size = (200, 100),
style = wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)self.Show(True)
class ThumbPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)self.sizer = wx.BoxSizer(wx.HORIZONTAL)
wx.Image_AddHandler(wx.JPEGHandler)
imgName = "data/cs_thumbnail.jpg"
self.thumb = wx.Image(imgName, wx.BITMAP_TYPE_JPEG, -1)# self.thumbImg = wx.Image(opj('data/cs_thumbnail.jpg'),
# wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
# self.thumbBmap = wx.StaticBitmap(self, -1, thumbImg, (0, 0),
# (thumbImg.GetWidth(), thumbImg.GetHeight()))self.sizer.Add(self.thumb, 0, wx.SHAPED)
# layout sizers
self.SetSizer(self.sizer)
self.sizer.Fit(self)app = wx.PySimpleApp()
mframe = MainWindow(None, -1, "bitmap test")
tpanel = ThumbPanel(mframe, -1)app.MainLoop()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org.
= = = = = = = = = = = = = = = = = = = =
Bruce Who
HuXuZhao@hotmail.com
2005-03-30