Skip to content

Commit 113fb41

Browse files
committed
Merge remote-tracking branch 'origin/bind_savvy_evt_handler' into development
2 parents b185539 + d17b1a4 commit 113fb41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+14905
-16
lines changed

README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Please keep in mind that Python Toolbox is still in alpha stage, and that backwa
3232

3333
## Present ##
3434

35-
Python Toolbox is at version 0.1, which is an alpha release. It's being used in production every day, but backward compatibility isn't guaranteed yet.
35+
Python Toolbox is at version 0.2, which is an alpha release. It's being used in production every day, but backward compatibility isn't guaranteed yet.
3636

3737
## Next tasks ##
3838

@@ -64,4 +64,4 @@ It also supports PyPy 1.8. (Which runs Python 2.7.)
6464

6565
# Current state #
6666

67-
The Python Toolbox is at version 0.1.0, which is an alpha release. At this experimental stage of the project, backward compatibility will _not_ be maintained.
67+
The Python Toolbox is at version 0.2, which is an alpha release. At this experimental stage of the project, backward compatibility will _not_ be maintained.

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
# built documents.
4646
#
4747
# The short X.Y version.
48-
version = '0.1.0'
48+
version = '0.2.0'
4949
# The full version, including alpha/beta/rc tags.
50-
release = '0.1.0'
50+
release = '0.2.0'
5151

5252
# The language for content autogenerated by Sphinx. Refer to documentation
5353
# for a list of supported languages.

python_toolbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
import python_toolbox.version_info
1616
import python_toolbox.monkeypatch_copy_reg
1717

18-
__version_info__ = python_toolbox.version_info.VersionInfo(0, 1, 0)
19-
__version__ = '0.1'
18+
__version_info__ = python_toolbox.version_info.VersionInfo(0, 2, 0)
19+
__version__ = '0.2'
2020

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''This package defines generic wxPython widgets.'''
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
This module defines the `` class.
6+
7+
See its documentation for more information.
8+
'''
9+
10+
import wx
11+
12+
from python_toolbox.wx_tools.widgets.cute_button import CuteButton
13+
14+
15+
class CuteBitmapButton(wx.BitmapButton, CuteButton):
16+
''' '''
17+
def __init__(self, parent, id=-1, bitmap=wx.NullBitmap,
18+
pos=wx.DefaultPosition, size=wx.DefaultSize,
19+
style=wx.BU_AUTODRAW, validator=wx.DefaultValidator,
20+
name=wx.ButtonNameStr, bitmap_disabled=None, tool_tip=None,
21+
help_text=None):
22+
23+
wx.BitmapButton.__init__(self, parent=parent, id=id, bitmap=bitmap,
24+
pos=pos, size=size, style=style,
25+
validator=validator, name=name)
26+
if bitmap_disabled is not None:
27+
self.SetBitmapDisabled(bitmap_disabled)
28+
self.set_tool_tip_and_help_text(tool_tip, help_text)
29+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
This module defines the `CuteButton` class.
6+
7+
See its documentation for more information.
8+
'''
9+
10+
import wx
11+
12+
from python_toolbox.wx_tools.widgets.cute_control import CuteControl
13+
14+
15+
class CuteButton(wx.Button, CuteControl):
16+
''' '''
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
This module defines the `` class.
6+
7+
See its documentation for more information.
8+
'''
9+
10+
import wx
11+
12+
from python_toolbox.wx_tools.widgets.cute_window import CuteWindow
13+
14+
15+
class CuteControl(wx.Control, CuteWindow):
16+
''' '''
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
Defines the `CuteDialog` class.
6+
7+
See its documentation for more info.
8+
'''
9+
10+
import wx
11+
12+
from .cute_top_level_window import CuteTopLevelWindow
13+
from .cute_dialog_type import CuteDialogType
14+
15+
16+
class CuteDialog(wx.Dialog, CuteTopLevelWindow):
17+
'''
18+
An improved `wx.Dialog`.
19+
20+
The advantages of this class over `wx.Dialog`:
21+
22+
- `ShowModal` centers the dialog on its parent, which sometimes doesn't
23+
happen by itself on Mac.
24+
- A `create_and_show_modal` class method.
25+
- A "context help" button on Windows only.
26+
- Other advantages given by `CuteTopLevelWindow`
27+
28+
'''
29+
30+
__metaclass__ = CuteDialogType
31+
32+
33+
def __init__(self, *args, **kwargs):
34+
if not kwargs.pop('skip_wx_init', False):
35+
wx.Dialog.__init__(self, *args, **kwargs)
36+
CuteTopLevelWindow.__init__(self, *args, **kwargs)
37+
self.ExtraStyle |= wx.FRAME_EX_CONTEXTHELP
38+
39+
40+
def ShowModal(self):
41+
self.Centre(wx.BOTH)
42+
return super(CuteDialog, self).ShowModal()
43+
44+
45+
@classmethod # blocktodo: Use everywhere I can, document
46+
def create_and_show_modal(cls, parent, *args, **kwargs):
47+
dialog = cls(parent, *args, **kwargs)
48+
try:
49+
result = dialog.ShowModal()
50+
finally:
51+
dialog.Destroy()
52+
return result
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
This module defines the `CuteDialogType` metaclass.
6+
7+
See its documentation for more information.
8+
'''
9+
10+
from __future__ import with_statement
11+
12+
import wx
13+
14+
from python_toolbox.wx_tools.cursors import CursorChanger
15+
from python_toolbox import context_managers
16+
17+
from python_toolbox.wx_tools.widgets.cute_window import CuteWindow
18+
19+
20+
class CuteDialogType(type(CuteWindow)):
21+
def __call__(self, parent, *args, **kwargs):
22+
context_manager = \
23+
CursorChanger(parent, wx.CURSOR_WAIT) if parent else \
24+
context_managers.BlankContextManager()
25+
with context_manager:
26+
return type.__call__(self, parent, *args, **kwargs)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2009-2011 Ram Rachum.
2+
# This program is distributed under the LGPL2.1 license.
3+
4+
'''
5+
Defines the `CuteDirDialog` class.
6+
7+
See its documentation for more info.
8+
'''
9+
10+
import wx
11+
12+
from python_toolbox.wx_tools.cursors import CursorChanger
13+
from .cute_dialog import CuteDialog
14+
15+
16+
class CuteDirDialog(CuteDialog, wx.DirDialog):
17+
'''
18+
An improved `wx.DirDialog`.
19+
20+
The advantages of this class over `wx.DirDialog`:
21+
22+
- A class method `.create_show_modal_and_get_path` for quick usage.
23+
- Other advantages given by `CuteDialog`.
24+
25+
'''
26+
27+
def __init__(self, parent, message=wx.DirSelectorPromptStr,
28+
defaultPath=wx.EmptyString, style=wx.DD_DEFAULT_STYLE,
29+
pos=wx.DefaultPosition, size=wx.DefaultSize,
30+
name=wx.DirDialogNameStr):
31+
wx.DirDialog.__init__(self, parent, message, defaultPath, style, pos,
32+
size, name)
33+
CuteDialog.__init__(self, parent, -1, style=style, size=size, pos=pos,
34+
skip_wx_init=True)
35+
self.ExtraStyle &= ~wx.FRAME_EX_CONTEXTHELP
36+
37+
38+
@classmethod
39+
def create_show_modal_and_get_path(cls, *args, **kwargs):
40+
'''
41+
Create `CuteDirDialog`, show it, and get the path that was selected.
42+
43+
Returns `None` if "Cancel" was pressed.
44+
'''
45+
dialog = cls(*args, **kwargs)
46+
try:
47+
result = dialog.ShowModal()
48+
finally:
49+
dialog.Destroy()
50+
return dialog.GetPath() if result == wx.ID_OK else None
51+

0 commit comments

Comments
 (0)