1 |
bh |
1541 |
# Copyright (c) 2001, 2003 by Intevation GmbH |
2 |
jonathan |
438 |
# Authors: |
3 |
|
|
# Jonathan Coles <[email protected]> |
4 |
|
|
# |
5 |
|
|
# This program is free software under the GPL (>=v2) |
6 |
|
|
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
|
8 |
bh |
1541 |
"""Miscellaneous UI related functions""" |
9 |
|
|
|
10 |
|
|
__version__ = "$Revision$" |
11 |
|
|
# $Source$ |
12 |
|
|
# $Id$ |
13 |
|
|
|
14 |
|
|
|
15 |
jonathan |
438 |
from Thuban.Model.color import Color |
16 |
jonathan |
1284 |
from wxPython.wx import wxColour, \ |
17 |
|
|
wxBeginBusyCursor, wxEndBusyCursor, wxSafeYield |
18 |
jonathan |
438 |
|
19 |
|
|
def Color2wxColour(color): |
20 |
bh |
1541 |
"""Return a wxColor object for the Thuban color object color""" |
21 |
bh |
1936 |
return wxColour(int(round(color.red * 255)), |
22 |
|
|
int(round(color.green * 255)), |
23 |
|
|
int(round(color.blue * 255))) |
24 |
jonathan |
438 |
|
25 |
|
|
def wxColour2Color(colour): |
26 |
bh |
1541 |
"""Return a Thuban color object for the wxColor object color""" |
27 |
jonathan |
438 |
assert(colour is not None) |
28 |
|
|
# this doesn't work because colour is really a wxColourPtr! |
29 |
|
|
#assert(isinstance(colour, wxColour)) |
30 |
|
|
return Color(colour.Red() / 255.0, |
31 |
|
|
colour.Green() / 255.0, |
32 |
|
|
colour.Blue() / 255.0) |
33 |
|
|
|
34 |
jonathan |
1275 |
def ThubanBeginBusyCursor(): |
35 |
bh |
1541 |
"""Thuban wrapper for wxBeginBusyCursor |
36 |
|
|
|
37 |
|
|
In addition to calling wxBeginBusyCursor this function also calls |
38 |
|
|
wxSafeYield to make sure that the cursor change takes effect. wxGTK |
39 |
|
|
2.4 at least doesn't do that automatically. |
40 |
|
|
|
41 |
|
|
This function and the corresponding ThubanEndBusyCursor function are |
42 |
|
|
the functions to use in Thuban to set a busy cursor. |
43 |
|
|
""" |
44 |
jonathan |
1275 |
wxBeginBusyCursor() |
45 |
jonathan |
1284 |
wxSafeYield() |
46 |
jonathan |
1275 |
|
47 |
|
|
def ThubanEndBusyCursor(): |
48 |
bh |
1541 |
"""Thuban wrapper for wxEndBusyCursor |
49 |
|
|
|
50 |
|
|
This function doesn't do anything more than calling wxEndBusyCursor |
51 |
|
|
yet, but please use this whereever you use ThubanBeginBusyCursor. |
52 |
|
|
""" |
53 |
jonathan |
1275 |
wxEndBusyCursor() |