A bugfix in the wxTreeCtrl.GetItem wrapper
Some test/demo modifications and additions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5095 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ab2208b54e
commit
f17fee68ea
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
54
utils/wxPython/tests/blit.py
Normal file
54
utils/wxPython/tests/blit.py
Normal file
@ -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
|
||||
|
||||
|
||||
|
61
utils/wxPython/tests/listGetItem.py
Normal file
61
utils/wxPython/tests/listGetItem.py
Normal file
@ -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()
|
49
utils/wxPython/tests/testDlg.py
Normal file
49
utils/wxPython/tests/testDlg.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user