]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/Sizers.py
Committing in .
[wxWidgets.git] / wxPython / demo / Sizers.py
... / ...
CommitLineData
1#----------------------------------------------------------------------
2# sizer test code
3#----------------------------------------------------------------------
4
5from wxPython.wx import *
6from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer
7
8#----------------------------------------------------------------------
9
10def makeSimpleBox1(win):
11 box = wxBoxSizer(wxHORIZONTAL)
12 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
13 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
14 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
15 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
16
17 return box
18
19#----------------------------------------------------------------------
20
21def makeSimpleBox2(win):
22 box = wxBoxSizer(wxVERTICAL)
23 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
24 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
25 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
26 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
27
28 return box
29
30#----------------------------------------------------------------------
31
32def makeSimpleBox3(win):
33 box = wxBoxSizer(wxHORIZONTAL)
34 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
35 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
36 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
37 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
38 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
39
40 return box
41
42#----------------------------------------------------------------------
43
44def makeSimpleBox4(win):
45 box = wxBoxSizer(wxHORIZONTAL)
46 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
47 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
48 box.Add(wxButton(win, 1010, "three"), 1, wxEXPAND)
49 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
50 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
51
52 return box
53
54#----------------------------------------------------------------------
55
56def makeSimpleBox5(win):
57 box = wxBoxSizer(wxHORIZONTAL)
58 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
59 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
60 box.Add(wxButton(win, 1010, "three"), 3, wxEXPAND)
61 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
62 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
63
64 return box
65
66#----------------------------------------------------------------------
67
68def makeSimpleBox6(win):
69 box = wxBoxSizer(wxHORIZONTAL)
70 box.Add(wxButton(win, 1010, "one"), 1, wxALIGN_TOP)
71 box.Add(wxButton(win, 1010, "two"), 1, wxEXPAND)
72 box.Add(wxButton(win, 1010, "three"), 1, wxALIGN_CENTER)
73 box.Add(wxButton(win, 1010, "four"), 1, wxEXPAND)
74 box.Add(wxButton(win, 1010, "five"), 1, wxALIGN_BOTTOM)
75
76 return box
77
78#----------------------------------------------------------------------
79
80def makeSimpleBox7(win):
81 box = wxBoxSizer(wxHORIZONTAL)
82 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
83 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
84 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
85 box.Add(60, 20, 0, wxEXPAND)
86 box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
87
88 return box
89
90#----------------------------------------------------------------------
91
92def makeSimpleBox8(win):
93 box = wxBoxSizer(wxVERTICAL)
94 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
95 box.Add(0,0, 1)
96 box.Add(wxButton(win, 1010, "two"), 0, wxALIGN_CENTER)
97 box.Add(0,0, 1)
98 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
99 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
100# box.Add(wxButton(win, 1010, "five"), 1, wxEXPAND)
101
102 return box
103
104#----------------------------------------------------------------------
105#----------------------------------------------------------------------
106
107def makeSimpleBorder1(win):
108 bdr = wxBoxSizer(wxHORIZONTAL)
109 btn = wxButton(win, 1010, "border")
110 btn.SetSize(wxSize(80, 80))
111 bdr.Add(btn, 1, wxEXPAND|wxALL, 15)
112
113 return bdr
114
115#----------------------------------------------------------------------
116
117def makeSimpleBorder2(win):
118 bdr = wxBoxSizer(wxHORIZONTAL)
119 btn = wxButton(win, 1010, "border")
120 btn.SetSize(wxSize(80, 80))
121 bdr.Add(btn, 1, wxEXPAND | wxEAST | wxWEST, 15)
122
123 return bdr
124
125#----------------------------------------------------------------------
126
127def makeSimpleBorder3(win):
128 bdr = wxBoxSizer(wxHORIZONTAL)
129 btn = wxButton(win, 1010, "border")
130 btn.SetSize(wxSize(80, 80))
131 bdr.Add(btn, 1, wxEXPAND | wxNORTH | wxWEST, 15)
132
133 return bdr
134
135#----------------------------------------------------------------------
136#----------------------------------------------------------------------
137
138def makeBoxInBox(win):
139 box = wxBoxSizer(wxVERTICAL)
140
141 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
142
143 box2 = wxBoxSizer(wxHORIZONTAL)
144 box2.AddMany([ (wxButton(win, 1010, "two"), 0, wxEXPAND),
145 (wxButton(win, 1010, "three"), 0, wxEXPAND),
146 (wxButton(win, 1010, "four"), 0, wxEXPAND),
147 (wxButton(win, 1010, "five"), 0, wxEXPAND),
148 ])
149
150 box3 = wxBoxSizer(wxVERTICAL)
151 box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
152 (wxButton(win, 1010, "seven"), 2, wxEXPAND),
153 (wxButton(win, 1010, "eight"), 1, wxEXPAND),
154 (wxButton(win, 1010, "nine"), 1, wxEXPAND),
155 ])
156
157 box2.Add(box3, 1, wxEXPAND)
158 box.Add(box2, 1, wxEXPAND)
159
160 box.Add(wxButton(win, 1010, "ten"), 0, wxEXPAND)
161
162 return box
163
164#----------------------------------------------------------------------
165
166def makeBoxInBorder(win):
167 bdr = wxBoxSizer(wxHORIZONTAL)
168 box = makeSimpleBox3(win)
169 bdr.Add(box, 1, wxEXPAND | wxALL, 15)
170
171 return bdr
172
173#----------------------------------------------------------------------
174
175def makeBorderInBox(win):
176 insideBox = wxBoxSizer(wxHORIZONTAL)
177
178 box2 = wxBoxSizer(wxHORIZONTAL)
179 box2.AddMany([ (wxButton(win, 1010, "one"), 0, wxEXPAND),
180 (wxButton(win, 1010, "two"), 0, wxEXPAND),
181 (wxButton(win, 1010, "three"), 0, wxEXPAND),
182 (wxButton(win, 1010, "four"), 0, wxEXPAND),
183 (wxButton(win, 1010, "five"), 0, wxEXPAND),
184 ])
185
186 insideBox.Add(box2, 0, wxEXPAND)
187
188 bdr = wxBoxSizer(wxHORIZONTAL)
189 bdr.Add(wxButton(win, 1010, "border"), 1, wxEXPAND | wxALL)
190 insideBox.Add(bdr, 1, wxEXPAND | wxALL, 20)
191
192 box3 = wxBoxSizer(wxVERTICAL)
193 box3.AddMany([ (wxButton(win, 1010, "six"), 0, wxEXPAND),
194 (wxButton(win, 1010, "seven"), 2, wxEXPAND),
195 (wxButton(win, 1010, "eight"), 1, wxEXPAND),
196 (wxButton(win, 1010, "nine"), 1, wxEXPAND),
197 ])
198 insideBox.Add(box3, 1, wxEXPAND)
199
200 outsideBox = wxBoxSizer(wxVERTICAL)
201 outsideBox.Add(wxButton(win, 1010, "top"), 0, wxEXPAND)
202 outsideBox.Add(insideBox, 1, wxEXPAND)
203 outsideBox.Add(wxButton(win, 1010, "bottom"), 0, wxEXPAND)
204
205 return outsideBox
206
207
208#----------------------------------------------------------------------
209
210def makeGrid1(win):
211 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
212
213 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
214 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
215 (wxButton(win, 1010, 'three'), 0, wxEXPAND),
216 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
217 (wxButton(win, 1010, 'five'), 0, wxEXPAND),
218 #(75, 50),
219 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
220 (wxButton(win, 1010, 'seven'), 0, wxEXPAND),
221 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
222 (wxButton(win, 1010, 'nine'), 0, wxEXPAND),
223 ])
224
225 return gs
226
227#----------------------------------------------------------------------
228
229def makeGrid2(win):
230 gs = wxGridSizer(3, 3) # rows, cols, hgap, vgap
231
232 box = wxBoxSizer(wxVERTICAL)
233 box.Add(wxButton(win, 1010, 'A'), 0, wxEXPAND)
234 box.Add(wxButton(win, 1010, 'B'), 1, wxEXPAND)
235
236 gs2 = wxGridSizer(2,2, 4, 4)
237 gs2.AddMany([ (wxButton(win, 1010, 'C'), 0, wxEXPAND),
238 (wxButton(win, 1010, 'E'), 0, wxEXPAND),
239 (wxButton(win, 1010, 'F'), 0, wxEXPAND),
240 (wxButton(win, 1010, 'G'), 0, wxEXPAND)])
241
242 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxALIGN_RIGHT | wxALIGN_BOTTOM),
243 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
244 (wxButton(win, 1010, 'three'), 0, wxALIGN_LEFT | wxALIGN_BOTTOM),
245 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
246 (wxButton(win, 1010, 'five'), 0, wxALIGN_CENTER),
247 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
248 (box, 0, wxEXPAND | wxALL, 10),
249 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
250 (gs2, 0, wxEXPAND | wxALL, 4),
251 ])
252
253 return gs
254
255#----------------------------------------------------------------------
256
257def makeGrid3(win):
258 gs = wxFlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
259
260 gs.AddMany([ (wxButton(win, 1010, 'one'), 0, wxEXPAND),
261 (wxButton(win, 1010, 'two'), 0, wxEXPAND),
262 (wxButton(win, 1010, 'three'), 0, wxEXPAND),
263 (wxButton(win, 1010, 'four'), 0, wxEXPAND),
264 #(wxButton(win, 1010, 'five'), 0, wxEXPAND),
265 (175, 50),
266 (wxButton(win, 1010, 'six'), 0, wxEXPAND),
267 (wxButton(win, 1010, 'seven'), 0, wxEXPAND),
268 (wxButton(win, 1010, 'eight'), 0, wxEXPAND),
269 (wxButton(win, 1010, 'nine'), 0, wxEXPAND),
270 ])
271
272 gs.AddGrowableRow(0)
273 gs.AddGrowableRow(2)
274 gs.AddGrowableCol(1)
275 return gs
276
277#----------------------------------------------------------------------
278
279def makeGrid4(win):
280 bpos = wxDefaultPosition
281 bsize = wxSize(100, 50)
282 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
283
284 gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
285 0, wxALIGN_TOP | wxALIGN_LEFT ),
286 (wxButton(win, 1010, 'two', bpos, bsize),
287 0, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
288 (wxButton(win, 1010, 'three', bpos, bsize),
289 0, wxALIGN_TOP | wxALIGN_RIGHT ),
290 (wxButton(win, 1010, 'four', bpos, bsize),
291 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
292 (wxButton(win, 1010, 'five', bpos, bsize),
293 0, wxALIGN_CENTER ),
294 (wxButton(win, 1010, 'six', bpos, bsize),
295 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
296 (wxButton(win, 1010, 'seven', bpos, bsize),
297 0, wxALIGN_BOTTOM | wxALIGN_LEFT ),
298 (wxButton(win, 1010, 'eight', bpos, bsize),
299 0, wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
300 (wxButton(win, 1010, 'nine', bpos, bsize),
301 0, wxALIGN_BOTTOM | wxALIGN_RIGHT ),
302 ])
303
304 return gs
305
306#----------------------------------------------------------------------
307
308def makeShapes(win):
309 bpos = wxDefaultPosition
310 bsize = wxSize(100, 50)
311 gs = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
312
313 gs.AddMany([ (wxButton(win, 1010, 'one', bpos, bsize),
314 0, wxSHAPED | wxALIGN_TOP | wxALIGN_LEFT ),
315 (wxButton(win, 1010, 'two', bpos, bsize),
316 0, wxSHAPED | wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL ),
317 (wxButton(win, 1010, 'three', bpos, bsize),
318 0, wxSHAPED | wxALIGN_TOP | wxALIGN_RIGHT ),
319 (wxButton(win, 1010, 'four', bpos, bsize),
320 0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT ),
321 (wxButton(win, 1010, 'five', bpos, bsize),
322 0, wxSHAPED | wxALIGN_CENTER ),
323 (wxButton(win, 1010, 'six', bpos, bsize),
324 0, wxSHAPED | wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ),
325 (wxButton(win, 1010, 'seven', bpos, bsize),
326 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_LEFT ),
327 (wxButton(win, 1010, 'eight', bpos, bsize),
328 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_CENTER_HORIZONTAL ),
329 (wxButton(win, 1010, 'nine', bpos, bsize),
330 0, wxSHAPED | wxALIGN_BOTTOM | wxALIGN_RIGHT ),
331 ])
332
333 return gs
334
335#----------------------------------------------------------------------
336
337def makeSimpleBoxShaped(win):
338 box = wxBoxSizer(wxHORIZONTAL)
339 box.Add(wxButton(win, 1010, "one"), 0, wxEXPAND)
340 box.Add(wxButton(win, 1010, "two"), 0, wxEXPAND)
341 box.Add(wxButton(win, 1010, "three"), 0, wxEXPAND)
342 box.Add(wxButton(win, 1010, "four"), 0, wxEXPAND)
343 box.Add(wxButton(win, 1010, "five"), 1, wxSHAPED)
344
345 return box
346
347#----------------------------------------------------------------------
348
349theTests = [
350 ("Simple horizontal boxes", makeSimpleBox1,
351 "This is a HORIZONTAL box sizer with four non-stretchable buttons held "
352 "within it. Notice that the buttons are added and aligned in the horizontal "
353 "dimension. Also notice that they are fixed size in the horizontal dimension, "
354 "but will stretch vertically."
355 ),
356
357 ("Simple vertical boxes", makeSimpleBox2,
358 "Exactly the same as the previous sample but using a VERTICAL box sizer "
359 "instead of a HORIZONTAL one."
360 ),
361
362 ("Add a stretchable", makeSimpleBox3,
363 "We've added one more button with the strechable flag turned on. Notice "
364 "how it grows to fill the extra space in the otherwise fixed dimension."
365 ),
366
367 ("More than one stretchable", makeSimpleBox4,
368 "Here there are several items that are stretchable, they all divide up the "
369 "extra space evenly."
370 ),
371
372 ("Weighting factor", makeSimpleBox5,
373 "This one shows more than one strechable, but one of them has a weighting "
374 "factor so it gets more of the free space."
375 ),
376
377 ("Edge Affinity", makeSimpleBox6,
378 "For items that don't completly fill their allotted space, and don't "
379 "stretch, you can specify which side (or the center) they should stay "
380 "attached to."
381 ),
382
383 ("Spacer", makeSimpleBox7,
384 "You can add empty space to be managed by a Sizer just as if it were a "
385 "window or another Sizer."
386 ),
387
388 ("Centering in available space", makeSimpleBox8,
389 "This one shows an item that does not expand to fill it's space, but rather"
390 "stays centered within it."
391 ),
392
393# ("Percent Sizer", makeSimpleBox6,
394# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
395# "the weighting factors add up to 100!"
396# ),
397
398 ("", None, ""),
399
400 ("Simple border sizer", makeSimpleBorder1,
401 "The wxBoxSizer can leave empty space around its contents. This one "
402 "gives a border all the way around."
403 ),
404
405 ("East and West border", makeSimpleBorder2,
406 "You can pick and choose which sides have borders."
407 ),
408
409 ("North and West border", makeSimpleBorder3,
410 "You can pick and choose which sides have borders."
411 ),
412
413 ("", None, ""),
414
415 ("Boxes inside of boxes", makeBoxInBox,
416 "This one shows nesting of boxes within boxes within boxes, using both "
417 "orientations. Notice also that button seven has a greater weighting "
418 "factor than its siblings."
419 ),
420
421 ("Boxes inside a Border", makeBoxInBorder,
422 "Sizers of different types can be nested withing each other as well. "
423 "Here is a box sizer with several buttons embedded within a border sizer."
424 ),
425
426 ("Border in a Box", makeBorderInBox,
427 "Another nesting example. This one has Boxes and a Border inside another Box."
428 ),
429
430 ("", None, ""),
431
432 ("Simple Grid", makeGrid1,
433 "This is an example of the wxGridSizer. In this case all row heights "
434 "and column widths are kept the same as all the others and all items "
435 "fill their available space. The horzontal and vertical gaps are set to "
436 "2 pixels each."
437 ),
438
439 ("More Grid Features", makeGrid2,
440 "This is another example of the wxGridSizer. This one has no gaps in the grid, "
441 "but various cells are given different alignment options and some of them "
442 "hold nested sizers."
443 ),
444
445 ("Flexible Grid", makeGrid3,
446 "This grid allows the rows to have different heights and the columns to have "
447 "different widths. You can also specify rows and columns that are growable, "
448 "which we have done for the first and last row and the middle column for "
449 "this example.\n"
450 "\nThere is also a spacer in the middle cell instead of an actual window."
451 ),
452
453 ("Grid with Alignment", makeGrid4,
454 "New alignment flags allow for the positioning of items in any corner or centered "
455 "position."
456 ),
457
458 ("", None, ""),
459
460 ("Proportional resize", makeSimpleBoxShaped,
461 "Managed items can preserve their original aspect ratio. The last item has the "
462 "wxSHAPED flag set and will resize proportional to its origingal size."
463 ),
464
465 ("Proportional resize with Alignments", makeShapes,
466 "This one shows various alignments as well as proportional resizing for all items."
467 ),
468
469 ]
470#----------------------------------------------------------------------
471
472class TestFrame(wxFrame):
473 def __init__(self, parent, title, sizerFunc):
474 wxFrame.__init__(self, parent, -1, title)
475 EVT_BUTTON(self, 1010, self.OnButton)
476
477 self.sizer = sizerFunc(self)
478 self.CreateStatusBar()
479 self.SetStatusText("Resize this frame to see how the sizers respond...")
480 self.sizer.Fit(self)
481
482 self.SetAutoLayout(true)
483 self.SetSizer(self.sizer)
484 EVT_CLOSE(self, self.OnCloseWindow)
485
486 def OnCloseWindow(self, event):
487 self.MakeModal(false)
488 self.Destroy()
489
490 def OnButton(self, event):
491 self.Close(true)
492
493#----------------------------------------------------------------------
494
495
496
497class TestSelectionPanel(wxPanel):
498 def __init__(self, parent, frame):
499 wxPanel.__init__(self, parent, -1)
500 self.frame = frame
501
502 self.list = wxListBox(self, 401,
503 wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 100),
504 [])
505 EVT_LISTBOX(self, 401, self.OnSelect)
506 EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
507
508 self.btn = wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
509 EVT_BUTTON(self, 402, self.OnDClick)
510
511 self.text = wxTextCtrl(self, -1, "",
512 wxDLG_PNT(self, 10, 115),
513 wxDLG_SZE(self, 200, 50),
514 wxTE_MULTILINE | wxTE_READONLY)
515
516 for item in theTests:
517 self.list.Append(item[0])
518
519
520
521 def OnSelect(self, event):
522 pos = self.list.GetSelection()
523 self.text.SetValue(theTests[pos][2])
524
525
526 def OnDClick(self, event):
527 pos = self.list.GetSelection()
528 title = theTests[pos][0]
529 func = theTests[pos][1]
530
531 if func:
532 win = TestFrame(self, title, func)
533 win.CentreOnParent(wxBOTH)
534 win.Show(true)
535 win.MakeModal(true)
536
537#----------------------------------------------------------------------
538
539def runTest(frame, nb, log):
540 win = TestSelectionPanel(nb, frame)
541 return win
542
543overview = ""
544#wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
545#wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
546#wxBorderSizer.__doc__
547
548#----------------------------------------------------------------------
549
550
551
552if __name__ == '__main__':
553
554 class MainFrame(wxFrame):
555 def __init__(self):
556 wxFrame.__init__(self, None, -1, "Testing...")
557
558 self.CreateStatusBar()
559 mainmenu = wxMenuBar()
560 menu = wxMenu()
561 menu.Append(200, 'E&xit', 'Get the heck outta here!')
562 mainmenu.Append(menu, "&File")
563 self.SetMenuBar(mainmenu)
564 EVT_MENU(self, 200, self.OnExit)
565 self.panel = TestSelectionPanel(self, self)
566 self.SetSize(wxSize(400, 380))
567 EVT_CLOSE(self, self.OnCloseWindow)
568
569 def OnCloseWindow(self, event):
570 self.Destroy()
571
572 def OnExit(self, event):
573 self.Close(true)
574
575
576 class TestApp(wxApp):
577 def OnInit(self):
578 frame = MainFrame()
579 frame.Show(true)
580 self.SetTopWindow(frame)
581 return true
582
583 app = TestApp(0)
584 app.MainLoop()
585
586
587#----------------------------------------------------------------------