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!

<<attachment: arrow_blue.png>>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to