diff --git a/utils/wxPython/demo/wxTreeCtrl.py b/utils/wxPython/demo/wxTreeCtrl.py index 48b74fff4a..b3407c0fbe 100644 --- a/utils/wxPython/demo/wxTreeCtrl.py +++ b/utils/wxPython/demo/wxTreeCtrl.py @@ -15,14 +15,15 @@ class TestTreeCtrlPanel(wxPanel): self.tree = wxTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE) - self.il = wxImageList(16, 16) - idx1 = self.il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) - idx2 = self.il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP)) - idx3 = self.il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP)) - idx4 = self.il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP)) - idx5 = self.il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP)) + il = wxImageList(16, 16) + idx1 = il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) + idx2 = il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP)) + idx3 = il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP)) + idx4 = il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP)) + idx5 = il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP)) - self.tree.SetImageList(self.il) + self.tree.SetImageList(il) + self.il = il self.root = self.tree.AddRoot("The Root Item") self.tree.SetItemImage(self.root, idx1) diff --git a/utils/wxPython/src/controls2.i b/utils/wxPython/src/controls2.i index 8bae5da0dd..cacc96e928 100644 --- a/utils/wxPython/src/controls2.i +++ b/utils/wxPython/src/controls2.i @@ -165,6 +165,7 @@ public: wxListItem* info = new wxListItem; info->m_itemId = itemId; info->m_col = col; + info->m_mask = 0xFFFF; self->GetItem(*info); return info; } diff --git a/utils/wxPython/src/msw/controls2.cpp b/utils/wxPython/src/msw/controls2.cpp index 9b7cb275af..0158195b6f 100644 --- a/utils/wxPython/src/msw/controls2.cpp +++ b/utils/wxPython/src/msw/controls2.cpp @@ -1855,6 +1855,7 @@ static wxListItem * wxListCtrl_GetItem(wxListCtrl *self,long itemId,int col) { wxListItem* info = new wxListItem; info->m_itemId = itemId; info->m_col = col; + info->m_mask = 0xFFFF; self->GetItem(*info); return info; } diff --git a/utils/wxPython/tests/blit.py b/utils/wxPython/tests/blit.py new file mode 100644 index 0000000000..6d7b9f5b33 --- /dev/null +++ b/utils/wxPython/tests/blit.py @@ -0,0 +1,54 @@ +#------------------------------------------------- + +from wxPython.wx import * + + +class MyFrame(wxFrame): + def __init__(self,parent,title,id): + wxFrame.__init__(self,parent,title,id, + wxPoint(100,100),wxSize(300,300)) + + + self.SetBackgroundColour(wxWHITE) + self.windowx,self.windowy=self.GetClientSizeTuple() + + # make a memory DC to draw into... + self.mask=wxMemoryDC() + + self.maskbitmap=wxEmptyBitmap(self.windowx,self.windowy) + self.mask.SelectObject(self.maskbitmap) + self.mask.SetBackgroundMode(wxTRANSPARENT) + + self.mask.SetDeviceOrigin(0,0) + + self.mask.SetBrush(wxBrush(wxColour(150,160,0),wxSOLID)) + self.mask.SetPen(wxPen(wxColour(1,2,3),1,wxSOLID)) + self.mask.DrawRectangle(0,0,self.windowx,self.windowy) + + img = wxImageFromBitmap(self.maskbitmap) + print (img.GetRed(0,0), img.GetGreen(0,0), img.GetBlue(0,0)) + + + def OnPaint(self,evt): + """ overriding OnPaint to give handler. """ + dc = wxPaintDC(self) + + dc.Blit(0,0,self.windowx,self.windowy,self.mask,0,0,wxCOPY) + +#----------------------------------------------------------- + +if __name__ == "__main__": + class MyApp(wxApp): + def OnInit(self): + + self.frame = MyFrame(NULL, -1, "Blit Test") + self.frame.Show(true) + + self.exiting = FALSE; + return true + + app = MyApp(0) # Create an instance of the application + app.MainLoop() # Tell it to start processing events + + + diff --git a/utils/wxPython/tests/listGetItem.py b/utils/wxPython/tests/listGetItem.py new file mode 100644 index 0000000000..1db340fa51 --- /dev/null +++ b/utils/wxPython/tests/listGetItem.py @@ -0,0 +1,61 @@ +from wxPython.wx import * + +LIST_ID = 101 + +class MyFrame(wxFrame): + def __init__(self, parent, id, title): + wxFrame.__init__(self, parent, id, title, + wxDefaultPosition, wxSize(400, 400)) + self.panel = wxPanel(self, -1) + self.list = wxListCtrl(self.panel, LIST_ID, + wxPoint(10, 10), wxSize(370, 330), + wxLC_REPORT|wxSUNKEN_BORDER) + self.list.InsertColumn(0, "Id") + self.list.InsertColumn(1, "Type") + self.list.InsertColumn(2, "Description") + + self.insertRow(self.list, 0, 'CD', 'Dark Side of the Moon') + self.insertRow(self.list, 1, 'DVD', 'The Matrix') + self.insertRow(self.list, 2, 'Book', 'Crime and Punishment') + + self.list.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER) + self.list.SetColumnWidth(1, wxLIST_AUTOSIZE) + self.list.SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER) + + EVT_LIST_ITEM_SELECTED(self.panel, LIST_ID, self.OnListSelect) + + self.panel.Layout() + return + + def OnListSelect(self, event): + item = self.list.GetItem(event.m_itemIndex, 1) + print item.m_itemId, item.m_col, item.m_state + type = self.list.GetItem(event.m_itemIndex, col=1).m_text + desc = self.list.GetItem(event.m_itemIndex, col=2).m_text + print ('Row Selected: Id: %d, Type: %s, Desc: %s' % + (event.m_itemIndex, `type`, `desc`)) + return + + def insertRow(self, list, row, type, desc): + list.InsertStringItem(row, 'label' + `row`) + list.SetStringItem(row, 0, `row`) + list.SetStringItem(row, 1, type) + list.SetStringItem(row, 2, desc) + return + + def OnCloseWindow(self, event): + self.Destroy() + return + + + +class MyApp(wxApp): + def OnInit(self): + frame = MyFrame(None, -1, 'ListCtrl Test') + frame.Show(1) + self.SetTopWindow(frame) + return 1 + + +app = MyApp(0) +app.MainLoop() diff --git a/utils/wxPython/tests/testDlg.py b/utils/wxPython/tests/testDlg.py new file mode 100644 index 0000000000..6dee2656d4 --- /dev/null +++ b/utils/wxPython/tests/testDlg.py @@ -0,0 +1,49 @@ +## import all of the wxPython GUI package +from wxPython.wx import * + + +## Create a new frame class, derived from the wxPython Frame. +class Dialog(wxDialog): + + def __init__(self, parent, title): + # First, call the base class' __init__ method to create the frame + wxDialog.__init__( self, parent, -1, title, wxDefaultPosition, wxDefaultSize ) + + wxButton(self, wxID_OK, "OK", (10, 10)) + wxButton(self, wxID_CANCEL, "Cancel", (50,50)) + self.Centre( wxBOTH ) + + + # This method is called automatically when the CLOSE event is + # sent to this window + #def OnCloseWindow(self, event): + # self.Destroy() + + #def OnCloseMe(self, event): + #self.Close(true) + + +def main(): + # Every wxWindows application must have a class derived from wxApp + class App(wxApp): + + # wxWindows calls this method to initialize the application + def OnInit(self): + + # Create an instance of our customized Frame class + dialog = Dialog( NULL, 'test' ) + dialog.ShowModal() + print "got here" + dialog.Destroy() + + # Tell wxWindows that this is our main window + # Return a success flag + return true + + app = App(0) # Create an instance of the application class + app.MainLoop() # Tell it to start processing events + + + +if __name__ == '__main__': + main()