Merged the wxPy_newswig branch into the HEAD branch (main trunk)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-11-12 21:34:20 +00:00
parent eb6a4098a0
commit d14a1e2856
987 changed files with 671143 additions and 783083 deletions
-6
View File
@@ -1,6 +0,0 @@
*.py
*.pyc
*.pyd
.DS_Store
locale
wxc.pyd.manifest
+14
View File
@@ -0,0 +1,14 @@
# The "old" wxPython package
# We need to be able to import from the wx package, but there is also
# a wxPyton.wx module and that woudl normally be chosen first by
# import statements. So instead we'll have a wxPython._wx module and
# then stuff it into sys.modules with a wxPython.wx alias so odl
# programs will still work.
import _wx
import sys
sys.modules['wxPython.wx'] = _wx
wx = _wx
del sys
+10
View File
@@ -0,0 +1,10 @@
# Load all symbols that should appear in the wxPython.wx namespace
from core import *
from gdi import *
from windows import *
from controls import *
from misc import *
# Cleanup this one.
del wx
+50
View File
@@ -0,0 +1,50 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.calendar
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxCAL_SUNDAY_FIRST = wx.calendar.CAL_SUNDAY_FIRST
wxCAL_MONDAY_FIRST = wx.calendar.CAL_MONDAY_FIRST
wxCAL_SHOW_HOLIDAYS = wx.calendar.CAL_SHOW_HOLIDAYS
wxCAL_NO_YEAR_CHANGE = wx.calendar.CAL_NO_YEAR_CHANGE
wxCAL_NO_MONTH_CHANGE = wx.calendar.CAL_NO_MONTH_CHANGE
wxCAL_SEQUENTIAL_MONTH_SELECTION = wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION
wxCAL_SHOW_SURROUNDING_WEEKS = wx.calendar.CAL_SHOW_SURROUNDING_WEEKS
wxCAL_HITTEST_NOWHERE = wx.calendar.CAL_HITTEST_NOWHERE
wxCAL_HITTEST_HEADER = wx.calendar.CAL_HITTEST_HEADER
wxCAL_HITTEST_DAY = wx.calendar.CAL_HITTEST_DAY
wxCAL_HITTEST_INCMONTH = wx.calendar.CAL_HITTEST_INCMONTH
wxCAL_HITTEST_DECMONTH = wx.calendar.CAL_HITTEST_DECMONTH
wxCAL_HITTEST_SURROUNDING_WEEK = wx.calendar.CAL_HITTEST_SURROUNDING_WEEK
wxCAL_BORDER_NONE = wx.calendar.CAL_BORDER_NONE
wxCAL_BORDER_SQUARE = wx.calendar.CAL_BORDER_SQUARE
wxCAL_BORDER_ROUND = wx.calendar.CAL_BORDER_ROUND
wxCalendarDateAttrBorder = wx.calendar.CalendarDateAttrBorder
wxCalendarDateAttr = wx.calendar.CalendarDateAttr
wxCalendarEvent = wx.calendar.CalendarEvent
wxEVT_CALENDAR_DOUBLECLICKED = wx.calendar.wxEVT_CALENDAR_DOUBLECLICKED
wxEVT_CALENDAR_SEL_CHANGED = wx.calendar.wxEVT_CALENDAR_SEL_CHANGED
wxEVT_CALENDAR_DAY_CHANGED = wx.calendar.wxEVT_CALENDAR_DAY_CHANGED
wxEVT_CALENDAR_MONTH_CHANGED = wx.calendar.wxEVT_CALENDAR_MONTH_CHANGED
wxEVT_CALENDAR_YEAR_CHANGED = wx.calendar.wxEVT_CALENDAR_YEAR_CHANGED
wxEVT_CALENDAR_WEEKDAY_CLICKED = wx.calendar.wxEVT_CALENDAR_WEEKDAY_CLICKED
wxPreCalendarCtrl = wx.calendar.PreCalendarCtrl
wxCalendarCtrl = wx.calendar.CalendarCtrl
+363
View File
@@ -0,0 +1,363 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.controls
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxBU_LEFT = wx.controls.BU_LEFT
wxBU_TOP = wx.controls.BU_TOP
wxBU_RIGHT = wx.controls.BU_RIGHT
wxBU_BOTTOM = wx.controls.BU_BOTTOM
wxBU_EXACTFIT = wx.controls.BU_EXACTFIT
wxBU_AUTODRAW = wx.controls.BU_AUTODRAW
wxPreButton = wx.controls.PreButton
wxButton_GetDefaultSize = wx.controls.Button_GetDefaultSize
wxButton = wx.controls.Button
wxPreBitmapButton = wx.controls.PreBitmapButton
wxBitmapButton = wx.controls.BitmapButton
wxCHK_2STATE = wx.controls.CHK_2STATE
wxCHK_3STATE = wx.controls.CHK_3STATE
wxCHK_ALLOW_3RD_STATE_FOR_USER = wx.controls.CHK_ALLOW_3RD_STATE_FOR_USER
wxCHK_UNCHECKED = wx.controls.CHK_UNCHECKED
wxCHK_CHECKED = wx.controls.CHK_CHECKED
wxCHK_UNDETERMINED = wx.controls.CHK_UNDETERMINED
wxPreCheckBox = wx.controls.PreCheckBox
wxCheckBox = wx.controls.CheckBox
wxPreChoice = wx.controls.PreChoice
wxChoice = wx.controls.Choice
wxPreComboBox = wx.controls.PreComboBox
wxComboBox = wx.controls.ComboBox
wxGA_HORIZONTAL = wx.controls.GA_HORIZONTAL
wxGA_VERTICAL = wx.controls.GA_VERTICAL
wxGA_SMOOTH = wx.controls.GA_SMOOTH
wxGA_PROGRESSBAR = wx.controls.GA_PROGRESSBAR
wxPreGauge = wx.controls.PreGauge
wxGauge = wx.controls.Gauge
wxPreStaticBox = wx.controls.PreStaticBox
wxStaticBox = wx.controls.StaticBox
wxPreStaticLine = wx.controls.PreStaticLine
wxStaticLine_GetDefaultSize = wx.controls.StaticLine_GetDefaultSize
wxStaticLine = wx.controls.StaticLine
wxPreStaticText = wx.controls.PreStaticText
wxStaticText = wx.controls.StaticText
wxPreStaticBitmap = wx.controls.PreStaticBitmap
wxStaticBitmap = wx.controls.StaticBitmap
wxPreListBox = wx.controls.PreListBox
wxListBox = wx.controls.ListBox
wxPreCheckListBox = wx.controls.PreCheckListBox
wxCheckListBox = wx.controls.CheckListBox
wxTE_NO_VSCROLL = wx.controls.TE_NO_VSCROLL
wxTE_AUTO_SCROLL = wx.controls.TE_AUTO_SCROLL
wxTE_READONLY = wx.controls.TE_READONLY
wxTE_MULTILINE = wx.controls.TE_MULTILINE
wxTE_PROCESS_TAB = wx.controls.TE_PROCESS_TAB
wxTE_LEFT = wx.controls.TE_LEFT
wxTE_CENTER = wx.controls.TE_CENTER
wxTE_RIGHT = wx.controls.TE_RIGHT
wxTE_CENTRE = wx.controls.TE_CENTRE
wxTE_RICH = wx.controls.TE_RICH
wxTE_PROCESS_ENTER = wx.controls.TE_PROCESS_ENTER
wxTE_PASSWORD = wx.controls.TE_PASSWORD
wxTE_AUTO_URL = wx.controls.TE_AUTO_URL
wxTE_NOHIDESEL = wx.controls.TE_NOHIDESEL
wxTE_DONTWRAP = wx.controls.TE_DONTWRAP
wxTE_LINEWRAP = wx.controls.TE_LINEWRAP
wxTE_WORDWRAP = wx.controls.TE_WORDWRAP
wxTE_RICH2 = wx.controls.TE_RICH2
wxTEXT_ALIGNMENT_DEFAULT = wx.controls.TEXT_ALIGNMENT_DEFAULT
wxTEXT_ALIGNMENT_LEFT = wx.controls.TEXT_ALIGNMENT_LEFT
wxTEXT_ALIGNMENT_CENTRE = wx.controls.TEXT_ALIGNMENT_CENTRE
wxTEXT_ALIGNMENT_CENTER = wx.controls.TEXT_ALIGNMENT_CENTER
wxTEXT_ALIGNMENT_RIGHT = wx.controls.TEXT_ALIGNMENT_RIGHT
wxTEXT_ALIGNMENT_JUSTIFIED = wx.controls.TEXT_ALIGNMENT_JUSTIFIED
wxTEXT_ATTR_TEXT_COLOUR = wx.controls.TEXT_ATTR_TEXT_COLOUR
wxTEXT_ATTR_BACKGROUND_COLOUR = wx.controls.TEXT_ATTR_BACKGROUND_COLOUR
wxTEXT_ATTR_FONT_FACE = wx.controls.TEXT_ATTR_FONT_FACE
wxTEXT_ATTR_FONT_SIZE = wx.controls.TEXT_ATTR_FONT_SIZE
wxTEXT_ATTR_FONT_WEIGHT = wx.controls.TEXT_ATTR_FONT_WEIGHT
wxTEXT_ATTR_FONT_ITALIC = wx.controls.TEXT_ATTR_FONT_ITALIC
wxTEXT_ATTR_FONT_UNDERLINE = wx.controls.TEXT_ATTR_FONT_UNDERLINE
wxTEXT_ATTR_FONT = wx.controls.TEXT_ATTR_FONT
wxTEXT_ATTR_ALIGNMENT = wx.controls.TEXT_ATTR_ALIGNMENT
wxTEXT_ATTR_LEFT_INDENT = wx.controls.TEXT_ATTR_LEFT_INDENT
wxTEXT_ATTR_RIGHT_INDENT = wx.controls.TEXT_ATTR_RIGHT_INDENT
wxTEXT_ATTR_TABS = wx.controls.TEXT_ATTR_TABS
wxTextAttr_Combine = wx.controls.TextAttr_Combine
wxTextAttr = wx.controls.TextAttr
wxPreTextCtrl = wx.controls.PreTextCtrl
wxTextCtrl = wx.controls.TextCtrl
wxEVT_COMMAND_TEXT_UPDATED = wx.controls.wxEVT_COMMAND_TEXT_UPDATED
wxEVT_COMMAND_TEXT_ENTER = wx.controls.wxEVT_COMMAND_TEXT_ENTER
wxEVT_COMMAND_TEXT_URL = wx.controls.wxEVT_COMMAND_TEXT_URL
wxEVT_COMMAND_TEXT_MAXLEN = wx.controls.wxEVT_COMMAND_TEXT_MAXLEN
wxTextUrlEvent = wx.controls.TextUrlEvent
wxPreScrollBar = wx.controls.PreScrollBar
wxScrollBar = wx.controls.ScrollBar
wxSP_HORIZONTAL = wx.controls.SP_HORIZONTAL
wxSP_VERTICAL = wx.controls.SP_VERTICAL
wxSP_ARROW_KEYS = wx.controls.SP_ARROW_KEYS
wxSP_WRAP = wx.controls.SP_WRAP
wxPreSpinButton = wx.controls.PreSpinButton
wxSpinButton = wx.controls.SpinButton
wxPreSpinCtrl = wx.controls.PreSpinCtrl
wxSpinCtrl = wx.controls.SpinCtrl
wxEVT_COMMAND_SPINCTRL_UPDATED = wx.controls.wxEVT_COMMAND_SPINCTRL_UPDATED
wxPreRadioBox = wx.controls.PreRadioBox
wxRadioBox = wx.controls.RadioBox
wxPreRadioButton = wx.controls.PreRadioButton
wxRadioButton = wx.controls.RadioButton
wxPreSlider = wx.controls.PreSlider
wxSlider = wx.controls.Slider
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED = wx.controls.wxEVT_COMMAND_TOGGLEBUTTON_CLICKED
wxPreToggleButton = wx.controls.PreToggleButton
wxToggleButton = wx.controls.ToggleButton
wxBookCtrl = wx.controls.BookCtrl
wxBookCtrlEvent = wx.controls.BookCtrlEvent
wxNB_FIXEDWIDTH = wx.controls.NB_FIXEDWIDTH
wxNB_TOP = wx.controls.NB_TOP
wxNB_LEFT = wx.controls.NB_LEFT
wxNB_RIGHT = wx.controls.NB_RIGHT
wxNB_BOTTOM = wx.controls.NB_BOTTOM
wxNB_MULTILINE = wx.controls.NB_MULTILINE
wxNB_HITTEST_NOWHERE = wx.controls.NB_HITTEST_NOWHERE
wxNB_HITTEST_ONICON = wx.controls.NB_HITTEST_ONICON
wxNB_HITTEST_ONLABEL = wx.controls.NB_HITTEST_ONLABEL
wxNB_HITTEST_ONITEM = wx.controls.NB_HITTEST_ONITEM
wxPreNotebook = wx.controls.PreNotebook
wxNotebook = wx.controls.Notebook
wxNotebookEvent = wx.controls.NotebookEvent
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wx.controls.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wx.controls.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
wxLB_DEFAULT = wx.controls.LB_DEFAULT
wxLB_TOP = wx.controls.LB_TOP
wxLB_BOTTOM = wx.controls.LB_BOTTOM
wxLB_LEFT = wx.controls.LB_LEFT
wxLB_RIGHT = wx.controls.LB_RIGHT
wxLB_ALIGN_MASK = wx.controls.LB_ALIGN_MASK
wxPreListbook = wx.controls.PreListbook
wxListbook = wx.controls.Listbook
wxListbookEvent = wx.controls.ListbookEvent
wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED = wx.controls.wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wx.controls.wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
wxBookCtrlSizer = wx.controls.BookCtrlSizer
wxNotebookSizer = wx.controls.NotebookSizer
wxTOOL_STYLE_BUTTON = wx.controls.TOOL_STYLE_BUTTON
wxTOOL_STYLE_SEPARATOR = wx.controls.TOOL_STYLE_SEPARATOR
wxTOOL_STYLE_CONTROL = wx.controls.TOOL_STYLE_CONTROL
wxTB_HORIZONTAL = wx.controls.TB_HORIZONTAL
wxTB_VERTICAL = wx.controls.TB_VERTICAL
wxTB_3DBUTTONS = wx.controls.TB_3DBUTTONS
wxTB_FLAT = wx.controls.TB_FLAT
wxTB_DOCKABLE = wx.controls.TB_DOCKABLE
wxTB_NOICONS = wx.controls.TB_NOICONS
wxTB_TEXT = wx.controls.TB_TEXT
wxTB_NODIVIDER = wx.controls.TB_NODIVIDER
wxTB_NOALIGN = wx.controls.TB_NOALIGN
wxTB_HORZ_LAYOUT = wx.controls.TB_HORZ_LAYOUT
wxTB_HORZ_TEXT = wx.controls.TB_HORZ_TEXT
wxToolBarToolBase = wx.controls.ToolBarToolBase
wxToolBarBase = wx.controls.ToolBarBase
wxPreToolBar = wx.controls.PreToolBar
wxToolBar = wx.controls.ToolBar
wxLC_VRULES = wx.controls.LC_VRULES
wxLC_HRULES = wx.controls.LC_HRULES
wxLC_ICON = wx.controls.LC_ICON
wxLC_SMALL_ICON = wx.controls.LC_SMALL_ICON
wxLC_LIST = wx.controls.LC_LIST
wxLC_REPORT = wx.controls.LC_REPORT
wxLC_ALIGN_TOP = wx.controls.LC_ALIGN_TOP
wxLC_ALIGN_LEFT = wx.controls.LC_ALIGN_LEFT
wxLC_AUTOARRANGE = wx.controls.LC_AUTOARRANGE
wxLC_VIRTUAL = wx.controls.LC_VIRTUAL
wxLC_EDIT_LABELS = wx.controls.LC_EDIT_LABELS
wxLC_NO_HEADER = wx.controls.LC_NO_HEADER
wxLC_NO_SORT_HEADER = wx.controls.LC_NO_SORT_HEADER
wxLC_SINGLE_SEL = wx.controls.LC_SINGLE_SEL
wxLC_SORT_ASCENDING = wx.controls.LC_SORT_ASCENDING
wxLC_SORT_DESCENDING = wx.controls.LC_SORT_DESCENDING
wxLC_MASK_TYPE = wx.controls.LC_MASK_TYPE
wxLC_MASK_ALIGN = wx.controls.LC_MASK_ALIGN
wxLC_MASK_SORT = wx.controls.LC_MASK_SORT
wxLIST_MASK_STATE = wx.controls.LIST_MASK_STATE
wxLIST_MASK_TEXT = wx.controls.LIST_MASK_TEXT
wxLIST_MASK_IMAGE = wx.controls.LIST_MASK_IMAGE
wxLIST_MASK_DATA = wx.controls.LIST_MASK_DATA
wxLIST_SET_ITEM = wx.controls.LIST_SET_ITEM
wxLIST_MASK_WIDTH = wx.controls.LIST_MASK_WIDTH
wxLIST_MASK_FORMAT = wx.controls.LIST_MASK_FORMAT
wxLIST_STATE_DONTCARE = wx.controls.LIST_STATE_DONTCARE
wxLIST_STATE_DROPHILITED = wx.controls.LIST_STATE_DROPHILITED
wxLIST_STATE_FOCUSED = wx.controls.LIST_STATE_FOCUSED
wxLIST_STATE_SELECTED = wx.controls.LIST_STATE_SELECTED
wxLIST_STATE_CUT = wx.controls.LIST_STATE_CUT
wxLIST_STATE_DISABLED = wx.controls.LIST_STATE_DISABLED
wxLIST_STATE_FILTERED = wx.controls.LIST_STATE_FILTERED
wxLIST_STATE_INUSE = wx.controls.LIST_STATE_INUSE
wxLIST_STATE_PICKED = wx.controls.LIST_STATE_PICKED
wxLIST_STATE_SOURCE = wx.controls.LIST_STATE_SOURCE
wxLIST_HITTEST_ABOVE = wx.controls.LIST_HITTEST_ABOVE
wxLIST_HITTEST_BELOW = wx.controls.LIST_HITTEST_BELOW
wxLIST_HITTEST_NOWHERE = wx.controls.LIST_HITTEST_NOWHERE
wxLIST_HITTEST_ONITEMICON = wx.controls.LIST_HITTEST_ONITEMICON
wxLIST_HITTEST_ONITEMLABEL = wx.controls.LIST_HITTEST_ONITEMLABEL
wxLIST_HITTEST_ONITEMRIGHT = wx.controls.LIST_HITTEST_ONITEMRIGHT
wxLIST_HITTEST_ONITEMSTATEICON = wx.controls.LIST_HITTEST_ONITEMSTATEICON
wxLIST_HITTEST_TOLEFT = wx.controls.LIST_HITTEST_TOLEFT
wxLIST_HITTEST_TORIGHT = wx.controls.LIST_HITTEST_TORIGHT
wxLIST_HITTEST_ONITEM = wx.controls.LIST_HITTEST_ONITEM
wxLIST_NEXT_ABOVE = wx.controls.LIST_NEXT_ABOVE
wxLIST_NEXT_ALL = wx.controls.LIST_NEXT_ALL
wxLIST_NEXT_BELOW = wx.controls.LIST_NEXT_BELOW
wxLIST_NEXT_LEFT = wx.controls.LIST_NEXT_LEFT
wxLIST_NEXT_RIGHT = wx.controls.LIST_NEXT_RIGHT
wxLIST_ALIGN_DEFAULT = wx.controls.LIST_ALIGN_DEFAULT
wxLIST_ALIGN_LEFT = wx.controls.LIST_ALIGN_LEFT
wxLIST_ALIGN_TOP = wx.controls.LIST_ALIGN_TOP
wxLIST_ALIGN_SNAP_TO_GRID = wx.controls.LIST_ALIGN_SNAP_TO_GRID
wxLIST_FORMAT_LEFT = wx.controls.LIST_FORMAT_LEFT
wxLIST_FORMAT_RIGHT = wx.controls.LIST_FORMAT_RIGHT
wxLIST_FORMAT_CENTRE = wx.controls.LIST_FORMAT_CENTRE
wxLIST_FORMAT_CENTER = wx.controls.LIST_FORMAT_CENTER
wxLIST_AUTOSIZE = wx.controls.LIST_AUTOSIZE
wxLIST_AUTOSIZE_USEHEADER = wx.controls.LIST_AUTOSIZE_USEHEADER
wxLIST_RECT_BOUNDS = wx.controls.LIST_RECT_BOUNDS
wxLIST_RECT_ICON = wx.controls.LIST_RECT_ICON
wxLIST_RECT_LABEL = wx.controls.LIST_RECT_LABEL
wxLIST_FIND_UP = wx.controls.LIST_FIND_UP
wxLIST_FIND_DOWN = wx.controls.LIST_FIND_DOWN
wxLIST_FIND_LEFT = wx.controls.LIST_FIND_LEFT
wxLIST_FIND_RIGHT = wx.controls.LIST_FIND_RIGHT
wxListItemAttr = wx.controls.ListItemAttr
wxListItem = wx.controls.ListItem
wxListEvent = wx.controls.ListEvent
wxEVT_COMMAND_LIST_BEGIN_DRAG = wx.controls.wxEVT_COMMAND_LIST_BEGIN_DRAG
wxEVT_COMMAND_LIST_BEGIN_RDRAG = wx.controls.wxEVT_COMMAND_LIST_BEGIN_RDRAG
wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wx.controls.wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
wxEVT_COMMAND_LIST_END_LABEL_EDIT = wx.controls.wxEVT_COMMAND_LIST_END_LABEL_EDIT
wxEVT_COMMAND_LIST_DELETE_ITEM = wx.controls.wxEVT_COMMAND_LIST_DELETE_ITEM
wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wx.controls.wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
wxEVT_COMMAND_LIST_GET_INFO = wx.controls.wxEVT_COMMAND_LIST_GET_INFO
wxEVT_COMMAND_LIST_SET_INFO = wx.controls.wxEVT_COMMAND_LIST_SET_INFO
wxEVT_COMMAND_LIST_ITEM_SELECTED = wx.controls.wxEVT_COMMAND_LIST_ITEM_SELECTED
wxEVT_COMMAND_LIST_ITEM_DESELECTED = wx.controls.wxEVT_COMMAND_LIST_ITEM_DESELECTED
wxEVT_COMMAND_LIST_KEY_DOWN = wx.controls.wxEVT_COMMAND_LIST_KEY_DOWN
wxEVT_COMMAND_LIST_INSERT_ITEM = wx.controls.wxEVT_COMMAND_LIST_INSERT_ITEM
wxEVT_COMMAND_LIST_COL_CLICK = wx.controls.wxEVT_COMMAND_LIST_COL_CLICK
wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wx.controls.wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wx.controls.wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wx.controls.wxEVT_COMMAND_LIST_ITEM_ACTIVATED
wxEVT_COMMAND_LIST_CACHE_HINT = wx.controls.wxEVT_COMMAND_LIST_CACHE_HINT
wxEVT_COMMAND_LIST_COL_RIGHT_CLICK = wx.controls.wxEVT_COMMAND_LIST_COL_RIGHT_CLICK
wxEVT_COMMAND_LIST_COL_BEGIN_DRAG = wx.controls.wxEVT_COMMAND_LIST_COL_BEGIN_DRAG
wxEVT_COMMAND_LIST_COL_DRAGGING = wx.controls.wxEVT_COMMAND_LIST_COL_DRAGGING
wxEVT_COMMAND_LIST_COL_END_DRAG = wx.controls.wxEVT_COMMAND_LIST_COL_END_DRAG
wxEVT_COMMAND_LIST_ITEM_FOCUSED = wx.controls.wxEVT_COMMAND_LIST_ITEM_FOCUSED
wxPreListCtrl = wx.controls.PreListCtrl
wxListCtrl = wx.controls.ListCtrl
wxPreListView = wx.controls.PreListView
wxListView = wx.controls.ListView
wxTR_NO_BUTTONS = wx.controls.TR_NO_BUTTONS
wxTR_HAS_BUTTONS = wx.controls.TR_HAS_BUTTONS
wxTR_NO_LINES = wx.controls.TR_NO_LINES
wxTR_LINES_AT_ROOT = wx.controls.TR_LINES_AT_ROOT
wxTR_SINGLE = wx.controls.TR_SINGLE
wxTR_MULTIPLE = wx.controls.TR_MULTIPLE
wxTR_EXTENDED = wx.controls.TR_EXTENDED
wxTR_HAS_VARIABLE_ROW_HEIGHT = wx.controls.TR_HAS_VARIABLE_ROW_HEIGHT
wxTR_EDIT_LABELS = wx.controls.TR_EDIT_LABELS
wxTR_HIDE_ROOT = wx.controls.TR_HIDE_ROOT
wxTR_ROW_LINES = wx.controls.TR_ROW_LINES
wxTR_FULL_ROW_HIGHLIGHT = wx.controls.TR_FULL_ROW_HIGHLIGHT
wxTR_DEFAULT_STYLE = wx.controls.TR_DEFAULT_STYLE
wxTR_TWIST_BUTTONS = wx.controls.TR_TWIST_BUTTONS
wxTR_MAC_BUTTONS = wx.controls.TR_MAC_BUTTONS
wxTR_AQUA_BUTTONS = wx.controls.TR_AQUA_BUTTONS
wxTreeItemIcon_Normal = wx.controls.TreeItemIcon_Normal
wxTreeItemIcon_Selected = wx.controls.TreeItemIcon_Selected
wxTreeItemIcon_Expanded = wx.controls.TreeItemIcon_Expanded
wxTreeItemIcon_SelectedExpanded = wx.controls.TreeItemIcon_SelectedExpanded
wxTreeItemIcon_Max = wx.controls.TreeItemIcon_Max
wxTREE_HITTEST_ABOVE = wx.controls.TREE_HITTEST_ABOVE
wxTREE_HITTEST_BELOW = wx.controls.TREE_HITTEST_BELOW
wxTREE_HITTEST_NOWHERE = wx.controls.TREE_HITTEST_NOWHERE
wxTREE_HITTEST_ONITEMBUTTON = wx.controls.TREE_HITTEST_ONITEMBUTTON
wxTREE_HITTEST_ONITEMICON = wx.controls.TREE_HITTEST_ONITEMICON
wxTREE_HITTEST_ONITEMINDENT = wx.controls.TREE_HITTEST_ONITEMINDENT
wxTREE_HITTEST_ONITEMLABEL = wx.controls.TREE_HITTEST_ONITEMLABEL
wxTREE_HITTEST_ONITEMRIGHT = wx.controls.TREE_HITTEST_ONITEMRIGHT
wxTREE_HITTEST_ONITEMSTATEICON = wx.controls.TREE_HITTEST_ONITEMSTATEICON
wxTREE_HITTEST_TOLEFT = wx.controls.TREE_HITTEST_TOLEFT
wxTREE_HITTEST_TORIGHT = wx.controls.TREE_HITTEST_TORIGHT
wxTREE_HITTEST_ONITEMUPPERPART = wx.controls.TREE_HITTEST_ONITEMUPPERPART
wxTREE_HITTEST_ONITEMLOWERPART = wx.controls.TREE_HITTEST_ONITEMLOWERPART
wxTREE_HITTEST_ONITEM = wx.controls.TREE_HITTEST_ONITEM
wxTreeItemId = wx.controls.TreeItemId
wxTreeItemData = wx.controls.TreeItemData
wxEVT_COMMAND_TREE_BEGIN_DRAG = wx.controls.wxEVT_COMMAND_TREE_BEGIN_DRAG
wxEVT_COMMAND_TREE_BEGIN_RDRAG = wx.controls.wxEVT_COMMAND_TREE_BEGIN_RDRAG
wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wx.controls.wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
wxEVT_COMMAND_TREE_END_LABEL_EDIT = wx.controls.wxEVT_COMMAND_TREE_END_LABEL_EDIT
wxEVT_COMMAND_TREE_DELETE_ITEM = wx.controls.wxEVT_COMMAND_TREE_DELETE_ITEM
wxEVT_COMMAND_TREE_GET_INFO = wx.controls.wxEVT_COMMAND_TREE_GET_INFO
wxEVT_COMMAND_TREE_SET_INFO = wx.controls.wxEVT_COMMAND_TREE_SET_INFO
wxEVT_COMMAND_TREE_ITEM_EXPANDED = wx.controls.wxEVT_COMMAND_TREE_ITEM_EXPANDED
wxEVT_COMMAND_TREE_ITEM_EXPANDING = wx.controls.wxEVT_COMMAND_TREE_ITEM_EXPANDING
wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wx.controls.wxEVT_COMMAND_TREE_ITEM_COLLAPSED
wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wx.controls.wxEVT_COMMAND_TREE_ITEM_COLLAPSING
wxEVT_COMMAND_TREE_SEL_CHANGED = wx.controls.wxEVT_COMMAND_TREE_SEL_CHANGED
wxEVT_COMMAND_TREE_SEL_CHANGING = wx.controls.wxEVT_COMMAND_TREE_SEL_CHANGING
wxEVT_COMMAND_TREE_KEY_DOWN = wx.controls.wxEVT_COMMAND_TREE_KEY_DOWN
wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wx.controls.wxEVT_COMMAND_TREE_ITEM_ACTIVATED
wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wx.controls.wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK
wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wx.controls.wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK
wxEVT_COMMAND_TREE_END_DRAG = wx.controls.wxEVT_COMMAND_TREE_END_DRAG
wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK = wx.controls.wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK
wxTreeEvent = wx.controls.TreeEvent
wxPreTreeCtrl = wx.controls.PreTreeCtrl
wxTreeCtrl = wx.controls.TreeCtrl
wxDIRCTRL_DIR_ONLY = wx.controls.DIRCTRL_DIR_ONLY
wxDIRCTRL_SELECT_FIRST = wx.controls.DIRCTRL_SELECT_FIRST
wxDIRCTRL_SHOW_FILTERS = wx.controls.DIRCTRL_SHOW_FILTERS
wxDIRCTRL_3D_INTERNAL = wx.controls.DIRCTRL_3D_INTERNAL
wxDIRCTRL_EDIT_LABELS = wx.controls.DIRCTRL_EDIT_LABELS
wxPreGenericDirCtrl = wx.controls.PreGenericDirCtrl
wxGenericDirCtrl = wx.controls.GenericDirCtrl
wxPreDirFilterListCtrl = wx.controls.PreDirFilterListCtrl
wxDirFilterListCtrl = wx.controls.DirFilterListCtrl
wxPyControl = wx.controls.PyControl
wxFRAME_EX_CONTEXTHELP = wx.controls.FRAME_EX_CONTEXTHELP
wxDIALOG_EX_CONTEXTHELP = wx.controls.DIALOG_EX_CONTEXTHELP
wxEVT_HELP = wx.controls.wxEVT_HELP
wxEVT_DETAILED_HELP = wx.controls.wxEVT_DETAILED_HELP
wxHelpEvent = wx.controls.HelpEvent
wxContextHelp = wx.controls.ContextHelp
wxContextHelpButton = wx.controls.ContextHelpButton
wxHelpProvider_Set = wx.controls.HelpProvider_Set
wxHelpProvider_Get = wx.controls.HelpProvider_Get
wxHelpProvider = wx.controls.HelpProvider
wxSimpleHelpProvider = wx.controls.SimpleHelpProvider
d = globals()
for k, v in wx.controls.__dict__.iteritems():
if k.startswith('EVT'):
d[k] = v
del d, k, v
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+61
View File
@@ -0,0 +1,61 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.gizmos
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxEVT_DYNAMIC_SASH_SPLIT = wx.gizmos.wxEVT_DYNAMIC_SASH_SPLIT
wxEVT_DYNAMIC_SASH_UNIFY = wx.gizmos.wxEVT_DYNAMIC_SASH_UNIFY
wxDS_MANAGE_SCROLLBARS = wx.gizmos.DS_MANAGE_SCROLLBARS
wxDS_DRAG_CORNER = wx.gizmos.DS_DRAG_CORNER
wxDynamicSashSplitEvent = wx.gizmos.DynamicSashSplitEvent
wxDynamicSashUnifyEvent = wx.gizmos.DynamicSashUnifyEvent
wxPreDynamicSashWindow = wx.gizmos.PreDynamicSashWindow
wxDynamicSashWindow = wx.gizmos.DynamicSashWindow
wxEL_ALLOW_NEW = wx.gizmos.EL_ALLOW_NEW
wxEL_ALLOW_EDIT = wx.gizmos.EL_ALLOW_EDIT
wxEL_ALLOW_DELETE = wx.gizmos.EL_ALLOW_DELETE
wxEditableListBox = wx.gizmos.EditableListBox
wxRemotelyScrolledTreeCtrl = wx.gizmos.RemotelyScrolledTreeCtrl
wxTreeCompanionWindow = wx.gizmos.TreeCompanionWindow
wxThinSplitterWindow = wx.gizmos.ThinSplitterWindow
wxSplitterScrolledWindow = wx.gizmos.SplitterScrolledWindow
wxLED_ALIGN_LEFT = wx.gizmos.LED_ALIGN_LEFT
wxLED_ALIGN_RIGHT = wx.gizmos.LED_ALIGN_RIGHT
wxLED_ALIGN_CENTER = wx.gizmos.LED_ALIGN_CENTER
wxLED_ALIGN_MASK = wx.gizmos.LED_ALIGN_MASK
wxLED_DRAW_FADED = wx.gizmos.LED_DRAW_FADED
wxPreLEDNumberCtrl = wx.gizmos.PreLEDNumberCtrl
wxLEDNumberCtrl = wx.gizmos.LEDNumberCtrl
wxTL_ALIGN_LEFT = wx.gizmos.TL_ALIGN_LEFT
wxTL_ALIGN_RIGHT = wx.gizmos.TL_ALIGN_RIGHT
wxTL_ALIGN_CENTER = wx.gizmos.TL_ALIGN_CENTER
wxTREE_HITTEST_ONITEMCOLUMN = wx.gizmos.TREE_HITTEST_ONITEMCOLUMN
wxTreeListColumnInfo = wx.gizmos.TreeListColumnInfo
wxPreTreeListCtrl = wx.gizmos.PreTreeListCtrl
wxTreeListCtrl = wx.gizmos.TreeListCtrl
d = globals()
for k, v in wx.gizmos.__dict__.iteritems():
if k.startswith('EVT'):
d[k] = v
del d, k, v
+42
View File
@@ -0,0 +1,42 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.glcanvas
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxGLContext = wx.glcanvas.GLContext
WX_GL_RGBA = wx.glcanvas.WX_GL_RGBA
WX_GL_BUFFER_SIZE = wx.glcanvas.WX_GL_BUFFER_SIZE
WX_GL_LEVEL = wx.glcanvas.WX_GL_LEVEL
WX_GL_DOUBLEBUFFER = wx.glcanvas.WX_GL_DOUBLEBUFFER
WX_GL_STEREO = wx.glcanvas.WX_GL_STEREO
WX_GL_AUX_BUFFERS = wx.glcanvas.WX_GL_AUX_BUFFERS
WX_GL_MIN_RED = wx.glcanvas.WX_GL_MIN_RED
WX_GL_MIN_GREEN = wx.glcanvas.WX_GL_MIN_GREEN
WX_GL_MIN_BLUE = wx.glcanvas.WX_GL_MIN_BLUE
WX_GL_MIN_ALPHA = wx.glcanvas.WX_GL_MIN_ALPHA
WX_GL_DEPTH_SIZE = wx.glcanvas.WX_GL_DEPTH_SIZE
WX_GL_STENCIL_SIZE = wx.glcanvas.WX_GL_STENCIL_SIZE
WX_GL_MIN_ACCUM_RED = wx.glcanvas.WX_GL_MIN_ACCUM_RED
WX_GL_MIN_ACCUM_GREEN = wx.glcanvas.WX_GL_MIN_ACCUM_GREEN
WX_GL_MIN_ACCUM_BLUE = wx.glcanvas.WX_GL_MIN_ACCUM_BLUE
WX_GL_MIN_ACCUM_ALPHA = wx.glcanvas.WX_GL_MIN_ACCUM_ALPHA
wxGLCanvasWithContext = wx.glcanvas.GLCanvasWithContext
wxGLCanvas = wx.glcanvas.GLCanvas
+97
View File
@@ -0,0 +1,97 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.grid
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxGRID_VALUE_STRING = wx.grid.GRID_VALUE_STRING
wxGRID_VALUE_BOOL = wx.grid.GRID_VALUE_BOOL
wxGRID_VALUE_NUMBER = wx.grid.GRID_VALUE_NUMBER
wxGRID_VALUE_FLOAT = wx.grid.GRID_VALUE_FLOAT
wxGRID_VALUE_CHOICE = wx.grid.GRID_VALUE_CHOICE
wxGRID_VALUE_TEXT = wx.grid.GRID_VALUE_TEXT
wxGRID_VALUE_LONG = wx.grid.GRID_VALUE_LONG
wxGRID_VALUE_CHOICEINT = wx.grid.GRID_VALUE_CHOICEINT
wxGRID_VALUE_DATETIME = wx.grid.GRID_VALUE_DATETIME
wxGridNoCellCoords = wx.grid.GridNoCellCoords
wxGridNoCellRect = wx.grid.GridNoCellRect
wxGridCellRenderer = wx.grid.GridCellRenderer
wxPyGridCellRenderer = wx.grid.PyGridCellRenderer
wxGridCellStringRenderer = wx.grid.GridCellStringRenderer
wxGridCellNumberRenderer = wx.grid.GridCellNumberRenderer
wxGridCellFloatRenderer = wx.grid.GridCellFloatRenderer
wxGridCellBoolRenderer = wx.grid.GridCellBoolRenderer
wxGridCellDateTimeRenderer = wx.grid.GridCellDateTimeRenderer
wxGridCellEnumRenderer = wx.grid.GridCellEnumRenderer
wxGridCellAutoWrapStringRenderer = wx.grid.GridCellAutoWrapStringRenderer
wxGridCellEditor = wx.grid.GridCellEditor
wxPyGridCellEditor = wx.grid.PyGridCellEditor
wxGridCellTextEditor = wx.grid.GridCellTextEditor
wxGridCellNumberEditor = wx.grid.GridCellNumberEditor
wxGridCellFloatEditor = wx.grid.GridCellFloatEditor
wxGridCellBoolEditor = wx.grid.GridCellBoolEditor
wxGridCellChoiceEditor = wx.grid.GridCellChoiceEditor
wxGridCellEnumEditor = wx.grid.GridCellEnumEditor
wxGridCellAutoWrapStringEditor = wx.grid.GridCellAutoWrapStringEditor
wxGridCellAttr = wx.grid.GridCellAttr
wxGridCellAttrProvider = wx.grid.GridCellAttrProvider
wxPyGridCellAttrProvider = wx.grid.PyGridCellAttrProvider
wxGridTableBase = wx.grid.GridTableBase
wxPyGridTableBase = wx.grid.PyGridTableBase
wxGridStringTable = wx.grid.GridStringTable
wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES
wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES = wx.grid.GRIDTABLE_REQUEST_VIEW_SEND_VALUES
wxGRIDTABLE_NOTIFY_ROWS_INSERTED = wx.grid.GRIDTABLE_NOTIFY_ROWS_INSERTED
wxGRIDTABLE_NOTIFY_ROWS_APPENDED = wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED
wxGRIDTABLE_NOTIFY_ROWS_DELETED = wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED
wxGRIDTABLE_NOTIFY_COLS_INSERTED = wx.grid.GRIDTABLE_NOTIFY_COLS_INSERTED
wxGRIDTABLE_NOTIFY_COLS_APPENDED = wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED
wxGRIDTABLE_NOTIFY_COLS_DELETED = wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED
wxGridTableMessage = wx.grid.GridTableMessage
wxGridCellCoords = wx.grid.GridCellCoords
wxGrid = wx.grid.Grid
wxGridEvent = wx.grid.GridEvent
wxGridSizeEvent = wx.grid.GridSizeEvent
wxGridRangeSelectEvent = wx.grid.GridRangeSelectEvent
wxGridEditorCreatedEvent = wx.grid.GridEditorCreatedEvent
wxEVT_GRID_CELL_LEFT_CLICK = wx.grid.wxEVT_GRID_CELL_LEFT_CLICK
wxEVT_GRID_CELL_RIGHT_CLICK = wx.grid.wxEVT_GRID_CELL_RIGHT_CLICK
wxEVT_GRID_CELL_LEFT_DCLICK = wx.grid.wxEVT_GRID_CELL_LEFT_DCLICK
wxEVT_GRID_CELL_RIGHT_DCLICK = wx.grid.wxEVT_GRID_CELL_RIGHT_DCLICK
wxEVT_GRID_LABEL_LEFT_CLICK = wx.grid.wxEVT_GRID_LABEL_LEFT_CLICK
wxEVT_GRID_LABEL_RIGHT_CLICK = wx.grid.wxEVT_GRID_LABEL_RIGHT_CLICK
wxEVT_GRID_LABEL_LEFT_DCLICK = wx.grid.wxEVT_GRID_LABEL_LEFT_DCLICK
wxEVT_GRID_LABEL_RIGHT_DCLICK = wx.grid.wxEVT_GRID_LABEL_RIGHT_DCLICK
wxEVT_GRID_ROW_SIZE = wx.grid.wxEVT_GRID_ROW_SIZE
wxEVT_GRID_COL_SIZE = wx.grid.wxEVT_GRID_COL_SIZE
wxEVT_GRID_RANGE_SELECT = wx.grid.wxEVT_GRID_RANGE_SELECT
wxEVT_GRID_CELL_CHANGE = wx.grid.wxEVT_GRID_CELL_CHANGE
wxEVT_GRID_SELECT_CELL = wx.grid.wxEVT_GRID_SELECT_CELL
wxEVT_GRID_EDITOR_SHOWN = wx.grid.wxEVT_GRID_EDITOR_SHOWN
wxEVT_GRID_EDITOR_HIDDEN = wx.grid.wxEVT_GRID_EDITOR_HIDDEN
wxEVT_GRID_EDITOR_CREATED = wx.grid.wxEVT_GRID_EDITOR_CREATED
d = globals()
for k, v in wx.grid.__dict__.iteritems():
if k.startswith('EVT'):
d[k] = v
del d, k, v
+103
View File
@@ -0,0 +1,103 @@
## This file reverse renames symbols in the wx package to give
## them their wx prefix again, for backwards compatibility.
##
## Generated by ./distrib/build_renamers.py
# This silly stuff here is so the wxPython.wx module doesn't conflict
# with the wx package. We need to import modules from the wx package
# here, then we'll put the wxPython.wx entry back in sys.modules.
import sys
_wx = None
if sys.modules.has_key('wxPython.wx'):
_wx = sys.modules['wxPython.wx']
del sys.modules['wxPython.wx']
import wx.html
sys.modules['wxPython.wx'] = _wx
del sys, _wx
# Now assign all the reverse-renamed names:
wxHTML_ALIGN_LEFT = wx.html.HTML_ALIGN_LEFT
wxHTML_ALIGN_CENTER = wx.html.HTML_ALIGN_CENTER
wxHTML_ALIGN_RIGHT = wx.html.HTML_ALIGN_RIGHT
wxHTML_ALIGN_BOTTOM = wx.html.HTML_ALIGN_BOTTOM
wxHTML_ALIGN_TOP = wx.html.HTML_ALIGN_TOP
wxHTML_CLR_FOREGROUND = wx.html.HTML_CLR_FOREGROUND
wxHTML_CLR_BACKGROUND = wx.html.HTML_CLR_BACKGROUND
wxHTML_UNITS_PIXELS = wx.html.HTML_UNITS_PIXELS
wxHTML_UNITS_PERCENT = wx.html.HTML_UNITS_PERCENT
wxHTML_INDENT_LEFT = wx.html.HTML_INDENT_LEFT
wxHTML_INDENT_RIGHT = wx.html.HTML_INDENT_RIGHT
wxHTML_INDENT_TOP = wx.html.HTML_INDENT_TOP
wxHTML_INDENT_BOTTOM = wx.html.HTML_INDENT_BOTTOM
wxHTML_INDENT_HORIZONTAL = wx.html.HTML_INDENT_HORIZONTAL
wxHTML_INDENT_VERTICAL = wx.html.HTML_INDENT_VERTICAL
wxHTML_INDENT_ALL = wx.html.HTML_INDENT_ALL
wxHTML_COND_ISANCHOR = wx.html.HTML_COND_ISANCHOR
wxHTML_COND_ISIMAGEMAP = wx.html.HTML_COND_ISIMAGEMAP
wxHTML_COND_USER = wx.html.HTML_COND_USER
wxHW_SCROLLBAR_NEVER = wx.html.HW_SCROLLBAR_NEVER
wxHW_SCROLLBAR_AUTO = wx.html.HW_SCROLLBAR_AUTO
wxHW_NO_SELECTION = wx.html.HW_NO_SELECTION
wxHW_DEFAULT_STYLE = wx.html.HW_DEFAULT_STYLE
wxHTML_OPEN = wx.html.HTML_OPEN
wxHTML_BLOCK = wx.html.HTML_BLOCK
wxHTML_REDIRECT = wx.html.HTML_REDIRECT
wxHTML_URL_PAGE = wx.html.HTML_URL_PAGE
wxHTML_URL_IMAGE = wx.html.HTML_URL_IMAGE
wxHTML_URL_OTHER = wx.html.HTML_URL_OTHER
wxHtmlLinkInfo = wx.html.HtmlLinkInfo
wxHtmlTag = wx.html.HtmlTag
wxHtmlParser = wx.html.HtmlParser
wxHtmlWinParser = wx.html.HtmlWinParser
wxHtmlTagHandler = wx.html.HtmlTagHandler
wxHtmlWinTagHandler = wx.html.HtmlWinTagHandler
wxHtmlWinParser_AddTagHandler = wx.html.HtmlWinParser_AddTagHandler
wxHtmlSelection = wx.html.HtmlSelection
wxHTML_SEL_OUT = wx.html.HTML_SEL_OUT
wxHTML_SEL_IN = wx.html.HTML_SEL_IN
wxHTML_SEL_CHANGING = wx.html.HTML_SEL_CHANGING
wxHtmlRenderingState = wx.html.HtmlRenderingState
wxHtmlRenderingStyle = wx.html.HtmlRenderingStyle
wxDefaultHtmlRenderingStyle = wx.html.DefaultHtmlRenderingStyle
wxHtmlRenderingInfo = wx.html.HtmlRenderingInfo
wxHTML_FIND_EXACT = wx.html.HTML_FIND_EXACT
wxHTML_FIND_NEAREST_BEFORE = wx.html.HTML_FIND_NEAREST_BEFORE
wxHTML_FIND_NEAREST_AFTER = wx.html.HTML_FIND_NEAREST_AFTER
wxHtmlCell = wx.html.HtmlCell
wxHtmlWordCell = wx.html.HtmlWordCell
wxHtmlContainerCell = wx.html.HtmlContainerCell
wxHtmlColourCell = wx.html.HtmlColourCell
wxHtmlFontCell = wx.html.HtmlFontCell
wxHtmlWidgetCell = wx.html.HtmlWidgetCell
wxHtmlFilter = wx.html.HtmlFilter
wxPreHtmlWindow = wx.html.PreHtmlWindow
wxHtmlWindow_AddFilter = wx.html.HtmlWindow_AddFilter
wxHtmlWindow = wx.html.HtmlWindow
wxHtmlDCRenderer = wx.html.HtmlDCRenderer
wxPAGE_ODD = wx.html.PAGE_ODD
wxPAGE_EVEN = wx.html.PAGE_EVEN
wxPAGE_ALL = wx.html.PAGE_ALL
wxHtmlPrintout_AddFilter = wx.html.HtmlPrintout_AddFilter
wxHtmlPrintout_CleanUpStatics = wx.html.HtmlPrintout_CleanUpStatics
wxHtmlPrintout = wx.html.HtmlPrintout
wxHtmlEasyPrinting = wx.html.HtmlEasyPrinting
wxHtmlBookRecord = wx.html.HtmlBookRecord
wxHtmlContentsItem = wx.html.HtmlContentsItem
wxHtmlSearchStatus = wx.html.HtmlSearchStatus
wxHtmlHelpData = wx.html.HtmlHelpData
wxHtmlHelpFrame = wx.html.HtmlHelpFrame
wxHF_TOOLBAR = wx.html.HF_TOOLBAR
wxHF_FLATTOOLBAR = wx.html.HF_FLATTOOLBAR
wxHF_CONTENTS = wx.html.HF_CONTENTS
wxHF_INDEX = wx.html.HF_INDEX
wxHF_SEARCH = wx.html.HF_SEARCH
wxHF_BOOKMARKS = wx.html.HF_BOOKMARKS
wxHF_OPENFILES = wx.html.HF_OPENFILES
wxHF_PRINT = wx.html.HF_PRINT
wxHF_DEFAULTSTYLE = wx.html.HF_DEFAULTSTYLE
wxHtmlHelpController = wx.html.HtmlHelpController
+16 -122
View File
@@ -1,125 +1,19 @@
# Name: CDate.py
# Purpose: Date and Calendar classes
#
# Author: Lorne White (email: lwhite1@planet.eon.net)
#
# Created:
# Version 0.2 1999/11/08
# Licence: wxWindows license
#----------------------------------------------------------------------------
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
import time
import wx.lib.CDate
Month = {2: 'February', 3: 'March', None: 0, 'July': 7, 11:
'November', 'December': 12, 'June': 6, 'January': 1, 'September': 9,
'August': 8, 'March': 3, 'November': 11, 'April': 4, 12: 'December',
'May': 5, 10: 'October', 9: 'September', 8: 'August', 7: 'July', 6:
'June', 5: 'May', 4: 'April', 'October': 10, 'February': 2, 1:
'January', 0: None}
# Number of days per month (except for February in leap years)
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
# Full and abbreviated names of weekdays
day_name = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
day_abbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', ]
# Return number of leap years in range [y1, y2)
# Assume y1 <= y2 and no funny (non-leap century) years
def leapdays(y1, y2):
return (y2+3)/4 - (y1+3)/4
# Return 1 for leap years, 0 for non-leap years
def isleap(year):
return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
def FillDate(val):
s = str(val)
if len(s) < 2:
s = '0' + s
return s
def julianDay(year, month, day):
b = 0L
year, month, day = long(year), long(month), long(day)
if month > 12L:
year = year + month/12L
month = month%12
elif month < 1L:
month = -month
year = year - month/12L - 1L
month = 12L - month%12L
if year > 0L:
yearCorr = 0L
else:
yearCorr = 3L
if month < 3L:
year = year - 1L
month = month + 12L
if year*10000L + month*100L + day > 15821014L:
b = 2L - year/100L + year/400L
return (1461L*year - yearCorr)/4L + 306001L*(month + 1L)/10000L + day + 1720994L + b
def TodayDay():
date = time.localtime(time.time())
year = date[0]
month = date[1]
day = date[2]
julian = julianDay(year, month, day)
daywk = dayOfWeek(julian)
daywk = day_name[daywk]
return(daywk)
def FormatDay(value):
date = FromFormat(value)
daywk = DateCalc.dayOfWeek(date)
daywk = day_name[daywk]
return(daywk)
def FromJulian(julian):
julian = long(julian)
if (julian < 2299160L):
b = julian + 1525L
else:
alpha = (4L*julian - 7468861L)/146097L
b = julian + 1526L + alpha - alpha/4L
c = (20L*b - 2442L)/7305L
d = 1461L*c/4L
e = 10000L*(b - d)/306001L
day = int(b - d - 306001L*e/10000L)
if e < 14L:
month = int(e - 1L)
else:
month = int(e - 13L)
if month > 2:
year = c - 4716L
else:
year = c - 4715L
year = int(year)
return year, month, day
def dayOfWeek(julian):
return int((julian + 1L)%7L)
def daysPerMonth(month, year):
ndays = mdays[month] + (month == 2 and isleap(year))
return ndays
class now:
def __init__(self):
self.date = time.localtime(time.time())
self.year = self.date[0]
self.month = self.date[1]
self.day = self.date[2]
class Date:
def __init__(self, year, month, day):
self.julian = julianDay(year, month, day)
self.month = month
self.year = year
self.day_of_week = dayOfWeek(self.julian)
self.days_in_month = daysPerMonth(self.month, self.year)
__doc__ = wx.lib.CDate.__doc__
Date = wx.lib.CDate.Date
FillDate = wx.lib.CDate.FillDate
FormatDay = wx.lib.CDate.FormatDay
FromJulian = wx.lib.CDate.FromJulian
TodayDay = wx.lib.CDate.TodayDay
dayOfWeek = wx.lib.CDate.dayOfWeek
daysPerMonth = wx.lib.CDate.daysPerMonth
isleap = wx.lib.CDate.isleap
julianDay = wx.lib.CDate.julianDay
leapdays = wx.lib.CDate.leapdays
now = wx.lib.CDate.now
+6 -46
View File
@@ -1,49 +1,9 @@
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
"""
sorry no documentation...
Christopher J. Fama
"""
from wxPython.wx import *
from wxPython.html import *
class wxPyClickableHtmlWindow(wxHtmlWindow):
"""
Class for a wxHtmlWindow which responds to clicks on links by opening a
browser pointed at that link, and to shift-clicks by copying the link
to the clipboard.
"""
def __init__(self,parent,ID,**kw):
apply(wxHtmlWindow.__init__,(self,parent,ID),kw)
def OnLinkClicked(self,link):
self.link = wxTextDataObject(link.GetHref())
if link.GetEvent().ShiftDown():
if wxTheClipboard.Open():
wxTheClipboard.SetData(self.link)
wxTheClipboard.Close()
else:
dlg = wxMessageDialog(self,"Couldn't open clipboard!\n",wxOK)
wxBell()
dlg.ShowModal()
dlg.Destroy()
else:
if 0: # Chris's original code...
if sys.platform not in ["windows",'nt'] :
#TODO: A MORE APPROPRIATE COMMAND LINE FOR Linux
#[or rather, non-Windows platforms... as of writing,
#this MEANS Linux, until wxPython for wxMac comes along...]
command = "/usr/bin/netscape"
else:
command = "start"
command = "%s \"%s\"" % (command,
self.link.GetText ())
os.system (command)
else: # My alternative
import webbrowser
webbrowser.open(link.GetHref())
import wx.lib.ClickableHtmlWindow
__doc__ = wx.lib.ClickableHtmlWindow.__doc__
wxPyClickableHtmlWindow = wx.lib.ClickableHtmlWindow.wxPyClickableHtmlWindow
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -1,6 +0,0 @@
from wxPython.py.PyCrust import *
if __name__ == '__main__':
main()
@@ -1,6 +0,0 @@
from wxPython.py.PyFilling import *
if __name__ == '__main__':
main()
@@ -1,6 +0,0 @@
from wxPython.py.PyShell import *
if __name__ == '__main__':
main()
@@ -1,5 +0,0 @@
# Change this to an ImportError after the next release
import warnings
warnings.warn("PyCrust has been renamed to Py. Use 'from wx import py'", stacklevel=2)
-2
View File
@@ -1,2 +0,0 @@
from wxPython.py.crust import *
-3
View File
@@ -1,3 +0,0 @@
from wxPython.py.filling import *
-3
View File
@@ -1,3 +0,0 @@
from wxPython.py.shell import *
-7
View File
@@ -1,7 +0,0 @@
from wxPython.py.PyWrap import *
if __name__ == '__main__':
sys.path.insert(0, os.curdir)
main(sys.argv)
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,4 +1 @@
#
+11 -138
View File
@@ -1,141 +1,14 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.activexwrapper
# Purpose: a wxWindow derived class that can hold an ActiveX control
#
# Author: Robin Dunn
#
# RCS-ID: $Id$
# Copyright: (c) 2000 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
from wxPython.wx import *
try:
import win32ui
import pywin.mfc.activex
import win32com.client
except ImportError:
raise ImportError( "ActiveXWrapper requires PythonWin. Please install the win32all-xxx.exe package.")
##from win32con import WS_TABSTOP, WS_VISIBLE
WS_TABSTOP = 0x00010000
WS_VISIBLE = 0x10000000
#----------------------------------------------------------------------
def MakeActiveXClass(CoClass, eventClass=None, eventObj=None):
"""
Dynamically construct a new class that derives from wxWindow, the
ActiveX control and the appropriate COM classes. This new class
can be used just like the wxWindow class, but will also respond
appropriately to the methods and properties of the COM object. If
this class, a derived class or a mix-in class has method names
that match the COM object's event names, they will be called
automatically.
CoClass -- A COM control class from a module generated by
makepy.py from a COM TypeLibrary. Can also accept a
CLSID.
eventClass -- If given, this class will be added to the set of
base classes that the new class is drived from. It is
good for mix-in classes for catching events.
eventObj -- If given, this object will be searched for attributes
by the new class's __getattr__ method, (like a mix-in
object.) This is useful if you want to catch COM
callbacks in an existing object, (such as the parent
window.)
"""
if type(CoClass) == type(""):
# use the CLSID to get the real class
CoClass = win32com.client.CLSIDToClass(CoClass)
# determine the base classes
axEventClass = CoClass.default_source
baseClasses = [wxWindow, pywin.mfc.activex.Control, CoClass, axEventClass]
if eventClass:
baseClasses.append(eventClass)
baseClasses = tuple(baseClasses)
# define the class attributes
className = 'AXControl_'+CoClass.__name__
classDict = { '__init__' : axw__init__,
'__getattr__' : axw__getattr__,
'axw_OnSize' : axw_OnSize,
'axw_OEB' : axw_OEB,
'_name' : className,
'_eventBase' : axEventClass,
'_eventObj' : eventObj,
'Cleanup' : axw_Cleanup,
}
# make a new class object
import new
classObj = new.classobj(className, baseClasses, classDict)
return classObj
# These functions will be used as methods in the new class
def axw__init__(self, parent, ID, pos=wxDefaultPosition, size=wxDefaultSize, style=0):
# init base classes
pywin.mfc.activex.Control.__init__(self)
wxWindow.__init__(self, parent, -1, pos, size, style|wxNO_FULL_REPAINT_ON_RESIZE)
win32ui.EnableControlContainer()
self._eventObj = self._eventObj # move from class to instance
# create a pythonwin wrapper around this wxWindow
handle = self.GetHandle()
self._wnd = win32ui.CreateWindowFromHandle(handle)
# create the control
sz = self.GetSize()
self.CreateControl(self._name, WS_TABSTOP | WS_VISIBLE,
(0, 0, sz.width, sz.height), self._wnd, ID)
# init the ax events part of the object
self._eventBase.__init__(self, self._dispobj_)
# hook some wx events
EVT_SIZE(self, self.axw_OnSize)
#EVT_ERASE_BACKGROUND(self, self.axw_OEB)
def axw__getattr__(self, attr):
try:
return pywin.mfc.activex.Control.__getattr__(self, attr)
except AttributeError:
try:
eo = self.__dict__['_eventObj']
return getattr(eo, attr)
except AttributeError:
raise AttributeError('Attribute not found: %s' % attr)
def axw_OnSize(self, event):
sz = self.GetClientSize() # get wxWindow size
self.MoveWindow((0, 0, sz.width, sz.height), 1) # move the AXControl
def axw_OEB(self, event):
pass
def axw_Cleanup(self):
del self._wnd
self.close()
pass
## anything else???
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
import wx.lib.activexwrapper
__doc__ = wx.lib.activexwrapper.__doc__
MakeActiveXClass = wx.lib.activexwrapper.MakeActiveXClass
axw_Cleanup = wx.lib.activexwrapper.axw_Cleanup
axw_OEB = wx.lib.activexwrapper.axw_OEB
axw_OnSize = wx.lib.activexwrapper.axw_OnSize
axw__getattr__ = wx.lib.activexwrapper.axw__getattr__
axw__init__ = wx.lib.activexwrapper.axw__init__
+6 -198
View File
@@ -1,201 +1,9 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.analogclock
# Purpose: A simple analog clock window
#
# Author: several folks on wxPython-users
#
# Created: 16-April-2003
# RCS-ID: $Id$
# Copyright: (c) 2003 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
import math, sys, string, time
from wxPython.wx import *
class AnalogClockWindow(wxWindow):
"""A simple analog clock window"""
TICKS_NONE = 0
TICKS_SQUARE = 1
TICKS_CIRCLE = 2
def __init__(self, parent, ID=-1, pos=wxDefaultPosition, size=wxDefaultSize,
style=0, name="clock"):
# Initialize the wxWindow...
wxWindow.__init__(self, parent, ID, pos, size, style, name)
# Initialize the default clock settings...
self.minuteMarks = 60
self.hourMarks = 12
self.tickMarksBrushC = self.GetForegroundColour()
self.tickMarksPenC = self.GetForegroundColour()
self.tickMarkStyle = self.TICKS_SQUARE
# Make an initial bitmap for the face, it will be updated and
# painted at the first EVT_SIZE event.
W, H = size
self.faceBitmap = wxEmptyBitmap(max(W,1), max(H,1))
# Initialize the timer that drives the update of the clock
# face. Update every half second to ensure that there is at
# least one true update during each realtime second.
self.timer = wxTimer(self)
self.timer.Start(500)
# Set event handlers...
EVT_PAINT(self, self.OnPaint)
EVT_ERASE_BACKGROUND(self, lambda x: None)
EVT_SIZE(self, self.OnSize)
EVT_TIMER(self, -1, self.OnTimerExpire)
EVT_WINDOW_DESTROY(self, self.OnQuit)
def SetTickMarkStyle(self, style):
"""
Set the style of the marks around the edge of the clock.
Options are TICKS_NONE, TICKS_SQUARE, and TICKS_CIRCLE
"""
self.tickMarkStyle = style
def SetTickMarkColours(self, brushC, penC="BLACK"):
"""
Set the brush colour and optionally the pen colour of
the marks around the edge of the clock.
"""
self.tickMarksBrushC = brushC
self.tickMarksPenC = penC
SetTickMarkColour = SetTickMarkColours
def SetHandsColour(self, c):
"""An alias for SetForegroundColour"""
self.SetForegroundColour(c) # the hands just use the foreground colour
# Using the current settings, render the points and line endings for the
# circle inside the specified device context. In this case, the DC is
# a memory based device context that will be blitted to the actual
# display DC inside the OnPaint() event handler.
def OnSize(self, event):
# The faceBitmap init is done here, to make sure the buffer is always
# the same size as the Window
size = self.GetClientSize()
self.faceBitmap = wxEmptyBitmap(size.width, size.height)
self.DrawFace()
def OnPaint(self, event):
self.DrawHands(wxPaintDC(self))
def OnQuit(self, event):
self.timer.Stop()
del self.timer
def OnTimerExpire(self, event):
self.DrawHands(wxClientDC(self))
def DrawHands(self, drawDC):
# Start by drawing the face bitmap
drawDC.DrawBitmap(self.faceBitmap,0,0)
currentTime = time.localtime(time.time())
hour, minutes, seconds = currentTime[3:6]
W,H = self.faceBitmap.GetWidth(), self.faceBitmap.GetHeight()
centerX = W / 2
centerY = H / 2
radius = min(centerX, centerY)
hour += minutes / 60.0 # added so the hour hand moves continuously
x, y = self.point(hour, 12, (radius * .65))
hourX, hourY = (x + centerX), (centerY - y)
x, y = self.point(minutes, 60, (radius * .85))
minutesX, minutesY = (x + centerX), (centerY - y)
x, y = self.point(seconds, 60, (radius * .85))
secondsX, secondsY = (x + centerX), (centerY - y)
# Draw the hour hand...
drawDC.SetPen(wxPen(self.GetForegroundColour(), 5, wxSOLID))
drawDC.DrawLine(centerX, centerY, hourX, hourY)
# Draw the minutes hand...
drawDC.SetPen(wxPen(self.GetForegroundColour(), 3, wxSOLID))
drawDC.DrawLine(centerX, centerY, minutesX, minutesY)
# Draw the seconds hand...
drawDC.SetPen(wxPen(self.GetForegroundColour(), 1, wxSOLID))
drawDC.DrawLine(centerX, centerY, secondsX, secondsY)
# Draw the specified set of line marks inside the clock face for the
# hours or minutes...
def DrawFace(self):
backgroundBrush = wxBrush(self.GetBackgroundColour(), wxSOLID)
drawDC = wxMemoryDC()
drawDC.SelectObject(self.faceBitmap)
drawDC.SetBackground(backgroundBrush)
drawDC.Clear()
W,H = self.faceBitmap.GetWidth(), self.faceBitmap.GetHeight()
centerX = W / 2
centerY = H / 2
# Draw the marks for hours and minutes...
self.DrawTimeMarks(drawDC, self.minuteMarks, centerX, centerY, 4)
self.DrawTimeMarks(drawDC, self.hourMarks, centerX, centerY, 9)
def DrawTimeMarks(self, drawDC, markCount, centerX, centerY, markSize):
for i in range(markCount):
x, y = self.point(i + 1, markCount, min(centerX,centerY) - 16)
scaledX = x + centerX - markSize/2
scaledY = centerY - y - markSize/2
drawDC.SetBrush(wxBrush(self.tickMarksBrushC, wxSOLID))
drawDC.SetPen(wxPen(self.tickMarksPenC, 1, wxSOLID))
if self.tickMarkStyle != self.TICKS_NONE:
if self.tickMarkStyle == self.TICKS_CIRCLE:
drawDC.DrawEllipse(scaledX - 2, scaledY, markSize, markSize)
else:
drawDC.DrawRectangle(scaledX - 3, scaledY, markSize, markSize)
def point(self, tick, range, radius):
angle = tick * (360.0 / range)
radiansPerDegree = math.pi / 180
pointX = int(round(radius * math.sin(angle * radiansPerDegree)))
pointY = int(round(radius * math.cos(angle * radiansPerDegree)))
return wxPoint(pointX, pointY)
if __name__ == "__main__":
class App(wxApp):
def OnInit(self):
frame = wxFrame(None, -1, "AnalogClockWindow Test", size=(375,375))
clock = AnalogClockWindow(frame)
clock.SetTickMarkColours("RED")
clock.SetHandsColour("WHITE")
clock.SetBackgroundColour("BLUE")
frame.Centre(wxBOTH)
frame.Show(True)
self.SetTopWindow(frame)
return true
theApp = App(0)
theApp.MainLoop()
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
import wx.lib.analogclock
__doc__ = wx.lib.analogclock.__doc__
AnalogClockWindow = wx.lib.analogclock.AnalogClockWindow
+6 -88
View File
@@ -1,91 +1,9 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.anchors
# Purpose: A class that provides an easy to use interface over layout
# constraints for anchored layout.
#
# Author: Riaan Booysen
#
# Created: 15-Dec-2000
# RCS-ID: $Id$
# Copyright: (c) 2000 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
from wxPython.wx import wxLayoutConstraints, wxTop, wxLeft, wxBottom, wxRight, \
wxHeight, wxWidth
import wx.lib.anchors
class LayoutAnchors(wxLayoutConstraints):
""" A class that implements Delphi's Anchors with wxLayoutConstraints.
__doc__ = wx.lib.anchors.__doc__
Anchored sides maintain the distance from the edge of the
control to the same edge of the parent.
When neither side is selected, the control keeps the same
relative position to both sides.
The current position and size of the control and it's parent
is used when setting up the constraints. To change the size or
position of an already anchored control, set the constraints to
None, reposition or resize and reapply the anchors.
Examples:
Let's anchor the right and bottom edge of a control and
resize it's parent.
ctrl.SetConstraints(LayoutAnchors(ctrl, left=0, top=0, right=1, bottom=1))
+=========+ +===================+
| +-----+ | | |
| | * | -> | |
| +--*--+ | | +-----+ |
+---------+ | | * |
| +--*--+ |
+-------------------+
* = anchored edge
When anchored on both sides the control will stretch horizontally.
ctrl.SetConstraints(LayoutAnchors(ctrl, 1, 0, 1, 1))
+=========+ +===================+
| +-----+ | | |
| * * | -> | |
| +--*--+ | | +---------------+ |
+---------+ | * ctrl * |
| +-------*-------+ |
+-------------------+
* = anchored edge
"""
def __init__(self, control, left = 1, top = 1, right = 0, bottom = 0):
wxLayoutConstraints.__init__(self)
parent = control.GetParent()
if not parent: return
pPos, pSize = parent.GetPosition(), parent.GetClientSize()
cPos, cSize = control.GetPosition(), control.GetSize()
self.setConstraintSides(self.left, wxLeft, left,
self.right, wxRight, right,
self.width, wxWidth, self.centreX,
cPos.x, cSize.x, pSize.x, parent)
self.setConstraintSides(self.top, wxTop, top,
self.bottom, wxBottom, bottom,
self.height, wxHeight, self.centreY,
cPos.y, cSize.y, pSize.y, parent)
def setConstraintSides(self, side1, side1Edge, side1Anchor,
side2, side2Edge, side2Anchor,
size, sizeEdge, centre,
cPos, cSize, pSize, parent):
if side2Anchor:
side2.SameAs(parent, side2Edge, pSize - (cPos + cSize))
if side1Anchor:
side1.SameAs(parent, side1Edge, cPos)
if not side2Anchor:
size.AsIs()
else:
size.AsIs()
if not side2Anchor:
centre.PercentOf(parent, sizeEdge,
int(((cPos + cSize / 2.0) / pSize)*100))
LayoutAnchors = wx.lib.anchors.LayoutAnchors
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,26 +1 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
This file is part of wxPyColourChooser.
This version of wxPyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
from pycolourchooser import *
# For the American in you
wxPyColorChooser = wxPyColourChooser
__all__ = [
'canvas',
'pycolourbox',
'pycolourchooser',
'pycolourslider',
'pypalette',
]
#
+7 -117
View File
@@ -1,120 +1,10 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.canvas
This version of wxPyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
__doc__ = wx.lib.colourchooser.canvas.__doc__
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
from wxPython.wx import *
class BitmapBuffer(wxMemoryDC):
"""A screen buffer class.
This class implements a screen output buffer. Data is meant to
be drawn in the buffer class and then blitted directly to the
output device, or on-screen window.
"""
def __init__(self, width, height, colour):
"""Initialize the empty buffer object."""
wxMemoryDC.__init__(self)
self.width = width
self.height = height
self.colour = colour
self.bitmap = wxEmptyBitmap(self.width, self.height)
self.SelectObject(self.bitmap)
# Initialize the buffer to the background colour
self.SetBackground(wxBrush(self.colour, wxSOLID))
self.Clear()
# Make each logical unit of the buffer equal to 1 pixel
self.SetMapMode(wxMM_TEXT)
def GetBitmap(self):
"""Returns the internal bitmap for direct drawing."""
return self.bitmap
class Canvas(wxWindow):
"""A canvas class for arbitrary drawing.
The Canvas class implements a window that allows for drawing
arbitrary graphics. It implements a double buffer scheme and
blits the off-screen buffer to the window during paint calls
by the windowing system for speed.
Some other methods for determining the canvas colour and size
are also provided.
"""
def __init__(self, parent, id,
pos=wxDefaultPosition,
size=wxDefaultSize,
style=wxSIMPLE_BORDER):
"""Creates a canvas instance and initializes the off-screen
buffer. Also sets the handler for rendering the canvas
automatically via size and paint calls from the windowing
system."""
wxWindow.__init__(self, parent, id, pos, size, style)
# Perform an intial sizing
self.ReDraw()
# Register event handlers
EVT_SIZE(self, self.onSize)
EVT_PAINT(self, self.onPaint)
def MakeNewBuffer(self):
size = self.GetSizeTuple()
self.buffer = BitmapBuffer(size[0], size[1],
self.GetBackgroundColour())
def onSize(self, event):
"""Perform actual redraw to off-screen buffer only when the
size of the canvas has changed. This saves a lot of computation
since the same image can be re-used, provided the canvas size
hasn't changed."""
self.MakeNewBuffer()
self.DrawBuffer()
self.Refresh()
def ReDraw(self):
"""Explicitly tells the canvas to redraw it's contents."""
self.onSize(None)
def Refresh(self):
"""Re-draws the buffer contents on-screen."""
dc = wxClientDC(self)
self.Blit(dc)
def onPaint(self, event):
"""Renders the off-screen buffer on-screen."""
dc = wxPaintDC(self)
self.Blit(dc)
def Blit(self, dc):
"""Performs the blit of the buffer contents on-screen."""
width, height = self.buffer.GetSize()
dc.BeginDrawing()
dc.Blit(0, 0, width, height, self.buffer, 0, 0)
dc.EndDrawing()
def GetBoundingRect(self):
"""Returns a tuple that contains the co-ordinates of the
top-left and bottom-right corners of the canvas."""
x, y = self.GetPositionTuple()
w, h = self.GetSize()
return(x, y + h, x + w, y)
def DrawBuffer(self):
"""Actual drawing function for drawing into the off-screen
buffer. To be overrideen in the implementing class. Do nothing
by default."""
pass
BitmapBuffer = wx.lib.colourchooser.canvas.BitmapBuffer
Canvas = wx.lib.colourchooser.canvas.Canvas
+5 -21
View File
@@ -1,24 +1,8 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.intl
This version of wxPyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
__doc__ = wx.lib.colourchooser.intl.__doc__
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
try:
import gettext
gettext.bindtextdomain('wxpycolourchooser')
gettext.textdomain('wxpycolourchooser')
_ = gettext.gettext
except Exception, strerror:
print "Warning: Couldn't import translation function: %(str)s" %{ 'str' : strerror }
print "Defaulting to En"
_ = lambda x: x
@@ -1,79 +1,9 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.pycolourbox
This version of wxPyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
__doc__ = wx.lib.colourchooser.pycolourbox.__doc__
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
from wxPython.wx import *
class PyColourBox(wxPanel):
"""A Colour Selection Box
The Colour selection box implements button like behavior but contains
a solid-filled, coloured sub-box. Placing the colour in a sub-box allows
for filling in the main panel's background for a high-lighting effect.
"""
def __init__(self, parent, id, colour=(0, 0, 0), size=(25, 20)):
"""Creates a new colour box instance and initializes the colour
content."""
wxPanel.__init__(self, parent, id,
size=wxSize(size[0], size[1]))
self.colour_box = wxPanel(self, -1, style=wxSIMPLE_BORDER)
sizer = wxGridSizer(1, 1)
sizer.Add(self.colour_box, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
sizer.SetItemMinSize(self.colour_box, size[0] - 5, size[1] - 5)
self.SetAutoLayout(True)
self.SetSizer(sizer)
self.Layout()
self.real_bg = self.GetBackgroundColour()
self.SetColourTuple(colour)
def GetColourBox(self):
"""Returns a reference to the internal box object containing the
color. This function is useful for setting up event handlers for
the box."""
return self.colour_box
def GetColour(self):
"""Returns a wxColour object indicating the box's current colour."""
return self.colour_box.GetBackgroundColour()
def SetColour(self, colour):
"""Accepts a wxColour object and sets the box's current color."""
self.colour_box.SetBackgroundColour(colour)
self.colour_box.Refresh()
def SetColourTuple(self, colour):
"""Sets the box's current couple to the given tuple."""
self.colour = colour
self.colour_box.SetBackgroundColour(wxColour(*self.colour))
def Update(self):
wxPanel.Update(self)
self.colour_box.Update()
def SetHighlight(self, val):
"""Accepts a boolean 'val' toggling the box's highlighting."""
# XXX This code has been disabled for now until I can figure out
# how to get this to work reliably across all platforms.
if val:
#A wxColourPtr is returned in windows, making this difficult
red =(self.real_bg.Red() - 45) % 255
green =(self.real_bg.Green() - 45) % 255
blue =(self.real_bg.Blue() - 45) % 255
new_colour = wxColour(red, green, blue)
self.SetBackgroundColour(new_colour)
else:
self.SetBackgroundColour(self.real_bg)
self.Refresh()
PyColourBox = wx.lib.colourchooser.pycolourbox.PyColourBox
@@ -1,385 +1,10 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.pycolourchooser
This version of wxPyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
__doc__ = wx.lib.colourchooser.pycolourchooser.__doc__
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
import pycolourbox
import pypalette
import pycolourslider
import colorsys
from intl import _
from wxPython.wx import *
class wxPyColourChooser(wxPanel):
"""A Pure-Python implementation of the colour chooser dialog.
The PyColourChooser is a pure python implementation of the colour
chooser dialog. It's useful for embedding the colour choosing functionality
inside other widgets, when the pop-up dialog is undesirable. It can also
be used as a drop-in replacement on the GTK platform, as the native
dialog is kind of ugly.
"""
colour_names = [
'ORANGE',
'GOLDENROD',
'WHEAT',
'SPRING GREEN',
'SKY BLUE',
'SLATE BLUE',
'MEDIUM VIOLET RED',
'PURPLE',
'RED',
'YELLOW',
'MEDIUM SPRING GREEN',
'PALE GREEN',
'CYAN',
'LIGHT STEEL BLUE',
'ORCHID',
'LIGHT MAGENTA',
'BROWN',
'YELLOW',
'GREEN',
'CADET BLUE',
'MEDIUM BLUE',
'MAGENTA',
'MAROON',
'ORANGE RED',
'FIREBRICK',
'CORAL',
'FOREST GREEN',
'AQUAMARINE',
'BLUE',
'NAVY',
'THISTLE',
'MEDIUM VIOLET RED',
'INDIAN RED',
'GOLD',
'MEDIUM SEA GREEN',
'MEDIUM BLUE',
'MIDNIGHT BLUE',
'GREY',
'PURPLE',
'KHAKI',
'BLACK',
'MEDIUM FOREST GREEN',
'KHAKI',
'DARK GREY',
'SEA GREEN',
'LIGHT GREY',
'MEDIUM SLATE BLUE',
'WHITE',
]
# Generate the custom colours. These colours are shared across
# all instances of the colour chooser
NO_CUSTOM_COLOURS = 16
custom_colours = [ (wxColour(255, 255, 255),
pycolourslider.PyColourSlider.HEIGHT / 2)
] * NO_CUSTOM_COLOURS
last_custom = 0
idADD_CUSTOM = wxNewId()
idSCROLL = wxNewId()
def __init__(self, parent, id):
"""Creates an instance of the colour chooser. Note that it is best to
accept the given size of the colour chooser as it is currently not
resizeable."""
wxPanel.__init__(self, parent, id)
self.basic_label = wxStaticText(self, -1, _("Basic Colours:"))
self.custom_label = wxStaticText(self, -1, _("Custom Colours:"))
self.add_button = wxButton(self, self.idADD_CUSTOM, _("Add to Custom Colours"))
EVT_BUTTON(self, self.idADD_CUSTOM, self.onAddCustom)
# Since we're going to be constructing widgets that require some serious
# computation, let's process any events (like redraws) right now
wxYield()
# Create the basic colours palette
self.colour_boxs = [ ]
colour_grid = wxGridSizer(6, 8)
for name in self.colour_names:
new_id = wxNewId()
box = pycolourbox.PyColourBox(self, new_id)
EVT_LEFT_DOWN(box.GetColourBox(), lambda x, b=box: self.onBasicClick(x, b))
self.colour_boxs.append(box)
colour_grid.Add(box, 0, wxEXPAND)
# Create the custom colours palette
self.custom_boxs = [ ]
custom_grid = wxGridSizer(2, 8)
for wxcolour, slidepos in self.custom_colours:
new_id = wxNewId()
custom = pycolourbox.PyColourBox(self, new_id)
EVT_LEFT_DOWN(custom.GetColourBox(), lambda x, b=custom: self.onCustomClick(x, b))
custom.SetColour(wxcolour)
custom_grid.Add(custom, 0, wxEXPAND)
self.custom_boxs.append(custom)
csizer = wxBoxSizer(wxVERTICAL)
csizer.Add(1, 25)
csizer.Add(self.basic_label, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add(colour_grid, 0, wxEXPAND)
csizer.Add(1, 25)
csizer.Add(self.custom_label, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add(custom_grid, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add(self.add_button, 0, wxEXPAND)
self.palette = pypalette.PyPalette(self, -1)
self.colour_slider = pycolourslider.PyColourSlider(self, -1)
self.slider = wxSlider(self, self.idSCROLL, 86, 0, self.colour_slider.HEIGHT - 1,
style=wxSL_VERTICAL, size=wxSize(15, self.colour_slider.HEIGHT))
EVT_COMMAND_SCROLL(self, self.idSCROLL, self.onScroll)
psizer = wxBoxSizer(wxHORIZONTAL)
psizer.Add(self.palette, 0, 0)
psizer.Add(10, 1)
psizer.Add(self.colour_slider, 0, wxALIGN_CENTER_VERTICAL)
psizer.Add(self.slider, 0, wxALIGN_CENTER_VERTICAL)
# Register mouse events for dragging across the palette
EVT_LEFT_DOWN(self.palette, self.onPaletteDown)
EVT_LEFT_UP(self.palette, self.onPaletteUp)
EVT_MOTION(self.palette, self.onPaletteMotion)
self.mouse_down = False
self.solid = pycolourbox.PyColourBox(self, -1, size=wxSize(75, 50))
slabel = wxStaticText(self, -1, _("Solid Colour"))
ssizer = wxBoxSizer(wxVERTICAL)
ssizer.Add(self.solid, 0, 0)
ssizer.Add(1, 2)
ssizer.Add(slabel, 0, wxALIGN_CENTER_HORIZONTAL)
hlabel = wxStaticText(self, -1, _("H:"))
self.hentry = wxTextCtrl(self, -1)
self.hentry.SetSize((40, -1))
slabel = wxStaticText(self, -1, _("S:"))
self.sentry = wxTextCtrl(self, -1)
self.sentry.SetSize((40, -1))
vlabel = wxStaticText(self, -1, _("V:"))
self.ventry = wxTextCtrl(self, -1)
self.ventry.SetSize((40, -1))
hsvgrid = wxFlexGridSizer(1, 6, 2, 2)
hsvgrid.AddMany ([
(hlabel, 0, wxALIGN_CENTER_VERTICAL), (self.hentry, 0, 0),
(slabel, 0, wxALIGN_CENTER_VERTICAL), (self.sentry, 0, 0),
(vlabel, 0, wxALIGN_CENTER_VERTICAL), (self.ventry, 0, 0),
])
rlabel = wxStaticText(self, -1, _("R:"))
self.rentry = wxTextCtrl(self, -1)
self.rentry.SetSize((40, -1))
glabel = wxStaticText(self, -1, _("G:"))
self.gentry = wxTextCtrl(self, -1)
self.gentry.SetSize((40, -1))
blabel = wxStaticText(self, -1, _("B:"))
self.bentry = wxTextCtrl(self, -1)
self.bentry.SetSize((40, -1))
lgrid = wxFlexGridSizer(1, 6, 2, 2)
lgrid.AddMany([
(rlabel, 0, wxALIGN_CENTER_VERTICAL), (self.rentry, 0, 0),
(glabel, 0, wxALIGN_CENTER_VERTICAL), (self.gentry, 0, 0),
(blabel, 0, wxALIGN_CENTER_VERTICAL), (self.bentry, 0, 0),
])
gsizer = wxGridSizer(2, 1)
gsizer.SetVGap (10)
gsizer.SetHGap (2)
gsizer.Add(hsvgrid, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
gsizer.Add(lgrid, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
hsizer = wxBoxSizer(wxHORIZONTAL)
hsizer.Add(ssizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
hsizer.Add(gsizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
vsizer = wxBoxSizer(wxVERTICAL)
vsizer.Add(1, 5)
vsizer.Add(psizer, 0, 0)
vsizer.Add(1, 15)
vsizer.Add(hsizer, 0, wxEXPAND)
sizer = wxBoxSizer(wxHORIZONTAL)
sizer.Add(5, 1)
sizer.Add(csizer, 0, wxEXPAND)
sizer.Add(10, 1)
sizer.Add(vsizer, 0, wxEXPAND)
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
self.InitColours()
self.UpdateColour(self.solid.GetColour())
def InitColours(self):
"""Initializes the pre-set palette colours."""
for i in range(len(self.colour_names)):
colour = wxTheColourDatabase.FindColour(self.colour_names[i])
self.colour_boxs[i].SetColourTuple((colour.Red(),
colour.Green(),
colour.Blue()))
def onBasicClick(self, event, box):
"""Highlights the selected colour box and updates the solid colour
display and colour slider to reflect the choice."""
if hasattr(self, '_old_custom_highlight'):
self._old_custom_highlight.SetHighlight(False)
if hasattr(self, '_old_colour_highlight'):
self._old_colour_highlight.SetHighlight(False)
box.SetHighlight(True)
self._old_colour_highlight = box
self.UpdateColour(box.GetColour())
def onCustomClick(self, event, box):
"""Highlights the selected custom colour box and updates the solid
colour display and colour slider to reflect the choice."""
if hasattr(self, '_old_colour_highlight'):
self._old_colour_highlight.SetHighlight(False)
if hasattr(self, '_old_custom_highlight'):
self._old_custom_highlight.SetHighlight(False)
box.SetHighlight(True)
self._old_custom_highlight = box
# Update the colour panel and then the slider accordingly
box_index = self.custom_boxs.index(box)
base_colour, slidepos = self.custom_colours[box_index]
self.UpdateColour(box.GetColour())
self.slider.SetValue(slidepos)
def onAddCustom(self, event):
"""Adds a custom colour to the custom colour box set. Boxes are
chosen in a round-robin fashion, eventually overwriting previously
added colours."""
# Store the colour and slider position so we can restore the
# custom colours just as they were
self.setCustomColour(self.last_custom,
self.solid.GetColour(),
self.colour_slider.GetBaseColour(),
self.slider.GetValue())
self.last_custom = (self.last_custom + 1) % self.NO_CUSTOM_COLOURS
def setCustomColour (self, index, true_colour, base_colour, slidepos):
"""Sets the custom colour at the given index. true_colour is wxColour
object containing the actual rgb value of the custom colour.
base_colour (wxColour) and slidepos (int) are used to configure the
colour slider and set everything to its original position."""
self.custom_boxs[index].SetColour(true_colour)
self.custom_colours[index] = (base_colour, slidepos)
def UpdateColour(self, colour):
"""Performs necessary updates for when the colour selection has
changed."""
# Reset the palette to erase any highlighting
self.palette.ReDraw()
# Set the color info
self.solid.SetColour(colour)
self.colour_slider.SetBaseColour(colour)
self.colour_slider.ReDraw()
self.slider.SetValue(0)
self.UpdateEntries(colour)
def UpdateEntries(self, colour):
"""Updates the color levels to display the new values."""
# Temporary bindings
r = colour.Red()
g = colour.Green()
b = colour.Blue()
# Update the RGB entries
self.rentry.SetValue(str(r))
self.gentry.SetValue(str(g))
self.bentry.SetValue(str(b))
# Convert to HSV
h,s,v = colorsys.rgb_to_hsv(r / 255.0, g / 255.0, b / 255.0)
self.hentry.SetValue("%.2f" % (h))
self.sentry.SetValue("%.2f" % (s))
self.ventry.SetValue("%.2f" % (v))
def onPaletteDown(self, event):
"""Stores state that the mouse has been pressed and updates
the selected colour values."""
self.mouse_down = True
self.palette.ReDraw()
self.doPaletteClick(event.m_x, event.m_y)
def onPaletteUp(self, event):
"""Stores state that the mouse is no longer depressed."""
self.mouse_down = False
def onPaletteMotion(self, event):
"""Updates the colour values during mouse motion while the
mouse button is depressed."""
if self.mouse_down:
self.doPaletteClick(event.m_x, event.m_y)
def doPaletteClick(self, m_x, m_y):
"""Updates the colour values based on the mouse location
over the palette."""
# Get the colour value and update
colour = self.palette.GetValue(m_x, m_y)
self.UpdateColour(colour)
# Highlight a fresh selected area
self.palette.ReDraw()
self.palette.HighlightPoint(m_x, m_y)
# Force an onscreen update
self.solid.Update()
self.colour_slider.Refresh()
def onScroll(self, event):
"""Updates the solid colour display to reflect the changing slider."""
value = self.slider.GetValue()
colour = self.colour_slider.GetValue(value)
self.solid.SetColour(colour)
self.UpdateEntries(colour)
def SetValue(self, colour):
"""Updates the colour chooser to reflect the given wxColour."""
self.UpdateColour(colour)
def GetValue(self):
"""Returns a wxColour object indicating the current colour choice."""
return self.solid.GetColour()
def main():
"""Simple test display."""
class App(wxApp):
def OnInit(self):
frame = wxFrame(NULL, -1, 'PyColourChooser Test')
chooser = wxPyColourChooser(frame, -1)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(chooser, 0, 0)
frame.SetAutoLayout(True)
frame.SetSizer(sizer)
sizer.Fit(frame)
frame.Show(True)
self.SetTopWindow(frame)
return True
app = App()
app.MainLoop()
if __name__ == '__main__':
main()
main = wx.lib.colourchooser.pycolourchooser.main
wxPyColourChooser = wx.lib.colourchooser.pycolourchooser.wxPyColourChooser
@@ -1,82 +1,9 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.pycolourslider
You should have received a file COPYING containing license terms
along with this program; if not, write to Michael Gilfix
(mgilfix@eecs.tufts.edu) for a copy.
__doc__ = wx.lib.colourchooser.pycolourslider.__doc__
This version of wxPyColourChooser is open source; you can redistribute it and/or
modify it under the terms listed in the file COPYING.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
import canvas
import colorsys
from wxPython.wx import *
class PyColourSlider(canvas.Canvas):
"""A Pure-Python Colour Slider
The colour slider displays transitions from value 0 to value 1 in
HSV, allowing the user to select a colour within the transition
spectrum.
This class is best accompanying by a wxSlider that allows the user
to select a particular colour shade.
"""
HEIGHT = 172
WIDTH = 12
def __init__(self, parent, id, colour=None):
"""Creates a blank slider instance. A colour must be set before the
slider will be filled in."""
# Set the base colour first since our base class calls the buffer
# drawing function
self.SetBaseColour(colour)
canvas.Canvas.__init__(self, parent, id,
size=wxSize(self.WIDTH, self.HEIGHT))
def SetBaseColour(self, colour):
"""Sets the base, or target colour, to use as the central colour
when calculating colour transitions."""
self.base_colour = colour
def GetBaseColour(self):
"""Return the current colour used as a colour base for filling out
the slider."""
return self.base_colour
def GetValue(self, pos):
"""Returns the colour value for a position on the slider. The position
must be within the valid height of the slider, or results can be
unpredictable."""
return self.buffer.GetPixel(0, pos)
def DrawBuffer(self):
"""Actual implementation of the widget's drawing. We simply draw
from value 0.0 to value 1.0 in HSV."""
if self.base_colour is None:
return
target_red = self.base_colour.Red()
target_green = self.base_colour.Green()
target_blue = self.base_colour.Blue()
h,s,v = colorsys.rgb_to_hsv(target_red / 255.0, target_green / 255.0,
target_blue / 255.0)
v = 1.0
vstep = 1.0 / self.HEIGHT
for y_pos in range(0, self.HEIGHT):
r,g,b = [c * 255.0 for c in colorsys.hsv_to_rgb(h,s,v)]
colour = wxColour(int(r), int(g), int(b))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.DrawRectangle(0, y_pos, 15, 1)
v = v - vstep
PyColourSlider = wx.lib.colourchooser.pycolourslider.PyColourSlider
@@ -1,214 +1,12 @@
"""
wxPyColourChooser
Copyright (C) 2002 Michael Gilfix
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
This file is part of wxPyColourChooser.
import wx.lib.colourchooser.pypalette
You should have received a file COPYING containing license terms
along with this program; if not, write to Michael Gilfix
(mgilfix@eecs.tufts.edu) for a copy.
__doc__ = wx.lib.colourchooser.pypalette.__doc__
This version of wxPyColourChooser is open source; you can redistribute it and/or
modify it under the terms listed in the file COPYING.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
import canvas
import colorsys
import cStringIO, zlib
from wxPython.wx import *
# Bitmap functions generated from img2py
def getData():
return zlib.decompress(
'x\xdaUV{<\x93{\x18\x1f:\xe3\xc8Xj\xa3a\xe6R\x9db*B.3\x93\xeb\xe9\x1c\xb7\
\xe4\xb2r9\x8c\xe5\x12e\xc9\xda\x88\x9a\xb4\x83\xcet\xa1N\xae\x85\xe3\xb2\
\xe1,\xb7\xc2\x8a\xd0\x99D\xc8t\xdc\x86r\x1f\x96\\\x16k:\xebC\xe78\xef\xe7\
\xf3\xbe\xbf?\xde\xf7\xf9=\xcf\xf3\xbd<\xbf\xf7WgG;\x90,L\x16\x00\x00\x80\
\x1c\xec\xad]\xc5+[|7\xc8\x00\xc5O\xccv\xddE\xf1\xb2\x8d`\xe5\xe0&#\xbebdpT\
\x00`\xbb\x94\x835\xc6\x8d\x989\x97\xd5N\xca\xb3\x05\xdb\xdc\x9c[\xd0\xf4\
\xd2\xe6\x7f\xb9\xd3\xaa\xe9\x85\xd3\xd5\xd9\xbe]\xa7\xf2\xf1\xf2\x1b\xef\
\x1b\xe6\xb7\tF\xca\t`\xef\xf9\xb5\xa2\x87\xe1\x8d\xd3\x8ft\xef\x06z\xa5\x8f\
\xd7\x04\xf6y\xaf\xfbT\x0e\xad~\xce\xf1E\xa7\xc7\xe9\r\x8c\xab\xb7\xad_\xe4/\
r\xf9\xb1\xbe\x97[\xb3\x88\xfcx\xd6\\\xdf\x15\x88\xca\xcc\xc0\xb0\x10\xef\
\x81B\x9a\xf3Xzq\x1c\xb9\xa2E\xb2\xd3v\x80\xfd90@Ju[\xc3H\xe0\xea\xca\xdc\
\xfbr\xde\xbb\xf0U\xcd\xf4\xd7\xfe\xabc\xbaN\xc2\xe3\xcc>T\xa6)(\xaa\x9f\xe7\
\n\xaa\xe9\x00gcz\xa8Y\xb4\x8a\xc4\x0fr\x9a\x89\xe4\x9eJ\xe7\xa6z\xaf\xf7\
\xcc\xc4\x11YI\xbfx\n@y\x04\x01\x00\nL\xd8\xb3#\xfa\x0e\'\xb7\xc1n\x98\xd3h\
\xd5\x14\xd50\xeaA\x0bd\x8a\x16\x07\x96\xa0#\x13/!\xbf\xf1\xe5\x94)\xd5\xc3\
\xfe\x9ej\x0c<\x8b<8\x89\x98\xcb\x9ek\x18X^\xf9\xa9\xffJ\r/\xd93\xda\xc2\xfd\
\xfa\tt\xb9\xa3\x07\xe8u1\xc5\\O\xe9w\x94\xd6\n\x1e\xe8\xb1Q#@Z\xe2\x10\xd1\
\xcb\xc7\x17\xbd\x9e\x94\x14~\xf9\xd6\xe0\xb1\xb3\xe8\xd8\x07E\xe4\xa6F\x87\
\xbe6:K\xf8\xfanrn\x8b\xa4=e\xb3\x98\xf3\xc8\xde|\x0b\xf0\xb5\xb7\xfb\x0e\
\xf5\x83:m3\xcbs\xfe*T\xc7\x89\xe1\x1a\xc8X=\xbfZ\xc4#\xd0\xee\x93d\xb6lL\
\x15\xe4\xe3\xf7\xd8w\r\x1eK\xe0\xce\xad-`\x19g\xe6\x1f\xc8}\xcc}\xee\xecF\
\x19_\xa6PUq\xee\xa2\x80\x1d\xbc\xf5\x14g\xe04\xa4\xc0EZB\xe6[\x1al\xb2!,\
\xac\xa4\xf3O\x83\xa5y\x96(\xa7\xdd\xc61\x1aX\xa4X\xa8\x96\xdf2\x93\x067\x1c\
\xf0\xed\x10\xaa\xe3\xe9\x96\xac\'l\x14\xb7\xc1\x0ed\x85\x96\xb1\x84m&d\x872\
\x1f)\xe6wt\xd6\tV\xbe\xd4\xbe\xeaE\xcf\xaca\x92f4*Z\xce\xf8\xa0\xd9\x97\xa2\
+\xcc\x90$\xbb\xac8\x0b\xf7\x93\xfa\xb6\xf2\x92\x9d\xa0M\xec\xc6\xaa<\x17\
\xad\x8d\'\xc29\xd1uQjcU}\x8a\x1c\xbf\x9fg\x12\x9c\x1f\\4RZ8\xe2\xf5s@J\t\
\xc5\rU\x92\xab\xf6B\xb3\x97\x8f^\xb8\xa5_\xd0\x98tQ\xa6KA\x12\x0c\x14gl\xc0\
\x00\xe4f*=\xa3\x1ef\x0c\rU<\xb1sO\xaa\x0c\x82;\r)\xc8\x9c\xc0\x1f9CMch\xd4\
\x9fn\xde/g\xc3C\xb0\xb0\x8cuS6\xf3;\x8d2q\x7fG7\x88;\xb4~9\xd5e\xa1}\x7f\
\xd5\xa9Z\x88\x99\xaft+\xeca?\xa2qh\xaf\x8af\xbf\x82\xfe%\xac\xf6\nC_\xc6D\
\xc6Ry\xb3\xb7N\x11"\xcfU\xbb@m\x86AY\na\xfa;\xa1\x93\x96\xf2i\xd0\x04S\x90~\
\x1b\xb8z[1C\xde\x15w\xed\x0b\xd8\xd0\xbe\\\x19\x84\x84\xfe\x1bE\re\xda\x1az\
6\xe6\xbe!+\x86V\xbd\xfb\xc3\xfb\xd9[\xff\xc0\x8c\xc5\nH<\x82U#2S\t\xc8\x1en\
\xa7\xb5E\xde\x14W\xd2w\xe3\xf0\x18\x02\xa0\xf7\xad\xb6\xb2\x96\xfb\xbbH\x02\
\x0b\x85P\xb7\xe4\x02!\xe6a\xc4d\xe8]\x17\xa4\x8bk2G\xaf\xa2p\\\x8e\xd0\x8e\
\t\nf\xce\xf0\x10}O\xc1\x95\x9e\x80\xa6\x91\x8d\xae0\xcf\xa0\xc7\x97-h\xc3\
\x1f\xb8"l\x14\xcaz9\xffYl\x15.l|\xc4\x94\xdd&\x9c\x9f\xf8\xb8f7\x08cA\x1e\
\x85\x11,\xb0\xba\xf1\x87639\xfbJ\xef~e\xf3\xdbK\xd4\xe7\xec\xa5\x92\x17\xf7\
\x1aO\xe3*\xd5\xf3\xcbA\xef\xf4\xa4[\x1d\xaf\xd7>M-\xf1\xb9@\xea\x96x\xd9(\
\x06Z\xec+J\xed\xe5\xd45\x95\xe1\xba\xeb\xf4\xa4\xa3i\xbb\x82}\xd0\xf6Lh\xe8\
E4;0\x9aPk\x0emo~G\x04\xb6&u\xb31\x80\xdao\x01\xf5P\x1d\xd8\x05\x92qmV\xf6R\
\x17\x89\x1a-\xf4\x15P*\xf9?|\xcea\xa9\x8f\x99~6\x92^\xf8\x03s\x11;v\xe2D\
\xc4^\x1c>Q\xbfY\xd0n\xbaE\xc0b=\x91\x0c=[U\x86\xfb\x06\xb52\x92\x19M1uz<\
\xb1\xa4r~4\x83E\xe2y\x08\x0f\nQ\x84\xe8\xfa\xfa\xea\x13\x0e\xd4\x95\x91\\\
\x7f\xf6)\x08`\xb6\x89\xc5\x95^\xff\xe2\\\x03X\xe4\xbe\x88x\x8f\xe34\xb7\xe6\
\xbe\t\xf8\\w\x9c\xd3\x1a\xee\x98\xeeW\x92\xad\x83\x99\xb6B\xcb\x8f\xbdD\x86\
\xc6\xe3\xab\x1b\xb2\xdf\x08:9\xbc\x9e\xf3\xf9h\xd1\xec\xd98\xc8%\x0b\x87c\
\xb8\xbc\x0f\xad\x89\xca\xa5\x94J\xa9\x88j\x1ddo\x91u\x84\xf3\xcd\xea\xc5\
\xf6\x99\xab\xe0\xd7-\x92\xff:\xe6)T\x07\x0bd\x1b\xa9+9\xa4\x86\xec2F\xa1\
\xa6\x7f\xbc\xd1C\x9e\xf4=D\x12\xa2\x07\x94\t\xb1\xe8\xb5\xfb\x94\x14q~R\xa1\
\xe6Y<\xad\xcb\x94j\xbc\xb3##\x0f\xd0 \xbf\xc9\x01\xf8\xad\xb8V\x82sdO7\xbd\
\xbe\xd5Bd\x9f\xc0m#\xd4h<j\xf5*\x84\x86VKt\x0c4\xc1QkD\xbd\xee\xd0\xdc\xcc\
\xad\xc5bN\'\x8f\x1b\x92\x95\x8e\xdf,\xb1\xfa\xe0\xc7f\xd5\xc7\x95\xd1&\xe06\
\xcb\xb4t/\xa0KTj\xd0\xe2\xfb\xd2\xc3!\xf1\xcb?\r7_\x14K$xs(\xfa}~\xe2\xd9\
\xe5gP\xd4\xfaq\x97\xb1\x0b\xd2]\xe5|\x19o2(Vm\xfe>\xe5\x13jZ\xdan\x98\xf3\
\xe4:\x1ep\x93B\xec6?\tO\x0eaB\x99>\xc6Zkr\xcf!\x1b\x84|\xb5\xdb\x8b*O\xb4\
\xe7\x14Ko\xa0\x93\xecmq\xd7\xf0\xbd\x12\x07\x8d\x95\xd7\x7f\xf5&\xb8bmj\xda\
/&`>e\xeb\xfc\x14a\x19\x94S\x7f\xd2\xb5:\x8c\x04\x8f\x91\x03\xc2Q\x0e\xff{\
\x93\xc7\xea\xd6\xbb\x1b\x0e7\xe7E\xa6\xae\x9d\xc6\x85%\x9e\xfbnc\xe3\xff\
\xd4\xa2`9\x13\xa3\x97\x9e\xa4\x9b\x06\xa5\x9f\xec\x9f\x1a\x0c\xf0\xfe\xcd\
\x021\x9b\x0cM\xc06\xfd u:\xe7:g\x02\xc1r\x926\x9b\x7f\xe2\xf9\xe3\xed\xf1qU\
\xbe\xbf\xe8\x91\t\x0c0\xfb-\xe5%d\xef\x19v\x966\xec\xaaB\xe2`N[\x8c\xda\x98\
\xf4\xb4\x83\x13\xcc\x8a\x83\x81\xa3\x91%\xdb\xad\xab\xff\x87\xe1\xba\xda\
\xb5\xdb\xf0\x17\xfd\xf4F\x18KTNH\xf5J\xbc\x97\xdfB:\xa7\x96\xdf/k\x1c\xeaF_\
\x8c\xfc\xdfap\x1e\x99\xae8\x94b\xa1t<\xb54.3c\xd9\xe8y=u9FM;D\xa6\xc0\xea~\
\x0f"O\xee\x81\xdc\xa3\xb2\x1a\xa0\xa7\x02\xb9\x7f>\xfdg\x974\xc8\x0b\xbaU6P\
\xe7\x14\xd8\xd5 \x90\xbc\x0b\xf0\xb7\xc4\x7f\x08\xfaPl\xf5\xa7\x96\xac\xc2\
\x0f*\x05\xf3\x83\xe8\xce\xa7\xc4\x8c\xdbX\xa4U\x9b\xeeW\xe9\xf1\xbf\xa4Q#\
\xcbDQ\x18h\x02\xca\'\xca\xee),1"\x8d\xfb<\x15\xafl\xb8\xb3z\x18\x18\xaf\xb6\
I$\xa2\xbc\xe5\xe5J\xbe\x00\r\x08&<\x0eK\x98\x0e.[\xd1\xea`\xa9\xe2\x96\xae-\
d9%\xc0 \x85\xc5{c_\x03x\xaf\x8f\x98P= 0\x8e\xff\xaa\xf5>7\xfeO\x7f\x1b\xcbm\
\xb1W\xa7\t\x9b\xe1w\x02\xc5\xb5\x9fM/\x8d\xab\xe4u\r\x06\xa0\xd6\xc9\xb5\
\xf2\xb7J\x01\xda<\r\x9f\xd1\x06\x03\xea>\xab\x9d\xe6\xde\xb4\xbb\xb1\xc6\
\xa3EP\x1e\x17\x16\xf2\x1c\xa7\x823\xa7\xcc~\xd1\xdb\xb2\xcb\xbd\xe1\xdb\xf0\
W(,\xe9XD)3I\xc4\x15z_\x98\x8b\xb2v\xdb\x13\xd0\xb8\xf3U"\xb713\xaf\xa0\x1dC\
j\x0b\xb0\xf9\xfd\xef\x0ex\xd7l\xa5\xc1\xf7Z\xd2\x12\x1f\xbe\r\x87Shjm\xe3\
\x1c\x92\xbc\xc7^\x9e\xe5\x84\xf9\xb8\xcb\x88+\x12\xb4M\xee\xb0\xbb\xcd\xc4\
\x9c\xc7V\x1f\xde\x1b\x02\xb0!\x0c\xbeY&\xf6\xe9\xdd[u:0\x0f)(\xc5g\n\xd5\
\xb6\xcc\xf0st\n\x113\x81Q\xcc\xef\xaa\x1b\x9a#\xad|\x12\x98\xd8\xf7"\xa2\
\xa2\xd7\xdbwz+\x08\xb8\x0c\x9d&mZ\\-<\xbaG6j\x9cy@\x8ah\x10@\x8e\xd9\x12\
\x9dK\x00\xf3\xabdo\x1f\x8b\x80\x9c\xf7i^#\xc1X\x7f-\x13R](\x17\xa0\x89p\x9c\
L\x1a\xc5\x9c\x88U\xde\xc7\x9d\xd04\x04\x8en\x11\x8112\xbd\xf6J\x96wP\x06\
\xcd\xa9x\x08\xf7\xc3\xfc\x0e\xceE\xef\xf9j\xd50\x19~\x02~\xf7C\x13\xae\xd8\
\xea\x8e\xc9\x8c\xafpU\xc8\x8d\xaa\xe5\x88Q\xfan\x93\xf7\xf0(\xb0\x93\xf5NH\
\x1f\xae\xc5\xf8\xaa\x97F4\x19;\x19\xe4=\x89\xe0\xae\x15\xc9\xb6\xfe\xe2\xce\
\x1e\xca\xe6\x1a\n<\t\xa9].x\x03\xfd\x1c\x86Fd?\xbd\x17|z\x03\xa8\xafX[N"|\
\x16\xa3#\x0e\x92\xf0h{^+K\x04/!\x8f\xac\xf4\xe4\xbbH\xa9.\x85q\xdd\x93\xc7\
\xbb`\x96\xbb\xb5\xefQ\xdc\x9ch+G\xf8\xbf\xf6b\xdc\xfbww\xcf\xc7\x85\xf7\n@\
\x8d[\xdc\x1b\x8e\xd5\x85\x1c\xf0@JG\x08\xc9;\n\xfb\x9dX\xc5\x8e\t\\\xb3g#\
\xa0\xa2\xb7`\n\x96\x116?\xda\x83\xea\xa1\x7f.Y\x9f\xcb\xda_\x8c\xe9\x01s\
\x0f\xf6\x03\xb7:\xa0\xc6\x94\xaat\xc4\x96r\x1c\x12\x06\x1dZ\xf7\x10V\xd5\
\x088\x02N\xc6\xcc\x05y\xd7\xc0T\x07,c\xea\xb2\xcf\xc7=>y\x87M_\x9a\x86\x12\
\xa5\x92\x83\n_"\x84\xff\x8b7\x95\xfeu\x02\x9c\xf7\xe4\xfacQyo\xda\xbb\t\xed\
\xdeS\xd3\xb7\x04/j\xdb\x96\xae\xec\xd3\x01\xb8P\x8ap\x8c7\x88\xc2\xa8\xfd\
\x1d\xd5\xd1=\xab$*\x8c\x9dd\xacu\x07\xe3\xa6X\xed\x1d\xb9eHd@\x8f\xb7\xd4V\
\xdc\x95\x0f\xa91\xba\xe3s?\n\x12\xf2\x97\xefh\xf4\x1d\x89\x04\xccC)\x8f\x83\
\xbf\x84\xd5\xe0A\xb7\xccC\xf9\xc3fGA\x92\xe4\x12\x89\x03\x14bb\xdfe\xd9\x7f\
\x0f\x86\xc6R\xf9wC\x114\xe0\xdd\xae9\xc9ef\x92\xb6\x12\x1eU\'ZW\xa2\xe9\xa7\
4\x15\xfdb\nr\x17\xf1\xe15IkA\xe5\x12aM[&\x93T\x16\xa5\x92x\xf8\xc3\xd4\xca\
\xd8[\x96]wPNO\t!5\xaf&\xfarlLC\xdd\x00\xdd\x8e\x13qc\xea&]nAb\x8b1>)9\x047\
\xc5\x8e\x1a\xd5\x84\x8b\x7f\x8f\x01\x0e6\x8e\xd6eV~W\xff\x01[x\x1b=' )
def getBitmap():
return wxBitmapFromImage(getImage())
def getImage():
stream = cStringIO.StringIO(getData())
return wxImageFromStream(stream)
class PyPalette(canvas.Canvas):
"""The Pure-Python Palette
The PyPalette is a pure python implementation of a colour palette. The
palette implementation here imitates the palette layout used by MS
Windows and Adobe Photoshop.
The actual palette image has been embedded as an XPM for speed. The
actual reverse-engineered drawing algorithm is provided in the
GeneratePaletteBMP() method. The algorithm is tweakable by supplying
the granularity factor to improve speed at the cost of display
beauty. Since the generator isn't used in real time, no one will
likely care :) But if you need it for some sort of unforeseen realtime
application, it's there.
"""
HORIZONTAL_STEP = 2
VERTICAL_STEP = 4
def __init__(self, parent, id):
"""Creates a palette object."""
# Load the pre-generated palette XPM
self.palette = getBitmap ()
canvas.Canvas.__init__ (self, parent, id, size=wxSize(200, 192))
def GetValue(self, x, y):
"""Returns a colour value at a specific x, y coordinate pair. This
is useful for determining the colour found a specific mouse click
in an external event handler."""
return self.buffer.GetPixel(x, y)
def DrawBuffer(self):
"""Draws the palette XPM into the memory buffer."""
#self.GeneratePaletteBMP ("foo.bmp")
self.buffer.DrawBitmap(self.palette, 0, 0, 0)
def HighlightPoint(self, x, y):
"""Highlights an area of the palette with a little circle around
the coordinate point"""
colour = wxColour(0, 0, 0)
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxTRANSPARENT))
self.buffer.DrawCircle(x, y, 3)
self.Refresh()
def GeneratePaletteBMP(self, file_name, granularity=1):
"""The actual palette drawing algorithm.
This used to be 100% reverse engineered by looking at the
values on the MS map, but has since been redone Correctly(tm)
according to the HSV (hue, saturation, value) colour model by
Charl P. Botha <http://cpbotha.net/>.
Speed is tweakable by changing the granularity factor, but
that affects how nice the output looks (makes the vertical
blocks bigger. This method was used to generate the embedded
XPM data."""
self.vertical_step = self.VERTICAL_STEP * granularity
width, height = self.GetSize ()
# simply iterate over hue (horizontal) and saturation (vertical)
value = 1.0
for y in range(0, height, self.vertical_step):
saturation = 1.0 - float(y) / float(height)
for x in range(0, width, self.HORIZONTAL_STEP):
hue = float(x) / float(width)
r,g,b = colorsys.hsv_to_rgb(hue, saturation, value)
colour = wxColour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxSOLID))
self.buffer.DrawRectangle(x, y,
self.HORIZONTAL_STEP,
self.vertical_step)
# this code is now simpler (and works)
bitmap = self.buffer.GetBitmap()
image = wxImageFromBitmap(bitmap)
image.SaveFile (file_name, wxBITMAP_TYPE_XPM)
PyPalette = wx.lib.colourchooser.pypalette.PyPalette
getBitmap = wx.lib.colourchooser.pypalette.getBitmap
getData = wx.lib.colourchooser.pypalette.getData
getImage = wx.lib.colourchooser.pypalette.getImage
File diff suppressed because it is too large Load Diff
+8 -87
View File
@@ -1,90 +1,11 @@
#----------------------------------------------------------------------------
# Name: ColourSelect.py
# Purpose: Colour Box Selection Control
#
# Author: Lorne White, Lorne.White@telusplanet.net
#
# Created: Feb 25, 2001
# Licence: wxWindows license
#----------------------------------------------------------------------------
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
from wxPython.wx import *
import wx.lib.colourselect
# creates a colour wxButton with selectable color
# button click provides a colour selection box
# button colour will change to new colour
# GetColour method to get the selected colour
# Updates:
# call back to function if changes made
# Cliff Wells, logiplexsoftware@earthlink.net:
# - Made ColourSelect into "is a button" rather than "has a button"
# - Added label parameter and logic to adjust the label colour according to the background
# colour
# - Added id argument
# - Rearranged arguments to more closely follow wx conventions
# - Simplified some of the code
# Cliff Wells, 2002/02/07
# - Added ColourSelect Event
EVT_COMMAND_COLOURSELECT = wxNewId()
class ColourSelectEvent(wxPyCommandEvent):
def __init__(self, id, value):
wxPyCommandEvent.__init__(self, id = id)
self.SetEventType(EVT_COMMAND_COLOURSELECT)
self.value = value
def GetValue(self):
return self.value
def EVT_COLOURSELECT(win, id, func):
win.Connect(id, -1, EVT_COMMAND_COLOURSELECT, func)
class ColourSelect(wxButton):
def __init__(self, parent, id, label = "", bcolour=(0, 0, 0),
pos = wxDefaultPosition, size = wxDefaultSize,
callback = None):
wxButton.__init__(self, parent, id, label, pos=pos, size=size)
self.SetColour(bcolour)
self.callback = callback
EVT_BUTTON(parent, self.GetId(), self.OnClick)
def GetColour(self):
return self.set_colour
def GetValue(self):
return self.set_colour
def SetColour(self, bcolour):
self.set_colour_val = wxColor(bcolour[0], bcolour[1], bcolour[2])
self.SetBackgroundColour(self.set_colour_val)
avg = reduce(lambda a, b: a + b, bcolour) / 3
fcolour = avg > 128 and (0, 0, 0) or (255, 255, 255)
self.SetForegroundColour(apply(wxColour, fcolour))
self.set_colour = bcolour
def SetValue(self, bcolour):
self.SetColour(bcolour)
def OnChange(self):
wxPostEvent(self, ColourSelectEvent(self.GetId(), self.GetValue()))
if self.callback is not None:
self.callback()
def OnClick(self, event):
data = wxColourData()
data.SetChooseFull(True)
data.SetColour(self.set_colour_val)
dlg = wxColourDialog(self.GetParent(), data)
changed = dlg.ShowModal() == wxID_OK
if changed:
data = dlg.GetColourData()
self.SetColour(data.GetColour().Get())
dlg.Destroy()
if changed:
self.OnChange() # moved after dlg.Destroy, since who knows what the callback will do...
__doc__ = wx.lib.colourselect.__doc__
ColourSelect = wx.lib.colourselect.ColourSelect
ColourSelectEvent = wx.lib.colourselect.ColourSelectEvent
EVT_COLOURSELECT = wx.lib.colourselect.EVT_COLOURSELECT
+24 -382
View File
@@ -1,385 +1,27 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.dialogs
# Purpose: wxScrolledMessageDialog, wxMultipleChoiceDialog and
# function wrappers for the common dialogs by Kevin Altis.
#
# Author: Various
#
# Created: 3-January-2002
# RCS-ID: $Id$
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
from wxPython import wx
from layoutf import Layoutf
import wx.lib.dialogs
#----------------------------------------------------------------------
__doc__ = wx.lib.dialogs.__doc__
class wxScrolledMessageDialog(wx.wxDialog):
def __init__(self, parent, msg, caption, pos = wx.wxDefaultPosition, size = (500,300)):
wx.wxDialog.__init__(self, parent, -1, caption, pos, size)
x, y = pos
if x == -1 and y == -1:
self.CenterOnScreen(wx.wxBOTH)
text = wx.wxTextCtrl(self, -1, msg, wx.wxDefaultPosition,
wx.wxDefaultSize,
wx.wxTE_MULTILINE | wx.wxTE_READONLY)
ok = wx.wxButton(self, wx.wxID_OK, "OK")
text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!25', (self,)))
self.SetAutoLayout(1)
self.Layout()
class wxMultipleChoiceDialog(wx.wxDialog):
def __init__(self, parent, msg, title, lst, pos = wx.wxDefaultPosition,
size = (200,200), style = wx.wxDEFAULT_DIALOG_STYLE):
wx.wxDialog.__init__(self, parent, -1, title, pos, size, style)
x, y = pos
if x == -1 and y == -1:
self.CenterOnScreen(wx.wxBOTH)
dc = wx.wxClientDC(self)
height = 0
for line in msg.splitlines():
height = height + dc.GetTextExtent(line)[1] + 2
stat = wx.wxStaticText(self, -1, msg)
self.lbox = wx.wxListBox(self, 100, wx.wxDefaultPosition,
wx.wxDefaultSize, lst, wx.wxLB_MULTIPLE)
ok = wx.wxButton(self, wx.wxID_OK, "OK")
cancel = wx.wxButton(self, wx.wxID_CANCEL, "Cancel")
stat.SetConstraints(Layoutf('t=t10#1;l=l5#1;r=r5#1;h!%d' % (height,),
(self,)))
self.lbox.SetConstraints(Layoutf('t=b10#2;l=l5#1;r=r5#1;b=t5#3',
(self, stat, ok)))
ok.SetConstraints(Layoutf('b=b5#1;x%w25#1;w!80;h!25', (self,)))
cancel.SetConstraints(Layoutf('b=b5#1;x%w75#1;w!80;h!25', (self,)))
self.SetAutoLayout(1)
self.lst = lst
self.Layout()
def GetValue(self):
return self.lbox.GetSelections()
def GetValueString(self):
sel = self.lbox.GetSelections()
val = []
for i in sel:
val.append(self.lst[i])
return tuple(val)
#----------------------------------------------------------------------
"""
function wrappers for wxPython system dialogs
Author: Kevin Altis
Date: 2003-1-2
Rev: 3
This is the third refactor of the PythonCard dialog.py module
for inclusion in the main wxPython distribution. There are a number of
design decisions and subsequent code refactoring to be done, so I'm
releasing this just to get some feedback.
rev 3:
- result dictionary replaced by DialogResults class instance
- should message arg be replaced with msg? most wxWindows dialogs
seem to use the abbreviation?
rev 2:
- All dialog classes have been replaced by function wrappers
- Changed arg lists to more closely match wxWindows docs and wxPython.lib.dialogs
- changed 'returned' value to the actual button id the user clicked on
- added a returnedString value for the string version of the return value
- reworked colorDialog and fontDialog so you can pass in just a color or font
for the most common usage case
- probably need to use colour instead of color to match the English English
spelling in wxWindows (sigh)
- I still think we could lose the parent arg and just always use None
"""
class DialogResults:
def __init__(self, returned):
self.returned = returned
self.accepted = returned in (wx.wxID_OK, wx.wxID_YES)
self.returnedString = returnedString(returned)
def __repr__(self):
return str(self.__dict__)
def returnedString(ret):
if ret == wx.wxID_OK:
return "Ok"
elif ret == wx.wxID_CANCEL:
return "Cancel"
elif ret == wx.wxID_YES:
return "Yes"
elif ret == wx.wxID_NO:
return "No"
# findDialog was created before wxPython got a Find/Replace dialog
# but it may be instructive as to how a function wrapper can
# be added for your own custom dialogs
# this dialog is always modal, while wxFindReplaceDialog is
# modeless and so doesn't lend itself to a function wrapper
def findDialog(parent=None, searchText='', wholeWordsOnly=0, caseSensitive=0):
dlg = wx.wxDialog(parent, -1, "Find", wx.wxDefaultPosition, wx.wxSize(370, 120))
wx.wxStaticText(dlg, -1, 'Find what:', wx.wxPoint(7, 10))
wSearchText = wx.wxTextCtrl(dlg, -1, searchText,
wx.wxPoint(70, 7), wx.wxSize(195, -1))
wSearchText.SetValue(searchText)
wx.wxButton(dlg, wx.wxID_OK, "Find Next", wx.wxPoint(280, 5), wx.wxDefaultSize).SetDefault()
wx.wxButton(dlg, wx.wxID_CANCEL, "Cancel", wx.wxPoint(280, 35), wx.wxDefaultSize)
wWholeWord = wx.wxCheckBox(dlg, -1, 'Match whole word only',
wx.wxPoint(7, 35), wx.wxDefaultSize, wx.wxNO_BORDER)
if wholeWordsOnly:
wWholeWord.SetValue(1)
wCase = wx.wxCheckBox(dlg, -1, 'Match case',
wx.wxPoint(7, 55), wx.wxDefaultSize, wx.wxNO_BORDER)
if caseSensitive:
wCase.SetValue(1)
wSearchText.SetSelection(0, len(wSearchText.GetValue()))
wSearchText.SetFocus()
result = DialogResults(dlg.ShowModal())
result.text = wSearchText.GetValue()
result.wholeword = wWholeWord.GetValue()
result.casesensitive = wCase.GetValue()
dlg.Destroy()
return result
def colorDialog(parent=None, colorData=None, color=None):
if colorData:
dialog = wx.wxColourDialog(parent, colorData)
else:
dialog = wx.wxColourDialog(parent)
dialog.GetColourData().SetChooseFull(1)
if color is not None:
dialog.GetColourData().SetColour(color)
result = DialogResults(dialog.ShowModal())
result.colorData = dialog.GetColourData()
result.color = result.colorData.GetColour().Get()
dialog.Destroy()
return result
# it is easier to just duplicate the code than
# try and replace color with colour in the result
def colourDialog(parent=None, colourData=None, colour=None):
if colourData:
dialog = wx.wxColourDialog(parent, colourData)
else:
dialog = wx.wxColourDialog(parent)
dialog.GetColourData().SetChooseFull(1)
if colour is not None:
dialog.GetColourData().SetColour(color)
result = DialogResults(dialog.ShowModal())
result.colourData = dialog.GetColourData()
result.colour = result.colourData.GetColour().Get()
dialog.Destroy()
return result
def fontDialog(parent=None, fontData=None, font=None):
if fontData is None:
fontData = wx.wxFontData()
if font is not None:
aFontData.SetInitialFont(font)
dialog = wx.wxFontDialog(parent, fontData)
result = DialogResults(dialog.ShowModal())
if result.accepted:
fontData = dialog.GetFontData()
result.fontData = fontData
result.color = fontData.GetColour().Get()
result.colour = result.color
result.font = fontData.GetChosenFont()
else:
result.color = None
result.colour = None
result.font = None
dialog.Destroy()
return result
def textEntryDialog(parent=None, message='', title='', defaultText='', style=wx.wxOK | wx.wxCANCEL):
dialog = wx.wxTextEntryDialog(parent, message, title, defaultText, style)
result = DialogResults(dialog.ShowModal())
result.text = dialog.GetValue()
dialog.Destroy()
return result
def messageDialog(parent=None, message='', title='Message box',
aStyle = wx.wxOK | wx.wxCANCEL | wx.wxCENTRE,
pos=wx.wxDefaultPosition):
dialog = wx.wxMessageDialog(parent, message, title, aStyle, pos)
result = DialogResults(dialog.ShowModal())
dialog.Destroy()
return result
# KEA alerts are common, so I'm providing a class rather than
# requiring the user code to set up the right icons and buttons
# the with messageDialog function
def alertDialog(parent=None, message='', title='Alert', pos=wx.wxDefaultPosition):
return messageDialog(parent, message, title, wx.wxICON_EXCLAMATION | wx.wxOK, pos)
def scrolledMessageDialog(parent=None, message='', title='', pos=wx.wxDefaultPosition, size=(500,300)):
dialog = wxScrolledMessageDialog(parent, message, title, pos, size)
result = DialogResults(dialog.ShowModal())
dialog.Destroy()
return result
def fileDialog(parent=None, title='Open', directory='', filename='', wildcard='*.*',
style=wx.wxOPEN | wx.wxMULTIPLE):
dialog = wx.wxFileDialog(parent, title, directory, filename, wildcard, style)
result = DialogResults(dialog.ShowModal())
if result.accepted:
result.paths = dialog.GetPaths()
else:
result.paths = None
dialog.Destroy()
return result
# openFileDialog and saveFileDialog are convenience functions
# they represent the most common usages of the fileDialog
# with the most common style options
def openFileDialog(parent=None, title='Open', directory='', filename='',
wildcard='All Files (*.*)|*.*',
style=wx.wxOPEN | wx.wxMULTIPLE):
return fileDialog(parent, title, directory, filename, wildcard, style)
def saveFileDialog(parent=None, title='Save', directory='', filename='',
wildcard='All Files (*.*)|*.*',
style=wx.wxSAVE | wx.wxHIDE_READONLY | wx.wxOVERWRITE_PROMPT):
return fileDialog(parent, title, directory, filename, wildcard, style)
def dirDialog(parent=None, message='Choose a directory', path='', style=0,
pos=wx.wxDefaultPosition, size=wx.wxDefaultSize):
dialog = wx.wxDirDialog(parent, message, path, style, pos, size)
result = DialogResults(dialog.ShowModal())
if result.accepted:
result.path = dialog.GetPath()
else:
result.path = None
dialog.Destroy()
return result
directoryDialog = dirDialog
def singleChoiceDialog(parent=None, message='', title='', lst=[],
style=wx.wxOK | wx.wxCANCEL | wx.wxCENTRE):
dialog = wx.wxSingleChoiceDialog(parent,
message,
title,
lst,
style)
result = DialogResults(dialog.ShowModal())
result.selection = dialog.GetStringSelection()
dialog.Destroy()
return result
def multipleChoiceDialog(parent=None, message='', title='', lst=[], pos=wx.wxDefaultPosition, size=(200,200)):
dialog = wxMultipleChoiceDialog(parent, message, title, lst, pos, size)
result = DialogResults(dialog.ShowModal())
result.selection = dialog.GetValueString()
dialog.Destroy()
return result
if __name__ == '__main__':
class MyApp(wx.wxApp):
def OnInit(self):
frame = wx.wxFrame(wx.NULL, -1, "Dialogs", size=(400, 200))
panel = wx.wxPanel(frame, -1)
self.panel = panel
frame.Show(1)
dialogNames = [
'alertDialog',
'colorDialog',
'directoryDialog',
'fileDialog',
'findDialog',
'fontDialog',
'messageDialog',
'multipleChoiceDialog',
'openFileDialog',
'saveFileDialog',
'scrolledMessageDialog',
'singleChoiceDialog',
'textEntryDialog',
]
self.nameList = wx.wxListBox(panel, -1, (0, 0), (130, 180), dialogNames, style=wx.wxLB_SINGLE)
wx.EVT_LISTBOX(panel, self.nameList.GetId(), self.OnNameListSelected)
tstyle = wx.wxTE_RICH2 | wx.wxTE_PROCESS_TAB | wx.wxTE_MULTILINE
self.text1 = wx.wxTextCtrl(panel, -1, pos=(150, 0), size=(200, 180), style=tstyle)
self.SetTopWindow(frame)
return 1
def OnNameListSelected(self, evt):
import pprint
sel = evt.GetString()
result = None
if sel == 'alertDialog':
result = alertDialog(message='Danger Will Robinson')
elif sel == 'colorDialog':
result = colorDialog()
elif sel == 'directoryDialog':
result = directoryDialog()
elif sel == 'fileDialog':
wildcard = "JPG files (*.jpg;*.jpeg)|*.jpeg;*.JPG;*.JPEG;*.jpg|GIF files (*.gif)|*.GIF;*.gif|All Files (*.*)|*.*"
result = fileDialog(None, 'Open', '', '', wildcard)
elif sel == 'findDialog':
result = findDialog()
elif sel == 'fontDialog':
result = fontDialog()
elif sel == 'messageDialog':
result = messageDialog(None, 'Hello from Python and wxPython!',
'A Message Box', wx.wxOK | wx.wxICON_INFORMATION)
#wx.wxYES_NO | wx.wxNO_DEFAULT | wx.wxCANCEL | wx.wxICON_INFORMATION)
#result = messageDialog(None, 'message', 'title')
elif sel == 'multipleChoiceDialog':
result = multipleChoiceDialog(None, "message", "title", ['one', 'two', 'three'])
elif sel == 'openFileDialog':
result = openFileDialog()
elif sel == 'saveFileDialog':
result = saveFileDialog()
elif sel == 'scrolledMessageDialog':
msg = "Can't find the file dialog.py"
try:
# read this source file and then display it
import sys
filename = sys.argv[-1]
fp = open(filename)
message = fp.read()
fp.close()
except:
pass
result = scrolledMessageDialog(None, message, filename)
elif sel == 'singleChoiceDialog':
result = singleChoiceDialog(None, "message", "title", ['one', 'two', 'three'])
elif sel == 'textEntryDialog':
result = textEntryDialog(None, "message", "title", "text")
if result:
#self.text1.SetValue(pprint.pformat(result.__dict__))
self.text1.SetValue(str(result))
app = MyApp(0)
app.MainLoop()
DialogResults = wx.lib.dialogs.DialogResults
alertDialog = wx.lib.dialogs.alertDialog
colorDialog = wx.lib.dialogs.colorDialog
colourDialog = wx.lib.dialogs.colourDialog
dirDialog = wx.lib.dialogs.dirDialog
directoryDialog = wx.lib.dialogs.directoryDialog
fileDialog = wx.lib.dialogs.fileDialog
findDialog = wx.lib.dialogs.findDialog
fontDialog = wx.lib.dialogs.fontDialog
messageDialog = wx.lib.dialogs.messageDialog
multipleChoiceDialog = wx.lib.dialogs.multipleChoiceDialog
openFileDialog = wx.lib.dialogs.openFileDialog
returnedString = wx.lib.dialogs.returnedString
saveFileDialog = wx.lib.dialogs.saveFileDialog
scrolledMessageDialog = wx.lib.dialogs.scrolledMessageDialog
singleChoiceDialog = wx.lib.dialogs.singleChoiceDialog
textEntryDialog = wx.lib.dialogs.textEntryDialog
wxMultipleChoiceDialog = wx.lib.dialogs.wxMultipleChoiceDialog
wxScrolledMessageDialog = wx.lib.dialogs.wxScrolledMessageDialog
-77
View File
@@ -1,77 +0,0 @@
wxEditor component
------------------
The wxEditor class implements a simple text editor using wxPython. You
can create a custom editor by subclassing wxEditor. Even though much of
the editor is implemented in Python, it runs surprisingly smoothly on
normal hardware with small files.
Keys
----
Keys are similar to Windows-based editors:
Tab: 1 to 4 spaces (to next tab stop)
Cursor movement: Arrow keys
Beginning of line: Home
End of line: End
Beginning of buffer: Control-Home
End of the buffer: Control-End
Select text: Hold down Shift while moving the cursor
Copy: Shift-Insert, Control-C
Cut: Shift-Delete, Control-X
Paste: Control-Insert, Control-V
How to use it
-------------
The demo code (demo/wxEditor.py) shows how to use it as a simple text
box. Use the SetText() and GetText() methods to set or get text from
the component; these both return a list of strings.
The samples/FrogEdit directory has an example of a simple text editor
application that uses the wxEditor component.
Subclassing
-----------
To add or change functionality, you can subclass this
component. One example of this might be to change the key
Alt key commands. In that case you would (for example) override the
SetAltFuncs() method.
History
-------
The original author of this component was Dirk Holtwic. It originally
had limited support for syntax highlighting, but was not a usable text
editor, as it didn't implement select (with keys or mouse), or any of
the usual key sequences you'd expect in an editor. Robin Dunn did some
refactoring work to make it more usable. Steve Howell and Adam Feuer
did a lot of refactoring, and added some functionality, including
keyboard and mouse select, properly working scrollbars, and
overridable keys. Adam and Steve also removed support for
syntax-highlighting while refactoring the code.
To do
-----
Alt/Ctrl Arrow keys move by word
Descriptive help text for keys
Speed improvements
Different fonts/colors
Authors
-------
Steve Howell, Adam Feuer, Dirk Holtwic, Robin Dunn
Contact
-------
You can find the latest code for wxEditor here:
http://www.pobox.com/~adamf/software/
We're not actively maintaining this code, but we can answer
questions about it. You can email us at:
Adam Feuer <adamf at pobox dot com>
Steve Howell <showell at zipcon dot net>
29 November 2001
-16
View File
@@ -1,17 +1 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.editor
# Purpose: A package containing a colourizable text editror
#
# Author: Robin Dunn
#
# Created: 30-Dec-1999
# RCS-ID: $Id$
# Copyright: (c) 1999 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
# This file makes this directory into a Python package
# import the main classes into the package namespace.
from editor import wxEditor
File diff suppressed because it is too large Load Diff
+7 -24
View File
@@ -1,27 +1,10 @@
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
# images converted with wxPython's img2py.py tool
from wxPython.wx import wxImageFromStream, wxBitmapFromImage
import cStringIO
##----------- Common Functions
def GetBitmap(ImageData):
return wxBitmapFromImage(GetImage(ImageData))
def GetImage(ImageData):
stream = cStringIO.StringIO(ImageData)
return wxImageFromStream(stream)
##----------- Image Data
EofImageData = \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x07\x00\x00\x00\x07\x08\x06\
\x00\x00\x00\xc4RW\xd3\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\
\x00:IDATx\x9c]\x8e\xc1\r\x000\x08\x02\xc5\tn\xff)\xdd\xa0}\xd1`\xf9(\x9c\t\
\n(kf\x0e \xfbN\x90\xf3\xc1\x0c\xd2\xab\xaa\x16Huv\xa4\x00\xb5\x97\x1f\xac\
\x87\x1c\xe4\xe1\x05`2\x15\x9e\xc54\xca\xb4\x00\x00\x00\x00IEND\xaeB`\x82'
import wx.lib.editor.images
__doc__ = wx.lib.editor.images.__doc__
GetBitmap = wx.lib.editor.images.GetBitmap
GetImage = wx.lib.editor.images.GetImage
+7 -39
View File
@@ -1,42 +1,10 @@
True = 1
False = 0
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
def RestOfLine(sx, width, data, bool):
if len(data) == 0 and sx == 0:
return [('', bool)]
if sx >= len(data):
return []
return [(data[sx:sx+width], bool)]
def Selection(SelectBegin,SelectEnd, sx, width, line, data):
if SelectEnd is None or SelectBegin is None:
return RestOfLine(sx, width, data, False)
(bRow, bCol) = SelectBegin
(eRow, eCol) = SelectEnd
if (eRow < bRow):
(bRow, bCol) = SelectEnd
(eRow, eCol) = SelectBegin
if (line < bRow or eRow < line):
return RestOfLine(sx, width, data, False)
if (bRow < line and line < eRow):
return RestOfLine(sx, width, data, True)
if (bRow == eRow) and (eCol < bCol):
(bCol, eCol) = (eCol, bCol)
# selection either starts or ends on this line
end = min(sx+width, len(data))
if (bRow < line):
bCol = 0
if (line < eRow):
eCol = end
pieces = []
if (sx < bCol):
if bCol <= end:
pieces += [(data[sx:bCol], False)]
else:
return [(data[sx:end], False)]
pieces += [(data[max(bCol,sx):min(eCol,end)], True)]
if (eCol < end):
pieces += [(data[eCol:end], False)]
return pieces
import wx.lib.editor.selection
__doc__ = wx.lib.editor.selection.__doc__
RestOfLine = wx.lib.editor.selection.RestOfLine
Selection = wx.lib.editor.selection.Selection
File diff suppressed because it is too large Load Diff
+21 -407
View File
@@ -1,410 +1,24 @@
"""<font weight="bold" size="16">FancyText</font> -- <font style="italic" size="16">methods for rendering XML specified text</font>
<font family="swiss" size="12">
This module exports four main methods::
<font family="fixed" style="slant">
def GetExtent(str, dc=None, enclose=True)
def GetFullExtent(str, dc=None, enclose=True)
def RenderToBitmap(str, background=None, enclose=True)
def RenderToDC(str, dc, x, y, enclose=True)
</font>
In all cases, 'str' is an XML string. Note that start and end tags
are only required if *enclose* is set to False. In this case the
text should be wrapped in FancyText tags.
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
In addition, the module exports one class::
<font family="fixed" style="slant">
class StaticFancyText(self, window, id, text, background, ...)
</font>
This class works similar to StaticText except it interprets its text
as FancyText.
The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text
in different <font size="20">sizes</font>, <font color="blue">colors</font>, <font style="italic">styles</font>, <font weight="bold">weights</font> and
<font family="script">families</font>. It also supports a limited set of symbols,
currently <times/>, <infinity/>, <angle/> as well as greek letters in both
upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>).
We can use doctest/guitest to display this string in all its marked up glory.
<font family="fixed">
>>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
>>> sft = StaticFancyText(frame, -1, __doc__, wx.Brush("light grey", wx.SOLID))
>>> frame.SetClientSize(sft.GetSize())
>>> didit = frame.Show()
>>> from guitest import PauseTests; PauseTests()
</font></font>
The End"""
# Copyright 2001-2003 Timothy Hochberg
# Use as you see fit. No warantees, I cannot be help responsible, etc.
import copy
import math
import sys
import wx
import xml.parsers.expat
__all__ = "GetExtent", "GetFullExtent", "RenderToBitmap", "RenderToDC", "StaticFancyText"
if sys.platform == "win32":
_greekEncoding = str(wx.FONTENCODING_CP1253)
else:
_greekEncoding = str(wx.FONTENCODING_ISO8859_7)
_families = {"fixed" : wx.FIXED, "default" : wx.DEFAULT, "decorative" : wx.DECORATIVE, "roman" : wx.ROMAN,
"script" : wx.SCRIPT, "swiss" : wx.SWISS, "modern" : wx.MODERN}
_styles = {"normal" : wx.NORMAL, "slant" : wx.SLANT, "italic" : wx.ITALIC}
_weights = {"normal" : wx.NORMAL, "light" : wx.LIGHT, "bold" : wx.BOLD}
# The next three classes: Renderer, SizeRenderer and DCRenderer are
# what you will need to override to extend the XML language. All of
# the font stuff as well as the subscript and superscript stuff are in
# Renderer.
_greek_letters = ("alpha", "beta", "gamma", "delta", "epsilon", "zeta",
"eta", "theta", "iota", "kappa", "lambda", "mu", "nu",
"xi", "omnikron", "pi", "rho", "altsigma", "sigma", "tau", "upsilon",
"phi", "chi", "psi", "omega")
def iround(number):
return int(round(number))
def iceil(number):
return int(math.ceil(number))
class Renderer:
"""Class for rendering XML marked up text.
See the module docstring for a description of the markup.
This class must be subclassed and the methods the methods that do
the drawing overridden for a particular output device.
"""
defaultSize = wx.NORMAL_FONT.GetPointSize()
defaultFamily = wx.DEFAULT
defaultStyle = wx.NORMAL
defaultWeight = wx.NORMAL
defaultEncoding = wx.Font_GetDefaultEncoding()
defaultColor = "black"
def __init__(self, dc=None, x=0, y=None):
if dc == None:
dc = wx.MemoryDC()
self.dc = dc
self.offsets = [0]
self.fonts = [{}]
self.width = self.height = 0
self.x = x
self.minY = self.maxY = self._y = y
def getY(self):
if self._y is None:
self.minY = self.maxY = self._y = self.dc.GetTextExtent("M")[1]
return self._y
def setY(self, value):
self._y = y
y = property(getY, setY)
def startElement(self, name, attrs):
method = "start_" + name
if not hasattr(self, method):
raise ValueError("XML tag '%s' not supported" % name)
getattr(self, method)(attrs)
def endElement(self, name):
methname = "end_" + name
if hasattr(self, methname):
getattr(self, methname)()
elif hasattr(self, "start_" + name):
pass
else:
raise ValueError("XML tag '%s' not supported" % methname)
def characterData(self, data):
self.dc.SetFont(self.getCurrentFont())
for i, chunk in enumerate(data.split('\n')):
if i:
self.x = 0
self.y = self.mayY = self.maxY + self.dc.GetTextExtent("M")[1]
if chunk:
width, height, descent, extl = self.dc.GetFullTextExtent(chunk)
self.renderCharacterData(data, iround(self.x), iround(self.y + self.offsets[-1] - height + descent))
else:
width = height = descent = extl = 0
self.updateDims(width, height, descent, extl)
def updateDims(self, width, height, descent, externalLeading):
self.x += width
self.width = max(self.x, self.width)
self.minY = min(self.minY, self.y+self.offsets[-1]-height+descent)
self.maxY = max(self.maxY, self.y+self.offsets[-1]+descent)
self.height = self.maxY - self.minY
def start_FancyText(self, attrs):
pass
start_wxFancyText = start_FancyText # For backward compatibility
def start_font(self, attrs):
for key, value in attrs.items():
if key == "size":
value = int(value)
elif key == "family":
value = _families[value]
elif key == "style":
value = _styles[value]
elif key == "weight":
value = _weights[value]
elif key == "encoding":
value = int(value)
elif key == "color":
pass
else:
raise ValueError("unknown font attribute '%s'" % key)
attrs[key] = value
font = copy.copy(self.fonts[-1])
font.update(attrs)
self.fonts.append(font)
def end_font(self):
self.fonts.pop()
def start_sub(self, attrs):
if attrs.keys():
raise ValueError("<sub> does not take attributes")
font = self.getCurrentFont()
self.offsets.append(self.offsets[-1] + self.dc.GetFullTextExtent("M", font)[1]*0.5)
self.start_font({"size" : font.GetPointSize() * 0.8})
def end_sub(self):
self.fonts.pop()
self.offsets.pop()
def start_sup(self, attrs):
if attrs.keys():
raise ValueError("<sup> does not take attributes")
font = self.getCurrentFont()
self.offsets.append(self.offsets[-1] - self.dc.GetFullTextExtent("M", font)[1]*0.3)
self.start_font({"size" : font.GetPointSize() * 0.8})
def end_sup(self):
self.fonts.pop()
self.offsets.pop()
def getCurrentFont(self):
font = self.fonts[-1]
return wx.TheFontList.FindOrCreateFont(font.get("size", self.defaultSize),
font.get("family", self.defaultFamily),
font.get("style", self.defaultStyle),
font.get("weight", self.defaultWeight),
encoding = font.get("encoding", self.defaultEncoding))
def getCurrentColor(self):
font = self.fonts[-1]
return wx.TheColourDatabase.FindColour(font.get("color", self.defaultColor))
def getCurrentPen(self):
return wx.ThePenList.FindOrCreatePen(self.getCurrentColor(), 1, wx.SOLID)
def renderCharacterData(self, data, x, y):
raise NotImplementedError()
def _addGreek():
alpha = 0xE1
Alpha = 0xC1
def end(self):
pass
for i, name in enumerate(_greek_letters):
def start(self, attrs, code=chr(alpha+i)):
self.start_font({"encoding" : _greekEncoding})
self.characterData(code)
self.end_font()
setattr(Renderer, "start_%s" % name, start)
setattr(Renderer, "end_%s" % name, end)
if name == "altsigma":
continue # There is no capital for altsigma
def start(self, attrs, code=chr(Alpha+i)):
self.start_font({"encoding" : _greekEncoding})
self.characterData(code)
self.end_font()
setattr(Renderer, "start_%s" % name.capitalize(), start)
setattr(Renderer, "end_%s" % name.capitalize(), end)
_addGreek()
class SizeRenderer(Renderer):
"""Processes text as if rendering it, but just computes the size."""
def __init__(self, dc=None):
Renderer.__init__(self, dc, 0, 0)
def renderCharacterData(self, data, x, y):
pass
def start_angle(self, attrs):
self.characterData("M")
def start_infinity(self, attrs):
width, height = self.dc.GetTextExtent("M")
width = max(width, 10)
height = max(height, width / 2)
self.updateDims(width, height, 0, 0)
def start_times(self, attrs):
self.characterData("M")
def start_in(self, attrs):
self.characterData("M")
def start_times(self, attrs):
self.characterData("M")
class DCRenderer(Renderer):
"""Renders text to a wxPython device context DC."""
def renderCharacterData(self, data, x, y):
self.dc.SetTextForeground(self.getCurrentColor())
self.dc.DrawText(data, x, y)
def start_angle(self, attrs):
self.dc.SetFont(self.getCurrentFont())
self.dc.SetPen(self.getCurrentPen())
width, height, descent, leading = self.dc.GetFullTextExtent("M")
y = self.y + self.offsets[-1]
self.dc.DrawLine(iround(self.x), iround(y),iround( self.x+width), iround(y))
self.dc.DrawLine(iround(self.x), iround(y), iround(self.x+width), iround(y-width))
self.updateDims(width, height, descent, leading)
def start_infinity(self, attrs):
self.dc.SetFont(self.getCurrentFont())
self.dc.SetPen(self.getCurrentPen())
width, height, descent, leading = self.dc.GetFullTextExtent("M")
width = max(width, 10)
height = max(height, width / 2)
self.dc.SetPen(wx.Pen(self.getCurrentColor(), max(1, width/10)))
self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
y = self.y + self.offsets[-1]
r = iround( 0.95 * width / 4)
xc = (2*self.x + width) / 2
yc = iround(y-1.5*r)
self.dc.DrawCircle(xc - r, yc, r)
self.dc.DrawCircle(xc + r, yc, r)
self.updateDims(width, height, 0, 0)
def start_times(self, attrs):
self.dc.SetFont(self.getCurrentFont())
self.dc.SetPen(self.getCurrentPen())
width, height, descent, leading = self.dc.GetFullTextExtent("M")
y = self.y + self.offsets[-1]
width *= 0.8
width = iround(width+.5)
self.dc.SetPen(wx.Pen(self.getCurrentColor(), 1))
self.dc.DrawLine(iround(self.x), iround(y-width), iround(self.x+width-1), iround(y-1))
self.dc.DrawLine(iround(self.x), iround(y-2), iround(self.x+width-1), iround(y-width-1))
self.updateDims(width, height, 0, 0)
def RenderToRenderer(str, renderer, enclose=True):
try:
if enclose:
str = '<?xml version="1.0"?><FancyText>%s</FancyText>' % str
p = xml.parsers.expat.ParserCreate()
p.returns_unicode = 0
p.StartElementHandler = renderer.startElement
p.EndElementHandler = renderer.endElement
p.CharacterDataHandler = renderer.characterData
p.Parse(str, 1)
except xml.parsers.expat.error, err:
raise ValueError('error parsing text text "%s": %s' % (str, err))
# Public interface
def GetExtent(str, dc=None, enclose=True):
"Return the extent of str"
renderer = SizeRenderer(dc)
RenderToRenderer(str, renderer, enclose)
return iceil(renderer.width), iceil(renderer.height) # XXX round up
def GetFullExtent(str, dc=None, enclose=True):
renderer = SizeRenderer(dc)
RenderToRenderer(str, renderer, enclose)
return iceil(renderer.width), iceil(renderer.height), -iceil(renderer.minY) # XXX round up
def RenderToBitmap(str, background=None, enclose=1):
"Return str rendered on a minumum size bitmap"
dc = wx.MemoryDC()
width, height, dy = GetFullExtent(str, dc, enclose)
bmp = wx.EmptyBitmap(width, height)
dc.SelectObject(bmp)
if background is None:
dc.SetBackground(wx.WHITE_BRUSH)
else:
dc.SetBackground(background)
dc.Clear()
renderer = DCRenderer(dc, y=dy)
dc.BeginDrawing()
RenderToRenderer(str, renderer, enclose)
dc.EndDrawing()
dc.SelectObject(wx.NullBitmap)
if background is None:
img = wx.ImageFromBitmap(bmp)
bg = dc.GetBackground().GetColour()
img.SetMaskColour(bg.Red(), bg.Green(), bg.Blue())
bmp = img.ConvertToBitmap()
return bmp
def RenderToDC(str, dc, x, y, enclose=1):
"Render str onto a wxDC at (x,y)"
width, height, dy = GetFullExtent(str, dc)
renderer = DCRenderer(dc, x, y+dy)
RenderToRenderer(str, renderer, enclose)
class StaticFancyText(wx.StaticBitmap):
def __init__(self, window, id, text, *args, **kargs):
args = list(args)
kargs.setdefault('name', 'staticFancyText')
if 'background' in kargs:
background = kargs.pop('background')
elif args:
background = args.pop(0)
else:
background = wx.Brush(window.GetBackgroundColour(), wx.SOLID)
bmp = RenderToBitmap(text, background)
wx.StaticBitmap.__init__(self, window, id, bmp, *args, **kargs)
# Old names for backward compatibiliry
getExtent = GetExtent
renderToBitmap = RenderToBitmap
renderToDC = RenderToDC
# Test Driver
def test():
app = wx.PyApp()
box = wx.BoxSizer(wx.VERTICAL)
frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
frame.SetBackgroundColour("light grey")
sft = StaticFancyText(frame, -1, __doc__)
box.Add(sft, 1, wx.EXPAND)
frame.SetSizer(box)
frame.SetAutoLayout(True)
box.Fit(frame)
box.SetSizeHints(frame)
frame.Show()
app.MainLoop()
if __name__ == "__main__":
test()
import wx.lib.fancytext
__doc__ = wx.lib.fancytext.__doc__
DCRenderer = wx.lib.fancytext.DCRenderer
GetExtent = wx.lib.fancytext.GetExtent
GetFullExtent = wx.lib.fancytext.GetFullExtent
RenderToBitmap = wx.lib.fancytext.RenderToBitmap
RenderToDC = wx.lib.fancytext.RenderToDC
RenderToRenderer = wx.lib.fancytext.RenderToRenderer
Renderer = wx.lib.fancytext.Renderer
SizeRenderer = wx.lib.fancytext.SizeRenderer
StaticFancyText = wx.lib.fancytext.StaticFancyText
_addGreek = wx.lib.fancytext._addGreek
getExtent = wx.lib.fancytext.getExtent
iceil = wx.lib.fancytext.iceil
iround = wx.lib.fancytext.iround
renderToBitmap = wx.lib.fancytext.renderToBitmap
renderToDC = wx.lib.fancytext.renderToDC
test = wx.lib.fancytext.test
+8 -444
View File
@@ -1,447 +1,11 @@
#----------------------------------------------------------------------
# Name: wxPython.lib.filebrowsebutton
# Purpose: Composite controls that provide a Browse button next to
# either a wxTextCtrl or a wxComboBox. The Browse button
# launches a wxFileDialog and loads the result into the
# other control.
#
# Author: Mike Fletcher
#
# RCS-ID: $Id$
# Copyright: (c) 2000 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
from wxPython.wx import *
import os, types
#----------------------------------------------------------------------
class FileBrowseButton(wxPanel):
""" A control to allow the user to type in a filename
or browse with the standard file dialog to select file
__init__ (
parent, id, pos, size -- passed directly to wxPanel initialisation
style = wxTAB_TRAVERSAL -- passed directly to wxPanel initialisation
labelText -- Text for label to left of text field
buttonText -- Text for button which launches the file dialog
toolTip -- Help text
dialogTitle -- Title used in file dialog
startDirectory -- Default directory for file dialog startup
fileMask -- File mask (glob pattern, such as *.*) to use in file dialog
fileMode -- wxOPEN or wxSAVE, indicates type of file dialog to use
changeCallback -- callback receives all > > changes in value of control
)
GetValue() -- retrieve current value of text control
SetValue(string) -- set current value of text control
label -- pointer to internal label widget
textControl -- pointer to internal text control
browseButton -- pointer to button
"""
def __init__ (self, parent, id= -1,
pos = wxDefaultPosition, size = wxDefaultSize,
style = wxTAB_TRAVERSAL,
labelText= "File Entry:",
buttonText= "Browse",
toolTip= "Type filename or click browse to choose file",
# following are the values for a file dialog box
dialogTitle = "Choose a file",
startDirectory = ".",
initialValue = "",
fileMask = "*.*",
fileMode = wxOPEN,
# callback for when value changes (optional)
changeCallback= lambda x:x
):
# store variables
self.labelText = labelText
self.buttonText = buttonText
self.toolTip = toolTip
self.dialogTitle = dialogTitle
self.startDirectory = startDirectory
self.initialValue = initialValue
self.fileMask = fileMask
self.fileMode = fileMode
self.changeCallback = changeCallback
self.callCallback = True
# get background to match it
try:
self._bc = parent.GetBackgroundColour()
except:
pass
# create the dialog
self.createDialog(parent, id, pos, size, style )
# Setting a value causes the changeCallback to be called.
# In this case that would be before the return of the
# constructor. Not good. So a default value on
# SetValue is used to disable the callback
self.SetValue( initialValue, 0)
def createDialog( self, parent, id, pos, size, style ):
"""Setup the graphic representation of the dialog"""
wxPanel.__init__ (self, parent, id, pos, size, style)
# try to set the background colour
try:
self.SetBackgroundColour(self._bc)
except:
pass
box = wxBoxSizer(wxHORIZONTAL)
self.label = self.createLabel( )
box.Add( self.label, 0, wxCENTER )
self.textControl = self.createTextControl()
box.Add( self.textControl, 1, wxLEFT|wxCENTER, 5)
self.browseButton = self.createBrowseButton()
box.Add( self.browseButton, 0, wxLEFT|wxCENTER, 5)
# add a border around the whole thing and resize the panel to fit
outsidebox = wxBoxSizer(wxVERTICAL)
outsidebox.Add(box, 1, wxEXPAND|wxALL, 3)
outsidebox.Fit(self)
self.SetAutoLayout(True)
self.SetSizer( outsidebox )
self.Layout()
if type( size ) == types.TupleType:
size = apply( wxSize, size)
self.SetDimensions(-1, -1, size.width, size.height, wxSIZE_USE_EXISTING)
# if size.width != -1 or size.height != -1:
# self.SetSize(size)
def SetBackgroundColour(self,color):
wxPanel.SetBackgroundColour(self,color)
self.label.SetBackgroundColour(color)
def createLabel( self ):
"""Create the label/caption"""
label = wxStaticText(self, -1, self.labelText, style =wxALIGN_RIGHT )
font = label.GetFont()
w, h, d, e = self.GetFullTextExtent(self.labelText, font)
label.SetSize(wxSize(w+5, h))
return label
def createTextControl( self):
"""Create the text control"""
ID = wxNewId()
textControl = wxTextCtrl(self, ID)
textControl.SetToolTipString( self.toolTip )
if self.changeCallback:
EVT_TEXT(textControl, ID, self.OnChanged)
EVT_COMBOBOX(textControl, ID, self.OnChanged)
return textControl
def OnChanged(self, evt):
if self.callCallback and self.changeCallback:
self.changeCallback(evt)
def createBrowseButton( self):
"""Create the browse-button control"""
ID = wxNewId()
button =wxButton(self, ID, self.buttonText)
button.SetToolTipString( self.toolTip )
EVT_BUTTON(button, ID, self.OnBrowse)
return button
def OnBrowse (self, event = None):
""" Going to browse for file... """
current = self.GetValue()
directory = os.path.split(current)
if os.path.isdir( current):
directory = current
current = ''
elif directory and os.path.isdir( directory[0] ):
current = directory[1]
directory = directory [0]
else:
directory = self.startDirectory
dlg = wxFileDialog(self, self.dialogTitle, directory, current, self.fileMask, self.fileMode)
if dlg.ShowModal() == wxID_OK:
self.SetValue(dlg.GetPath())
dlg.Destroy()
def GetValue (self):
""" Convenient access to text control value """
return self.textControl.GetValue()
def SetValue (self, value, callBack=1):
""" Convenient setting of text control value """
save = self.callCallback
self.callCallback = callBack
self.textControl.SetValue(value)
self.callCallback = save
def Enable (self, value):
""" Convenient enabling/disabling of entire control """
self.label.Enable (value)
self.textControl.Enable (value)
return self.browseButton.Enable (value)
def GetLabel( self ):
""" Retrieve the label's current text """
return self.label.GetLabel()
def SetLabel( self, value ):
""" Set the label's current text """
rvalue = self.label.SetLabel( value )
self.Refresh( True )
return rvalue
class FileBrowseButtonWithHistory( FileBrowseButton ):
""" with following additions:
__init__(..., history=None)
history -- optional list of paths for initial history drop-down
(must be passed by name, not a positional argument)
If history is callable it will must return a list used
for the history drop-down
changeCallback -- as for FileBrowseButton, but with a work-around
for win32 systems which don't appear to create EVT_COMBOBOX
events properly. There is a (slight) chance that this work-around
will cause some systems to create two events for each Combobox
selection. If you discover this condition, please report it!
As for a FileBrowseButton.__init__ otherwise.
GetHistoryControl()
Return reference to the control which implements interfaces
required for manipulating the history list. See GetHistoryControl
documentation for description of what that interface is.
GetHistory()
Return current history list
SetHistory( value=(), selectionIndex = None )
Set current history list, if selectionIndex is not None, select that index
"""
def __init__( self, *arguments, **namedarguments):
self.history = namedarguments.get( "history" )
if self.history:
del namedarguments["history"]
self.historyCallBack=None
if callable(self.history):
self.historyCallBack=self.history
self.history=None
apply( FileBrowseButton.__init__, ( self,)+arguments, namedarguments)
def createTextControl( self):
"""Create the text control"""
ID = wxNewId()
textControl = wxComboBox(self, ID, style = wxCB_DROPDOWN )
textControl.SetToolTipString( self.toolTip )
EVT_SET_FOCUS(textControl, self.OnSetFocus)
if self.changeCallback:
EVT_TEXT(textControl, ID, self.changeCallback)
EVT_COMBOBOX(textControl, ID, self.changeCallback)
if self.history:
history=self.history
self.history=None
self.SetHistory( history, control=textControl)
return textControl
def GetHistoryControl( self ):
"""Return a pointer to the control which provides (at least)
the following methods for manipulating the history list.:
Append( item ) -- add item
Clear() -- clear all items
Delete( index ) -- 0-based index to delete from list
SetSelection( index ) -- 0-based index to select in list
Semantics of the methods follow those for the wxComboBox control
"""
return self.textControl
def SetHistory( self, value=(), selectionIndex = None, control=None ):
"""Set the current history list"""
if control is None:
control = self.GetHistoryControl()
if self.history == value:
return
self.history = value
# Clear history values not the selected one.
tempValue=control.GetValue()
# clear previous values
control.Clear()
control.SetValue(tempValue)
# walk through, appending new values
for path in value:
control.Append( path )
if selectionIndex is not None:
control.SetSelection( selectionIndex )
def GetHistory( self ):
"""Return the current history list"""
if self.historyCallBack != None:
return self.historyCallBack()
else:
return list( self.history )
def OnSetFocus(self, event):
"""When the history scroll is selected, update the history"""
if self.historyCallBack != None:
self.SetHistory( self.historyCallBack(), control=self.textControl)
event.Skip()
if wxPlatform == "__WXMSW__":
def SetValue (self, value, callBack=1):
""" Convenient setting of text control value, works
around limitation of wxComboBox """
save = self.callCallback
self.callCallback = callBack
self.textControl.SetValue(value)
self.callCallback = save
# Hack to call an event handler
class LocalEvent:
def __init__(self, string):
self._string=string
def GetString(self):
return self._string
if callBack==1:
# The callback wasn't being called when SetValue was used ??
# So added this explicit call to it
self.changeCallback(LocalEvent(value))
class DirBrowseButton(FileBrowseButton):
def __init__(self, parent, id = -1,
pos = wxDefaultPosition, size = wxDefaultSize,
style = wxTAB_TRAVERSAL,
labelText = 'Select a directory:',
buttonText = 'Browse',
toolTip = 'Type directory name or browse to select',
dialogTitle = '',
startDirectory = '.',
changeCallback = None,
dialogClass = wxDirDialog):
FileBrowseButton.__init__(self, parent, id, pos, size, style,
labelText, buttonText, toolTip,
dialogTitle, startDirectory,
changeCallback = changeCallback)
#
self._dirDialog = dialogClass(self,
message = dialogTitle,
defaultPath = startDirectory)
#
def OnBrowse(self, ev = None):
dialog = self._dirDialog
if dialog.ShowModal() == wxID_OK:
self.SetValue(dialog.GetPath())
#
def __del__(self):
if self.__dict__.has_key('_dirDialog'):
self._dirDialog.Destroy()
#----------------------------------------------------------------------
if __name__ == "__main__":
#from skeletonbuilder import rulesfile
class SimpleCallback:
def __init__( self, tag ):
self.tag = tag
def __call__( self, event ):
print self.tag, event.GetString()
class DemoFrame( wxFrame ):
def __init__(self, parent):
wxFrame.__init__(self, parent, 2400, "File entry with browse", size=(500,260) )
EVT_CLOSE(self, self.OnCloseWindow)
panel = wxPanel (self,-1)
innerbox = wxBoxSizer(wxVERTICAL)
control = FileBrowseButton(
panel,
initialValue = "z:\\temp",
)
innerbox.Add( control, 0, wxEXPAND )
middlecontrol = FileBrowseButtonWithHistory(
panel,
labelText = "With History",
initialValue = "d:\\temp",
history = ["c:\\temp", "c:\\tmp", "r:\\temp","z:\\temp"],
changeCallback= SimpleCallback( "With History" ),
)
innerbox.Add( middlecontrol, 0, wxEXPAND )
middlecontrol = FileBrowseButtonWithHistory(
panel,
labelText = "History callback",
initialValue = "d:\\temp",
history = self.historyCallBack,
changeCallback= SimpleCallback( "History callback" ),
)
innerbox.Add( middlecontrol, 0, wxEXPAND )
self.bottomcontrol = control = FileBrowseButton(
panel,
labelText = "With Callback",
style = wxSUNKEN_BORDER|wxCLIP_CHILDREN ,
changeCallback= SimpleCallback( "With Callback" ),
)
innerbox.Add( control, 0, wxEXPAND)
self.bottommostcontrol = control = DirBrowseButton(
panel,
labelText = "Simple dir browse button",
style = wxSUNKEN_BORDER|wxCLIP_CHILDREN)
innerbox.Add( control, 0, wxEXPAND)
ID = wxNewId()
innerbox.Add( wxButton( panel, ID,"Change Label", ), 1, wxEXPAND)
EVT_BUTTON( self, ID, self.OnChangeLabel )
ID = wxNewId()
innerbox.Add( wxButton( panel, ID,"Change Value", ), 1, wxEXPAND)
EVT_BUTTON( self, ID, self.OnChangeValue )
panel.SetAutoLayout(True)
panel.SetSizer( innerbox )
self.history={"c:\\temp":1, "c:\\tmp":1, "r:\\temp":1,"z:\\temp":1}
def historyCallBack(self):
keys=self.history.keys()
keys.sort()
return keys
def OnFileNameChangedHistory (self, event):
self.history[event.GetString ()]=1
def OnCloseMe(self, event):
self.Close(True)
def OnChangeLabel( self, event ):
self.bottomcontrol.SetLabel( "Label Updated" )
def OnChangeValue( self, event ):
self.bottomcontrol.SetValue( "r:\\somewhere\\over\\the\\rainbow.htm" )
def OnCloseWindow(self, event):
self.Destroy()
class DemoApp(wxApp):
def OnInit(self):
wxImage_AddHandler(wxJPEGHandler())
wxImage_AddHandler(wxPNGHandler())
wxImage_AddHandler(wxGIFHandler())
frame = DemoFrame(NULL)
#frame = RulesPanel(NULL )
frame.Show(True)
self.SetTopWindow(frame)
return True
def test( ):
app = DemoApp(0)
app.MainLoop()
print 'Creating dialog'
test( )
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
import wx.lib.filebrowsebutton
__doc__ = wx.lib.filebrowsebutton.__doc__
DirBrowseButton = wx.lib.filebrowsebutton.DirBrowseButton
FileBrowseButton = wx.lib.filebrowsebutton.FileBrowseButton
FileBrowseButtonWithHistory = wx.lib.filebrowsebutton.FileBrowseButtonWithHistory
+6 -280
View File
@@ -1,283 +1,9 @@
#----------------------------------------------------------------------------
# Name: floatbar.py
# Purpose: Contains floating toolbar class
#
# Author: Bryn Keller
#
# Created: 10/4/99
#----------------------------------------------------------------------------
"""
NOTE: This module is *not* supported in any way. Use it however you
wish, but be warned that dealing with any consequences is
entirly up to you.
--Robin
"""
from wxPython.wx import *
if wxPlatform == '__WXGTK__':
#
# For wxGTK all we have to do is set the wxTB_DOCKABLE flag
#
class wxFloatBar(wxToolBar):
def __init__(self, parent, ID,
pos = wxDefaultPosition,
size = wxDefaultSize,
style = 0,
name = 'toolbar'):
wxToolBar.__init__(self, parent, ID, pos, size,
style|wxTB_DOCKABLE, name)
# these other methods just become no-ops
def SetFloatable(self, float):
pass
def IsFloating(self):
return 1
def GetTitle(self):
return ""
def SetTitle(self, title):
pass
else:
_DOCKTHRESHOLD = 25
class wxFloatBar(wxToolBar):
"""
wxToolBar subclass which can be dragged off its frame and later
replaced there. Drag on the toolbar to release it, close it like
a normal window to make it return to its original
position. Programmatically, call SetFloatable(True) and then
Float(True) to float, Float(False) to dock.
"""
def __init__(self,*_args,**_kwargs):
"""
In addition to the usual arguments, wxFloatBar accepts keyword
args of: title(string): the title that should appear on the
toolbar's frame when it is floating. floatable(bool): whether
user actions (i.e., dragging) can float the toolbar or not.
"""
args = (self,) + _args
apply(wxToolBar.__init__, args, _kwargs)
if _kwargs.has_key('floatable'):
self.floatable = _kwargs['floatable']
assert type(self.floatable) == type(0)
else:
self.floatable = 0
self.floating = 0
if _kwargs.has_key('title'):
self.title = _kwargs['title']
assert type(self.title) == type("")
else:
self.title = ""
EVT_MOUSE_EVENTS(self, self.OnMouse)
self.parentframe = wxPyTypeCast(args[1], 'wxFrame')
def IsFloatable(self):
return self.floatable
def SetFloatable(self, float):
self.floatable = float
#Find the size of a title bar.
if not hasattr(self, 'titleheight'):
test = wxMiniFrame(NULL, -1, "TEST")
test.SetClientSize(wxSize(0,0))
self.titleheight = test.GetSizeTuple()[1]
test.Destroy()
def IsFloating(self):
return self.floating
def Realize(self):
wxToolBar.Realize(self)
def GetTitle(self):
return self.title
def SetTitle(self, title):
print 'SetTitle', title
self.title = title
if self.IsFloating():
self.floatframe.SetTitle(self.title)
## def GetHome(self):
## """
## Returns the frame which this toolbar will return to when
## docked, or the parent if currently docked.
## """
## if hasattr(self, 'parentframe'):
## return self.parentframe
## else:
## return wxPyTypeCast(self.GetParent(), 'wxFrame')
## def SetHome(self, frame):
## """
## Called when docked, this will remove the toolbar from its
## current frame and attach it to another. If called when
## floating, it will dock to the frame specified when the toolbar
## window is closed.
## """
## if self.IsFloating():
## self.parentframe = frame
## self.floatframe.Reparent(frame)
## else:
## parent = wxPyTypeCast(self.GetParent(), 'wxFrame')
## self.Reparent(frame)
## parent.SetToolBar(None)
## size = parent.GetSize()
## parent.SetSize(wxSize(0,0))
## parent.SetSize(size)
## frame.SetToolBar(self)
## size = frame.GetSize()
## frame.SetSize(wxSize(0,0))
## frame.SetSize(size)
def Float(self, bool):
"Floats or docks the toolbar programmatically."
if bool:
self.parentframe = wxPyTypeCast(self.GetParent(), 'wxFrame')
print self.title
if self.title:
useStyle = wxDEFAULT_FRAME_STYLE
else:
useStyle = wxTHICK_FRAME
self.floatframe = wxMiniFrame(self.parentframe, -1, self.title,
style = useStyle)
self.Reparent(self.floatframe)
self.parentframe.SetToolBar(None)
self.floating = 1
psize = self.parentframe.GetSize()
self.parentframe.SetSize(wxSize(0,0))
self.parentframe.SetSize(psize)
self.floatframe.SetToolBar(self)
self.oldcolor = self.GetBackgroundColour()
w = psize.width
h = self.GetSize().height
if self.title:
h = h + self.titleheight
self.floatframe.SetSize(wxSize(w,h))
self.floatframe.SetClientSize(self.GetSize())
newpos = self.parentframe.GetPosition()
newpos.y = newpos.y + _DOCKTHRESHOLD * 2
self.floatframe.SetPosition(newpos)
self.floatframe.Show(True)
EVT_CLOSE(self.floatframe, self.OnDock)
#EVT_MOVE(self.floatframe, self.OnMove)
else:
self.Reparent(self.parentframe)
self.parentframe.SetToolBar(self)
self.floating = 0
self.floatframe.SetToolBar(None)
self.floatframe.Destroy()
size = self.parentframe.GetSize()
self.parentframe.SetSize(wxSize(0,0))
self.parentframe.SetSize(size)
self.SetBackgroundColour(self.oldcolor)
def OnDock(self, e):
self.Float(0)
if hasattr(self, 'oldpos'):
del self.oldpos
def OnMove(self, e):
homepos = self.parentframe.ClientToScreen(wxPoint(0,0))
floatpos = self.floatframe.GetPosition()
if (abs(homepos.x - floatpos.x) < _DOCKTHRESHOLD and
abs(homepos.y - floatpos.y) < _DOCKTHRESHOLD):
self.Float(0)
#homepos = self.parentframe.GetPositionTuple()
#homepos = homepos[0], homepos[1] + self.titleheight
#floatpos = self.floatframe.GetPositionTuple()
#if abs(homepos[0] - floatpos[0]) < 35 and abs(homepos[1] - floatpos[1]) < 35:
# self._SetFauxBarVisible(True)
#else:
# self._SetFauxBarVisible(False)
def OnMouse(self, e):
if not self.IsFloatable():
e.Skip()
return
if e.ButtonDClick(1) or e.ButtonDClick(2) or e.ButtonDClick(3) or e.ButtonDown() or e.ButtonUp():
e.Skip()
if e.ButtonDown():
self.CaptureMouse()
self.oldpos = (e.GetX(), e.GetY())
if e.Entering():
self.oldpos = (e.GetX(), e.GetY())
if e.ButtonUp():
self.ReleaseMouse()
if self.IsFloating():
homepos = self.parentframe.ClientToScreen(wxPoint(0,0))
floatpos = self.floatframe.GetPosition()
if (abs(homepos.x - floatpos.x) < _DOCKTHRESHOLD and
abs(homepos.y - floatpos.y) < _DOCKTHRESHOLD):
self.Float(0)
return
if e.Dragging():
if not self.IsFloating():
self.Float(True)
self.oldpos = (e.GetX(), e.GetY())
else:
if hasattr(self, 'oldpos'):
loc = self.floatframe.GetPosition()
pt = wxPoint(loc.x - (self.oldpos[0]-e.GetX()), loc.y - (self.oldpos[1]-e.GetY()))
self.floatframe.Move(pt)
def _SetFauxBarVisible(self, vis):
return
if vis:
if self.parentframe.GetToolBar() == None:
if not hasattr(self, 'nullbar'):
self.nullbar = wxToolBar(self.parentframe, -1)
print "Adding fauxbar."
self.nullbar.Reparent(self.parentframe)
print "Reparented."
self.parentframe.SetToolBar(self.nullbar)
print "Set toolbar"
col = wxNamedColour("GREY")
self.nullbar.SetBackgroundColour(col)
print "Set color"
size = self.parentframe.GetSize()
self.parentframe.SetSize(wxSize(0,0))
self.parentframe.SetSize(size)
print "Set size"
else:
print self.parentframe.GetToolBar()
else:
if self.parentframe.GetToolBar() != None:
print "Removing fauxbar"
self.nullbar.Reparent(self.floatframe)
self.parentframe.SetToolBar(None)
size = self.parentframe.GetSize()
self.parentframe.SetSize(wxSize(0,0))
self.parentframe.SetSize(size)
## This file imports items from the wx package into the wxPython package for
## backwards compatibility. Some names will also have a 'wx' added on if
## that is how they used to be named in the old wxPython package.
import wx.lib.floatbar
__doc__ = wx.lib.floatbar.__doc__
wxFloatBar = wx.lib.floatbar.wxFloatBar

Some files were not shown because too many files have changed in this diff Show More