Some little demo tweaks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -82,7 +82,7 @@ class DoodlePad(wx.Window):
|
|||||||
|
|
||||||
# create our own data format and use it in a
|
# create our own data format and use it in a
|
||||||
# custom data object
|
# custom data object
|
||||||
ldata = wx.CustomDataObject(wx.CustomDataFormat("DoodleLines"))
|
ldata = wx.CustomDataObject("DoodleLines")
|
||||||
ldata.SetData(linesdata)
|
ldata.SetData(linesdata)
|
||||||
|
|
||||||
# Also create a Bitmap version of the drawing
|
# Also create a Bitmap version of the drawing
|
||||||
@@ -125,8 +125,7 @@ class DoodleDropTarget(wx.PyDropTarget):
|
|||||||
self.dv = window
|
self.dv = window
|
||||||
|
|
||||||
# specify the type of data we will accept
|
# specify the type of data we will accept
|
||||||
self.df = wx.CustomDataFormat("DoodleLines")
|
self.data = wx.CustomDataObject("DoodleLines")
|
||||||
self.data = wx.CustomDataObject(self.df)
|
|
||||||
self.SetDataObject(self.data)
|
self.SetDataObject(self.data)
|
||||||
|
|
||||||
|
|
||||||
@@ -216,8 +215,8 @@ class CustomDnDPanel(wx.Panel):
|
|||||||
"Draw a little picture in this window\n"
|
"Draw a little picture in this window\n"
|
||||||
"then switch the mode below and drag the\n"
|
"then switch the mode below and drag the\n"
|
||||||
"picture to the lower window or to another\n"
|
"picture to the lower window or to another\n"
|
||||||
"application that accepts BMP's as a drop\n"
|
"application that accepts Bitmaps as a\n"
|
||||||
"target.\n"
|
"drop target.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
rb1 = wx.RadioButton(self, -1, "Draw", style=wx.RB_GROUP)
|
rb1 = wx.RadioButton(self, -1, "Draw", style=wx.RB_GROUP)
|
||||||
|
@@ -48,16 +48,19 @@ class ClipTextPanel(wx.Panel):
|
|||||||
def OnCopy(self, evt):
|
def OnCopy(self, evt):
|
||||||
self.do = wx.TextDataObject()
|
self.do = wx.TextDataObject()
|
||||||
self.do.SetText(self.text.GetValue())
|
self.do.SetText(self.text.GetValue())
|
||||||
wx.TheClipboard.Open()
|
if wx.TheClipboard.Open():
|
||||||
wx.TheClipboard.SetData(self.do)
|
wx.TheClipboard.SetData(self.do)
|
||||||
wx.TheClipboard.Close()
|
wx.TheClipboard.Close()
|
||||||
|
else:
|
||||||
|
wx.MessageBox("Unable to open the clipboard", "Error")
|
||||||
|
|
||||||
|
|
||||||
def OnPaste(self, evt):
|
def OnPaste(self, evt):
|
||||||
|
success = False
|
||||||
do = wx.TextDataObject()
|
do = wx.TextDataObject()
|
||||||
wx.TheClipboard.Open()
|
if wx.TheClipboard.Open():
|
||||||
success = wx.TheClipboard.GetData(do)
|
success = wx.TheClipboard.GetData(do)
|
||||||
wx.TheClipboard.Close()
|
wx.TheClipboard.Close()
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
self.text.SetValue(do.GetText())
|
self.text.SetValue(do.GetText())
|
||||||
@@ -73,14 +76,19 @@ class ClipTextPanel(wx.Panel):
|
|||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
bmp = wx.Bitmap(dlg.GetPath(), wx.BITMAP_TYPE_BMP)
|
bmp = wx.Bitmap(dlg.GetPath(), wx.BITMAP_TYPE_BMP)
|
||||||
bmpdo = wx.BitmapDataObject(bmp)
|
bmpdo = wx.BitmapDataObject(bmp)
|
||||||
wx.TheClipboard.Open()
|
if wx.TheClipboard.Open():
|
||||||
wx.TheClipboard.SetData(bmpdo)
|
wx.TheClipboard.SetData(bmpdo)
|
||||||
wx.TheClipboard.Close()
|
wx.TheClipboard.Close()
|
||||||
|
|
||||||
wx.MessageBox(
|
wx.MessageBox(
|
||||||
"The bitmap is now in the Clipboard. Switch to a graphics\n"
|
"The bitmap is now in the Clipboard. Switch to a graphics\n"
|
||||||
"editor and try pasting it in..."
|
"editor and try pasting it in..."
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
wx.MessageBox(
|
||||||
|
"There is no data in the clipboard in the required format",
|
||||||
|
"Error"
|
||||||
|
)
|
||||||
|
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
@@ -132,7 +132,7 @@ class TestPrintPanel(wx.Panel):
|
|||||||
printerDialog.ShowModal();
|
printerDialog.ShowModal();
|
||||||
|
|
||||||
# this makes a copy of the wx.PrintData instead of just saving
|
# this makes a copy of the wx.PrintData instead of just saving
|
||||||
# a reference to the one inside the printDialogData that will
|
# a reference to the one inside the PrintDialogData that will
|
||||||
# be destroyed when the dialog is destroyed
|
# be destroyed when the dialog is destroyed
|
||||||
self.printData = wx.PrintData( printerDialog.GetPrintDialogData().GetPrintData() )
|
self.printData = wx.PrintData( printerDialog.GetPrintDialogData().GetPrintData() )
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user