Hi, I'm new to wxpython and I created a test program. So far, it works, but
there are some problems with it.

For some reason, I get a small box in the top left corner. Not sure why
that's happening.

Also, I can't get my picture to bind to my Play().

Lastly, do you recommend using StaticBitmap as a button? I don't want to use
the wx.Button because I want to create my own custom buttons with its own
borders and such.

I've attached my png.

import wx

class Frame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition,



class Picture(wx.Panel):
def __init__(self, parent, ID):
wx.Panel.__init__(self, parent, ID)

bitmap =
self.pic = wx.StaticBitmap(parent, ID, bitmap, wx.Point(30,120),
wx.Size(20,20), 0, "Name")

self.pic.Bind(wx.EVT_BUTTON, self.Play)

# Add more pictures later

# Layout
self.sizer = wx.GridSizer(1,10,0,0)

def Play(self, event):
print "Hello"

class Box(wx.Panel):
def __init__(self, parent, ID):
wx.Panel.__init__(self, parent, ID)
self.control = wx.TextCtrl(parent, 1, style=wx.TE_MULTILINE)

# Layout
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.sizer.Add(self.control, 1, wx.EXPAND)

class myApp(wx.App):
def OnInit(self):
frame = Frame(None, -1, "Test")
return 1

app = myApp(0)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090523/0f8229d7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arrow_blue.png
Type: image/png
Size: 471 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090523/0f8229d7/attachment.png>

Search Discussions

  • Water Bottle at May 24, 2009 at 6:56 pm
    Okay, I found the root of the weird box problem on the top left corner. It
    has something to do with my panels. I changed the code so that I directly
    used the StaticBitmap and TextCtrl inside the Frame class and the weird box
    was gone. I'm not sure what I'm doing wrong with the Panels. Can anyone

    Also, I poked around other forums and it seems StaticBitmaps doesn't really
    trigger events (it's a static control). I tried using GenStaticBitmaps in
    the wx.lib.statbmp, and was able to achieve some triggers (for example,
    wx.EVT_ENTER_WINDOW). However, I want to make it so that my picture is a
    button without having to look like one of the standard looking buttons (like
    you have in wx.BitmapButton). Is there some sort of way to do that?

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20090524/25a30ea5/attachment.htm>
  • Water Bottle at May 24, 2009 at 7:30 pm
    Hm, so it seems that it was just a sizing issue with my wx.Panels. I defined
    my own size, and that fixed the weird box problem. Although, now that I'm
    defining the size, that may not be good for when I expand the window.
    Everything will be stretched. Anyone know a way around that?

    Still having trouble with the GenStaticBitmap and the events. Can't seem to
    find an event that uses 'clickable' as a trigger (like EVT_BUTTON, but that
    doesn't work with GenStaticBitmap)
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20090524/efe0082e/attachment.htm>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
postedMay 23, '09 at 9:32p
activeMay 24, '09 at 7:30p

1 user in discussion

Water Bottle: 3 posts



site design / logo © 2022 Grokbase