Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
window handle. If you can get the window handle into the python code, it should just work... More news on this later. Added wxImageList, wxToolTip. Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the wxRegConfig class. As usual, some bug fixes, tweaks, etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1734 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
BIN
utils/wxPython/tests/bitmaps/smiles.bmp
Normal file
BIN
utils/wxPython/tests/bitmaps/smiles.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 246 B |
@@ -5,30 +5,47 @@
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created:
|
||||
# Created: A long time ago, in a galaxy far, far away...
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
## import all of the wxPython GUI package
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
## Create a new frame class, derived from the wxPython Frame.
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title, wxPoint(100, 100), wxSize(160, 100))
|
||||
self.Connect(-1, -1, wxEVT_MOVE, self.OnMove)
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
# First, call the base class' __init__ method to create the frame
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 100))
|
||||
|
||||
# Associate some events with methods of this class
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
|
||||
|
||||
# This method is called automatically when the CLOSE event is
|
||||
# sent to this window
|
||||
def OnCloseWindow(self, event):
|
||||
# tell the window to kill itself
|
||||
self.Destroy()
|
||||
|
||||
|
||||
# This method is called by the System when the window is resized,
|
||||
# because of the association above.
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
print "size:", size.width, size.height
|
||||
|
||||
# This method is called by the System when the window is moved,
|
||||
# because of the association above.
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
print "pos:", pos.x, pos.y
|
||||
@@ -37,58 +54,29 @@ class MyFrame(wxFrame):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Every wxWindows application must have a class derived from wxApp
|
||||
class MyApp(wxApp):
|
||||
|
||||
# wxWindows calls this method to initialize the application
|
||||
def OnInit(self):
|
||||
|
||||
# Create an instance of our customized Frame class
|
||||
frame = MyFrame(NULL, -1, "This is a test")
|
||||
frame.Show(true)
|
||||
|
||||
# Tell wxWindows that this is our main window
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
# Return a success flag
|
||||
return true
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def main():
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
def t():
|
||||
import pdb
|
||||
pdb.run('main()')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
app = MyApp(0) # Create an instance of the application class
|
||||
app.MainLoop() # Tell it to start processing events
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.3 1998/12/15 20:44:34 RD
|
||||
# Changed the import semantics from "from wxPython import *" to "from
|
||||
# wxPython.wx import *" This is for people who are worried about
|
||||
# namespace pollution, they can use "from wxPython import wx" and then
|
||||
# prefix all the wxPython identifiers with "wx."
|
||||
#
|
||||
# Added wxTaskbarIcon for wxMSW.
|
||||
#
|
||||
# Made the events work for wxGrid.
|
||||
#
|
||||
# Added wxConfig.
|
||||
#
|
||||
# Added wxMiniFrame for wxGTK, (untested.)
|
||||
#
|
||||
# Changed many of the args and return values that were pointers to gdi
|
||||
# objects to references to reflect changes in the wxWindows API.
|
||||
#
|
||||
# Other assorted fixes and additions.
|
||||
#
|
||||
# Revision 1.2 1998/10/02 06:42:27 RD
|
||||
#
|
||||
# Version 0.4 of wxPython for MSW.
|
||||
#
|
||||
# Revision 1.1 1998/08/09 08:28:05 RD
|
||||
# Initial version
|
||||
#
|
||||
#
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class MyCanvas(wxWindow):
|
||||
font = wxFont(42, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
dc.SetFont(font)
|
||||
st = "Python Rules!"
|
||||
tw,th, d,e = dc.GetTextExtent(st)
|
||||
tw,th = dc.GetTextExtent(st)
|
||||
dc.DrawText(st, (size.width-tw)/2, (size.height-th)/2)
|
||||
dc.EndDrawing()
|
||||
|
||||
@@ -147,7 +147,20 @@ if __name__ == '__main__':
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.5 1999/02/20 09:04:43 RD
|
||||
# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
# window handle. If you can get the window handle into the python code,
|
||||
# it should just work... More news on this later.
|
||||
#
|
||||
# Added wxImageList, wxToolTip.
|
||||
#
|
||||
# Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
|
||||
# wxRegConfig class.
|
||||
#
|
||||
# As usual, some bug fixes, tweaks, etc.
|
||||
#
|
||||
# Revision 1.4 1998/12/16 22:12:46 RD
|
||||
#
|
||||
# Tweaks needed to be able to build wxPython with wxGTK.
|
||||
#
|
||||
# Revision 1.3 1998/12/15 20:44:35 RD
|
||||
|
@@ -271,6 +271,9 @@ class TestNotebookWindow(wxFrame):
|
||||
win = TestTreeCtrlPanel(nb, log)
|
||||
nb.AddPage(win, "TreeCtrl")
|
||||
|
||||
win = TestListCtrlPanel(nb, log)
|
||||
nb.AddPage(win, "ListCtrl")
|
||||
|
||||
win = ColoredPanel(nb, wxRED)
|
||||
nb.AddPage(win, "Red")
|
||||
|
||||
@@ -338,7 +341,7 @@ class CustomStatusBar(wxStatusBar):
|
||||
# figure out how tall to make it.
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.GetFont())
|
||||
(w,h, d,e) = dc.GetTextExtent('X')
|
||||
(w,h) = dc.GetTextExtent('X')
|
||||
h = int(h * 1.8)
|
||||
self.SetSize(wxSize(100, h))
|
||||
|
||||
@@ -499,6 +502,53 @@ class TestTreeCtrl(wxFrame):
|
||||
p = TestTreeCtrlPanel(self, log)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestListCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
tID = 1101
|
||||
|
||||
self.il = wxImageList(16, 16)
|
||||
idx1 = self.il.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
|
||||
|
||||
self.list = wxListCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT|wxSUNKEN_BORDER)
|
||||
self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
|
||||
|
||||
self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
|
||||
wxToolTip_Enable(true)
|
||||
|
||||
self.list.InsertColumn(0, "Column 0")
|
||||
self.list.InsertColumn(1, "Column 1")
|
||||
self.list.InsertColumn(2, "One More Column (2)")
|
||||
for x in range(50):
|
||||
self.list.InsertImageStringItem(x, "This is item %d" % x, idx1)
|
||||
self.list.SetStringItem(x, 1, "Col 1, item %d" % x)
|
||||
self.list.SetStringItem(x, 2, "item %d in column 2" % x)
|
||||
|
||||
self.list.SetColumnWidth(0, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(1, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(2, wxLIST_AUTOSIZE)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.list.SetDimensions(0, 0, w, h)
|
||||
|
||||
|
||||
|
||||
|
||||
class TestListCtrl(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test ListCtrl',
|
||||
wxDefaultPosition, wxSize(250, 300))
|
||||
|
||||
p = TestListCtrlPanel(self, log)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestSashWindow(wxMDIParentFrame):
|
||||
@@ -740,6 +790,10 @@ class AppFrame(wxFrame):
|
||||
menu.Append(mID, 'T&ree Control')
|
||||
EVT_MENU(self, mID, self.OnTestTreeCtrl)
|
||||
|
||||
mID = NewId()
|
||||
menu.Append(mID, '&List Control')
|
||||
EVT_MENU(self, mID, self.OnTestListCtrl)
|
||||
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'S&ash Window and Layout Algorithm')
|
||||
EVT_MENU(self, mID, self.OnTestSashWindow)
|
||||
@@ -890,6 +944,10 @@ class AppFrame(wxFrame):
|
||||
win = TestTreeCtrl(self, self)
|
||||
win.Show(true)
|
||||
|
||||
def OnTestListCtrl(self, event):
|
||||
win = TestListCtrl(self, self)
|
||||
win.Show(true)
|
||||
|
||||
def OnTestSashWindow(self, event):
|
||||
win = TestSashWindow(self, self)
|
||||
win.Show(true)
|
||||
@@ -942,7 +1000,20 @@ if __name__ == '__main__':
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.13 1999/02/20 09:04:44 RD
|
||||
# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
# window handle. If you can get the window handle into the python code,
|
||||
# it should just work... More news on this later.
|
||||
#
|
||||
# Added wxImageList, wxToolTip.
|
||||
#
|
||||
# Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
|
||||
# wxRegConfig class.
|
||||
#
|
||||
# As usual, some bug fixes, tweaks, etc.
|
||||
#
|
||||
# Revision 1.12 1999/01/30 07:31:33 RD
|
||||
#
|
||||
# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
|
||||
#
|
||||
# Various cleanup, tweaks, minor additions, etc. to maintain
|
||||
|
110
utils/wxPython/tests/test7.py
Normal file
110
utils/wxPython/tests/test7.py
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: test7.py
|
||||
# Purpose: A minimal wxPython program that is a bit smarter than test1.
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: A long time ago, in a galaxy far, far away...
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
## import all of the wxPython GUI package
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
## Create a new frame class, derived from the wxPython Frame.
|
||||
class MyFrame(wxFrame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
# First, call the base class' __init__ method to create the frame
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 100))
|
||||
|
||||
# Associate some events with methods of this class
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
|
||||
# Add a panel and some controls to display the size and position
|
||||
panel = wxPanel(self, -1)
|
||||
wxStaticText(panel, -1, "Size:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
|
||||
wxStaticText(panel, -1, "Pos:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 14)), wxDefaultSize)
|
||||
self.sizeCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 4)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
self.posCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 14)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
|
||||
# This method is called automatically when the CLOSE event is
|
||||
# sent to this window
|
||||
def OnCloseWindow(self, event):
|
||||
# tell the window to kill itself
|
||||
self.Destroy()
|
||||
|
||||
|
||||
# This method is called by the System when the window is resized,
|
||||
# because of the association above.
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
|
||||
|
||||
# tell the event system to continue looking for an event handler,
|
||||
# so the default handler will get called.
|
||||
event.Skip()
|
||||
|
||||
# This method is called by the System when the window is moved,
|
||||
# because of the association above.
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# Every wxWindows application must have a class derived from wxApp
|
||||
class MyApp(wxApp):
|
||||
|
||||
# wxWindows calls this method to initialize the application
|
||||
def OnInit(self):
|
||||
|
||||
# Create an instance of our customized Frame class
|
||||
frame = MyFrame(NULL, -1, "This is a test")
|
||||
frame.Show(true)
|
||||
|
||||
# Tell wxWindows that this is our main window
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
# Return a success flag
|
||||
return true
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
app = MyApp(0) # Create an instance of the application class
|
||||
app.MainLoop() # Tell it to start processing events
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user