mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Add wx.FileCtrl
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71217 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
1
TODO.txt
1
TODO.txt
@@ -131,7 +131,6 @@ other dev stuff
|
|||||||
|
|
||||||
* taskbar
|
* taskbar
|
||||||
* print (as in print framework classes)
|
* print (as in print framework classes)
|
||||||
* filectrl
|
|
||||||
* axbase (ActiveX. Need to figure out best ways to do MSW-only items...)
|
* axbase (ActiveX. Need to figure out best ways to do MSW-only items...)
|
||||||
* tipdlg
|
* tipdlg
|
||||||
* check that all items in _functions.i and _misc.i have been wrapped
|
* check that all items in _functions.i and _misc.i have been wrapped
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ INCLUDES = [ # core
|
|||||||
'treeitemdata',
|
'treeitemdata',
|
||||||
'treectrl',
|
'treectrl',
|
||||||
'pickers',
|
'pickers',
|
||||||
|
'filectrl',
|
||||||
|
|
||||||
# toplevel and dialogs
|
# toplevel and dialogs
|
||||||
'nonownedwnd',
|
'nonownedwnd',
|
||||||
|
|||||||
85
etg/filectrl.py
Normal file
85
etg/filectrl.py
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Name: etg/filectrl.py
|
||||||
|
# Author: Robin Dunn
|
||||||
|
#
|
||||||
|
# Created: 12-Apr-2012
|
||||||
|
# Copyright: (c) 2012 by Total Control Software
|
||||||
|
# License: wxWindows License
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import etgtools
|
||||||
|
import etgtools.tweaker_tools as tools
|
||||||
|
|
||||||
|
PACKAGE = "wx"
|
||||||
|
MODULE = "_core"
|
||||||
|
NAME = "filectrl" # Base name of the file to generate to for this script
|
||||||
|
DOCSTRING = ""
|
||||||
|
|
||||||
|
# The classes and/or the basename of the Doxygen XML files to be processed by
|
||||||
|
# this script.
|
||||||
|
ITEMS = [ "wxFileCtrl",
|
||||||
|
"wxFileCtrlEvent",
|
||||||
|
]
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def run():
|
||||||
|
# Parse the XML file(s) building a collection of Extractor objects
|
||||||
|
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
|
||||||
|
etgtools.parseDoxyXML(module, ITEMS)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------
|
||||||
|
# Tweak the parsed meta objects in the module object as needed for
|
||||||
|
# customizing the generated code and docstrings.
|
||||||
|
|
||||||
|
module.addHeaderCode('#include <wx/filectrl.h>')
|
||||||
|
|
||||||
|
c = module.find('wxFileCtrl')
|
||||||
|
assert isinstance(c, etgtools.ClassDef)
|
||||||
|
tools.fixWindowClass(c)
|
||||||
|
|
||||||
|
module.addGlobalStr('wxFileCtrlNameStr', c)
|
||||||
|
|
||||||
|
c.find('GetFilenames').ignore()
|
||||||
|
c.addCppMethod('wxArrayString*', 'GetFilenames', '()', doc="""\
|
||||||
|
Returns a list of filenames selected in the control. This function
|
||||||
|
should only be used with controls which have the wx.FC_MULTIPLE style,
|
||||||
|
use GetFilename for the others.""",
|
||||||
|
body="""\
|
||||||
|
wxArrayString* arr = new wxArrayString;
|
||||||
|
self->GetFilenames(*arr);
|
||||||
|
return arr;""",
|
||||||
|
factory=True)
|
||||||
|
|
||||||
|
c.find('GetPaths').ignore()
|
||||||
|
c.addCppMethod('wxArrayString*', 'GetPaths', '()', doc="""\
|
||||||
|
Returns a list of the full paths (directory and filename) of the files
|
||||||
|
chosen. This function should only be used with controlss which have
|
||||||
|
the wx.FC_MULTIPLE style, use GetPath for the others.
|
||||||
|
""",
|
||||||
|
body="""\
|
||||||
|
wxArrayString* arr = new wxArrayString;
|
||||||
|
self->GetPaths(*arr);
|
||||||
|
return arr;""",
|
||||||
|
factory=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
c = module.find('wxFileCtrlEvent')
|
||||||
|
tools.fixEventClass(c)
|
||||||
|
c.addPyCode("""\
|
||||||
|
EVT_FILECTRL_SELECTIONCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_SELECTIONCHANGED, 1)
|
||||||
|
EVT_FILECTRL_FILEACTIVATED = wx.PyEventBinder( wxEVT_FILECTRL_FILEACTIVATED, 1)
|
||||||
|
EVT_FILECTRL_FOLDERCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_FOLDERCHANGED, 1)
|
||||||
|
EVT_FILECTRL_FILTERCHANGED = wx.PyEventBinder( wxEVT_FILECTRL_FILTERCHANGED, 1)
|
||||||
|
""")
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------
|
||||||
|
tools.doCommonTweaks(module)
|
||||||
|
tools.runGenerators(module)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run()
|
||||||
|
|
||||||
62
unittests/test_filectrl.py
Normal file
62
unittests/test_filectrl.py
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import imp_unittest, unittest
|
||||||
|
import wtc
|
||||||
|
import wx
|
||||||
|
import os
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class filectrl_Tests(wtc.WidgetTestCase):
|
||||||
|
|
||||||
|
def test_filectrl1(self):
|
||||||
|
fc = wx.FileCtrl(self.frame)
|
||||||
|
|
||||||
|
def test_filectrl2(self):
|
||||||
|
fc = wx.FileCtrl()
|
||||||
|
fc.Create(self.frame)
|
||||||
|
|
||||||
|
def test_filectrl3(self):
|
||||||
|
wx.FC_OPEN
|
||||||
|
wx.FC_SAVE
|
||||||
|
wx.FC_MULTIPLE
|
||||||
|
wx.FC_NOSHOWHIDDEN
|
||||||
|
wx.FC_DEFAULT_STYLE
|
||||||
|
|
||||||
|
wx.wxEVT_FILECTRL_SELECTIONCHANGED
|
||||||
|
wx.wxEVT_FILECTRL_FILEACTIVATED
|
||||||
|
wx.wxEVT_FILECTRL_FOLDERCHANGED
|
||||||
|
wx.wxEVT_FILECTRL_FILTERCHANGED
|
||||||
|
wx.EVT_FILECTRL_SELECTIONCHANGED
|
||||||
|
wx.EVT_FILECTRL_FILEACTIVATED
|
||||||
|
wx.EVT_FILECTRL_FOLDERCHANGED
|
||||||
|
wx.EVT_FILECTRL_FILTERCHANGED
|
||||||
|
wx.FileCtrlEvent
|
||||||
|
|
||||||
|
|
||||||
|
def test_filectrl4(self):
|
||||||
|
fc = wx.FileCtrl(self.frame,
|
||||||
|
defaultDirectory=os.path.dirname(__file__),
|
||||||
|
defaultFilename=os.path.basename(__file__),
|
||||||
|
style=wx.FC_OPEN)
|
||||||
|
|
||||||
|
self.assertEqual(fc.GetFilename(), os.path.basename(__file__))
|
||||||
|
self.assertEqual(fc.GetPath(), __file__)
|
||||||
|
self.assertEqual(fc.Filename, os.path.basename(__file__))
|
||||||
|
self.assertEqual(fc.Path, __file__)
|
||||||
|
|
||||||
|
|
||||||
|
def test_filectrl5(self):
|
||||||
|
fc = wx.FileCtrl(self.frame,
|
||||||
|
defaultDirectory=os.path.dirname(__file__),
|
||||||
|
defaultFilename=os.path.basename(__file__),
|
||||||
|
style=wx.FC_OPEN|wx.FC_MULTIPLE)
|
||||||
|
|
||||||
|
self.assertEqual(fc.GetFilenames(), [os.path.basename(__file__)])
|
||||||
|
self.assertEqual(fc.GetPaths(), [__file__])
|
||||||
|
self.assertEqual(fc.Filenames, [os.path.basename(__file__)])
|
||||||
|
self.assertEqual(fc.Paths, [__file__])
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user