stupid q-n (wxPy)
Mike Rovner
mike at bindkey.com
Tue Apr 29 14:58:33 EDT 2003
"Max Khesin" <max at cNOvSisiPonAtecMh.com> wrote in message
news:7hzra.27540$su3.3180311 at twister.nyc.rr.com...
> The only detail I have is that the script was copy-pasted out straight of
> wxPython demo app. There were no specific instructions in the readme for
> running the code so I just gave it a shot. Since wxPython is so popular I
> fugured someone would just tell me "didn't you bla-bla, (idiot)?".
> anyway, thanks.
In wxPython/demo resides run.py which demo scripts import.
But *you* don't want to follow pretty complex demo framework in your
program.
Start with something very simple like that:
from wxPython.wx import *
class MainFrame(wxFrame):
def __init__(self, parent, id, title):
# create a frame for our demo
wxFrame.__init__(self, parent, id, title)
self.drawPanel = wxScrolledWindow(self, -1, style=wxSUNKEN_BORDER)
self.drawPanel.SetBackgroundColour(wxWHITE)
self.bmp=wxImage('test.jpg', wxBITMAP_TYPE_JPEG).ConvertToBitmap()
EVT_PAINT(self.drawPanel, self.draw)
def draw(self,evt):
dc = wxPaintDC(self.drawPanel)
self.drawPanel.PrepareDC(dc)
dc.BeginDrawing()
dc.DrawBitmap(self.bmp, 0, 0)
dc.SetBrush(wxBLACK_BRUSH)
dc.SetPen(wxGREY_PEN)
dc.DrawLine(0,0,200,200)
dc.EndDrawing()
class App(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
frame = MainFrame(NULL, -1, 'JPG Demo')
frame.Show(true)
self.SetTopWindow(frame)
return true
app=App(0)
app.MainLoop()
More information about the Python-list
mailing list