Added ability to use xml resource files. Still need to add ability to
subclass wxXmlResourceHandler, etc... Added wxGridAutoEditMixin to the mixins library package. Made ColourSelect be derived from wxButton. Fixed a few bugs here and there, added some missing methods, etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10588 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -8,6 +8,16 @@ Added EVT_GRID_EDITOR_CREATED and wxGridEditorCreatedEvent so the user
|
||||
code can get access to the edit control when it is created, (to push
|
||||
on a custom event handler for example.)
|
||||
|
||||
Added wxTextAttr class and SetStyle, SetDefaultStyle and
|
||||
GetDefaultStyle methods to wxTextCtrl.
|
||||
|
||||
Added ability to use xml resource files. Still need to add ability to
|
||||
subclass wxXmlResourceHandler, etc...
|
||||
|
||||
Added wxGridAutoEditMixin to the mixins library package.
|
||||
|
||||
Made ColourSelect be derived from wxButton.
|
||||
|
||||
|
||||
|
||||
2.3.0
|
||||
|
1
wxPython/contrib/xrc/.cvsignore
Normal file
1
wxPython/contrib/xrc/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
contrib
|
5
wxPython/contrib/xrc/b.bat
Executable file
5
wxPython/contrib/xrc/b.bat
Executable file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
cd %WXWIN%\wxPython
|
||||
call b.bat %$
|
||||
cd -
|
||||
|
1283
wxPython/contrib/xrc/xrc.cpp
Normal file
1283
wxPython/contrib/xrc/xrc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
161
wxPython/contrib/xrc/xrc.i
Normal file
161
wxPython/contrib/xrc/xrc.i
Normal file
@@ -0,0 +1,161 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: xrc.i
|
||||
// Purpose: Wrappers for the XML based Resource system
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 4-June-2001
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
%module xrc
|
||||
|
||||
|
||||
%{
|
||||
#include "export.h"
|
||||
#include "wx/xrc/xmlres.h"
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
%extern wx.i
|
||||
%extern windows.i
|
||||
%extern _defs.i
|
||||
%extern events.i
|
||||
%extern controls.i
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// This class holds XML resources from one or more .xml files
|
||||
// (or derived forms, either binary or zipped -- see manual for
|
||||
// details).
|
||||
|
||||
class wxXmlResource : public wxObject
|
||||
{
|
||||
public:
|
||||
// Ctor. If use_locale is TRUE, translatable strings are
|
||||
// translated via _(). You can disable it by passing use_locale=FALSE
|
||||
// (for example if you provide resource file for each locale)
|
||||
%name(wxXmlResourceEmpty)wxXmlResource(bool use_locale = TRUE); // TODO, a better %name
|
||||
|
||||
%addmethods {
|
||||
wxXmlResource(const wxString* filemask, bool use_locale = TRUE) {
|
||||
wxXmlResource* res = new wxXmlResource(*filemask, use_locale);
|
||||
res->InitAllHandlers();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
~wxXmlResource();
|
||||
|
||||
|
||||
// Loads resources from XML files that match given filemask.
|
||||
// This method understands VFS (see filesys.h).
|
||||
bool Load(const wxString& filemask);
|
||||
|
||||
// Initialize handlers for all supported controls/windows. This will
|
||||
// make the executable quite big because it forces linking against
|
||||
// most of wxWin library
|
||||
void InitAllHandlers();
|
||||
|
||||
// Initialize only specific handler (or custom handler). Convention says
|
||||
// that handler name is equal to control's name plus 'XmlHandler', e.g.
|
||||
// wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
|
||||
// (xmlres) can create include file that contains initialization code for
|
||||
// all controls used within the resource.
|
||||
void AddHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Removes all handlers
|
||||
void ClearHandlers();
|
||||
|
||||
// Loads menu from resource. Returns NULL on failure.
|
||||
wxMenu *LoadMenu(const wxString& name);
|
||||
|
||||
// Loads menubar from resource. Returns NULL on failure.
|
||||
wxMenuBar *LoadMenuBar(const wxString& name);
|
||||
|
||||
// Loads toolbar
|
||||
wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads dialog. dlg points to parent window (if any). Second form
|
||||
// is used to finish creation of already existing instance (main reason
|
||||
// for this is that you may want to use derived class with new event table)
|
||||
// Example (typical usage):
|
||||
// MyDialog dlg;
|
||||
// wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
|
||||
// dlg->ShowModal();
|
||||
wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
|
||||
%name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads panel. panel points to parent window (if any). Second form
|
||||
// is used to finish creation of already existing instance.
|
||||
wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
|
||||
%name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
|
||||
|
||||
bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads bitmap or icon resource from file:
|
||||
wxBitmap LoadBitmap(const wxString& name);
|
||||
wxIcon LoadIcon(const wxString& name);
|
||||
|
||||
// Attaches unknown control into given panel/window/dialog:
|
||||
// (unknown controls are used in conjunction with <object class="unknown">)
|
||||
bool AttachUnknownControl(const wxString& name, wxWindow *control,
|
||||
wxWindow *parent = NULL);
|
||||
|
||||
// Returns numeric ID that is equivalent to string id used in XML
|
||||
// resource. To be used in event tables
|
||||
// Macro XMLID is provided for convenience
|
||||
static int GetXMLID(const char *str_id);
|
||||
|
||||
// Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
|
||||
long GetVersion() const;
|
||||
|
||||
// Compares resources version to argument. Returns -1 if resources version
|
||||
// is less than the argument, +1 if greater and 0 if they equal.
|
||||
int CompareVersion(int major, int minor, int release, int revision) const;
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%readonly
|
||||
// Global instance of resource class. For your convenience.
|
||||
wxXmlResource *wxTheXmlResource;
|
||||
%readwrite
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%pragma(python) code = "
|
||||
def XMLID(str_id):
|
||||
return wxXmlResource_GetXMLID(str_id)
|
||||
|
||||
def XMLCTRL(window, str_id, *args):
|
||||
return window.FindWindowById(XMLID(str_id))
|
||||
|
||||
"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// TODO: Add wxXmlResourceHandler and etc.
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%init %{
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
wxXmlInitXmlModule();
|
||||
wxXmlInitResourceModule();
|
||||
wxTheXmlResource->InitAllHandlers();
|
||||
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
139
wxPython/contrib/xrc/xrc.py
Normal file
139
wxPython/contrib/xrc/xrc.py
Normal file
@@ -0,0 +1,139 @@
|
||||
# This file was created automatically by SWIG.
|
||||
import xrcc
|
||||
|
||||
from misc import *
|
||||
|
||||
from misc2 import *
|
||||
|
||||
from windows import *
|
||||
|
||||
from gdi import *
|
||||
|
||||
from clip_dnd import *
|
||||
|
||||
from events import *
|
||||
|
||||
from streams import *
|
||||
|
||||
from mdi import *
|
||||
|
||||
from frames import *
|
||||
|
||||
from stattool import *
|
||||
|
||||
from controls import *
|
||||
|
||||
from controls2 import *
|
||||
|
||||
from windows2 import *
|
||||
|
||||
from cmndlgs import *
|
||||
|
||||
from windows3 import *
|
||||
|
||||
from image import *
|
||||
|
||||
from printfw import *
|
||||
|
||||
from sizers import *
|
||||
|
||||
from filesys import *
|
||||
|
||||
from utils import *
|
||||
|
||||
def XMLID(str_id):
|
||||
return wxXmlResource_GetXMLID(str_id)
|
||||
|
||||
def XMLCTRL(window, str_id, *args):
|
||||
return window.FindWindowById(XMLID(str_id))
|
||||
|
||||
|
||||
class wxXmlResourcePtr(wxObjectPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __del__(self,xrcc=xrcc):
|
||||
if self.thisown == 1 :
|
||||
xrcc.delete_wxXmlResource(self)
|
||||
def Load(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_Load,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def InitAllHandlers(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_InitAllHandlers,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def AddHandler(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_AddHandler,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def ClearHandlers(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_ClearHandlers,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadMenu(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadMenu,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadMenuBar(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadMenuBar,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadToolBar(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadToolBar,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadDialog(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadDialog,(self,) + _args, _kwargs)
|
||||
if val: val = wxDialogPtr(val)
|
||||
return val
|
||||
def LoadOnDialog(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadOnDialog,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadPanel(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadPanel,(self,) + _args, _kwargs)
|
||||
if val: val = wxPanelPtr(val)
|
||||
return val
|
||||
def LoadOnPanel(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadOnPanel,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadFrame(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadFrame,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def LoadBitmap(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadBitmap,(self,) + _args, _kwargs)
|
||||
if val: val = wxBitmapPtr(val) ; val.thisown = 1
|
||||
return val
|
||||
def LoadIcon(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_LoadIcon,(self,) + _args, _kwargs)
|
||||
if val: val = wxIconPtr(val) ; val.thisown = 1
|
||||
return val
|
||||
def AttachUnknownControl(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_AttachUnknownControl,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetVersion(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_GetVersion,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def CompareVersion(self, *_args, **_kwargs):
|
||||
val = apply(xrcc.wxXmlResource_CompareVersion,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxXmlResource instance at %s>" % (self.this,)
|
||||
class wxXmlResource(wxXmlResourcePtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(xrcc.new_wxXmlResourceEmpty,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
def wxXmlResource(*_args,**_kwargs):
|
||||
val = wxXmlResourcePtr(apply(xrcc.new_wxXmlResource,_args,_kwargs))
|
||||
val.thisown = 1
|
||||
return val
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------- FUNCTION WRAPPERS ------------------
|
||||
|
||||
wxXmlResource_GetXMLID = xrcc.wxXmlResource_GetXMLID
|
||||
|
||||
|
||||
|
||||
#-------------- VARIABLE WRAPPERS ------------------
|
||||
|
||||
cvar = xrcc.cvar
|
||||
wxTheXmlResource = wxXmlResourcePtr(xrcc.cvar.wxTheXmlResource)
|
@@ -34,21 +34,22 @@ class TestColourSelect(wxPanel):
|
||||
self.y_pos = self.y_pos + delta
|
||||
|
||||
wxStaticText(self, -1, "Default", wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name
|
||||
self.colour_def = ColourSelect(self, wxPoint(self.x_pos+100, self.y_pos)) # default colour selection control
|
||||
self.colour_def = ColourSelect(self, -1, pos=wxPoint(self.x_pos+100, self.y_pos)) # default colour selection control
|
||||
|
||||
self.y_pos = self.y_pos + delta
|
||||
colours = [[255, 255, 0], [255, 0, 255], [0, 255, 0], [0, 0, 255]] # list of initial colours for display
|
||||
self.names = names = [ "Default Size", "Another Size", "Another Colour", "Larger"] # display names
|
||||
sizes = [ None, wxSize(60, 20), None, wxSize(60, 60)] # button sizes
|
||||
sizes = [ wxDefaultSize, wxSize(60, 20), wxDefaultSize, wxSize(60, 60)] # button sizes
|
||||
self.set_val = []
|
||||
|
||||
for i in range(len(colours)):
|
||||
wxStaticText(self, -1, names[i], wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name
|
||||
|
||||
val = ColourSelect(self, wxPoint(self.x_pos+100, self.y_pos), colours[i], sizes[i]) # colour selection button
|
||||
val = ColourSelect(self, -1, colours[i], wxPoint(self.x_pos+100, self.y_pos), sizes[i]) # colour selection button
|
||||
self.set_val.append(val) # store control for reference
|
||||
self.y_pos = self.y_pos + delta
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
result = []
|
||||
colour = self.colour_def.GetColour() # default control value
|
||||
|
@@ -1,11 +1,13 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.grid import *
|
||||
from wxPython.lib.mixins.grid import wxGridAutoEditMixin
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class SimpleGrid(wxGrid):
|
||||
class SimpleGrid(wxGrid, wxGridAutoEditMixin):
|
||||
def __init__(self, parent, log):
|
||||
wxGrid.__init__(self, parent, -1)
|
||||
wxGridAutoEditMixin.__init__(self)
|
||||
self.log = log
|
||||
self.moveTo = None
|
||||
|
||||
@@ -25,6 +27,10 @@ class SimpleGrid(wxGrid):
|
||||
self.SetCellBackgroundColour(2, 2, wxCYAN)
|
||||
self.SetReadOnly(3, 3, true)
|
||||
|
||||
self.SetCellEditor(5, 0, wxGridCellNumberEditor())
|
||||
self.SetCellValue(5, 0, "123")
|
||||
self.SetCellEditor(6, 0, wxGridCellFloatEditor())
|
||||
self.SetCellValue(6, 0, "123.34")
|
||||
|
||||
# attribute objects let you keep a set of formatting values
|
||||
# in one spot, and reuse them if needed
|
||||
@@ -135,11 +141,12 @@ class SimpleGrid(wxGrid):
|
||||
if value == 'no good':
|
||||
self.moveTo = evt.GetRow(), evt.GetCol()
|
||||
|
||||
|
||||
def OnIdle(self, evt):
|
||||
if self.moveTo != None:
|
||||
self.SetGridCursor(self.moveTo[0], self.moveTo[1])
|
||||
self.moveTo = None
|
||||
|
||||
evt.Skip()
|
||||
|
||||
|
||||
def OnSelectCell(self, evt):
|
||||
@@ -155,9 +162,7 @@ class SimpleGrid(wxGrid):
|
||||
value = self.GetCellValue(row, col)
|
||||
if value == 'no good 2':
|
||||
return # cancels the cell selection
|
||||
else:
|
||||
evt.Skip()
|
||||
|
||||
evt.Skip()
|
||||
|
||||
|
||||
def OnEditorShown(self, evt):
|
||||
|
@@ -22,9 +22,7 @@ import images
|
||||
|
||||
|
||||
_treeList = [
|
||||
('New since last release', ['ColourSelect', 'ImageBrowser', 'infoframe',
|
||||
'ColourDB', 'wxToggleButton', 'OOR', 'wxWave',
|
||||
'wxJoystick',
|
||||
('New since last release', ['wxTextCtrl', 'XML_Resource'
|
||||
]),
|
||||
|
||||
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),
|
||||
@@ -63,6 +61,7 @@ _treeList = [
|
||||
'PyShell', 'wxCalendar', 'wxMVCTree', 'wxVTKRenderWindow',
|
||||
'FileBrowseButton', 'GenericButtons', 'wxEditor',
|
||||
'PyShellWindow', 'ColourSelect', 'ImageBrowser',
|
||||
'infoframe', 'ColourDB',
|
||||
]),
|
||||
|
||||
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot', 'XMLtreeview']),
|
||||
@@ -112,6 +111,9 @@ class wxPythonDemo(wxFrame):
|
||||
splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D)
|
||||
splitter2 = wxSplitterWindow(splitter, -1, style=wxNO_3D|wxSP_3D)
|
||||
|
||||
def EmptyHandler(evt): pass
|
||||
EVT_ERASE_BACKGROUND(splitter, EmptyHandler)
|
||||
EVT_ERASE_BACKGROUND(splitter2, EmptyHandler)
|
||||
|
||||
# Prevent TreeCtrl from displaying all items after destruction
|
||||
self.dying = false
|
||||
@@ -176,7 +178,7 @@ class wxPythonDemo(wxFrame):
|
||||
EVT_LEFT_DOWN (self.tree, self.OnTreeLeftDown)
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wxNotebook(splitter2, -1)
|
||||
self.nb = wxNotebook(splitter2, -1, style=wxCLIP_CHILDREN)
|
||||
|
||||
# Set up a wxHtmlWindow on the Overview Notebook page
|
||||
# we put it in a panel first because there seems to be a
|
||||
@@ -187,7 +189,7 @@ class wxPythonDemo(wxFrame):
|
||||
self.nb.AddPage(self.ovr, "Overview")
|
||||
|
||||
else: # hopefully I can remove this hacky code soon, see bug #216861
|
||||
panel = wxPanel(self.nb, -1)
|
||||
panel = wxPanel(self.nb, -1, style=wxCLIP_CHILDREN)
|
||||
self.ovr = wxHtmlWindow(panel, -1, size=(400, 400))
|
||||
self.nb.AddPage(panel, "Overview")
|
||||
|
||||
@@ -195,6 +197,8 @@ class wxPythonDemo(wxFrame):
|
||||
ovr.SetSize(evt.GetSize())
|
||||
|
||||
EVT_SIZE(panel, OnOvrSize)
|
||||
EVT_ERASE_BACKGROUND(panel, EmptyHandler)
|
||||
|
||||
|
||||
self.SetOverview("Overview", overview)
|
||||
|
||||
@@ -470,7 +474,7 @@ class MyApp(wxApp):
|
||||
|
||||
def main():
|
||||
try:
|
||||
demoPath = os.path.split(__file__)[0]
|
||||
demoPath = os.path.dirname(__file__)
|
||||
os.chdir(demoPath)
|
||||
except:
|
||||
pass
|
||||
|
@@ -4,7 +4,7 @@ import sys
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
myEVT_BUTTON_CLICKPOS = 5015
|
||||
myEVT_BUTTON_CLICKPOS = wxNewEventType()
|
||||
|
||||
def EVT_BUTTON_CLICKPOS(win, id, func):
|
||||
win.Connect(id, -1, myEVT_BUTTON_CLICKPOS, func)
|
||||
|
49
wxPython/demo/XML_Resource.py
Normal file
49
wxPython/demo/XML_Resource.py
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.xrc import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
RESFILE = "data/resource_wdr.xrc"
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
# make the components
|
||||
label = wxStaticText(self, -1, "The lower panel was built from this XML:")
|
||||
label.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
|
||||
|
||||
text = wxTextCtrl(self, -1, open(RESFILE).read(),
|
||||
style=wxTE_READONLY|wxTE_MULTILINE)
|
||||
text.SetInsertionPoint(0)
|
||||
|
||||
line = wxStaticLine(self, -1)
|
||||
|
||||
res = wxXmlResource(RESFILE)
|
||||
panel = res.LoadPanel(self, "MyPanel")
|
||||
|
||||
# and do the layout
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(label, 0, wxEXPAND|wxTOP|wxLEFT, 5)
|
||||
sizer.Add(text, 1, wxEXPAND|wxALL, 5)
|
||||
sizer.Add(line, 0, wxEXPAND)
|
||||
sizer.Add(panel, 1, wxEXPAND|wxALL, 5)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(true)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """
|
||||
"""
|
BIN
wxPython/demo/data/resource.wdr
Normal file
BIN
wxPython/demo/data/resource.wdr
Normal file
Binary file not shown.
153
wxPython/demo/data/resource_wdr.xrc
Normal file
153
wxPython/demo/data/resource_wdr.xrc
Normal file
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- XML resource generated by wxDesigner from file: resource.wdr -->
|
||||
<!-- Do not modify this file, all changes will be lost! -->
|
||||
|
||||
<resource>
|
||||
|
||||
<object class="wxPanel" name="MyPanel">
|
||||
<object class="wxFlexGridSizer">
|
||||
<cols>2</cols>
|
||||
<rows>0</rows>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="ID_TEXT">
|
||||
<label>Name:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_NameField">
|
||||
<size>80,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="ID_TEXT">
|
||||
<label>Address:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_Addr1Field">
|
||||
<size>80,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxALIGN_CENTRE</flag>
|
||||
<border>5</border>
|
||||
<size>20,20</size>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_TEXTCTRL">
|
||||
<size>80,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="ID_TEXT">
|
||||
<label>City, State, Zip:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_CityField">
|
||||
<size>100,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_StateField">
|
||||
<size>30,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_ZipField">
|
||||
<size>50,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="ID_TEXT">
|
||||
<label>Phone:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_PhoneField">
|
||||
<size>80,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="ID_TEXT">
|
||||
<label>Email:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
|
||||
<border>5</border>
|
||||
<object class="wxTextCtrl" name="ID_EmailField">
|
||||
<size>80,-1</size>
|
||||
<value></value>
|
||||
</object>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||
<border>5</border>
|
||||
<size>20,20</size>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALIGN_CENTER_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>Save</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
||||
</resource>
|
@@ -90,7 +90,7 @@ class MyApp(wxApp):
|
||||
|
||||
# This inner loop will process any GUI events until there
|
||||
# are no more waiting.
|
||||
while self.Pending():
|
||||
while self.Pending():
|
||||
self.Dispatch()
|
||||
|
||||
# Send idle events to idle handlers. You may want to throtle
|
||||
|
@@ -44,7 +44,7 @@ command_lines = [
|
||||
"-a -n Tog1 -m #C0C0C0 bmp_source/tog1.bmp images.py",
|
||||
"-a -n Tog2 -m #C0C0C0 bmp_source/tog2.bmp images.py",
|
||||
|
||||
"-a -n Smiles bmp_source/smiles.bmp images.py",
|
||||
"-a -n Smiles -m #FFFFFF bmp_source/smiles.bmp images.py",
|
||||
|
||||
"-a -n GridBG bmp_source/GridBG.gif images.py",
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,12 +15,15 @@ class TestChoice(wxPanel):
|
||||
wxPoint(15, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
|
||||
wxChoice(self, 40, (80, 50), (95, 125),
|
||||
self.ch = wxChoice(self, 40, (80, 50), (95, 125),
|
||||
choices = sampleList)
|
||||
EVT_CHOICE(self, 40, self.EvtChoice)
|
||||
|
||||
|
||||
def EvtChoice(self, event):
|
||||
self.log.WriteText('EvtChoice: %s\n' % event.GetString())
|
||||
self.ch.Append("A new item")
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
@@ -68,7 +68,8 @@ class TestListCtrlPanel(wxPanel):
|
||||
|
||||
self.il = wxImageList(16, 16)
|
||||
bmp = images.getSmilesBitmap()
|
||||
idx1 = self.il.AddWithColourMask(bmp, wxWHITE)
|
||||
#idx1 = self.il.AddWithColourMask(bmp, wxWHITE)
|
||||
idx1 = self.il.Add(bmp)
|
||||
|
||||
self.list = wxListCtrl(self, tID,
|
||||
style=wxLC_REPORT|wxSUNKEN_BORDER)
|
||||
@@ -143,7 +144,6 @@ class TestListCtrlPanel(wxPanel):
|
||||
# this does
|
||||
self.list.SetItemState(10, 0, wxLIST_STATE_SELECTED)
|
||||
|
||||
|
||||
def OnItemActivated(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemActivated: %s\n" % self.list.GetItemText(self.currentItem))
|
||||
@@ -176,7 +176,10 @@ class TestListCtrlPanel(wxPanel):
|
||||
tPopupID3 = 2
|
||||
tPopupID4 = 3
|
||||
tPopupID5 = 5
|
||||
menu.Append(tPopupID1, "One")
|
||||
#menu.Append(tPopupID1, "One")
|
||||
item = wxMenuItem(menu, tPopupID1,"One")
|
||||
item.SetBitmap(images.getSmilesBitmap())
|
||||
menu.AppendItem(item)
|
||||
menu.Append(tPopupID2, "Two")
|
||||
menu.Append(tPopupID3, "Three")
|
||||
menu.Append(tPopupID4, "DeleteAllItems")
|
||||
|
@@ -1,4 +1,4 @@
|
||||
|
||||
import sys
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -8,23 +8,48 @@ class TestPanel(wxPanel):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
wxStaticText(self, -1, "wxTextCtrl", wxPoint(5, 25), wxSize(75, 20))
|
||||
t = wxTextCtrl(self, 10, "Test it out and see", wxPoint(80, 25), wxSize(150, 20))
|
||||
t.SetInsertionPoint(0)
|
||||
l1 = wxStaticText(self, -1, "wxTextCtrl")
|
||||
t1 = wxTextCtrl(self, 10, "Test it out and see", size=(125, -1))
|
||||
t1.SetInsertionPoint(0)
|
||||
EVT_TEXT(self, 10, self.EvtText)
|
||||
EVT_CHAR(t, self.EvtChar)
|
||||
EVT_CHAR(t1, self.EvtChar)
|
||||
|
||||
|
||||
wxStaticText(self, -1, "Passsword", wxPoint(5, 50), wxSize(75, 20))
|
||||
wxTextCtrl(self, 20, "", wxPoint(80, 50), wxSize(150, 20), wxTE_PASSWORD)
|
||||
l2 = wxStaticText(self, -1, "Passsword")
|
||||
t2 = wxTextCtrl(self, 20, "", size=(125, -1), style=wxTE_PASSWORD)
|
||||
EVT_TEXT(self, 20, self.EvtText)
|
||||
|
||||
wxStaticText(self, -1, "Multi-line", wxPoint(5, 75), wxSize(75, 20))
|
||||
t = wxTextCtrl(self, 30, "How does it work with a long line of text set in the control",
|
||||
wxPoint(80, 75), wxSize(200, 150), wxTE_MULTILINE)
|
||||
t.SetInsertionPoint(0)
|
||||
l3 = wxStaticText(self, -1, "Multi-line")
|
||||
t3 = wxTextCtrl(self, 30, "How does it work with a long line of text set in the control",
|
||||
size=(200, 100), style=wxTE_MULTILINE)
|
||||
t3.SetInsertionPoint(0)
|
||||
EVT_TEXT(self, 30, self.EvtText)
|
||||
|
||||
l4 = wxStaticText(self, -1, "Rich Text")
|
||||
t4 = wxTextCtrl(self, 40, "If supported by the native control, this is red, and this is a different font.",
|
||||
size=(200, 100), style=wxTE_MULTILINE|wxTE_RICH)
|
||||
t4.SetInsertionPoint(0)
|
||||
t4.SetStyle(44, 47, wxTextAttr("RED", "YELLOW"))
|
||||
|
||||
points = t4.GetFont().GetPointSize() # get the current size
|
||||
f = wxFont(points+2, wxROMAN, wxITALIC, wxBOLD, true)
|
||||
## print 'a1', sys.getrefcount(f)
|
||||
## t4.SetStyle(63, 77, wxTextAttr("BLUE", font=f))
|
||||
t4.SetStyle(63, 77, wxTextAttr("BLUE", wxNullColour, f))
|
||||
## print 'a2', sys.getrefcount(f)
|
||||
|
||||
sizer = wxFlexGridSizer(cols=2, hgap=6, vgap=6)
|
||||
sizer.AddMany([ l1, t1,
|
||||
l2, t2,
|
||||
l3, t3,
|
||||
l4, t4,
|
||||
])
|
||||
border = wxBoxSizer(wxVERTICAL)
|
||||
border.Add(sizer, 0, wxALL, 25)
|
||||
self.SetSizer(border)
|
||||
self.SetAutoLayout(true)
|
||||
|
||||
|
||||
def EvtText(self, event):
|
||||
self.log.WriteText('EvtText: %s\n' % event.GetString())
|
||||
|
||||
|
@@ -16,6 +16,7 @@ class TestToolBar(wxFrame):
|
||||
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
|
||||
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT)
|
||||
# wxTB_VERTICAL
|
||||
#tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
# wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
|
||||
#self.SetToolBar(tb)
|
||||
|
@@ -37,8 +37,8 @@ copy wxPython-%1\docs\ogl\ogl.htm wxPython-%1\docs\ogl\index.htm
|
||||
|
||||
rem **** zip up the docs
|
||||
rem zip -r ..\distrib\wxPython-docs-%1.zip wxPython-%1\docs
|
||||
tar cvf ..\distrib\wxPython-docs-%1.tar wxPython-%1
|
||||
gzip -9 ..\distrib\wxPython-docs-%1.tar
|
||||
tar cvf ..\dist\wxPython-docs-%1.tar wxPython-%1
|
||||
gzip -9 ..\dist\wxPython-docs-%1.tar
|
||||
|
||||
|
||||
rem **** Cleanup
|
||||
|
@@ -13,7 +13,7 @@ from my_distutils import run_swig, contrib_copy_tree
|
||||
# flags and values that affect this script
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
VERSION = "2.3.0"
|
||||
VERSION = "2.3.1b1"
|
||||
DESCRIPTION = "Cross platform GUI toolkit for Python"
|
||||
AUTHOR = "Robin Dunn"
|
||||
AUTHOR_EMAIL = "robin@alldunn.com"
|
||||
@@ -32,6 +32,8 @@ BUILD_GLCANVAS = 1 # If true, build the contrib/glcanvas extension module
|
||||
BUILD_OGL = 1 # If true, build the contrib/ogl extension module
|
||||
BUILD_STC = 1 # If true, build the contrib/stc extension module
|
||||
BUILD_IEWIN = 0 # Internet Explorer wrapper (experimental)
|
||||
BUILD_XRC = 1 # XML based resource system
|
||||
|
||||
|
||||
CORE_ONLY = 0 # if true, don't build any of the above
|
||||
GL_ONLY = 0 # Only used when making the -gl RPM. See the "b" script
|
||||
@@ -62,7 +64,7 @@ HYBRID = 0 # If set and not debug or FINAL, then build a
|
||||
# wxWindows must have been built with /MD, not /MDd
|
||||
# (using FINAL=hybrid will do it.)
|
||||
|
||||
WXDLLVER = '23_0' # Version part of DLL name
|
||||
WXDLLVER = '23_1' # Version part of DLL name
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@@ -570,6 +572,98 @@ if not GL_ONLY and BUILD_IEWIN:
|
||||
wxpExtensions.append(ext)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Define the XRC extension module
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not GL_ONLY and BUILD_XRC:
|
||||
print 'Preparing XRC...'
|
||||
location = 'contrib/xrc'
|
||||
XMLLOC = location + '/contrib/src/xrc'
|
||||
XMLINC = location + '/contrib/include'
|
||||
|
||||
swig_files = ['xrc.i']
|
||||
|
||||
swig_sources = run_swig(swig_files, location, '', PKGDIR,
|
||||
USE_SWIG, swig_force, swig_args)
|
||||
|
||||
xmlres_includes = includes[:]
|
||||
xmlres_includes.append('%s/expat/xmlparse' % XMLLOC)
|
||||
xmlres_includes.append('%s/expat/xmltok' % XMLLOC)
|
||||
xmlres_includes.append(XMLINC)
|
||||
|
||||
|
||||
# make sure local copy of contrib files are up to date
|
||||
if IN_CVS_TREE:
|
||||
contrib_copy_tree(WXDIR + '/contrib/include/wx/xrc', XMLINC+'/wx/xrc')
|
||||
contrib_copy_tree(WXDIR + '/contrib/src/xrc', XMLLOC)
|
||||
|
||||
ext = Extension('xrcc', ['%s/expat/xmlparse/xmlparse.c' % XMLLOC,
|
||||
'%s/expat/xmltok/xmlrole.c' % XMLLOC,
|
||||
'%s/expat/xmltok/xmltok.c' % XMLLOC,
|
||||
|
||||
'%s/xh_bmp.cpp' % XMLLOC,
|
||||
'%s/xh_bmpbt.cpp' % XMLLOC,
|
||||
'%s/xh_bttn.cpp' % XMLLOC,
|
||||
'%s/xh_cald.cpp' % XMLLOC,
|
||||
'%s/xh_chckb.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_chckl.cpp' % XMLLOC,
|
||||
'%s/xh_choic.cpp' % XMLLOC,
|
||||
'%s/xh_combo.cpp' % XMLLOC,
|
||||
'%s/xh_dlg.cpp' % XMLLOC,
|
||||
'%s/xh_frame.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_gauge.cpp' % XMLLOC,
|
||||
'%s/xh_html.cpp' % XMLLOC,
|
||||
'%s/xh_listb.cpp' % XMLLOC,
|
||||
'%s/xh_listc.cpp' % XMLLOC,
|
||||
'%s/xh_menu.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_notbk.cpp' % XMLLOC,
|
||||
'%s/xh_panel.cpp' % XMLLOC,
|
||||
'%s/xh_radbt.cpp' % XMLLOC,
|
||||
'%s/xh_radbx.cpp' % XMLLOC,
|
||||
'%s/xh_scrol.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_sizer.cpp' % XMLLOC,
|
||||
'%s/xh_slidr.cpp' % XMLLOC,
|
||||
'%s/xh_spin.cpp' % XMLLOC,
|
||||
'%s/xh_stbmp.cpp' % XMLLOC,
|
||||
'%s/xh_stbox.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_stlin.cpp' % XMLLOC,
|
||||
'%s/xh_sttxt.cpp' % XMLLOC,
|
||||
'%s/xh_text.cpp' % XMLLOC,
|
||||
'%s/xh_toolb.cpp' % XMLLOC,
|
||||
'%s/xh_tree.cpp' % XMLLOC,
|
||||
|
||||
'%s/xh_unkwn.cpp' % XMLLOC,
|
||||
'%s/xml.cpp' % XMLLOC,
|
||||
'%s/xmlbin.cpp' % XMLLOC,
|
||||
'%s/xmlbinz.cpp' % XMLLOC,
|
||||
'%s/xmlexpat.cpp' % XMLLOC,
|
||||
|
||||
'%s/xmlres.cpp' % XMLLOC,
|
||||
'%s/xmlrsall.cpp' % XMLLOC,
|
||||
'%s/xmlwrite.cpp' % XMLLOC,
|
||||
|
||||
] + swig_sources,
|
||||
|
||||
include_dirs = xmlres_includes,
|
||||
define_macros = defines,
|
||||
|
||||
library_dirs = libdirs,
|
||||
libraries = libs,
|
||||
|
||||
extra_compile_args = cflags,
|
||||
extra_link_args = lflags,
|
||||
)
|
||||
|
||||
wxpExtensions.append(ext)
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Do the Setup/Build/Install/Whatever
|
||||
|
@@ -1 +1 @@
|
||||
ver = '2.3.0'
|
||||
ver = '2.3.1b1'
|
||||
|
@@ -404,6 +404,8 @@ enum {
|
||||
wxID_PASTE,
|
||||
wxID_CLEAR,
|
||||
wxID_FIND,
|
||||
wxID_DUPLICATE,
|
||||
wxID_SELECTALL,
|
||||
wxID_FILE1,
|
||||
wxID_FILE2,
|
||||
wxID_FILE3,
|
||||
|
@@ -350,6 +350,33 @@ public:
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxTextAttr
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxTextAttr(const wxColour& colText = wxNullColour,
|
||||
const wxColour& colBack = wxNullColour,
|
||||
const wxFont& font = wxNullFont);
|
||||
~wxTextAttr();
|
||||
|
||||
// setters
|
||||
void SetTextColour(const wxColour& colText);
|
||||
void SetBackgroundColour(const wxColour& colBack);
|
||||
void SetFont(const wxFont& font);
|
||||
|
||||
// accessors
|
||||
bool HasTextColour() const;
|
||||
bool HasBackgroundColour() const;
|
||||
bool HasFont() const;
|
||||
|
||||
const wxColour& GetTextColour() const;
|
||||
const wxColour& GetBackgroundColour() const;
|
||||
const wxFont& GetFont() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wxTextCtrl : public wxControl {
|
||||
public:
|
||||
wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
|
||||
@@ -398,9 +425,13 @@ public:
|
||||
void Undo();
|
||||
void Redo();
|
||||
|
||||
bool SetStyle(long start, long end, const wxTextAttr& style);
|
||||
bool SetDefaultStyle(const wxTextAttr& style);
|
||||
const wxTextAttr& GetDefaultStyle() const;
|
||||
|
||||
%addmethods {
|
||||
void write(const wxString& text) {
|
||||
self->AppendText(text + '\n');
|
||||
self->AppendText(text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -291,7 +291,8 @@ public:
|
||||
|
||||
class wxIconizeEvent: public wxEvent {
|
||||
public:
|
||||
wxIconizeEvent(int id = 0);
|
||||
wxIconizeEvent(int id = 0, bool iconized = TRUE);
|
||||
bool Iconized();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -105,11 +105,12 @@ public:
|
||||
%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
|
||||
%new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
|
||||
%new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
|
||||
%new wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 );
|
||||
|
||||
#ifdef __WXMSW__
|
||||
%new wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1);
|
||||
#endif
|
||||
// #ifdef __WXMSW__
|
||||
// %new wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
// int width, int height, int depth = 1);
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
@@ -137,6 +138,7 @@ public:
|
||||
return cArray;
|
||||
}
|
||||
|
||||
|
||||
wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxBitmap* bmp;
|
||||
@@ -155,18 +157,21 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1) {
|
||||
if (! PyString_Check(data)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected string object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
|
||||
wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
|
||||
return new wxBitmap(bits, width, height, depth);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// #ifdef __WXMSW__
|
||||
// wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
// int width, int height, int depth = 1) {
|
||||
// if (! PyString_Check(data)) {
|
||||
// PyErr_SetString(PyExc_TypeError, "Expected string object");
|
||||
// return NULL;
|
||||
// }
|
||||
// return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
|
||||
// }
|
||||
// #endif
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -409,6 +409,8 @@ SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type) {
|
||||
Py_DECREF(sobj);
|
||||
}
|
||||
str = PyString_AsString(sobj);
|
||||
if (str == NULL)
|
||||
return "";
|
||||
return SWIG_GetPtr(str,ptr,type);
|
||||
}
|
||||
|
||||
|
@@ -747,7 +747,7 @@ public:
|
||||
int GetUPosition() { return -1; }
|
||||
int GetVPosition() { return -1; }
|
||||
int GetMovementThreshold() { return -1; }
|
||||
void SetMovementThreshold(int threshold) ;
|
||||
void SetMovementThreshold(int threshold) {}
|
||||
|
||||
bool IsOk(void) { return FALSE; }
|
||||
int GetNumberJoysticks() { return -1; }
|
||||
|
@@ -4401,6 +4401,388 @@ static PyObject *_wrap_wxCheckListBox_GetItemHeight(PyObject *self, PyObject *ar
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define new_wxTextAttr(_swigarg0,_swigarg1,_swigarg2) (new wxTextAttr(_swigarg0,_swigarg1,_swigarg2))
|
||||
static PyObject *_wrap_new_wxTextAttr(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _result;
|
||||
wxColour * _arg0 = (wxColour *) &wxNullColour;
|
||||
wxColour * _arg1 = (wxColour *) &wxNullColour;
|
||||
wxFont * _arg2 = (wxFont *) &wxNullFont;
|
||||
wxColour temp;
|
||||
PyObject * _obj0 = 0;
|
||||
wxColour temp0;
|
||||
PyObject * _obj1 = 0;
|
||||
PyObject * _argo2 = 0;
|
||||
char *_kwnames[] = { "colText","colBack","font", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|OOO:new_wxTextAttr",_kwnames,&_obj0,&_obj1,&_argo2))
|
||||
return NULL;
|
||||
if (_obj0)
|
||||
{
|
||||
_arg0 = &temp;
|
||||
if (! wxColour_helper(_obj0, &_arg0))
|
||||
return NULL;
|
||||
}
|
||||
if (_obj1)
|
||||
{
|
||||
_arg1 = &temp0;
|
||||
if (! wxColour_helper(_obj1, &_arg1))
|
||||
return NULL;
|
||||
}
|
||||
if (_argo2) {
|
||||
if (_argo2 == Py_None) { _arg2 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo2,(void **) &_arg2,"_wxFont_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 3 of new_wxTextAttr. Expected _wxFont_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxTextAttr *)new_wxTextAttr(*_arg0,*_arg1,*_arg2);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxTextAttr_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define delete_wxTextAttr(_swigobj) (delete _swigobj)
|
||||
static PyObject *_wrap_delete_wxTextAttr(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:delete_wxTextAttr",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of delete_wxTextAttr. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
delete_wxTextAttr(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_SetTextColour(_swigobj,_swigarg0) (_swigobj->SetTextColour(_swigarg0))
|
||||
static PyObject *_wrap_wxTextAttr_SetTextColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _arg0;
|
||||
wxColour * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
wxColour temp;
|
||||
PyObject * _obj1 = 0;
|
||||
char *_kwnames[] = { "self","colText", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxTextAttr_SetTextColour",_kwnames,&_argo0,&_obj1))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_SetTextColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
_arg1 = &temp;
|
||||
if (! wxColour_helper(_obj1, &_arg1))
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxTextAttr_SetTextColour(_arg0,*_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_SetBackgroundColour(_swigobj,_swigarg0) (_swigobj->SetBackgroundColour(_swigarg0))
|
||||
static PyObject *_wrap_wxTextAttr_SetBackgroundColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _arg0;
|
||||
wxColour * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
wxColour temp;
|
||||
PyObject * _obj1 = 0;
|
||||
char *_kwnames[] = { "self","colBack", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxTextAttr_SetBackgroundColour",_kwnames,&_argo0,&_obj1))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_SetBackgroundColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
_arg1 = &temp;
|
||||
if (! wxColour_helper(_obj1, &_arg1))
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxTextAttr_SetBackgroundColour(_arg0,*_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_SetFont(_swigobj,_swigarg0) (_swigobj->SetFont(_swigarg0))
|
||||
static PyObject *_wrap_wxTextAttr_SetFont(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _arg0;
|
||||
wxFont * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _argo1 = 0;
|
||||
char *_kwnames[] = { "self","font", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxTextAttr_SetFont",_kwnames,&_argo0,&_argo1))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_SetFont. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_argo1) {
|
||||
if (_argo1 == Py_None) { _arg1 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxFont_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxTextAttr_SetFont. Expected _wxFont_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxTextAttr_SetFont(_arg0,*_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_HasTextColour(_swigobj) (_swigobj->HasTextColour())
|
||||
static PyObject *_wrap_wxTextAttr_HasTextColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_HasTextColour",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_HasTextColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxTextAttr_HasTextColour(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_HasBackgroundColour(_swigobj) (_swigobj->HasBackgroundColour())
|
||||
static PyObject *_wrap_wxTextAttr_HasBackgroundColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_HasBackgroundColour",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_HasBackgroundColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxTextAttr_HasBackgroundColour(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_HasFont(_swigobj) (_swigobj->HasFont())
|
||||
static PyObject *_wrap_wxTextAttr_HasFont(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_HasFont",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_HasFont. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxTextAttr_HasFont(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_GetTextColour(_swigobj) (_swigobj->GetTextColour())
|
||||
static PyObject *_wrap_wxTextAttr_GetTextColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxColour * _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_GetTextColour",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_GetTextColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
const wxColour & _result_ref = wxTextAttr_GetTextColour(_arg0);
|
||||
_result = (wxColour *) &_result_ref;
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxColour_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_GetBackgroundColour(_swigobj) (_swigobj->GetBackgroundColour())
|
||||
static PyObject *_wrap_wxTextAttr_GetBackgroundColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxColour * _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_GetBackgroundColour",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_GetBackgroundColour. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
const wxColour & _result_ref = wxTextAttr_GetBackgroundColour(_arg0);
|
||||
_result = (wxColour *) &_result_ref;
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxColour_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextAttr_GetFont(_swigobj) (_swigobj->GetFont())
|
||||
static PyObject *_wrap_wxTextAttr_GetFont(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxFont * _result;
|
||||
wxTextAttr * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextAttr_GetFont",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextAttr_GetFont. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
const wxFont & _result_ref = wxTextAttr_GetFont(_arg0);
|
||||
_result = (wxFont *) &_result_ref;
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxFont_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static void *SwigwxTextCtrlTowxControl(void *ptr) {
|
||||
wxTextCtrl *src;
|
||||
wxControl *dest;
|
||||
@@ -5689,8 +6071,120 @@ static PyObject *_wrap_wxTextCtrl_Redo(PyObject *self, PyObject *args, PyObject
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextCtrl_SetStyle(_swigobj,_swigarg0,_swigarg1,_swigarg2) (_swigobj->SetStyle(_swigarg0,_swigarg1,_swigarg2))
|
||||
static PyObject *_wrap_wxTextCtrl_SetStyle(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxTextCtrl * _arg0;
|
||||
long _arg1;
|
||||
long _arg2;
|
||||
wxTextAttr * _arg3;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _argo3 = 0;
|
||||
char *_kwnames[] = { "self","start","end","style", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OllO:wxTextCtrl_SetStyle",_kwnames,&_argo0,&_arg1,&_arg2,&_argo3))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextCtrl_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextCtrl_SetStyle. Expected _wxTextCtrl_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_argo3) {
|
||||
if (_argo3 == Py_None) { _arg3 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo3,(void **) &_arg3,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 4 of wxTextCtrl_SetStyle. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxTextCtrl_SetStyle(_arg0,_arg1,_arg2,*_arg3);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextCtrl_SetDefaultStyle(_swigobj,_swigarg0) (_swigobj->SetDefaultStyle(_swigarg0))
|
||||
static PyObject *_wrap_wxTextCtrl_SetDefaultStyle(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxTextCtrl * _arg0;
|
||||
wxTextAttr * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _argo1 = 0;
|
||||
char *_kwnames[] = { "self","style", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxTextCtrl_SetDefaultStyle",_kwnames,&_argo0,&_argo1))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextCtrl_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextCtrl_SetDefaultStyle. Expected _wxTextCtrl_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_argo1) {
|
||||
if (_argo1 == Py_None) { _arg1 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxTextAttr_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxTextCtrl_SetDefaultStyle. Expected _wxTextAttr_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxTextCtrl_SetDefaultStyle(_arg0,*_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxTextCtrl_GetDefaultStyle(_swigobj) (_swigobj->GetDefaultStyle())
|
||||
static PyObject *_wrap_wxTextCtrl_GetDefaultStyle(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxTextAttr * _result;
|
||||
wxTextCtrl * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTextCtrl_GetDefaultStyle",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxTextCtrl_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxTextCtrl_GetDefaultStyle. Expected _wxTextCtrl_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
const wxTextAttr & _result_ref = wxTextCtrl_GetDefaultStyle(_arg0);
|
||||
_result = (wxTextAttr *) &_result_ref;
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxTextAttr_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static void wxTextCtrl_write(wxTextCtrl *self,const wxString & text) {
|
||||
self->AppendText(text + '\n');
|
||||
self->AppendText(text);
|
||||
}
|
||||
static PyObject *_wrap_wxTextCtrl_write(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
@@ -8431,6 +8925,9 @@ static PyMethodDef controlscMethods[] = {
|
||||
{ "wxScrollBar_GetRange", (PyCFunction) _wrap_wxScrollBar_GetRange, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxScrollBar", (PyCFunction) _wrap_new_wxScrollBar, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_write", (PyCFunction) _wrap_wxTextCtrl_write, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_GetDefaultStyle", (PyCFunction) _wrap_wxTextCtrl_GetDefaultStyle, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_SetDefaultStyle", (PyCFunction) _wrap_wxTextCtrl_SetDefaultStyle, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_SetStyle", (PyCFunction) _wrap_wxTextCtrl_SetStyle, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_Redo", (PyCFunction) _wrap_wxTextCtrl_Redo, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_Undo", (PyCFunction) _wrap_wxTextCtrl_Undo, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_IsEditable", (PyCFunction) _wrap_wxTextCtrl_IsEditable, METH_VARARGS | METH_KEYWORDS },
|
||||
@@ -8467,6 +8964,17 @@ static PyMethodDef controlscMethods[] = {
|
||||
{ "wxTextCtrl_Copy", (PyCFunction) _wrap_wxTextCtrl_Copy, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextCtrl_Clear", (PyCFunction) _wrap_wxTextCtrl_Clear, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxTextCtrl", (PyCFunction) _wrap_new_wxTextCtrl, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_GetFont", (PyCFunction) _wrap_wxTextAttr_GetFont, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_GetBackgroundColour", (PyCFunction) _wrap_wxTextAttr_GetBackgroundColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_GetTextColour", (PyCFunction) _wrap_wxTextAttr_GetTextColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_HasFont", (PyCFunction) _wrap_wxTextAttr_HasFont, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_HasBackgroundColour", (PyCFunction) _wrap_wxTextAttr_HasBackgroundColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_HasTextColour", (PyCFunction) _wrap_wxTextAttr_HasTextColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_SetFont", (PyCFunction) _wrap_wxTextAttr_SetFont, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_SetBackgroundColour", (PyCFunction) _wrap_wxTextAttr_SetBackgroundColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxTextAttr_SetTextColour", (PyCFunction) _wrap_wxTextAttr_SetTextColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "delete_wxTextAttr", (PyCFunction) _wrap_delete_wxTextAttr, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxTextAttr", (PyCFunction) _wrap_new_wxTextAttr, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxCheckListBox_GetItemHeight", (PyCFunction) _wrap_wxCheckListBox_GetItemHeight, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxCheckListBox_InsertItems", (PyCFunction) _wrap_wxCheckListBox_InsertItems, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxCheckListBox_Check", (PyCFunction) _wrap_wxCheckListBox_Check, METH_VARARGS | METH_KEYWORDS },
|
||||
|
@@ -442,6 +442,53 @@ class wxCheckListBox(wxCheckListBoxPtr):
|
||||
|
||||
|
||||
|
||||
class wxTextAttrPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __del__(self,controlsc=controlsc):
|
||||
if self.thisown == 1 :
|
||||
controlsc.delete_wxTextAttr(self)
|
||||
def SetTextColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_SetTextColour,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetBackgroundColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_SetBackgroundColour,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetFont(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_SetFont,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def HasTextColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_HasTextColour,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def HasBackgroundColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_HasBackgroundColour,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def HasFont(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_HasFont,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetTextColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_GetTextColour,(self,) + _args, _kwargs)
|
||||
if val: val = wxColourPtr(val)
|
||||
return val
|
||||
def GetBackgroundColour(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_GetBackgroundColour,(self,) + _args, _kwargs)
|
||||
if val: val = wxColourPtr(val)
|
||||
return val
|
||||
def GetFont(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextAttr_GetFont,(self,) + _args, _kwargs)
|
||||
if val: val = wxFontPtr(val)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxTextAttr instance at %s>" % (self.this,)
|
||||
class wxTextAttr(wxTextAttrPtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(controlsc.new_wxTextAttr,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
|
||||
class wxTextCtrlPtr(wxControlPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
@@ -551,6 +598,16 @@ class wxTextCtrlPtr(wxControlPtr):
|
||||
def Redo(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextCtrl_Redo,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetStyle(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextCtrl_SetStyle,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetDefaultStyle(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextCtrl_SetDefaultStyle,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetDefaultStyle(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextCtrl_GetDefaultStyle,(self,) + _args, _kwargs)
|
||||
if val: val = wxTextAttrPtr(val)
|
||||
return val
|
||||
def write(self, *_args, **_kwargs):
|
||||
val = apply(controlsc.wxTextCtrl_write,(self,) + _args, _kwargs)
|
||||
return val
|
||||
|
@@ -4719,20 +4719,23 @@ static void *SwigwxIconizeEventTowxObject(void *ptr) {
|
||||
return (void *) dest;
|
||||
}
|
||||
|
||||
#define new_wxIconizeEvent(_swigarg0) (new wxIconizeEvent(_swigarg0))
|
||||
#define new_wxIconizeEvent(_swigarg0,_swigarg1) (new wxIconizeEvent(_swigarg0,_swigarg1))
|
||||
static PyObject *_wrap_new_wxIconizeEvent(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxIconizeEvent * _result;
|
||||
int _arg0 = (int ) 0;
|
||||
char *_kwnames[] = { "id", NULL };
|
||||
bool _arg1 = (bool ) TRUE;
|
||||
int tempbool1 = (int) TRUE;
|
||||
char *_kwnames[] = { "id","iconized", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|i:new_wxIconizeEvent",_kwnames,&_arg0))
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"|ii:new_wxIconizeEvent",_kwnames,&_arg0,&tempbool1))
|
||||
return NULL;
|
||||
_arg1 = (bool ) tempbool1;
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxIconizeEvent *)new_wxIconizeEvent(_arg0);
|
||||
_result = (wxIconizeEvent *)new_wxIconizeEvent(_arg0,_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
@@ -4746,6 +4749,34 @@ static PyObject *_wrap_new_wxIconizeEvent(PyObject *self, PyObject *args, PyObje
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxIconizeEvent_Iconized(_swigobj) (_swigobj->Iconized())
|
||||
static PyObject *_wrap_wxIconizeEvent_Iconized(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxIconizeEvent * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIconizeEvent_Iconized",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIconizeEvent_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIconizeEvent_Iconized. Expected _wxIconizeEvent_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxIconizeEvent_Iconized(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static void *SwigwxMaximizeEventTowxEvent(void *ptr) {
|
||||
wxMaximizeEvent *src;
|
||||
wxEvent *dest;
|
||||
@@ -6820,6 +6851,7 @@ static PyMethodDef eventscMethods[] = {
|
||||
{ "wxJoystickEvent_GetPosition", (PyCFunction) _wrap_wxJoystickEvent_GetPosition, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxJoystickEvent", (PyCFunction) _wrap_new_wxJoystickEvent, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxMaximizeEvent", (PyCFunction) _wrap_new_wxMaximizeEvent, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxIconizeEvent_Iconized", (PyCFunction) _wrap_wxIconizeEvent_Iconized, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxIconizeEvent", (PyCFunction) _wrap_new_wxIconizeEvent, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxShowEvent_GetShow", (PyCFunction) _wrap_wxShowEvent_GetShow, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxShowEvent_SetShow", (PyCFunction) _wrap_wxShowEvent_SetShow, METH_VARARGS | METH_KEYWORDS },
|
||||
|
@@ -640,6 +640,9 @@ class wxIconizeEventPtr(wxEventPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def Iconized(self, *_args, **_kwargs):
|
||||
val = apply(eventsc.wxIconizeEvent_Iconized,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxIconizeEvent instance at %s>" % (self.this,)
|
||||
class wxIconizeEvent(wxIconizeEventPtr):
|
||||
|
@@ -120,6 +120,7 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
|
||||
return cArray;
|
||||
}
|
||||
|
||||
|
||||
wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxBitmap* bmp;
|
||||
@@ -138,18 +139,21 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1) {
|
||||
if (! PyString_Check(data)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected string object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
|
||||
wxBitmap* wxBitmapFromBits(char* bits, int width, int height, int depth = 1 ) {
|
||||
return new wxBitmap(bits, width, height, depth);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// #ifdef __WXMSW__
|
||||
// wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
// int width, int height, int depth = 1) {
|
||||
// if (! PyString_Check(data)) {
|
||||
// PyErr_SetString(PyExc_TypeError, "Expected string object");
|
||||
// return NULL;
|
||||
// }
|
||||
// return new wxBitmap((void*)PyString_AsString(data), type, width, height, depth);
|
||||
// }
|
||||
// #endif
|
||||
|
||||
wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
|
||||
return new wxMask(bitmap, colour);
|
||||
@@ -335,27 +339,22 @@ static PyObject *_wrap_wxBitmapFromIcon(PyObject *self, PyObject *args, PyObject
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxBitmapFromData(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
static PyObject *_wrap_wxBitmapFromBits(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxBitmap * _result;
|
||||
PyObject * _arg0;
|
||||
long _arg1;
|
||||
char * _arg0;
|
||||
int _arg1;
|
||||
int _arg2;
|
||||
int _arg3;
|
||||
int _arg4 = (int ) 1;
|
||||
PyObject * _obj0 = 0;
|
||||
char *_kwnames[] = { "data","type","width","height","depth", NULL };
|
||||
int _arg3 = (int ) 1;
|
||||
char *_kwnames[] = { "bits","width","height","depth", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Olii|i:wxBitmapFromData",_kwnames,&_obj0,&_arg1,&_arg2,&_arg3,&_arg4))
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"sii|i:wxBitmapFromBits",_kwnames,&_arg0,&_arg1,&_arg2,&_arg3))
|
||||
return NULL;
|
||||
{
|
||||
_arg0 = _obj0;
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxBitmap *)wxBitmapFromData(_arg0,_arg1,_arg2,_arg3,_arg4);
|
||||
_result = (wxBitmap *)wxBitmapFromBits(_arg0,_arg1,_arg2,_arg3);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
@@ -10987,7 +10986,7 @@ static PyMethodDef gdicMethods[] = {
|
||||
{ "wxIconFromXPMData", (PyCFunction) _wrap_wxIconFromXPMData, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxEmptyIcon", (PyCFunction) _wrap_wxEmptyIcon, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxMaskColour", (PyCFunction) _wrap_wxMaskColour, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmapFromData", (PyCFunction) _wrap_wxBitmapFromData, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmapFromBits", (PyCFunction) _wrap_wxBitmapFromBits, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmapFromIcon", (PyCFunction) _wrap_wxBitmapFromIcon, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmapFromXPMData", (PyCFunction) _wrap_wxBitmapFromXPMData, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxEmptyBitmap", (PyCFunction) _wrap_wxEmptyBitmap, METH_VARARGS | METH_KEYWORDS },
|
||||
|
@@ -1141,8 +1141,8 @@ def wxBitmapFromIcon(*_args, **_kwargs):
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxBitmapFromData(*_args, **_kwargs):
|
||||
val = apply(gdic.wxBitmapFromData,_args,_kwargs)
|
||||
def wxBitmapFromBits(*_args, **_kwargs):
|
||||
val = apply(gdic.wxBitmapFromBits,_args,_kwargs)
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
|
@@ -221,7 +221,7 @@ public:
|
||||
int GetUPosition() { return -1; }
|
||||
int GetVPosition() { return -1; }
|
||||
int GetMovementThreshold() { return -1; }
|
||||
void SetMovementThreshold(int threshold) ;
|
||||
void SetMovementThreshold(int threshold) {}
|
||||
|
||||
bool IsOk(void) { return FALSE; }
|
||||
int GetNumberJoysticks() { return -1; }
|
||||
|
@@ -1166,6 +1166,34 @@ static PyObject *_wrap_wxWindow_CenterOnScreen(PyObject *self, PyObject *args, P
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxWindow_Clear(_swigobj) (_swigobj->Clear())
|
||||
static PyObject *_wrap_wxWindow_Clear(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxWindow * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxWindow_Clear",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxWindow_Clear. Expected _wxWindow_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxWindow_Clear(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxWindow_ClientToScreenXY(_swigobj,_swigarg0,_swigarg1) (_swigobj->ClientToScreen(_swigarg0,_swigarg1))
|
||||
static PyObject *_wrap_wxWindow_ClientToScreenXY(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
@@ -10556,6 +10584,7 @@ static PyMethodDef windowscMethods[] = {
|
||||
{ "wxWindow_Close", (PyCFunction) _wrap_wxWindow_Close, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_ClientToScreen", (PyCFunction) _wrap_wxWindow_ClientToScreen, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_ClientToScreenXY", (PyCFunction) _wrap_wxWindow_ClientToScreenXY, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_Clear", (PyCFunction) _wrap_wxWindow_Clear, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_CenterOnScreen", (PyCFunction) _wrap_wxWindow_CenterOnScreen, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_CentreOnScreen", (PyCFunction) _wrap_wxWindow_CentreOnScreen, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxWindow_CenterOnParent", (PyCFunction) _wrap_wxWindow_CenterOnParent, METH_VARARGS | METH_KEYWORDS },
|
||||
|
@@ -130,6 +130,9 @@ class wxWindowPtr(wxEvtHandlerPtr):
|
||||
def CenterOnScreen(self, *_args, **_kwargs):
|
||||
val = apply(windowsc.wxWindow_CenterOnScreen,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def Clear(self, *_args, **_kwargs):
|
||||
val = apply(windowsc.wxWindow_Clear,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def ClientToScreenXY(self, *_args, **_kwargs):
|
||||
val = apply(windowsc.wxWindow_ClientToScreenXY,(self,) + _args, _kwargs)
|
||||
return val
|
||||
|
@@ -1931,6 +1931,7 @@ SWIGEXPORT(void) initwxc() {
|
||||
PyDict_SetItemString(d,"wxRESIZE_BORDER", PyInt_FromLong((long) wxRESIZE_BORDER));
|
||||
PyDict_SetItemString(d,"wxDIALOG_MODAL", PyInt_FromLong((long) wxDIALOG_MODAL));
|
||||
PyDict_SetItemString(d,"wxDIALOG_MODELESS", PyInt_FromLong((long) wxDIALOG_MODELESS));
|
||||
PyDict_SetItemString(d,"wxDIALOG_NO_PARENT", PyInt_FromLong((long) wxDIALOG_NO_PARENT));
|
||||
PyDict_SetItemString(d,"wxDEFAULT_FRAME_STYLE", PyInt_FromLong((long) wxDEFAULT_FRAME_STYLE));
|
||||
PyDict_SetItemString(d,"wxDEFAULT_DIALOG_STYLE", PyInt_FromLong((long) wxDEFAULT_DIALOG_STYLE));
|
||||
PyDict_SetItemString(d,"wxFRAME_TOOL_WINDOW", PyInt_FromLong((long) wxFRAME_TOOL_WINDOW));
|
||||
@@ -2115,6 +2116,8 @@ SWIGEXPORT(void) initwxc() {
|
||||
PyDict_SetItemString(d,"wxID_PASTE", PyInt_FromLong((long) wxID_PASTE));
|
||||
PyDict_SetItemString(d,"wxID_CLEAR", PyInt_FromLong((long) wxID_CLEAR));
|
||||
PyDict_SetItemString(d,"wxID_FIND", PyInt_FromLong((long) wxID_FIND));
|
||||
PyDict_SetItemString(d,"wxID_DUPLICATE", PyInt_FromLong((long) wxID_DUPLICATE));
|
||||
PyDict_SetItemString(d,"wxID_SELECTALL", PyInt_FromLong((long) wxID_SELECTALL));
|
||||
PyDict_SetItemString(d,"wxID_FILE1", PyInt_FromLong((long) wxID_FILE1));
|
||||
PyDict_SetItemString(d,"wxID_FILE2", PyInt_FromLong((long) wxID_FILE2));
|
||||
PyDict_SetItemString(d,"wxID_FILE3", PyInt_FromLong((long) wxID_FILE3));
|
||||
|
@@ -199,6 +199,7 @@ wxRESIZE_BOX = wxc.wxRESIZE_BOX
|
||||
wxRESIZE_BORDER = wxc.wxRESIZE_BORDER
|
||||
wxDIALOG_MODAL = wxc.wxDIALOG_MODAL
|
||||
wxDIALOG_MODELESS = wxc.wxDIALOG_MODELESS
|
||||
wxDIALOG_NO_PARENT = wxc.wxDIALOG_NO_PARENT
|
||||
wxDEFAULT_FRAME_STYLE = wxc.wxDEFAULT_FRAME_STYLE
|
||||
wxDEFAULT_DIALOG_STYLE = wxc.wxDEFAULT_DIALOG_STYLE
|
||||
wxFRAME_TOOL_WINDOW = wxc.wxFRAME_TOOL_WINDOW
|
||||
@@ -383,6 +384,8 @@ wxID_COPY = wxc.wxID_COPY
|
||||
wxID_PASTE = wxc.wxID_PASTE
|
||||
wxID_CLEAR = wxc.wxID_CLEAR
|
||||
wxID_FIND = wxc.wxID_FIND
|
||||
wxID_DUPLICATE = wxc.wxID_DUPLICATE
|
||||
wxID_SELECTALL = wxc.wxID_SELECTALL
|
||||
wxID_FILE1 = wxc.wxID_FILE1
|
||||
wxID_FILE2 = wxc.wxID_FILE2
|
||||
wxID_FILE3 = wxc.wxID_FILE3
|
||||
|
@@ -206,6 +206,8 @@ public:
|
||||
void CentreOnScreen(int direction = wxBOTH );
|
||||
void CenterOnScreen(int direction = wxBOTH );
|
||||
|
||||
void Clear();
|
||||
|
||||
// (uses apply'ed INOUT typemap, see above)
|
||||
%name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
|
||||
wxPoint ClientToScreen(const wxPoint& pt);
|
||||
|
@@ -16,40 +16,31 @@ from wxPython.wx import *
|
||||
# button colour will change to new colour
|
||||
# GetColour method to get the selected colour
|
||||
|
||||
class ColourSelect:
|
||||
def __init__(self, parent, position = wxPoint(20, 20), bcolour = [0, 0, 0], size = wxSize(20, 20)):
|
||||
self.win = parent
|
||||
if size is None:
|
||||
size = wxSize(20, 20)
|
||||
class ColourSelect(wxButton):
|
||||
def __init__(self, parent, id, bcolour=(0, 0, 0), pos=wxDefaultPosition, size=wxDefaultSize):
|
||||
wxButton.__init__(self, parent, id, "", pos=pos, size=size)
|
||||
EVT_BUTTON(parent, self.GetId(), self.OnClick)
|
||||
self.SetForegroundColour(wxWHITE)
|
||||
self.SetColour(bcolour)
|
||||
|
||||
mID = NewId()
|
||||
self.b = b = wxButton(parent, mID, "", position, size)
|
||||
EVT_BUTTON(parent, mID, self.OnClick)
|
||||
|
||||
self.set_colour_val = set_colour = wxColor(bcolour[0], bcolour[1], bcolour[2])
|
||||
b.SetBackgroundColour(set_colour)
|
||||
b.SetForegroundColour(wxWHITE)
|
||||
self.set_colour = bcolour
|
||||
|
||||
def SetColour(self, bcolour):
|
||||
self.b.SetBackgroundColour(bcolour)
|
||||
self.set_colour_val = set_colour = wxColor(bcolour[0], bcolour[1], bcolour[2])
|
||||
self.SetBackgroundColour(set_colour)
|
||||
self.set_colour = bcolour
|
||||
|
||||
|
||||
def GetColour(self):
|
||||
return self.set_colour
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
data = wxColourData()
|
||||
data.SetChooseFull(true)
|
||||
data.SetColour(self.set_colour_val)
|
||||
dlg = wxColourDialog(self.win, data)
|
||||
dlg = wxColourDialog(self.GetParent(), data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetColourData()
|
||||
self.set_colour = set = data.GetColour().Get()
|
||||
self.set_colour_val = bcolour = wxColour(set[0],set[1],set[2])
|
||||
self.b.SetBackgroundColour(bcolour)
|
||||
self.SetColour(data.GetColour().Get())
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
#
|
||||
# This was modified from rpcMixin.py distributed with wxPython
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# Name: rpcMixin
|
||||
# Version: 0.1
|
||||
# Version: 0.2.0
|
||||
# Purpose: provides xmlrpc server functionality for wxPython
|
||||
# applications via a mixin class
|
||||
#
|
||||
@@ -9,51 +12,74 @@
|
||||
# (http://www.pythonware.com/products/xmlrpc/)
|
||||
# the code was developed and tested using version 0.9.8
|
||||
#
|
||||
# Author: Greg Landrum (Landrum@RationalDiscovery.com)
|
||||
# Author: greg Landrum (Landrum@RationalDiscovery.com)
|
||||
#
|
||||
# Copyright: (c) 2000 by Greg Landrum and Rational Discovery LLC
|
||||
# Copyright: (c) 2000, 2001 by Greg Landrum and Rational Discovery LLC
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
Some Notes:
|
||||
"""provides xmlrpc server functionality for wxPython applications via a mixin class
|
||||
|
||||
1) The xmlrpc server runs in a separate thread from the main GUI
|
||||
application, communication between the two threads using a custom
|
||||
event (see the Threads demo in the wxPython docs for more info).
|
||||
**Some Notes:**
|
||||
|
||||
2) Neither the server nor the client are particularly smart about
|
||||
checking method names. So it's easy to shoot yourself in the foot
|
||||
by calling improper methods. It would be pretty easy to add
|
||||
either a list of allowed methods or a list of forbidden methods.
|
||||
1) The xmlrpc server runs in a separate thread from the main GUI
|
||||
application, communication between the two threads using a custom
|
||||
event (see the Threads demo in the wxPython docs for more info).
|
||||
|
||||
3) Authentication of xmlrpc clients is *not* performed. I think it
|
||||
would be pretty easy to do this in a hacky way, but I haven't done
|
||||
it yet.
|
||||
2) Neither the server nor the client are particularly smart about
|
||||
checking method names. So it's easy to shoot yourself in the foot
|
||||
by calling improper methods. It would be pretty easy to add
|
||||
either a list of allowed methods or a list of forbidden methods.
|
||||
|
||||
4) The default port number is 800, it's a windows thing... at least
|
||||
it seems like a windows thing to me. Since I'm not being smart
|
||||
about port numbers, you can probably hork yourself arbitrarily by
|
||||
firing up more than one xmlrpc-active frame at the same time, but
|
||||
I haven't tried that.
|
||||
3) Authentication of xmlrpc clients is *not* performed. I think it
|
||||
would be pretty easy to do this in a hacky way, but I haven't done
|
||||
it yet.
|
||||
|
||||
5) See the bottom of this file for an example of using the class.
|
||||
4) See the bottom of this file for an example of using the class.
|
||||
|
||||
Obligatory disclaimer:
|
||||
**Obligatory disclaimer:**
|
||||
This is my first crack at both using xmlrpc and multi-threaded
|
||||
programming, so there could be huge horrible bugs or design
|
||||
flaws. If you see one, I'd love to hear about them.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
""" ChangeLog
|
||||
23 May 2001: Version bumped to 0.2.0
|
||||
Numerous code and design changes
|
||||
|
||||
21 Mar. 2001: Version bumped to 0.1.4
|
||||
Updated rpcMixin.OnExternal to support methods with further references
|
||||
(i.e. now you can do rpcClient.foo.bar() and have it work)
|
||||
This probably ain't super legal in xmlrpc land, but it works just fine here
|
||||
and we need it.
|
||||
|
||||
6 Mar. 2001: Version bumped to 0.1.3
|
||||
Documentation changes to make this compatible with happydoc
|
||||
|
||||
21 Jan. 2001: Version bumped to 0.1.2
|
||||
OnExternal() method in the mixin class now uses getattr() to check if
|
||||
a desired method is present. It should have been done this way in
|
||||
the first place.
|
||||
14 Dec. 2000: Version bumped to 0.1.1
|
||||
rearranged locking code and made other changes so that multiple
|
||||
servers in one application are possible.
|
||||
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
import xmlrpcserver
|
||||
import Threading
|
||||
import xmlrpcserver,xmlrpclib
|
||||
import threading
|
||||
import SocketServer
|
||||
import string
|
||||
import new
|
||||
import sys
|
||||
|
||||
rpcPENDING = 0
|
||||
rpcDONE = 1
|
||||
rpcEXCEPT = 2
|
||||
|
||||
class RPCRequest:
|
||||
"""A wrapper to use for handling requests and their responses"""
|
||||
status = rpcPENDING
|
||||
@@ -64,6 +90,7 @@ wxEVT_EXTERNAL_EVENT = 25015
|
||||
class ExternalEvent(wxPyEvent):
|
||||
"""The custom event class used to pass xmlrpc calls from
|
||||
the server thread into the GUI thread
|
||||
|
||||
"""
|
||||
def __init__(self,method,args):
|
||||
wxPyEvent.__init__(self)
|
||||
@@ -71,8 +98,15 @@ class ExternalEvent(wxPyEvent):
|
||||
self.method = method
|
||||
self.args = args
|
||||
self.rpcStatus = RPCRequest()
|
||||
self.rpcStatusLock = Threading.Lock()
|
||||
self.rpcCondVar = Threading.Condition()
|
||||
self.rpcStatusLock = threading.Lock()
|
||||
self.rpcCondVar = threading.Condition()
|
||||
|
||||
def Destroy(self):
|
||||
self.method=None
|
||||
self.args=None
|
||||
self.rpcStatus = None
|
||||
self.rpcStatusLock = None
|
||||
self.rpcondVar = None
|
||||
|
||||
def EVT_EXTERNAL_EVENT(win,func):
|
||||
win.Connect(-1,-1,wxEVT_EXTERNAL_EVENT,func)
|
||||
@@ -80,11 +114,28 @@ def EVT_EXTERNAL_EVENT(win,func):
|
||||
class Handler(xmlrpcserver.RequestHandler):
|
||||
"""The handler class that the xmlrpcserver actually calls
|
||||
when a request comes in.
|
||||
|
||||
"""
|
||||
def log_message(self,*args):
|
||||
""" causes the server to stop spewing messages every time a request comes in
|
||||
|
||||
"""
|
||||
pass
|
||||
def call(self,method,params):
|
||||
"""When an xmlrpc request comes in, this is the method that
|
||||
gets called.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- method: name of the method to be called
|
||||
|
||||
- params: arguments to that method
|
||||
|
||||
"""
|
||||
if method == '_rpcPing':
|
||||
# we just acknowledge these without processing them
|
||||
return 'ack'
|
||||
|
||||
# construct the event
|
||||
evt = ExternalEvent(method,params)
|
||||
|
||||
@@ -93,16 +144,16 @@ class Handler(xmlrpcserver.RequestHandler):
|
||||
evt.rpcStatus.status = rpcPENDING
|
||||
evt.rpcStatusLock.release()
|
||||
|
||||
# acquire the condition lock
|
||||
evt.rpcCondVar.acquire()
|
||||
# dispatch the event to the GUI
|
||||
wxPostEvent(self._app,evt)
|
||||
|
||||
# wait for the GUI to finish
|
||||
while evt.rpcStatus.status == rpcPENDING:
|
||||
evt.rpcCondVar.wait()
|
||||
evt.rpcCondVar.release()
|
||||
evt.rpcStatusLock.acquire()
|
||||
if evt.rpcStatus.stwxTheColourDatabaseatus == rpcEXCEPT:
|
||||
if evt.rpcStatus.status == rpcEXCEPT:
|
||||
# The GUI threw an exception, release the status lock
|
||||
# and re-raise the exception
|
||||
evt.rpcStatusLock.release()
|
||||
@@ -110,9 +161,36 @@ class Handler(xmlrpcserver.RequestHandler):
|
||||
else:
|
||||
# everything went through without problems
|
||||
s = evt.rpcStatus.result
|
||||
|
||||
evt.rpcStatusLock.release()
|
||||
evt.Destroy()
|
||||
self._app = None
|
||||
return s
|
||||
|
||||
# this global Event is used to let the server thread
|
||||
# know when it should quit
|
||||
stopEvent = threading.Event()
|
||||
stopEvent.clear()
|
||||
|
||||
class _ServerThread(threading.Thread):
|
||||
""" this is the Thread class which actually runs the server
|
||||
|
||||
"""
|
||||
def __init__(self,server,verbose=0):
|
||||
self._xmlServ = server
|
||||
threading.Thread.__init__(self,verbose=verbose)
|
||||
|
||||
def stop(self):
|
||||
stopEvent.set()
|
||||
|
||||
def shouldStop(self):
|
||||
return stopEvent.isSet()
|
||||
|
||||
def run(self):
|
||||
while not self.shouldStop():
|
||||
self._xmlServ.handle_request()
|
||||
self._xmlServ = None
|
||||
|
||||
class rpcMixin:
|
||||
"""A mixin class to provide xmlrpc server functionality to wxPython
|
||||
frames/windows
|
||||
@@ -122,68 +200,148 @@ class rpcMixin:
|
||||
RPC is handled.
|
||||
|
||||
"""
|
||||
def __init__(self,host='',port=800):
|
||||
|
||||
# we'll try a range of ports for the server, this is the size of the
|
||||
# range to be scanned
|
||||
nPortsToTry=20
|
||||
if sys.platform == 'win32':
|
||||
defPort = 800
|
||||
else:
|
||||
defPort = 8023
|
||||
|
||||
def __init__(self,host='',port=-1,verbose=0,portScan=1):
|
||||
"""Constructor
|
||||
|
||||
**Arguments**
|
||||
|
||||
- host: (optional) the hostname for the server
|
||||
|
||||
- port: (optional) the port the server will use
|
||||
|
||||
- verbose: (optional) if set, the server thread will be launched
|
||||
in verbose mode
|
||||
|
||||
- portScan: (optional) if set, we'll scan across a number of ports
|
||||
to find one which is avaiable
|
||||
|
||||
"""
|
||||
Arguments:
|
||||
host: (optional) the hostname for the server
|
||||
port: (optional) the port the server will use
|
||||
"""
|
||||
EVT_EXTERNAL_EVENT(swxTheColourDatabaseelf,self.OnExternal)
|
||||
if port == -1:
|
||||
port = self.defPort
|
||||
self.verbose=verbose
|
||||
EVT_EXTERNAL_EVENT(self,self.OnExternal)
|
||||
if hasattr(self,'OnClose'):
|
||||
self._origOnClose = self.OnClose
|
||||
self.Disconnect(-1,-1,wxEVT_CLOSE_WINDOW)
|
||||
else:
|
||||
self._origOnClose = None
|
||||
EVT_CLOSE(self,self.OnClose)
|
||||
self.OnClose = self.RPCOnClose
|
||||
EVT_CLOSE(self,self.RPCOnClose)
|
||||
|
||||
exec('class Handler%d(Handler): pass'%(port))
|
||||
exec('tClass= Handler%d'%(port))
|
||||
tClass = new.classobj('Handler%d'%(port),(Handler,),{})
|
||||
tClass._app = self
|
||||
self._xmlServ = SocketServer.TCPServer((host,port),tClass)
|
||||
self.servThread = Threading.Thread(target=self._xmlServ.serve_forever)
|
||||
self.servThread.setDaemon(1)
|
||||
if portScan:
|
||||
self.rpcPort = -1
|
||||
for i in xrange(self.nPortsToTry):
|
||||
try:
|
||||
xmlServ = SocketServer.TCPServer((host,port+i),tClass)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
self.rpcPort = port+i
|
||||
else:
|
||||
self.rpcPort = port
|
||||
try:
|
||||
xmlServ = SocketServer.TCPServer((host,port),tClass)
|
||||
except:
|
||||
self.rpcPort = -1
|
||||
|
||||
if self.rpcPort == -1:
|
||||
raise 'RPCMixinError','Cannot initialize server'
|
||||
self.servThread = _ServerThread(xmlServ,verbose=self.verbose)
|
||||
self.servThread.setName('XML-RPC Server')
|
||||
self.servThread.start()
|
||||
|
||||
def OnClose(self,event):
|
||||
""" be sure to shutdown the server and the server thread before
|
||||
leaving
|
||||
def RPCOnClose(self,event):
|
||||
""" callback for when the application is closed
|
||||
|
||||
be sure to shutdown the server and the server thread before
|
||||
leaving
|
||||
|
||||
"""
|
||||
self._xmlServ = None
|
||||
self.servThread = None
|
||||
# by setting the global stopEvent we inform the server thread
|
||||
# that it's time to shut down.
|
||||
stopEvent.set()
|
||||
if event is not None:
|
||||
# if we came in here from a user event (as opposed to an RPC event),
|
||||
# then we'll need to kick the server one last time in order
|
||||
# to get that thread to terminate. do so now
|
||||
s1 = xmlrpclib.Server('http://localhost:%d'%(self.rpcPort))
|
||||
try:
|
||||
s1._rpcPing()
|
||||
except:
|
||||
pass
|
||||
|
||||
if self._origOnClose is not None:
|
||||
self._origOnClose(event)
|
||||
|
||||
def RPCQuit(self):
|
||||
""" shuts down everything, including the rpc server
|
||||
|
||||
"""
|
||||
self.RPCOnClose(None)
|
||||
def OnExternal(self,event):
|
||||
""" this is the callback used to handle RPCs
|
||||
|
||||
**Arguments**
|
||||
|
||||
- event: an _ExternalEvent_ sent by the rpc server
|
||||
|
||||
Exceptions are caught and returned in the global _rpcStatus
|
||||
structure. This allows the xmlrpc server to report the
|
||||
exception to the client without mucking up any of the delicate
|
||||
thread stuff.
|
||||
|
||||
"""
|
||||
event.rpcStatusLock.acquire()
|
||||
doQuit = 0
|
||||
try:
|
||||
res = eval('apply(self.%s,event.args)'%event.method)
|
||||
except:
|
||||
import sys,traceback
|
||||
traceback.print_exc()
|
||||
event.rpcStatus.result = sys.exc_info()[:2]
|
||||
methsplit = string.split(event.method,'.')
|
||||
meth = self
|
||||
for piece in methsplit:
|
||||
meth = getattr(meth,piece)
|
||||
except AttributeError,msg:
|
||||
event.rpcStatus.result = 'No Such Method',msg
|
||||
event.rpcStatus.status = rpcEXCEPT
|
||||
else:
|
||||
if res is None:
|
||||
event.rpcStatus.result = []
|
||||
try:
|
||||
res = apply(meth,event.args)
|
||||
except:
|
||||
import traceback
|
||||
if self.verbose: traceback.print_exc()
|
||||
event.rpcStatus.result = sys.exc_info()[:2]
|
||||
event.rpcStatus.status = rpcEXCEPT
|
||||
else:
|
||||
event.rpcStatus.result = res
|
||||
event.rpcStatus.status = rpcDONE
|
||||
if res is None:
|
||||
# returning None across the xmlrpc interface is problematic
|
||||
event.rpcStatus.result = []
|
||||
else:
|
||||
event.rpcStatus.result = res
|
||||
event.rpcStatus.status = rpcDONE
|
||||
|
||||
event.rpcStatusLock.release()
|
||||
|
||||
# broadcast (using the condition var) that we're done with the event
|
||||
event.rpcCondVar.acquire()
|
||||
event.rpcCondVar.notify()
|
||||
event.rpcCondVar.release()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
port = 800
|
||||
if len(sys.argv)>1:
|
||||
port = int(sys.argv[1])
|
||||
import time
|
||||
if sys.platform == 'win32':
|
||||
port = 800
|
||||
else:
|
||||
port = 8023
|
||||
|
||||
class rpcFrame(wxFrame,rpcMixin):
|
||||
"""A simple wxFrame with the rpcMixin functionality added
|
||||
@@ -199,6 +357,9 @@ if __name__ == '__main__':
|
||||
if kwargs.has_key('rpcPort'):
|
||||
mixinArgs['port'] = kwargs['rpcPort']
|
||||
del kwargs['rpcPort']
|
||||
if kwargs.has_key('rpcPortScan'):
|
||||
mixinArgs['portScan'] = kwargs['rpcPortScan']
|
||||
del kwargs['rpcPortScan']
|
||||
|
||||
apply(wxFrame.__init__,(self,)+args,kwargs)
|
||||
apply(rpcMixin.__init__,(self,),mixinArgs)
|
||||
@@ -220,17 +381,38 @@ if __name__ == '__main__':
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = rpcFrame(NULL, -1, "wxPython RPCDemo", wxDefaultPosition, wxSize(300,300),rpcHost='localhost',rpcPort=port)
|
||||
frame.Show(TRUE)
|
||||
import time
|
||||
|
||||
#self.SetTopWindow(frame)
|
||||
frame2 = rpcFrame(NULL, -1, "wxPython RPCDemo2", wxDefaultPosition, wxSize(300,300),rpcHost='localhost',rpcPort=port+1)
|
||||
frame2.Show(TRUE)
|
||||
|
||||
self.frame = rpcFrame(NULL, -1, "wxPython RPCDemo", wxDefaultPosition,
|
||||
wxSize(300,300),
|
||||
rpcHost='localhost',rpcPort=port)
|
||||
self.frame.Show(TRUE)
|
||||
return TRUE
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
def testcon(port):
|
||||
s1 = xmlrpclib.Server('http://localhost:%d'%(port))
|
||||
s1.SetTitle('Munged')
|
||||
s1._rpcPing()
|
||||
if doQuit:
|
||||
s1.RPCQuit()
|
||||
|
||||
doQuit = 1
|
||||
if len(sys.argv)>1 and sys.argv[1] == '-q':
|
||||
doQuit = 0
|
||||
nT = threading.activeCount()
|
||||
app = MyApp(0)
|
||||
activePort = app.frame.rpcPort
|
||||
t = threading.Thread(target=lambda x=activePort:testcon(x),verbose=0)
|
||||
t.start()
|
||||
|
||||
app.MainLoop()
|
||||
# give the threads time to shut down
|
||||
if threading.activeCount() > nT:
|
||||
print 'waiting for all threads to terminate'
|
||||
while threading.activeCount() > nT:
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user