Make all samples in the demo have a panel in the demo notebook. For
those that are frames or dialogs then the panel just has a button that launches it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,28 +1,45 @@
|
|||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a ColourDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
dlg = wx.ColourDialog(self)
|
||||||
|
|
||||||
|
# Ensure the full colour dialog is displayed,
|
||||||
|
# not the abbreviated version.
|
||||||
|
dlg.GetColourData().SetChooseFull(True)
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
|
||||||
|
# If the user selected OK, then the dialog's wx.ColourData will
|
||||||
|
# contain valid information. Fetch the data ...
|
||||||
|
data = dlg.GetColourData()
|
||||||
|
|
||||||
|
# ... then do something with it. The actual colour data will be
|
||||||
|
# returned as a three-tuple (r, g, b) in this particular case.
|
||||||
|
self.log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
||||||
|
|
||||||
|
# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
|
||||||
|
# friend. Don't use it again!
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
dlg = wx.ColourDialog(frame)
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
# Ensure the full colour dialog is displayed,
|
|
||||||
# not the abbreviated version.
|
|
||||||
dlg.GetColourData().SetChooseFull(True)
|
|
||||||
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
|
|
||||||
# If the user selected OK, then the dialog's wx.ColourData will
|
|
||||||
# contain valid information. Fetch the data ...
|
|
||||||
data = dlg.GetColourData()
|
|
||||||
|
|
||||||
# ... then do something with it. The actual colour data will be
|
|
||||||
# returned as a three-tuple (r, g, b) in this particular case.
|
|
||||||
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
|
||||||
|
|
||||||
# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
|
|
||||||
# friend. Don't use it again!
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -86,21 +86,39 @@ class TestDialog(wx.Dialog):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
class TestPanel(wx.Panel):
|
||||||
win = TestDialog(frame, -1, "This is a Dialog", size=(350, 200),
|
def __init__(self, parent, log):
|
||||||
#style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
|
self.log = log
|
||||||
style = wx.DEFAULT_DIALOG_STYLE
|
wx.Panel.__init__(self, parent, -1)
|
||||||
)
|
|
||||||
win.CenterOnScreen()
|
b = wx.Button(self, -1, "Create and Show a custom Dialog", (50,50))
|
||||||
val = win.ShowModal()
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
dlg = TestDialog(self, -1, "This is a Dialog", size=(350, 200),
|
||||||
|
#style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
|
||||||
|
style = wx.DEFAULT_DIALOG_STYLE
|
||||||
|
)
|
||||||
|
dlg.CenterOnScreen()
|
||||||
|
|
||||||
|
# this does not return until the dialog is closed.
|
||||||
|
val = dlg.ShowModal()
|
||||||
|
|
||||||
if val == wx.ID_OK:
|
if val == wx.ID_OK:
|
||||||
log.WriteText("You pressed OK\n")
|
self.log.WriteText("You pressed OK\n")
|
||||||
else:
|
else:
|
||||||
log.WriteText("You pressed Cancel\n")
|
self.log.WriteText("You pressed Cancel\n")
|
||||||
|
|
||||||
win.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@@ -3,24 +3,42 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
# In this case we include a "New directory" button.
|
self.log = log
|
||||||
dlg = wx.DirDialog(frame, "Choose a directory:",
|
wx.Panel.__init__(self, parent, -1)
|
||||||
style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
|
|
||||||
|
|
||||||
# If the user selects OK, then we process the dialog's data.
|
b = wx.Button(self, -1, "Create and Show a DirDialog", (50,50))
|
||||||
# This is done by getting the path data from the dialog - BEFORE
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
# we destroy it.
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
def OnButton(self, evt):
|
||||||
|
# In this case we include a "New directory" button.
|
||||||
|
dlg = wx.DirDialog(self, "Choose a directory:",
|
||||||
|
style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
|
||||||
|
|
||||||
|
# If the user selects OK, then we process the dialog's data.
|
||||||
|
# This is done by getting the path data from the dialog - BEFORE
|
||||||
|
# we destroy it.
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
self.log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||||
|
|
||||||
|
# Only destroy a dialog after you're done with it.
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
# Only destroy a dialog after you're done with it.
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overview = """\
|
overview = """\
|
||||||
This class represents the directory chooser dialog. It is used when all you
|
This class represents the directory chooser dialog. It is used when all you
|
||||||
|
@@ -6,42 +6,116 @@ import wx
|
|||||||
|
|
||||||
# This is how you pre-establish a file filter so that the dialog
|
# This is how you pre-establish a file filter so that the dialog
|
||||||
# only shows the extension(s) you want it to.
|
# only shows the extension(s) you want it to.
|
||||||
wildcard = "Python source (*.py)|*.py|" \
|
wildcard = "Python source (*.py)|*.py|" \
|
||||||
"Compiled Python (*.pyc)|*.pyc|" \
|
"Compiled Python (*.pyc)|*.pyc|" \
|
||||||
|
"SPAM files (*.spam)|*.spam|" \
|
||||||
|
"Egg file (*.egg)|*.egg|" \
|
||||||
"All files (*.*)|*.*"
|
"All files (*.*)|*.*"
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
#---------------------------------------------------------------------------
|
||||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show an OPEN FileDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a SAVE FileDialog", (50,90))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton2, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
self.log.WriteText("CWD: %s\n" % os.getcwd())
|
||||||
|
|
||||||
|
# Create the dialog. In this case the current directory is forced as the starting
|
||||||
|
# directory for the dialog, and no default file name is forced. This can easilly
|
||||||
|
# be changed in your program. This is an 'open' dialog, and allows multitple
|
||||||
|
# file selections as well.
|
||||||
|
#
|
||||||
|
# Finally, if the directory is changed in the process of getting files, this
|
||||||
|
# dialog is set up to change the current working directory to the path chosen.
|
||||||
|
dlg = wx.FileDialog(
|
||||||
|
self, message="Choose a file", defaultDir=os.getcwd(),
|
||||||
|
defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
|
# Show the dialog and retrieve the user response. If it is the OK response,
|
||||||
|
# process the data.
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
# This returns a Python list of files that were selected.
|
||||||
|
paths = dlg.GetPaths()
|
||||||
|
|
||||||
|
self.log.WriteText('You selected %d files:' % len(paths))
|
||||||
|
|
||||||
|
for path in paths:
|
||||||
|
self.log.WriteText(' %s\n' % path)
|
||||||
|
|
||||||
|
# Compare this with the debug above; did we change working dirs?
|
||||||
|
self.log.WriteText("CWD: %s\n" % os.getcwd())
|
||||||
|
|
||||||
|
# Destroy the dialog. Don't do this until you are done with it!
|
||||||
|
# BAD things can happen otherwise!
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton2(self, evt):
|
||||||
|
self.log.WriteText("CWD: %s\n" % os.getcwd())
|
||||||
|
|
||||||
|
# Create the dialog. In this case the current directory is forced as the starting
|
||||||
|
# directory for the dialog, and no default file name is forced. This can easilly
|
||||||
|
# be changed in your program. This is an 'save' dialog.
|
||||||
|
#
|
||||||
|
# Unlike the 'open dialog' example found elsewhere, this example does NOT
|
||||||
|
# force the current working directory to change if the user chooses a different
|
||||||
|
# directory than the one initially set.
|
||||||
|
dlg = wx.FileDialog(
|
||||||
|
self, message="Save file as ...", defaultDir=os.getcwd(),
|
||||||
|
defaultFile="", wildcard=wildcard, style=wx.SAVE
|
||||||
|
)
|
||||||
|
|
||||||
|
# This sets the default filter that the user will initially see. Otherwise,
|
||||||
|
# the first filter in the list will be used by default.
|
||||||
|
dlg.SetFilterIndex(2)
|
||||||
|
|
||||||
|
# Show the dialog and retrieve the user response. If it is the OK response,
|
||||||
|
# process the data.
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
path = dlg.GetPath()
|
||||||
|
self.log.WriteText('You selected "%s"' % path)
|
||||||
|
|
||||||
|
# Normally, at this point you would save your data using the file and path
|
||||||
|
# data that the user provided to you, but since we didn't actually start
|
||||||
|
# with any data to work with, that would be difficult.
|
||||||
|
#
|
||||||
|
# The code to do so would be similar to this, assuming 'data' contains
|
||||||
|
# the data you want to save:
|
||||||
|
#
|
||||||
|
# fp = file(path, 'w') # Create file anew
|
||||||
|
# fp.write(data)
|
||||||
|
# fp.close()
|
||||||
|
#
|
||||||
|
# You might want to add some error checking :-)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Note that the current working dir didn't change. This is good since
|
||||||
|
# that's the way we set it up.
|
||||||
|
self.log.WriteText("CWD: %s\n" % os.getcwd())
|
||||||
|
|
||||||
|
# Destroy the dialog. Don't do this until you are done with it!
|
||||||
|
# BAD things can happen otherwise!
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
# Create the dialog. In this case the current directory is forced as the starting
|
|
||||||
# directory for the dialog, and no default file name is forced. This can easilly
|
|
||||||
# be changed in your program. This is an 'open' dialog, and allows multitple
|
|
||||||
# file selection to boot.
|
|
||||||
#
|
|
||||||
# Finally, of the directory is changed in the process of getting files, this
|
|
||||||
# dialog is set up to change the current working directory to the path chosen.
|
|
||||||
dlg = wx.FileDialog(
|
|
||||||
frame, message="Choose a file", defaultDir=os.getcwd(),
|
|
||||||
defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
|
|
||||||
)
|
|
||||||
|
|
||||||
# Show the dialog and retrieve the user response. If it is the OK response,
|
|
||||||
# process the data.
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
# This returns a Python list of files that were selected.
|
|
||||||
paths = dlg.GetPaths()
|
|
||||||
|
|
||||||
log.WriteText('You selected %d files:' % len(paths))
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
for path in paths:
|
|
||||||
log.WriteText(' %s\n' % path)
|
|
||||||
|
|
||||||
# Compare this with the debug above; did we change working dirs?
|
def runTest(frame, nb, log):
|
||||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
# Destroy the dialog. Don't do this until you are done with it!
|
|
||||||
# BAD things can happen otherwise!
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
|
|
||||||
import os
|
|
||||||
import wx
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# This is how you pre-establish a file filter so that the dialog
|
|
||||||
# only shows the extension(s) you want it to.
|
|
||||||
wildcard = "Python source (*.py)|*.py|" \
|
|
||||||
"Compiled Python (*.pyc)|*.pyc|" \
|
|
||||||
"SPAM files (*.spam)|*.spam|" \
|
|
||||||
"Egg file (*.egg)|*.egg|" \
|
|
||||||
"All files (*.*)|*.*"
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
|
||||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
|
||||||
|
|
||||||
# Create the dialog. In this case the current directory is forced as the starting
|
|
||||||
# directory for the dialog, and no default file name is forced. This can easilly
|
|
||||||
# be changed in your program. This is an 'save' dialog.
|
|
||||||
#
|
|
||||||
# Unlike the 'open dialog' example found elsewhere, this example does NOT
|
|
||||||
# force the current working directory to change if the user chooses a different
|
|
||||||
# directory than the one initially set.
|
|
||||||
dlg = wx.FileDialog(
|
|
||||||
frame, message="Save file as ...", defaultDir=os.getcwd(),
|
|
||||||
defaultFile="", wildcard=wildcard, style=wx.SAVE
|
|
||||||
)
|
|
||||||
|
|
||||||
# This sets the default filter that the user will initially see. Otherwise,
|
|
||||||
# the first filter in the list will be used by default.
|
|
||||||
dlg.SetFilterIndex(2)
|
|
||||||
|
|
||||||
# Show the dialog and retrieve the user response. If it is the OK response,
|
|
||||||
# process the data.
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
path = dlg.GetPath()
|
|
||||||
log.WriteText('You selected "%s"' % path)
|
|
||||||
|
|
||||||
# Normally, at this point you would save your data using the file and path
|
|
||||||
# data that the user provided to you, but since we didn't actually start
|
|
||||||
# with any data to work with, that would be difficult.
|
|
||||||
#
|
|
||||||
# The code to do so would be similar to this, assuming 'data' contains
|
|
||||||
# the data you want to save:
|
|
||||||
#
|
|
||||||
# fp = file(path, 'w') # Create file anew
|
|
||||||
# fp.write(data)
|
|
||||||
# fp.close()
|
|
||||||
#
|
|
||||||
# You might want to add some error checking :-)
|
|
||||||
#
|
|
||||||
|
|
||||||
# Note that the current working dir didn't change. This is good since
|
|
||||||
# that's the way we set it up.
|
|
||||||
log.WriteText("CWD: %s\n" % os.getcwd())
|
|
||||||
|
|
||||||
# Destroy the dialog. Don't do this until you are done with it!
|
|
||||||
# BAD things can happen otherwise!
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
overview = """\
|
|
||||||
This class provides the file selection dialog. It incorporates OS-native features
|
|
||||||
depending on the OS in use, and can be used both for open and save operations.
|
|
||||||
The files displayed can be filtered by setting up a wildcard filter, multiple files
|
|
||||||
can be selected (open only), and files can be forced in a read-only mode.
|
|
||||||
|
|
||||||
There are two ways to get the results back from the dialog. GetFiles() returns only
|
|
||||||
the file names themselves, in a Python list. GetPaths() returns the full path and
|
|
||||||
filenames combined as a Python list.
|
|
||||||
|
|
||||||
One important thing to note: if you use the file extension filters, then files saved
|
|
||||||
with the filter set to something will automatically get that extension appended to them
|
|
||||||
if it is not already there. For example, suppose the dialog was displaying the 'egg'
|
|
||||||
extension and you entered a file name of 'fried'. It would be saved as 'fried.egg.'
|
|
||||||
Yum!
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import sys,os
|
|
||||||
import run
|
|
||||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
|
||||||
|
|
@@ -80,18 +80,34 @@ class TestFloatBar(wx.Frame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
if wx.Platform == "__WXMAC__":
|
||||||
|
dlg = wx.MessageDialog(
|
||||||
|
self, 'FloatBar does not work well on this platform.',
|
||||||
|
'Sorry', wx.OK | wx.ICON_INFORMATION
|
||||||
|
)
|
||||||
|
dlg.ShowModal()
|
||||||
|
dlg.Destroy()
|
||||||
|
else:
|
||||||
|
win = TestFloatBar(self, self.log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
if wx.Platform == "__WXMAC__":
|
win = TestPanel(nb, log)
|
||||||
dlg = wx.MessageDialog(
|
return win
|
||||||
frame, 'FloatBar does not work well on this platform.',
|
|
||||||
'Sorry', wx.OK | wx.ICON_INFORMATION
|
|
||||||
)
|
|
||||||
dlg.ShowModal()
|
|
||||||
dlg.Destroy()
|
|
||||||
else:
|
|
||||||
win = TestFloatBar(frame, log)
|
|
||||||
frame.otherWin = win
|
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -59,16 +59,30 @@ else:
|
|||||||
StartUpDemo = "props"
|
StartUpDemo = "props"
|
||||||
import wx
|
import wx
|
||||||
import time, random
|
import time, random
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the FloatBar sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500))
|
||||||
|
win.Show(True)
|
||||||
|
win.DrawTest()
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
"""
|
win = TestPanel(nb, log)
|
||||||
This method is used by the wxPython Demo Framework for integrating
|
return win
|
||||||
this demo with the rest.
|
|
||||||
"""
|
|
||||||
win = DrawFrame(None, -1, "FloatCanvas Drawing Window",wx.DefaultPosition,(500,500))
|
|
||||||
frame.otherWin = win
|
|
||||||
win.Show(True)
|
|
||||||
win.DrawTest()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from floatcanvas import NavCanvas, FloatCanvas
|
from floatcanvas import NavCanvas, FloatCanvas
|
||||||
|
@@ -26,11 +26,28 @@ class MyFrame(wx.Frame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a Frame", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = MyFrame(self, -1, "This is a wx.Frame", size=(350, 200),
|
||||||
|
style = wx.DEFAULT_FRAME_STYLE)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = MyFrame(frame, -1, "This is a wx.Frame", size=(350, 200),
|
win = TestPanel(nb, log)
|
||||||
style = wx.DEFAULT_FRAME_STYLE)# | wx.FRAME_TOOL_WINDOW )
|
return win
|
||||||
frame.otherWin = win
|
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@@ -117,12 +117,29 @@ assert when compiled in debug mode.""",
|
|||||||
print "item found: ", `item.GetPos()`, "--", `item.GetSpan()`
|
print "item found: ", `item.GetPos()`, "--", `item.GetSpan()`
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the GridBagSizer sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestFrame()
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = TestFrame()
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
@@ -4,6 +4,8 @@ import wx.grid as Grid
|
|||||||
|
|
||||||
import images
|
import images
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class MegaTable(Grid.PyGridTableBase):
|
class MegaTable(Grid.PyGridTableBase):
|
||||||
"""
|
"""
|
||||||
A custom wx.Grid Table using user supplied data
|
A custom wx.Grid Table using user supplied data
|
||||||
@@ -444,10 +446,25 @@ class TestFrame(wx.Frame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the MegaGrid", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestFrame(self)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = TestFrame(frame)
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -13,27 +13,47 @@ import os
|
|||||||
|
|
||||||
import wx
|
import wx
|
||||||
import wx.lib.imagebrowser as ib
|
import wx.lib.imagebrowser as ib
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show an ImageDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
# get current working directory
|
||||||
|
dir = os.getcwd()
|
||||||
|
|
||||||
|
# set the initial directory for the demo bitmaps
|
||||||
|
initial_dir = os.path.join(dir, 'bitmaps')
|
||||||
|
|
||||||
|
# open the image browser dialog
|
||||||
|
dlg = ib.ImageDialog(self, initial_dir)
|
||||||
|
|
||||||
|
dlg.Centre()
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
# show the selected file
|
||||||
|
self.log.WriteText("You Selected File: " + dlg.GetFile())
|
||||||
|
else:
|
||||||
|
self.log.WriteText("You pressed Cancel\n")
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
# get current working directory
|
win = TestPanel(nb, log)
|
||||||
dir = os.getcwd()
|
return win
|
||||||
|
|
||||||
# set the initial directory for the demo bitmaps
|
|
||||||
initial_dir = os.path.join(dir, 'bitmaps')
|
|
||||||
|
|
||||||
# open the image browser dialog
|
|
||||||
win = ib.ImageDialog(frame, initial_dir)
|
|
||||||
|
|
||||||
win.Centre()
|
|
||||||
|
|
||||||
if win.ShowModal() == wx.ID_OK:
|
|
||||||
# show the selected file
|
|
||||||
log.WriteText("You Selected File: " + win.GetFile())
|
|
||||||
else:
|
|
||||||
log.WriteText("You pressed Cancel\n")
|
|
||||||
|
|
||||||
win.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -251,15 +251,28 @@ check the source for this sample to see how to implement them.
|
|||||||
menu.InsertItem(pos, item)
|
menu.InsertItem(pos, item)
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the Menu sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = MyFrame(self, -1, self.log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
wx.RegisterId(10000)
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = MyFrame(frame, -1, log)
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -3,13 +3,32 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a MessageDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
dlg = wx.MessageDialog(self, 'Hello from Python and wxPython!',
|
||||||
|
'A Message Box',
|
||||||
|
wx.OK | wx.ICON_INFORMATION
|
||||||
|
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
|
||||||
|
)
|
||||||
|
dlg.ShowModal()
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!',
|
win = TestPanel(nb, log)
|
||||||
'A Message Box',
|
return win
|
||||||
wx.OK | wx.ICON_INFORMATION)
|
|
||||||
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION)
|
|
||||||
dlg.ShowModal()
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -25,14 +25,29 @@ class MyMiniFrame(wx.MiniFrame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a MiniFrame", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = MyMiniFrame(self, "This is a wx.MiniFrame",
|
||||||
|
style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
|
||||||
|
win.SetSize((200, 200))
|
||||||
|
win.CenterOnParent(wx.BOTH)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = MyMiniFrame(frame, "This is a wx.MiniFrame",
|
win = TestPanel(nb, log)
|
||||||
#pos=(250,250), size=(200,200),
|
return win
|
||||||
style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
|
|
||||||
win.SetSize((200, 200))
|
|
||||||
win.CenterOnParent(wx.BOTH)
|
|
||||||
frame.otherWin = win
|
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@@ -2,21 +2,39 @@
|
|||||||
import wx
|
import wx
|
||||||
import wx.lib.dialogs
|
import wx.lib.dialogs
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a MultipleChoiceDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange', 'grape', 'pineapple',
|
||||||
|
'blueberry', 'raspberry', 'blackberry', 'snozzleberry',
|
||||||
|
'etc', 'etc..', 'etc...' ]
|
||||||
|
|
||||||
|
dlg = wx.lib.dialogs.MultipleChoiceDialog(
|
||||||
|
self,
|
||||||
|
"Pick some from\n this list\nblah blah...",
|
||||||
|
"m.s.d.", lst)
|
||||||
|
|
||||||
|
if (dlg.ShowModal() == wx.ID_OK):
|
||||||
|
self.log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
|
win = TestPanel(nb, log)
|
||||||
'etc', 'etc..', 'etc...' ]
|
return win
|
||||||
|
|
||||||
dlg = wx.lib.dialogs.MultipleChoiceDialog(
|
|
||||||
frame,
|
|
||||||
"Pick some from\n this list\nblah blah...",
|
|
||||||
"m.s.d.", lst)
|
|
||||||
|
|
||||||
if (dlg.ShowModal() == wx.ID_OK):
|
|
||||||
log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -14,11 +14,11 @@ import images
|
|||||||
class TestNB(wx.Notebook):
|
class TestNB(wx.Notebook):
|
||||||
def __init__(self, parent, id, log):
|
def __init__(self, parent, id, log):
|
||||||
wx.Notebook.__init__(self, parent, id, size=(21,21), style=
|
wx.Notebook.__init__(self, parent, id, size=(21,21), style=
|
||||||
#wx.NB_TOP # | wx.NB_MULTILINE
|
#wx.NB_TOP # | wx.NB_MULTILINE
|
||||||
wx.NB_BOTTOM
|
#wx.NB_BOTTOM
|
||||||
#wx.NB_LEFT
|
#wx.NB_LEFT
|
||||||
#wx.NB_RIGHT
|
#wx.NB_RIGHT
|
||||||
)
|
)
|
||||||
self.log = log
|
self.log = log
|
||||||
|
|
||||||
win = self.makeColorPanel(wx.BLUE)
|
win = self.makeColorPanel(wx.BLUE)
|
||||||
|
@@ -3,22 +3,40 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a PageSetupDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
data = wx.PageSetupDialogData()
|
||||||
|
data.SetMarginTopLeft( (15, 15) )
|
||||||
|
data.SetMarginBottomRight( (15, 15) )
|
||||||
|
#data.SetDefaultMinMargins(True)
|
||||||
|
data.SetPaperId(wx.PAPER_LETTER)
|
||||||
|
|
||||||
|
dlg = wx.PageSetupDialog(self, data)
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
data = dlg.GetPageSetupData()
|
||||||
|
tl = data.GetMarginTopLeft()
|
||||||
|
br = data.GetMarginBottomRight()
|
||||||
|
self.log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
data = wx.PageSetupDialogData()
|
win = TestPanel(nb, log)
|
||||||
data.SetMarginTopLeft( (15, 15) )
|
return win
|
||||||
data.SetMarginBottomRight( (15, 15) )
|
|
||||||
#data.SetDefaultMinMargins(True)
|
|
||||||
data.SetPaperId(wx.PAPER_LETTER)
|
|
||||||
|
|
||||||
dlg = wx.PageSetupDialog(frame, data)
|
|
||||||
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
data = dlg.GetPageSetupData()
|
|
||||||
tl = data.GetMarginTopLeft()
|
|
||||||
br = data.GetMarginBottomRight()
|
|
||||||
log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,24 +1,43 @@
|
|||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a PrintDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
data = wx.PrintDialogData()
|
||||||
|
|
||||||
|
data.EnableSelection(True)
|
||||||
|
data.EnablePrintToFile(True)
|
||||||
|
data.EnablePageNumbers(True)
|
||||||
|
data.SetMinPage(1)
|
||||||
|
data.SetMaxPage(5)
|
||||||
|
data.SetAllPages(True)
|
||||||
|
|
||||||
|
dlg = wx.PrintDialog(self, data)
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
data = dlg.GetPrintDialogData()
|
||||||
|
self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
data = wx.PrintDialogData()
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
data.EnableSelection(True)
|
|
||||||
data.EnablePrintToFile(True)
|
|
||||||
data.EnablePageNumbers(True)
|
|
||||||
data.SetMinPage(1)
|
|
||||||
data.SetMaxPage(5)
|
|
||||||
data.SetAllPages(True)
|
|
||||||
|
|
||||||
dlg = wx.PrintDialog(frame, data)
|
|
||||||
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
data = dlg.GetPrintDialogData()
|
|
||||||
log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -12,30 +12,45 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a ProgressDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
max = 20
|
||||||
|
|
||||||
|
dlg = wx.ProgressDialog("Progress dialog example",
|
||||||
|
"An informative message",
|
||||||
|
maximum = max,
|
||||||
|
parent=self,
|
||||||
|
style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
|
||||||
|
|
||||||
|
keepGoing = True
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
while keepGoing and count < max:
|
||||||
|
count = count + 1
|
||||||
|
#print count
|
||||||
|
wx.Sleep(1)
|
||||||
|
|
||||||
|
if count == max / 2:
|
||||||
|
keepGoing = dlg.Update(count, "Half-time!")
|
||||||
|
else:
|
||||||
|
keepGoing = dlg.Update(count)
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
max = 20
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
dlg = wx.ProgressDialog("Progress dialog example",
|
|
||||||
"An informative message",
|
|
||||||
maximum = max,
|
|
||||||
parent=frame,
|
|
||||||
style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
|
|
||||||
|
|
||||||
keepGoing = True
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
while keepGoing and count < max:
|
|
||||||
count = count + 1
|
|
||||||
#print count
|
|
||||||
wx.Sleep(1)
|
|
||||||
|
|
||||||
if count == max / 2:
|
|
||||||
keepGoing = dlg.Update(count, "Half-time!")
|
|
||||||
else:
|
|
||||||
keepGoing = dlg.Update(count)
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -4,13 +4,31 @@ import wx.lib.dialogs
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a ScrolledMessageDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
f = open("Main.py", "r")
|
||||||
|
msg = f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
dlg = wx.lib.dialogs.ScrolledMessageDialog(self, msg, "message test")
|
||||||
|
dlg.ShowModal()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
f = open("Main.py", "r")
|
win = TestPanel(nb, log)
|
||||||
msg = f.read()
|
return win
|
||||||
f.close()
|
|
||||||
|
|
||||||
dlg = wx.lib.dialogs.ScrolledMessageDialog(frame, msg, "message test")
|
|
||||||
dlg.ShowModal()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -90,13 +90,27 @@ class TestFrame(wx.Frame):
|
|||||||
self.Move(fp)
|
self.Move(fp)
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the ShapedWindow sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestFrame(self, self.log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = TestFrame(nb, log)
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -3,18 +3,35 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a SingleChoiceDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
dlg = wx.SingleChoiceDialog(
|
||||||
|
self, 'Test Single Choice', 'The Caption',
|
||||||
|
['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
|
||||||
|
wx.CHOICEDLG_STYLE
|
||||||
|
)
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
self.log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
dlg = wx.SingleChoiceDialog(
|
win = TestPanel(nb, log)
|
||||||
frame, 'Test Single Choice', 'The Caption',
|
return win
|
||||||
['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
|
|
||||||
wx.CHOICEDLG_STYLE
|
|
||||||
)
|
|
||||||
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ class TestCustomStatusBar(wx.Frame):
|
|||||||
self.SetStatusBar(self.sb)
|
self.SetStatusBar(self.sb)
|
||||||
tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE)
|
tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||||
|
|
||||||
self.SetSize((500, 300))
|
self.SetSize((640, 480))
|
||||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||||
|
|
||||||
def OnCloseWindow(self, event):
|
def OnCloseWindow(self, event):
|
||||||
@@ -94,10 +94,26 @@ class TestCustomStatusBar(wx.Frame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the StatusBar sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestCustomStatusBar(self, self.log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = TestCustomStatusBar(frame, log)
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -3,18 +3,36 @@ import wx
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Create and Show a TextEntryDialog", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
dlg = wx.TextEntryDialog(
|
||||||
|
self, 'What is your favorite programming language?',
|
||||||
|
'Eh??', 'Python')
|
||||||
|
|
||||||
|
dlg.SetValue("Python is the best!")
|
||||||
|
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
self.log.WriteText('You entered: %s\n' % dlg.GetValue())
|
||||||
|
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
dlg = wx.TextEntryDialog(
|
win = TestPanel(nb, log)
|
||||||
frame, 'What is your favorite programming language?',
|
return win
|
||||||
'Eh??', 'Python')
|
|
||||||
|
|
||||||
dlg.SetValue("Python is the best!")
|
|
||||||
|
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
log.WriteText('You entered: %s\n' % dlg.GetValue())
|
|
||||||
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -212,19 +212,35 @@ class TestFrame(wx.Frame):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show Threads sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestFrame(frame, log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
win = TestFrame(frame, log)
|
win = TestPanel(nb, log)
|
||||||
frame.otherWin = win
|
return win
|
||||||
win.Show(True)
|
|
||||||
return None
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overview = """\
|
overview = """\
|
||||||
The main issue with multi-threaded GUI programming is the thread safty
|
The main issue with multi-threaded GUI programming is the thread safty
|
||||||
of the GUI itself. On most platforms the GUI is not thread safe and
|
of the GUI itself. On most platforms the GUI is not thread safe and
|
||||||
|
@@ -118,14 +118,31 @@ class TestToolBar(wx.Frame):
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
class TestPanel(wx.Panel):
|
||||||
win = TestToolBar(frame, log)
|
def __init__(self, parent, log):
|
||||||
frame.otherWin = win
|
self.log = log
|
||||||
win.Show(True)
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
b = wx.Button(self, -1, "Show the ToolBar sample", (50,50))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
|
||||||
|
|
||||||
|
|
||||||
|
def OnButton(self, evt):
|
||||||
|
win = TestToolBar(self, self.log)
|
||||||
|
win.Show(True)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overview = """\
|
overview = """\
|
||||||
wx.ToolBar is a narrow strip of icons on one side of a frame (top, bottom, sides)
|
wx.ToolBar is a narrow strip of icons on one side of a frame (top, bottom, sides)
|
||||||
|
Reference in New Issue
Block a user