Problems with StaticBitmaps and events

Discussion in 'Python' started by Water Bottle, May 23, 2009.

  1. Water Bottle

    Water Bottle Guest

    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,
    wx.Size(400,400))

    self.sizer=wx.BoxSizer(wx.VERTICAL)
    self.sizer.Add(Box(self,-1).sizer,1,wx.EXPAND)
    self.sizer.Add(Picture(self,-1).sizer,0,wx.EXPAND)

    self.SetSizer(self.sizer)
    self.SetAutoLayout(1)
    self.Show(1)

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

    bitmap =
    wx.Bitmap("/home/kevin/programming/python/media/data/arrow_blue.png",
    wx.BITMAP_TYPE_PNG)
    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)
    self.sizer.AddMany([(self.pic,1,wx.EXPAND),
    ])

    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")
    frame.Show()
    self.SetTopWindow(frame)
    return 1

    app = myApp(0)
    app.MainLoop()



    Thanks!
    Water Bottle, May 23, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shiv
    Replies:
    0
    Views:
    462
  2. Alvin Bruney
    Replies:
    1
    Views:
    706
  3. newbye
    Replies:
    0
    Views:
    570
    newbye
    Jul 6, 2006
  4. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    334
    Chris
    Aug 30, 2005
  5. Replies:
    1
    Views:
    145
    Peter Michaux
    Apr 27, 2007
Loading...

Share This Page