X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1462dfa3496ba7288691376c1de4c890d90787c..cfe17b74353dcf5ed47c1449e6e415aeb0f1c295:/utils/wxPython/demo/CustomDragAndDrop.py diff --git a/utils/wxPython/demo/CustomDragAndDrop.py b/utils/wxPython/demo/CustomDragAndDrop.py index 2756121871..560eada75c 100644 --- a/utils/wxPython/demo/CustomDragAndDrop.py +++ b/utils/wxPython/demo/CustomDragAndDrop.py @@ -169,12 +169,15 @@ class CustomDnDPanel(wxPanel): self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false)) sizer = wxBoxSizer(wxHORIZONTAL) - sizer.Add(wxStaticText(self, -1, - "Draw a little picture in this window\n" - "then Ctrl-Drag it to the lower \n" - "window or to another application\n" - "that accepts BMP's as a drop target."), - 1, wxEXPAND|wxALL, 10) + text = wxStaticText(self, -1, + "Draw a little picture in this window\n" + "then Ctrl-Drag it to the lower \n" + "window or to another application\n" + "that accepts BMP's as a drop target.\n\n" + "The lower window is accepting a\n" + "custom data type that is a pickled\n" + "Python list of lines data.") + sizer.Add(text, 1, wxALL, 10) insizer = wxBoxSizer(wxVERTICAL) insizer.Add(DoodlePad(self, log), 1, wxEXPAND|wxALL, 5) @@ -197,9 +200,12 @@ class TestPanel(wxPanel): self.SetAutoLayout(true) sizer = wxBoxSizer(wxVERTICAL) + msg = "Custom Drag-And-Drop" text = wxStaticText(self, -1, "", style=wxALIGN_CENTRE) text.SetFont(wxFont(24, wxSWISS, wxNORMAL, wxBOLD, false)) - text.SetLabel("Custom Drag-And-Drop") + text.SetLabel(msg) + w,h = text.GetTextExtent(msg) + text.SetSize(wxSize(w,h+1)) text.SetForegroundColour(wxBLUE) sizer.Add(text, 0, wxEXPAND|wxALL, 5) sizer.Add(wxStaticLine(self, -1), 0, wxEXPAND) @@ -215,6 +221,35 @@ def runTest(frame, nb, log): win = TestPanel(nb, log) return win + +if __name__ == '__main__': + import sys + class DummyLog: + def WriteText(self, text): + sys.stdout.write(text) + + class TestApp(wxApp): + def OnInit(self): + self.MakeFrame() + return true + + def MakeFrame(self, event=None): + frame = wxFrame(None, -1, "Custom Drag and Drop", size=(550,400)) + menu = wxMenu() + menu.Append(6543, "Window") + mb = wxMenuBar() + mb.Append(menu, "New") + frame.SetMenuBar(mb) + EVT_MENU(frame, 6543, self.MakeFrame) + panel = TestPanel(frame, DummyLog()) + frame.Show(true) + self.SetTopWindow(frame) + + + + app = TestApp(0) + app.MainLoop() + #---------------------------------------------------------------------- @@ -229,9 +264,10 @@ def runTest(frame, nb, log): overview = """\ -This demo shows Drand and Drop using a custom data type and a custom data object. A type called "DoodleLines" is created and a Python Pickle of a list is actually transfered in the drag and drop opperation. +This demo shows Drag and Drop using a custom data type and a custom data object. A type called "DoodleLines" is created and a Python Pickle of a list is actually transfered in the drag and drop opperation. A second data object is also created containing a bitmap of the image and is made available to any drop target that accepts bitmaps, such as MS Word. The two data objects are combined in a wxDataObjectComposite and the rest is handled by the framework. """ +