Fixes and other changes to the demo and some library modules so they

work better (or at all) on wxMac


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16500 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2002-08-13 23:59:08 +00:00
parent c50c32efd1
commit eb0f373c99
17 changed files with 133 additions and 61 deletions

View File

@ -306,8 +306,8 @@ class wxPythonDemo(wxFrame):
self.treeMap = {} self.treeMap = {}
self.tree = wxTreeCtrl(splitter, tID, self.tree = wxTreeCtrl(splitter, tID,
style=wxTR_HAS_BUTTONS | style=wxTR_HAS_BUTTONS |
wxTR_EDIT_LABELS | wxTR_HAS_VARIABLE_ROW_HEIGHT
wxTR_HAS_VARIABLE_ROW_HEIGHT) )
#self.tree.SetBackgroundColour(wxNamedColour("Pink")) #self.tree.SetBackgroundColour(wxNamedColour("Pink"))
root = self.tree.AddRoot("wxPython Overview") root = self.tree.AddRoot("wxPython Overview")

View File

@ -33,7 +33,7 @@ class RunDemoApp(wxApp):
def __init__(self, name, module): def __init__(self, name, module):
self.name = name self.name = name
self.demoModule = module self.demoModule = module
wxApp.__init__(self, wxPlatform == "__WXMAC__") wxApp.__init__(self, 0) ##wxPlatform == "__WXMAC__")
def OnInit(self): def OnInit(self):

View File

@ -165,11 +165,13 @@ class TestPanel(wxPanel):
def OnSelectClient(self, evt): def OnSelectClient(self, evt):
self.log.write("OnSelectClient\n")
self.client = eval(evt.GetString()) self.client = eval(evt.GetString())
self.getArt() self.getArt()
def OnSelectID(self, evt): def OnSelectID(self, evt):
self.log.write("OnSelectID\n")
self.artid = eval(evt.GetString()) self.artid = eval(evt.GetString())
self.getArt() self.getArt()

View File

@ -62,7 +62,10 @@ class TestPanel(wxPanel):
monthlist = GetMonthList() monthlist = GetMonthList()
mID = NewId() mID = NewId()
self.date = wxComboBox(self, mID, Month[start_month], wxPoint(100, 20), wxSize(90, -1), monthlist, wxCB_DROPDOWN) self.date = wxComboBox(self, mID, "",
wxPoint(100, 20), wxSize(90, -1),
monthlist, wxCB_DROPDOWN)
self.date.SetSelection(start_month-1)
EVT_COMBOBOX(self, mID, self.EvtComboBox) EVT_COMBOBOX(self, mID, self.EvtComboBox)
# set start month and year # set start month and year

View File

@ -1,10 +1,15 @@
from wxPython.wx import * from wxPython.wx import *
import string
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
wildcard = "Python source (*.py)|*.py|" \
"Compiled Python (*.pyc)|*.pyc|" \
"All files (*.*)|*.*"
def runTest(frame, nb, log): def runTest(frame, nb, log):
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN|wxMULTIPLE) dlg = wxFileDialog(frame, "Choose a file", "", "", wildcard, wxOPEN|wxMULTIPLE)
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
for path in dlg.GetPaths(): for path in dlg.GetPaths():
log.WriteText('You selected: %s\n' % path) log.WriteText('You selected: %s\n' % path)

View File

@ -8,8 +8,9 @@ def runTest(frame, nb, log):
data.EnableEffects(true) data.EnableEffects(true)
font_colour = wxColour(255, 0, 0) # colour of font (red) font_colour = wxColour(255, 0, 0) # colour of font (red)
data.SetColour(font_colour) # set colour data.SetColour(font_colour) # set colour
print data.GetColour() ##print data.GetColour()
dlg = wxFontDialog(frame, data) dlg = wxFontDialog(frame, data)
dlg.SetSize((250,250))
if dlg.ShowModal() == wxID_OK: if dlg.ShowModal() == wxID_OK:
data = dlg.GetFontData() data = dlg.GetFontData()
font = data.GetChosenFont() font = data.GetChosenFont()

View File

@ -19,6 +19,12 @@ class MyFrame(wxFrame):
self.CreateStatusBar() self.CreateStatusBar()
self.SetStatusText("This is the statusbar") self.SetStatusText("This is the statusbar")
tc = wxTextCtrl(self, -1, """
A bunch of bogus menus have been created for this frame. You
can play around with them to see how they behave and then
check the source for this sample to see how to implement them.
""", style=wxTE_READONLY|wxTE_MULTILINE)
# Prepare the menu bar # Prepare the menu bar
menuBar = wxMenuBar() menuBar = wxMenuBar()
@ -28,7 +34,7 @@ class MyFrame(wxFrame):
menu1.Append(102, "Venus", "") menu1.Append(102, "Venus", "")
menu1.Append(103, "Earth", "You may select Earth too") menu1.Append(103, "Earth", "You may select Earth too")
menu1.AppendSeparator() menu1.AppendSeparator()
menu1.Append(104, "Exit", "Close this frame") menu1.Append(104, "Close", "Close this frame")
# Add menu to the menu bar # Add menu to the menu bar
menuBar.Append(menu1, "&Planets") menuBar.Append(menu1, "&Planets")

View File

@ -19,7 +19,8 @@ class TestNB(wxNotebook):
self.AddPage(win, "Blue") self.AddPage(win, "Blue")
st = wxStaticText(win, -1, st = wxStaticText(win, -1,
"You can put nearly any type of window here,\n" "You can put nearly any type of window here,\n"
"and the tabs can be on any side... (look below.)", "and if the platform supports it then the\n"
"tabs can be on any side of the notebook.",
wxPoint(10, 10)) wxPoint(10, 10))
st.SetForegroundColour(wxWHITE) st.SetForegroundColour(wxWHITE)
st.SetBackgroundColour(wxBLUE) st.SetBackgroundColour(wxBLUE)

View File

@ -1,5 +1,12 @@
from wxPython.wx import * from wxPython.wx import *
havePopupWindow = 1
try:
wxPopupWindow
except NameError:
havePopupWindow = 0
wxPopupWindow = wxPopupTransientWindow = wxWindow
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class TestPopup(wxPopupWindow): class TestPopup(wxPopupWindow):
@ -158,8 +165,14 @@ class TestPopupWithListbox(wxPopupWindow):
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def runTest(frame, nb, log): def runTest(frame, nb, log):
if havePopupWindow:
win = TestPanel(nb, log) win = TestPanel(nb, log)
return win return win
else:
dlg = wxMessageDialog(frame, 'wxPopupWindow is not available on this platform.',
'Sorry', wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@ -13,7 +13,7 @@ def runTest(frame, nb, log):
keepGoing = true keepGoing = true
count = 0 count = 0
while keepGoing and count <= max: while keepGoing and count < max:
count = count + 1 count = count + 1
wxSleep(1) wxSleep(1)

View File

@ -3,6 +3,11 @@ from wxPython.wx import *
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
RBOX1 = wxNewId()
RBOX2 = wxNewId()
RBUT1 = wxNewId()
RBUT2 = wxNewId()
class TestRadioButtons(wxPanel): class TestRadioButtons(wxPanel):
def __init__(self, parent, log): def __init__(self, parent, log):
self.log = log self.log = log
@ -12,20 +17,32 @@ class TestRadioButtons(wxPanel):
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
'six', 'seven', 'eight'] 'six', 'seven', 'eight']
rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(35, 30), wxDefaultSize, sizer = wxBoxSizer(wxVERTICAL)
sampleList, 3, wxRA_SPECIFY_COLS) rb = wxRadioBox(self, RBOX1, "wxRadioBox",
EVT_RADIOBOX(self, 30, self.EvtRadioBox) wxDefaultPosition, wxDefaultSize,
sampleList, 2, wxRA_SPECIFY_COLS)
EVT_RADIOBOX(self, RBOX1, self.EvtRadioBox)
#rb.SetBackgroundColour(wxBLUE) #rb.SetBackgroundColour(wxBLUE)
rb.SetToolTip(wxToolTip("This is a ToolTip!")) rb.SetToolTip(wxToolTip("This is a ToolTip!"))
#rb.SetLabel("wxRadioBox")
sizer.Add(rb, 0, wxALL, 20)
wxRadioButton(self, 32, "wxRadioButton", (235, 35)) rb = wxRadioBox(self, RBOX2, "", wxDefaultPosition, wxDefaultSize,
wxRadioButton(self, 33, "wxRadioButton", (235, 55))
EVT_RADIOBUTTON(self, 32, self.EvtRadioButton)
EVT_RADIOBUTTON(self, 33, self.EvtRadioButton)
rb = wxRadioBox(self, 35, "", wxPoint(35, 120), wxDefaultSize,
sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER) sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER)
EVT_RADIOBOX(self, 35, self.EvtRadioBox) EVT_RADIOBOX(self, RBOX2, self.EvtRadioBox)
rb.SetToolTip(wxToolTip("This box has no label"))
sizer.Add(rb, 0, wxLEFT|wxRIGHT|wxBOTTOM, 20)
sizer.Add(wxStaticText(self, -1, "These are plain wxRadioButtons"),
0, wxLEFT|wxRIGHT, 20)
sizer.Add(wxRadioButton(self, RBUT1, "wxRadioButton 1"),
0, wxLEFT|wxRIGHT, 20)
sizer.Add(wxRadioButton(self, RBUT2, "wxRadioButton 2"),
0, wxLEFT|wxRIGHT, 20)
EVT_RADIOBUTTON(self, RBUT1, self.EvtRadioButton)
EVT_RADIOBUTTON(self, RBUT2, self.EvtRadioButton)
self.SetSizer(sizer)
def EvtRadioBox(self, event): def EvtRadioBox(self, event):

View File

@ -71,12 +71,14 @@ class CustomStatusBar(wxStatusBar):
class TestCustomStatusBar(wxFrame): class TestCustomStatusBar(wxFrame):
def __init__(self, parent, log): def __init__(self, parent, log):
wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar', wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar')
wxPoint(0,0), wxSize(500, 300)) #wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
self.sb = CustomStatusBar(self, log) self.sb = CustomStatusBar(self, log)
self.SetStatusBar(self.sb) self.SetStatusBar(self.sb)
tc = wxTextCtrl(self, -1, "", style=wxTE_READONLY|wxTE_MULTILINE)
self.SetSize((500, 300))
EVT_CLOSE(self, self.OnCloseWindow) EVT_CLOSE(self, self.OnCloseWindow)
def OnCloseWindow(self, event): def OnCloseWindow(self, event):

View File

@ -1,6 +1,12 @@
from wxPython.wx import * from wxPython.wx import *
haveToggleBtn = 1
try:
wxToggleButton
except NameError:
haveToggleBtn = 0
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class TestPanel(wxPanel): class TestPanel(wxPanel):
@ -25,8 +31,16 @@ class TestPanel(wxPanel):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def runTest(frame, nb, log): def runTest(frame, nb, log):
if haveToggleBtn:
win = TestPanel(nb, log) win = TestPanel(nb, log)
return win return win
else:
dlg = wxMessageDialog(frame, 'wxToggleButton is not available on this platform.',
'Sorry', wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -54,6 +54,7 @@ class TestToolBar(wxFrame):
EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all
EVT_TIMER(self, -1, self.OnClearSB) EVT_TIMER(self, -1, self.OnClearSB)
if wxPlatform != "__WXMAC__":
tb.AddSeparator() tb.AddSeparator()
cbID = wxNewId() cbID = wxNewId()
tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"], tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],

View File

@ -17,7 +17,7 @@ progDir="`dirname \"$0\"`"
defSrcPath="/projects/wx" defSrcPath="/projects/wx"
defDstPath="/projects/wx/wxPython/dist" defDstPath="/projects/wx/wxPython/dist"
pkgName="wxMacPython" pkgName="wxPythonOSX"
#version=`date +"%Y-%m-%d"` #version=`date +"%Y-%m-%d"`
version=`cd $defSrcPath/wxPython; python$PYVER -c 'import setup;print setup.VERSION'` version=`cd $defSrcPath/wxPython; python$PYVER -c 'import setup;print setup.VERSION'`

View File

@ -159,8 +159,13 @@ class wxGenButton(wxPyControl):
highlightClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNHIGHLIGHT) highlightClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNHIGHLIGHT)
self.shadowPen = wxPen(shadowClr, 1, wxSOLID) self.shadowPen = wxPen(shadowClr, 1, wxSOLID)
self.highlightPen = wxPen(highlightClr, 1, wxSOLID) self.highlightPen = wxPen(highlightClr, 1, wxSOLID)
if wxPlatform == "__WXMAC__":
self.focusIndPen = wxPen(textClr, 1, wxSOLID)
else:
self.focusIndPen = wxPen(textClr, 1, wxUSER_DASH) self.focusIndPen = wxPen(textClr, 1, wxUSER_DASH)
##self.focusIndPen = wxPen(textClr, 1, wxDOT) self.focusIndPen.SetDashes([1,1])
self.focusIndPen.SetCap(wxCAP_BUTT)
self.focusClr = highlightClr
def SetBackgroundColour(self, colour): def SetBackgroundColour(self, colour):
@ -176,6 +181,7 @@ class wxGenButton(wxPyControl):
self.shadowPen = wxPen(wxColour(sr,sg,sb), 1, wxSOLID) self.shadowPen = wxPen(wxColour(sr,sg,sb), 1, wxSOLID)
hr, hg, hb = min(255,r+64), min(255,g+64), min(255,b+64) hr, hg, hb = min(255,r+64), min(255,g+64), min(255,b+64)
self.highlightPen = wxPen(wxColour(hr,hg,hb), 1, wxSOLID) self.highlightPen = wxPen(wxColour(hr,hg,hb), 1, wxSOLID)
self.focusClr = wxColour(hr, hg, hb)
def _GetLabelSize(self): def _GetLabelSize(self):
@ -227,15 +233,17 @@ class wxGenButton(wxPyControl):
def DrawFocusIndicator(self, dc, w, h): def DrawFocusIndicator(self, dc, w, h):
bw = self.bezelWidth bw = self.bezelWidth
if self.hasFocus: ## if self.hasFocus:
self.focusIndPen.SetColour(self.GetForegroundColour()) ## self.focusIndPen.SetColour(self.GetForegroundColour())
else: ## else:
self.focusIndPen.SetColour(self.GetBackgroundColour()) ## #self.focusIndPen.SetColour(self.GetBackgroundColour())
self.focusIndPen.SetDashes([1,1]) ## self.focusIndPen.SetColour(self.GetForegroundColour())
self.focusIndPen.SetCap(wxCAP_BUTT) self.focusIndPen.SetColour(self.focusClr)
dc.SetLogicalFunction(wxINVERT)
dc.SetPen(self.focusIndPen) dc.SetPen(self.focusIndPen)
dc.SetBrush(wxTRANSPARENT_BRUSH) dc.SetBrush(wxTRANSPARENT_BRUSH)
dc.DrawRectangle(bw+2,bw+2, w-bw*2-4, h-bw*2-4) dc.DrawRectangle(bw+2,bw+2, w-bw*2-4, h-bw*2-4)
dc.SetLogicalFunction(wxCOPY)
def OnPaint(self, event): def OnPaint(self, event):

View File

@ -158,8 +158,9 @@ class wxEditor(wxScrolledWindow):
def UpdateView(self, dc = None): def UpdateView(self, dc = None):
if not dc: if dc is None:
dc = wxClientDC(self) dc = wxClientDC(self)
if dc.Ok():
self.SetCharDimensions() self.SetCharDimensions()
self.KeepCursorOnScreen() self.KeepCursorOnScreen()
self.DrawSimpleCursor(0,0,dc, true) self.DrawSimpleCursor(0,0,dc, true)
@ -188,9 +189,7 @@ class wxEditor(wxScrolledWindow):
self.selectColor = wxColour(238, 220, 120) # r, g, b = emacsOrange self.selectColor = wxColour(238, 220, 120) # r, g, b = emacsOrange
def InitDoubleBuffering(self): def InitDoubleBuffering(self):
bw,bh = self.GetClientSizeTuple() pass
self.mdc = wxMemoryDC()
self.mdc.SelectObject(wxEmptyBitmap(bw,bh))
def DrawEditText(self, t, x, y, dc): def DrawEditText(self, t, x, y, dc):
dc.DrawText(t, x * self.fw, y * self.fh) dc.DrawText(t, x * self.fw, y * self.fh)
@ -218,9 +217,10 @@ class wxEditor(wxScrolledWindow):
if not odc: if not odc:
odc = wxClientDC(self) odc = wxClientDC(self)
dc = self.mdc bmp = wxEmptyBitmap(max(1,self.bw), max(1,self.bh))
dc = wxBufferedDC(odc, bmp)
if dc.Ok():
dc.SetFont(self.font) dc.SetFont(self.font)
dc.SelectObject(wxEmptyBitmap(self.bw,self.bh))
dc.SetBackgroundMode(wxSOLID) dc.SetBackgroundMode(wxSOLID)
dc.SetTextBackground(self.bgColor) dc.SetTextBackground(self.bgColor)
dc.SetTextForeground(self.fgColor) dc.SetTextForeground(self.fgColor)
@ -229,8 +229,7 @@ class wxEditor(wxScrolledWindow):
self.DrawLine(line, dc) self.DrawLine(line, dc)
if len(self.lines) < self.sh + self.sy: if len(self.lines) < self.sh + self.sy:
self.DrawEofMarker(dc) self.DrawEofMarker(dc)
odc.Blit(0,0,self.bw,self.bh,dc,0,0,wxCOPY) self.DrawCursor(dc)
self.DrawCursor(odc)
##------------------ eofMarker stuff ##------------------ eofMarker stuff