Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx
- import random
- import os, sys
- import traceback
- class BlahFrame(wx.Frame):
- def __init__(self, parent, id, size):
- wx.Frame.__init__(self, parent, id, "Hello world!", size)
- # Create panel
- self.panel = wx.Panel(self)
- # Background setup
- if sys.platform == "linux22":
- print "wxGTK? YUCK!"
- else:
- print "Loading image from: "+os.path.join(os.getcwd(), "stripebg.png")
- self.bmp1 = wx.Bitmap(os.path.join(os.getcwd(), "stripebg.png"))
- self.Bind(wx.EVT_PAINT, self.on_paint)
- self.Bind(wx.EVT_SIZE, self.on_size)
- self.SetSize(size)
- self.invalidated = True
- self.button1 = wx.Button(self.panel, -1, label='Button1', pos=(10, 5))
- self.Show()
- def on_paint(self, event):
- # Draw BG of panel
- dc = wx.PaintDC(self.panel)
- w, h = dc.GetSize()
- # get image width and height
- iw = self.bmp1.GetWidth()
- ih = self.bmp1.GetHeight()
- for x in range(0, self.panel.GetSize()[0], iw):
- for y in range(0, self.panel.GetSize()[1], ih):
- dc.DrawBitmap(self.bmp1, x, y, True)
- app = wx.PySimpleApp()
- try:
- BlahInstance = BlahFrame(None, -1, size=(700,800))
- app.SetTopWindow(BlahInstance)
- app.MainLoop()
- except:
- print "Crashed..."
- traceback.print_exc()
Advertisement
Add Comment
Please, Sign In to add comment