8bf5d46efb
Added the missing wxWindow.GetUpdateRegion() method. Made a new change in SWIG (update your patches everybody) that provides a fix for global shadow objects that get an exception in their __del__ when their extension module has already been deleted. It was only a 1 line change in .../SWIG/Modules/pycpp.cxx at about line 496 if you want to do it by hand. It is now possible to run through MainLoop more than once in any one process. The cleanup that used to happen as MainLoop completed (and prevented it from running again) has been delayed until the wxc module is being unloaded by Python. wxWindow.PopupMenu() now takes a wxPoint instead of x,y. Added wxWindow.PopupMenuXY to be consistent with some other methods. Added wxGrid.SetEditInPlace and wxGrid.GetEditInPlace. You can now provide your own app.MainLoop method. See wxPython/demo/demoMainLoop.py for an example and some explaination. Got the in-place-edit for the wxTreeCtrl fixed and added some demo code to show how to use it. Put the wxIcon constructor back in for GTK as it now has one that matches MSW's. Added wxGrid.GetCells Added wxSystemSettings static methods as functions with names like wxSystemSettings_GetSystemColour. Removed wxPyMenu since using menu callbacks have been depreciated in wxWindows. Use wxMenu and events instead. Added alternate wxBitmap constructor (for MSW only) as wxBitmapFromData(data, type, width, height, depth = 1) Added a helper function named wxPyTypeCast that can convert shadow objects of one type into shadow objects of another type. (Like doing a down-cast.) See the implementation in wx.py for some docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
108 lines
3.5 KiB
Python
108 lines
3.5 KiB
Python
from wxPython.wx import *
|
|
from layoutf import Layoutf
|
|
import string
|
|
|
|
|
|
|
|
class wxScrolledMessageDialog(wxDialog):
|
|
|
|
def __init__(self, parent, msg, caption, pos = None, size = None):
|
|
if not pos:
|
|
pos = wxDefaultPosition
|
|
if not size:
|
|
size = wxSize(500,300)
|
|
wxDialog.__init__(self, parent, -1, caption, pos, size)
|
|
text = wxTextCtrl(self, -1, msg, wxDefaultPosition,
|
|
wxDefaultSize,
|
|
wxTE_MULTILINE | wxTE_READONLY)
|
|
ok = wxButton(self, wxID_OK, "OK")
|
|
text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
|
|
ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!25', (self,)))
|
|
self.SetAutoLayout(TRUE)
|
|
self.Layout()
|
|
|
|
|
|
class wxMultipleChoiceDialog(wxDialog):
|
|
|
|
def __init__(self, parent, msg, title, lst, pos = None, size = None):
|
|
if not pos:
|
|
pos = wxDefaultPosition
|
|
if not size:
|
|
size = wxSize(200,200)
|
|
wxDialog.__init__(self, parent, -1, title, pos, size)
|
|
dc = wxClientDC(self)
|
|
height = 0
|
|
for line in string.split(msg,'\n'):
|
|
height = height + dc.GetTextExtent(msg)[1] + 4
|
|
stat = wxStaticText(self, -1, msg)
|
|
self.lbox = wxListBox(self, 100, wxDefaultPosition,
|
|
wxDefaultSize, lst, wxLB_MULTIPLE)
|
|
ok = wxButton(self, wxID_OK, "OK")
|
|
cancel = wxButton(self, wxID_CANCEL, "Cancel")
|
|
stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
|
|
(self,)))
|
|
self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
|
|
(self, stat, ok)))
|
|
ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
|
|
cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
|
|
self.SetAutoLayout(TRUE)
|
|
self.lst = lst
|
|
self.Layout()
|
|
|
|
def OnSize(self, event):
|
|
self.Layout()
|
|
|
|
def GetValue(self):
|
|
return self.lbox.GetSelections()
|
|
|
|
def GetValueString(self):
|
|
sel = self.lbox.GetSelections()
|
|
val = []
|
|
for i in sel:
|
|
val.append(self.lst[i])
|
|
return tuple(val)
|
|
|
|
if __name__ == '__main__':
|
|
class MyFrame(wxFrame):
|
|
def __init__(self):
|
|
wxFrame.__init__(self, NULL, -1, "hello",
|
|
wxDefaultPosition, wxSize(200,200))
|
|
wxButton(self, 100, "Multiple Test",wxPoint(0,0))
|
|
wxButton(self, 101, "Message Test", wxPoint(0,100))
|
|
EVT_BUTTON(self, 100, self.OnMultipleTest)
|
|
EVT_BUTTON(self, 101, self.OnMessageTest)
|
|
|
|
def OnMultipleTest(self, event):
|
|
self.lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
|
|
'etc', 'etc..', 'etc...' ]
|
|
dlg = wxMultipleChoiceDialog(self,
|
|
"Pick some from\n this list\nblabla",
|
|
"m.s.d.", self.lst)
|
|
if (dlg.ShowModal() == wxID_OK):
|
|
print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString()
|
|
|
|
def OnMessageTest(self, event):
|
|
import sys;
|
|
f = open(sys.argv[0],"r")
|
|
msg = f.read()
|
|
dlg = wxScrolledMessageDialog(self, msg, "message test")
|
|
dlg.ShowModal()
|
|
|
|
|
|
class MyApp(wxApp):
|
|
def OnInit(self):
|
|
frame = MyFrame()
|
|
frame.Show(TRUE)
|
|
self.SetTopWindow(frame)
|
|
return TRUE
|
|
|
|
app = MyApp(0)
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|