| 1 | from wxPython.wx import * |
| 2 | from wxPython.lib.multisash import wxMultiSash |
| 3 | from wxPython.stc import * |
| 4 | |
| 5 | #--------------------------------------------------------------------------- |
| 6 | |
| 7 | sampleText="""\ |
| 8 | You can drag the little tab on the vertical sash left to create another view, |
| 9 | or you can drag the tab on the horizontal sash to the top to create another |
| 10 | horizontal view. |
| 11 | |
| 12 | The red blocks on the sashes will destroy the view (bottom,left) this block |
| 13 | belongs to. |
| 14 | |
| 15 | A yellow rectangle also highlights the current selected view. |
| 16 | |
| 17 | By calling GetSaveData on the multiSash control the control will return its |
| 18 | contents and the positions of each sash as a dictionary. |
| 19 | Calling SetSaveData with such a dictionary will restore the control to the |
| 20 | state it was in when it was saved. |
| 21 | |
| 22 | If the class, that is used as a view, has GetSaveData/SetSaveData implemented, |
| 23 | these will also be called to save/restore their state. Any object can be |
| 24 | returned by GetSaveData, as it is just another object in the dictionary. |
| 25 | """ |
| 26 | |
| 27 | #--------------------------------------------------------------------------- |
| 28 | |
| 29 | class TestWindow(wxStyledTextCtrl): |
| 30 | def __init__(self, parent): |
| 31 | wxStyledTextCtrl.__init__(self, parent, -1, style=wxNO_BORDER) |
| 32 | self.SetMarginWidth(1,0) |
| 33 | if wxPlatform == '__WXMSW__': |
| 34 | fSize = 10 |
| 35 | else: |
| 36 | fSize = 12 |
| 37 | self.StyleSetFont(wxSTC_STYLE_DEFAULT, |
| 38 | wxFont(fSize, wxMODERN, wxNORMAL, wxNORMAL)) |
| 39 | self.SetText(sampleText) |
| 40 | |
| 41 | class TestFrame(wxFrame): |
| 42 | def __init__(self, parent, log): |
| 43 | wxFrame.__init__(self, parent, -1, "Multi Sash Demo", |
| 44 | size=(640,480)) |
| 45 | self.multi = wxMultiSash(self,-1,pos = wxPoint(0,0), |
| 46 | size = (640,480)) |
| 47 | |
| 48 | # Use this method to set the default class that will be created when |
| 49 | # a new sash is created. The class's constructor needs 1 parameter |
| 50 | # which is the parent of the window |
| 51 | self.multi.SetDefaultChildClass(TestWindow) |
| 52 | |
| 53 | |
| 54 | #--------------------------------------------------------------------------- |
| 55 | |
| 56 | |
| 57 | def runTest(frame, nb, log): |
| 58 | multi = wxMultiSash(nb, -1, pos = (0,0), size = (640,480)) |
| 59 | |
| 60 | # Use this method to set the default class that will be created when |
| 61 | # a new sash is created. The class's constructor needs 1 parameter |
| 62 | # which is the parent of the window |
| 63 | multi.SetDefaultChildClass(TestWindow) |
| 64 | |
| 65 | return multi |
| 66 | |
| 67 | # win = TestPanel(nb, log) |
| 68 | # return win |
| 69 | |
| 70 | #---------------------------------------------------------------------- |
| 71 | |
| 72 | |
| 73 | |
| 74 | overview = """<html><body> |
| 75 | <h2><center>wxMultiSash</center></h2> |
| 76 | |
| 77 | wxMultiSash allows the user to split a window any number of times |
| 78 | either horizontally or vertically, and to close the split off windows |
| 79 | when desired. |
| 80 | |
| 81 | </body></html> |
| 82 | """ |
| 83 | |
| 84 | |
| 85 | |
| 86 | if __name__ == '__main__': |
| 87 | import sys,os |
| 88 | import run |
| 89 | run.main(['', os.path.basename(sys.argv[0])]) |
| 90 | |