Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problems with StaticBitmaps and events

Reply
Thread Tools

Problems with StaticBitmaps and events

 
 
Water Bottle
Guest
Posts: n/a
 
      05-23-2009
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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Differentiate between user caused events and script generated events jmpinchot@gmail.com Javascript 1 04-27-2007 03:05 AM
runtime events that generate other controls and events newbye ASP .Net 0 07-06-2006 06:27 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Re: passing variables between web page events & httpmodules events Alvin Bruney ASP .Net 1 11-24-2003 04:14 PM
Passing Variables between Web Page Events and HttpModule Events shiv ASP .Net 0 11-21-2003 04:29 PM



Advertisments