Images can now be embedded in Python source files.
Added tools to do the embedding. Added Constructors/methods where needed. Updated the demo to use mostly embedded images. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@ -3,6 +3,7 @@ from wxPython.wx import *
|
||||
from wxPython.lib.buttons import wxGenButton, wxGenBitmapButton, \
|
||||
wxGenToggleButton, wxGenBitmapToggleButton
|
||||
|
||||
import images
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -34,18 +35,18 @@ class TestPanel(wxPanel):
|
||||
#b.SetUseFocusIndicator(false)
|
||||
b.SetToolTipString("This is a BIG button...")
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getTest2Bitmap()
|
||||
b = wxGenBitmapButton(self, -1, bmp, (10, 130))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
||||
|
||||
|
||||
b = wxGenBitmapButton(self, -1, None, (140, 130))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
||||
bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getBulb1Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapLabel(bmp)
|
||||
bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getBulb2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapSelected(bmp)
|
||||
@ -57,11 +58,11 @@ class TestPanel(wxPanel):
|
||||
|
||||
b = wxGenBitmapToggleButton(self, -1, None, (140, 230))
|
||||
EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
|
||||
bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getBulb1Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapLabel(bmp)
|
||||
bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getBulb2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
b.SetBitmapSelected(bmp)
|
||||
|
@ -211,6 +211,7 @@ class GridEditorTest(wxGrid):
|
||||
self.SetColSize(1, 150)
|
||||
self.SetColSize(2, 150)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
|
@ -16,6 +16,8 @@ from wxPython.wx import *
|
||||
from wxPython.lib.splashscreen import SplashScreen
|
||||
from wxPython.html import wxHtmlWindow
|
||||
|
||||
import images
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -75,10 +77,10 @@ class wxPythonDemo(wxFrame):
|
||||
self.cwd = os.getcwd()
|
||||
self.curOverview = ""
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
|
||||
self.SetIcon(icon)
|
||||
icon = wxIconFromXPMData(images.getMondrianData())
|
||||
self.SetIcon(icon)
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
# setup a taskbar icon, and catch some events from it
|
||||
self.tbicon = wxTaskBarIcon()
|
||||
self.tbicon.SetIcon(icon, "wxPython Demo")
|
||||
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
Before Width: | Height: | Size: 990 B After Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
56
wxPython/demo/encode_bitmaps.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
This is a way to save the startup time when running img2py on lots of
|
||||
files...
|
||||
"""
|
||||
|
||||
import sys, string
|
||||
sys.path.insert(0, "../tools")
|
||||
|
||||
import img2py
|
||||
|
||||
|
||||
command_lines = [
|
||||
" -n Mondrian bmp_source/mondrian.ico images.py",
|
||||
|
||||
"-a -n _10s_ bmp_source/10s.gif images.py",
|
||||
"-a -n _01c_ bmp_source/01c.gif images.py",
|
||||
"-a -n _12h_ bmp_source/12h.gif images.py",
|
||||
"-a -n _13d_ bmp_source/13d.gif images.py",
|
||||
"-a -n Background bmp_source/backgrnd.png images.py",
|
||||
"-a -n TestStar -m #FFFFFF bmp_source/teststar.png images.py",
|
||||
"-a -n TestStar2 bmp_source/teststar.png images.py",
|
||||
"-a -n TestMask bmp_source/testmask.bmp images.py",
|
||||
|
||||
"-a -n Test2 bmp_source/test2.bmp images.py",
|
||||
"-a -n Robin bmp_source/robin.jpg images.py",
|
||||
|
||||
"-a -n Bulb1 bmp_source/lb1.bmp images.py",
|
||||
"-a -n Bulb2 bmp_source/lb2.bmp images.py",
|
||||
|
||||
"-a -n Calendar bmp_source/Calend.bmp images.py",
|
||||
"-a -n DbDec bmp_source/DbDec.bmp images.py",
|
||||
"-a -n Dec bmp_source/Dec.bmp images.py",
|
||||
"-a -n Pt bmp_source/Pt.bmp images.py",
|
||||
"-a -n DbInc bmp_source/DbInc.bmp images.py",
|
||||
"-a -n Inc bmp_source/Inc.bmp images.py",
|
||||
|
||||
"-a -n New bmp_source/new.bmp images.py",
|
||||
"-a -n Open bmp_source/open.bmp images.py",
|
||||
"-a -n Copy bmp_source/copy.bmp images.py",
|
||||
"-a -n Paste bmp_source/paste.bmp images.py",
|
||||
"-a -n Tog1 bmp_source/tog1.bmp images.py",
|
||||
"-a -n Tog2 bmp_source/tog2.bmp images.py",
|
||||
|
||||
"-a -n Smiles bmp_source/smiles.bmp images.py",
|
||||
|
||||
#"-a -n bmp_source/ images.py",
|
||||
]
|
||||
|
||||
|
||||
for line in command_lines:
|
||||
args = string.split(line)
|
||||
img2py.main(args)
|
||||
|
5183
wxPython/demo/images.py
Normal file
@ -24,7 +24,7 @@ beautifully documented...
|
||||
"""
|
||||
|
||||
from wxPython import wx
|
||||
import string # Don't use it, but it's fun expanding :-)
|
||||
import sys, string # Don't use it, but it's fun expanding :-)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@ -161,7 +161,8 @@ def runTest(frame, nb, log):
|
||||
This method is used by the wxPython Demo Framework for integrating
|
||||
this demo with the rest.
|
||||
"""
|
||||
thisModule = __import__(__name__, globals())
|
||||
#thisModule = __import__(__name__, globals())
|
||||
thisModule = sys.modules[__name__]
|
||||
win = wx.wxFrame(frame, -1, "PyTreeItemData Test")
|
||||
split = wx.wxSplitterWindow(win, -1)
|
||||
tree = pyTree(split, -1, thisModule)
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
@ -19,8 +21,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
b.SetToolTipString("This is a Hello button...")
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Author: Lorne White (email: lwhite1@planet.eon.net)
|
||||
#
|
||||
# Version 0.9
|
||||
# Version 0.9
|
||||
# Date: Feb 26, 2001
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
@ -12,8 +12,8 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.calendar import wxCalendar, Month, PrtCalDraw, CalenDlg
|
||||
|
||||
import images
|
||||
import os
|
||||
dir_path = os.getcwd()
|
||||
|
||||
|
||||
# highlighted days in month
|
||||
@ -107,7 +107,7 @@ class TestPanel(wxPanel):
|
||||
wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getCalendarBitmap()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 80))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestDlg)
|
||||
|
||||
@ -116,14 +116,12 @@ class TestPanel(wxPanel):
|
||||
wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 180))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestFrame)
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Print", wxPoint(350, 250), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
bmp = wxBitmap('bitmaps/Calend.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 280))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.OnPreview)
|
||||
|
||||
@ -316,26 +314,24 @@ class CalendFrame(wxFrame):
|
||||
def MakeToolMenu(self):
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||
|
||||
bmp_path = 'bitmaps/'
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, bmp_path + 'DbDec.bmp', 'Dec Year')
|
||||
SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year')
|
||||
EVT_TOOL(self, mID, self.OnDecYear)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, bmp_path + 'Dec.bmp', 'Dec Month')
|
||||
SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month')
|
||||
EVT_TOOL(self, mID, self.OnDecMonth)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, bmp_path + 'Pt.bmp', 'Current Month')
|
||||
SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month')
|
||||
EVT_TOOL(self, mID, self.OnCurrent)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, bmp_path + 'Inc.bmp', 'Inc Month')
|
||||
SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month')
|
||||
EVT_TOOL(self, mID, self.OnIncMonth)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, bmp_path + 'DbInc.bmp', 'Inc Year')
|
||||
SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year')
|
||||
EVT_TOOL(self, mID, self.OnIncYear)
|
||||
|
||||
tb.Realize()
|
||||
@ -518,9 +514,7 @@ class PrintCalend:
|
||||
self.ptheight = height
|
||||
|
||||
def SetToolPath(self, tb, id, bmp, title):
|
||||
global dir_path
|
||||
tb.AddSimpleTool(id, wxBitmap(os.path.join(dir_path, bmp), wxBITMAP_TYPE_BMP),
|
||||
title, title)
|
||||
tb.AddSimpleTool(id, bmp, title, title)
|
||||
|
||||
class SetPrintout(wxPrintout):
|
||||
def __init__(self, canvas):
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class DragShape:
|
||||
@ -47,14 +49,14 @@ class DragCanvas(wxScrolledWindow):
|
||||
self.dragShape = None
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_ARROW))
|
||||
self.bg_bmp = wxBitmap('bitmaps/backgrnd.png', wxBITMAP_TYPE_PNG)
|
||||
self.bg_bmp = images.getBackgroundBitmap()
|
||||
|
||||
|
||||
# Make a shape from an image and mask. This one will demo
|
||||
# dragging outside the window
|
||||
bmp = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
mask = wxMaskColour(bmp, wxWHITE)
|
||||
bmp.SetMask(mask)
|
||||
bmp = images.getTestStarBitmap()
|
||||
#mask = wxMaskColour(bmp, wxWHITE)
|
||||
#bmp.SetMask(mask)
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(5, 5)
|
||||
shape.fullscreen = true
|
||||
@ -84,8 +86,9 @@ class DragCanvas(wxScrolledWindow):
|
||||
|
||||
# Make some shapes from some playing card images.
|
||||
x = 200
|
||||
for card in ['01c.gif', '10s.gif', '12h.gif', '13d.gif']:
|
||||
bmp = wxBitmap('bitmaps/'+card, wxBITMAP_TYPE_GIF)
|
||||
for card in ['_01c_', '_12h_', '_13d_', '_10s_']:
|
||||
bmpFunc = getattr(images, "get%sBitmap" % card)
|
||||
bmp = bmpFunc()
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(x, 5)
|
||||
self.shapes.append(shape)
|
||||
|
@ -1,6 +1,9 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.floatbar import *
|
||||
|
||||
import images
|
||||
|
||||
|
||||
class TestFloatBar(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test ToolBar',
|
||||
@ -17,32 +20,28 @@ class TestFloatBar(wxFrame):
|
||||
tb.SetFloatable(1)
|
||||
tb.SetTitle("Floating!")
|
||||
self.CreateStatusBar()
|
||||
tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
|
||||
"New", "Long help for 'New'")
|
||||
|
||||
tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
|
||||
EVT_TOOL(self, 10, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
|
||||
|
||||
tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Open")
|
||||
tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
|
||||
EVT_TOOL(self, 20, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Copy")
|
||||
tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
|
||||
EVT_TOOL(self, 30, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
|
||||
|
||||
tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Paste")
|
||||
tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
|
||||
EVT_TOOL(self, 40, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
|
||||
|
||||
tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
|
||||
tb.AddTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(),
|
||||
shortHelpString="Toggle with 2 bitmaps", isToggle=true)
|
||||
EVT_TOOL(self, 60, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
|
||||
|
@ -57,6 +57,7 @@ musicdata = {
|
||||
39: ("Yes", "Rhythm Of Love", "Rock"),
|
||||
}
|
||||
|
||||
import images
|
||||
|
||||
class TestListCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
@ -66,7 +67,7 @@ class TestListCtrlPanel(wxPanel):
|
||||
tID = wxNewId()
|
||||
|
||||
self.il = wxImageList(16, 16)
|
||||
bmp = wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getSmilesBitmap()
|
||||
idx1 = self.il.AddWithColourMask(bmp, wxWHITE)
|
||||
|
||||
self.list = wxListCtrl(self, tID,
|
||||
|
@ -26,19 +26,21 @@ logicList = [
|
||||
('wxXOR', wxXOR),
|
||||
]
|
||||
|
||||
import images
|
||||
|
||||
class TestMaskWindow(wxScrolledWindow):
|
||||
def __init__(self, parent):
|
||||
wxScrolledWindow.__init__(self, parent, -1)
|
||||
self.SetBackgroundColour(wxColour(0,128,0))
|
||||
|
||||
# A reference bitmap that we won't mask
|
||||
self.bmp_nomask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
self.bmp_nomask = images.getTestStar2Bitmap()
|
||||
|
||||
# One that we will
|
||||
self.bmp_withmask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
self.bmp_withmask = images.getTestStar2Bitmap()
|
||||
|
||||
# this mask comes from a monochrome bitmap
|
||||
self.bmp_themask = wxBitmap('bitmaps/test_mask.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.bmp_themask = images.getTestMaskBitmap()
|
||||
self.bmp_themask.SetDepth(1)
|
||||
mask = wxMask(self.bmp_themask)
|
||||
|
||||
@ -47,7 +49,7 @@ class TestMaskWindow(wxScrolledWindow):
|
||||
|
||||
# Now we'll create a mask in a bit of an easier way, by picking a
|
||||
# colour in the image that is to be the transparent colour.
|
||||
self.bmp_withcolourmask = wxBitmap('bitmaps/test_image.png', wxBITMAP_TYPE_PNG)
|
||||
self.bmp_withcolourmask = images.getTestStar2Bitmap()
|
||||
mask = wxMaskColour(self.bmp_withcolourmask, wxWHITE)
|
||||
self.bmp_withcolourmask.SetMask(mask)
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.ogl import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# This creates some pens and brushes that the OGL library uses.
|
||||
|
||||
@ -41,40 +43,6 @@ class RoundedRectangleShape(wxRectangleShape):
|
||||
self.SetCornerRadius(-0.3)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
## class LabeledBitmapShape(wxBitmapShape):
|
||||
## def __init__(self, bmp, text):
|
||||
## wxBitmapShape.__init__(self)
|
||||
## self.SetBitmap(bmp)
|
||||
## self.region = r = wxShapeRegion()
|
||||
## r.SetPosition(0, 0) #bmp.GetHeight())
|
||||
## r.SetSize(bmp.GetWidth(), bmp.GetHeight())
|
||||
## r.SetText(text)
|
||||
## self.AddRegion(r)
|
||||
|
||||
## def OnMovePost(self, dc, x, y, old_x, old_y, display):
|
||||
## self.region.SetPosition(x, y)
|
||||
## self.base_OnMovePost(dc, x, y, old_x, old_y, display)
|
||||
|
||||
|
||||
## class LabeledBitmapShape(wxCompositeShape):
|
||||
## def __init__(self, canvas, bmp, text):
|
||||
## wxCompositeShape.__init__(self)
|
||||
## self.bs = wxBitmapShape()
|
||||
## self.bs.SetBitmap(bmp)
|
||||
## self.ts = wxTextShape()
|
||||
## self.ts.AddText(text)
|
||||
|
||||
## self.AddChild(self.bs)
|
||||
## self.AddChild(self.ts, self.bs)
|
||||
|
||||
## self.AddConstrainedShapes(gyCONSTRAINT_CENTRED_VERTICALLY, self, [self.bs, self.ts])
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_BELOW, self.bs, self.ts)
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_TOP, self, self.bs)
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_BOTTOM, self, self.ts)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class MyEvtHandler(wxShapeEvtHandler):
|
||||
@ -168,19 +136,9 @@ class TestWindow(wxShapeCanvas):
|
||||
self.MyAddShape(DiamondShape(90, 90), 345, 235, wxPen(wxBLUE, 3, wxDOT), wxRED_BRUSH, "Polygon")
|
||||
self.MyAddShape(RoundedRectangleShape(95,70), 140, 255, wxPen(wxRED, 1), rRectBrush, "Rounded Rect")
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
## s = LabeledBitmapShape(self, bmp, "Hello")
|
||||
## self.MyAddShape(s, 225, 150, None, None, None)
|
||||
## print s.Recompute()
|
||||
## s.CalculateSize()
|
||||
## print s.GetX(), s.GetY()
|
||||
## s.SetSize(225)
|
||||
## s.SetY(150)
|
||||
## s.SetSize(80, 80)
|
||||
## print s.GetX(), s.GetY()
|
||||
## #print s.GetSize()
|
||||
|
||||
s = wxBitmapShape()
|
||||
s.SetBitmap(bmp)
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyCanvas(wxScrolledWindow):
|
||||
@ -20,7 +22,7 @@ class MyCanvas(wxScrolledWindow):
|
||||
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_PENCIL))
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
self.bmp = bmp
|
||||
|
@ -2,6 +2,7 @@
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@ -13,13 +14,13 @@ class TestPanel(wxPanel):
|
||||
|
||||
wxStaticText(self, -1, "This is a wxStaticBitmap.", wxPoint(45, 15))
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
wxStaticBitmap(self, -1, bmp, wxPoint(80, 50),
|
||||
wxSize(bmp.GetWidth(), bmp.GetHeight()))
|
||||
|
||||
bmp = wxBitmap('bitmaps/robin.jpg', wxBITMAP_TYPE_JPEG)
|
||||
bmp = images.getRobinBitmap()
|
||||
wxStaticBitmap(self, -1, bmp, (80, 150))
|
||||
|
||||
wxStaticText(self, -1, "Hey, if Ousterhout can do it, so can I.",
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestToolBar(wxFrame):
|
||||
@ -20,31 +22,30 @@ class TestToolBar(wxFrame):
|
||||
|
||||
self.CreateStatusBar()
|
||||
|
||||
tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
|
||||
"New", "Long help for 'New'")
|
||||
tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
|
||||
EVT_TOOL(self, 10, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
|
||||
|
||||
tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Open", "Long help for 'Open'")
|
||||
tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
|
||||
EVT_TOOL(self, 20, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Copy", "Long help for 'Copy'")
|
||||
tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
|
||||
EVT_TOOL(self, 30, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
|
||||
|
||||
tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
|
||||
"Paste", "Long help for 'Paste'")
|
||||
tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
|
||||
EVT_TOOL(self, 40, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
|
||||
tool = tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
tool = tb.AddTool(50, images.getTog1Bitmap(),
|
||||
shortHelpString="Toggle this", isToggle=true)
|
||||
EVT_TOOL(self, 50, self.OnToolClick)
|
||||
|
||||
tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
|
||||
tb.AddTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(),
|
||||
shortHelpString="Toggle with 2 bitmaps", isToggle=true)
|
||||
EVT_TOOL(self, 60, self.OnToolClick)
|
||||
|
||||
|
@ -31,12 +31,13 @@ class TestTreeCtrlPanel(wxPanel):
|
||||
self.tree = MyTreeCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS)# | wxTR_MULTIPLE)
|
||||
|
||||
#import images
|
||||
#il = wxImageList(16, 16)
|
||||
#idx1 = il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
|
||||
#idx2 = il.Add(wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP))
|
||||
#idx3 = il.Add(wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP))
|
||||
#idx4 = il.Add(wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP))
|
||||
#idx5 = il.Add(wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP))
|
||||
#idx1 = il.Add(images.getSmilesBitmap())
|
||||
#idx2 = il.Add(images.getOpenBitmap())
|
||||
#idx3 = il.Add(images.getNewBitmap())
|
||||
#idx4 = il.Add(images.getCopyBitmap())
|
||||
#idx5 = il.Add(images.getPasteBitmap())
|
||||
|
||||
#self.tree.SetImageList(il)
|
||||
#self.il = il
|
||||
|
@ -105,18 +105,60 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Declarations of some alternate "constructors"
|
||||
%new wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1);
|
||||
%new wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings);
|
||||
%new wxBitmap* wxBitmapFromIcon(const wxIcon& icon);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
%new wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1);
|
||||
#endif
|
||||
|
||||
%{ // Alternate 'constructor'
|
||||
|
||||
|
||||
%{ // Implementations of some alternate "constructors"
|
||||
|
||||
wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
|
||||
return new wxBitmap(width, height, depth);
|
||||
}
|
||||
|
||||
static char** ConvertListOfStrings(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
int count;
|
||||
|
||||
if (!PyList_Check(listOfStrings)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
|
||||
return NULL;
|
||||
}
|
||||
count = PyList_Size(listOfStrings);
|
||||
cArray = new char*[count];
|
||||
|
||||
for(int x=0; x<count; x++) {
|
||||
// TODO: Need some validation and error checking here
|
||||
cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
|
||||
}
|
||||
return cArray;
|
||||
}
|
||||
|
||||
wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxBitmap* bmp;
|
||||
|
||||
cArray = ConvertListOfStrings(listOfStrings);
|
||||
if (! cArray)
|
||||
return NULL;
|
||||
bmp = new wxBitmap(cArray);
|
||||
delete [] cArray;
|
||||
return bmp;
|
||||
}
|
||||
|
||||
|
||||
wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
|
||||
return new wxBitmap(icon);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1) {
|
||||
@ -136,6 +178,8 @@ class wxMask {
|
||||
public:
|
||||
wxMask(const wxBitmap& bitmap);
|
||||
//~wxMask();
|
||||
|
||||
%addmethods { void Destroy() { delete self; } }
|
||||
};
|
||||
|
||||
%new wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour);
|
||||
@ -174,6 +218,8 @@ public:
|
||||
#ifdef __WXMSW__
|
||||
void SetSize(const wxSize& size);
|
||||
#endif
|
||||
void CopyFromBitmap(const wxBitmap& bmp);
|
||||
|
||||
%pragma(python) addtoclass = "
|
||||
def __del__(self,gdic=gdic):
|
||||
try:
|
||||
@ -182,10 +228,31 @@ public:
|
||||
except:
|
||||
pass
|
||||
"
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Declarations of some alternate "constructors"
|
||||
%new wxIcon* wxEmptyIcon();
|
||||
%new wxIcon* wxIconFromXPMData(PyObject* listOfStrings);
|
||||
|
||||
%{ // Implementations of some alternate "constructors"
|
||||
wxIcon* wxEmptyIcon() {
|
||||
return new wxIcon();
|
||||
}
|
||||
|
||||
wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxIcon* icon;
|
||||
|
||||
cArray = ConvertListOfStrings(listOfStrings);
|
||||
if (! cArray)
|
||||
return NULL;
|
||||
icon = new wxIcon(cArray);
|
||||
delete [] cArray;
|
||||
return icon;
|
||||
}
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxCursor
|
||||
|
@ -106,7 +106,8 @@ public:
|
||||
unsigned char GetGreen( int x, int y );
|
||||
unsigned char GetBlue( int x, int y );
|
||||
|
||||
bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
|
||||
static bool CanRead( const wxString& name );
|
||||
bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
|
||||
%name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
|
||||
|
||||
bool SaveFile( const wxString& name, int type );
|
||||
@ -163,6 +164,9 @@ public:
|
||||
unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
|
||||
// TODO: unsigned long ComputeHistogram( wxHashTable &h );
|
||||
|
||||
static void AddHandler( wxImageHandler *handler );
|
||||
static void InsertHandler( wxImageHandler *handler );
|
||||
static bool RemoveHandler( const wxString& name );
|
||||
};
|
||||
|
||||
// Alternate constructors
|
||||
@ -188,13 +192,6 @@ public:
|
||||
}
|
||||
%}
|
||||
|
||||
// Static Methods
|
||||
void wxImage_AddHandler(wxImageHandler *handler);
|
||||
%{
|
||||
void wxImage_AddHandler(wxImageHandler *handler) {
|
||||
wxImage::AddHandler(handler);
|
||||
}
|
||||
%}
|
||||
|
||||
void wxInitAllImageHandlers();
|
||||
|
||||
|
@ -111,11 +111,48 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
|
||||
static char* wxStringErrorMsg = "string type is required for parameter";
|
||||
|
||||
static wxString wxPyEmptyStr("");
|
||||
// Alternate 'constructor'
|
||||
// Implementations of some alternate "constructors"
|
||||
|
||||
wxBitmap* wxEmptyBitmap(int width, int height, int depth=-1) {
|
||||
return new wxBitmap(width, height, depth);
|
||||
}
|
||||
|
||||
static char** ConvertListOfStrings(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
int count;
|
||||
|
||||
if (!PyList_Check(listOfStrings)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expected a list of strings.");
|
||||
return NULL;
|
||||
}
|
||||
count = PyList_Size(listOfStrings);
|
||||
cArray = new char*[count];
|
||||
|
||||
for(int x=0; x<count; x++) {
|
||||
// TODO: Need some validation and error checking here
|
||||
cArray[x] = PyString_AsString(PyList_GET_ITEM(listOfStrings, x));
|
||||
}
|
||||
return cArray;
|
||||
}
|
||||
|
||||
wxBitmap* wxBitmapFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxBitmap* bmp;
|
||||
|
||||
cArray = ConvertListOfStrings(listOfStrings);
|
||||
if (! cArray)
|
||||
return NULL;
|
||||
bmp = new wxBitmap(cArray);
|
||||
delete [] cArray;
|
||||
return bmp;
|
||||
}
|
||||
|
||||
|
||||
wxBitmap* wxBitmapFromIcon(const wxIcon& icon) {
|
||||
return new wxBitmap(icon);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap* wxBitmapFromData(PyObject* data, long type,
|
||||
int width, int height, int depth = 1) {
|
||||
@ -130,6 +167,22 @@ static char* wxStringErrorMsg = "string type is required for parameter";
|
||||
|
||||
wxMask* wxMaskColour(const wxBitmap& bitmap, const wxColour& colour) {
|
||||
return new wxMask(bitmap, colour);
|
||||
}
|
||||
// Implementations of some alternate "constructors"
|
||||
wxIcon* wxEmptyIcon() {
|
||||
return new wxIcon();
|
||||
}
|
||||
|
||||
wxIcon* wxIconFromXPMData(PyObject* listOfStrings) {
|
||||
char** cArray = NULL;
|
||||
wxIcon* icon;
|
||||
|
||||
cArray = ConvertListOfStrings(listOfStrings);
|
||||
if (! cArray)
|
||||
return NULL;
|
||||
icon = new wxIcon(cArray);
|
||||
delete [] cArray;
|
||||
return icon;
|
||||
}
|
||||
// Alternate 'constructor'
|
||||
wxCursor* wxPyStockCursor(int id) {
|
||||
@ -231,6 +284,68 @@ static PyObject *_wrap_wxEmptyBitmap(PyObject *self, PyObject *args, PyObject *k
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxBitmapFromXPMData(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxBitmap * _result;
|
||||
PyObject * _arg0;
|
||||
PyObject * _obj0 = 0;
|
||||
char *_kwnames[] = { "listOfStrings", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxBitmapFromXPMData",_kwnames,&_obj0))
|
||||
return NULL;
|
||||
{
|
||||
_arg0 = _obj0;
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxBitmap *)wxBitmapFromXPMData(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxBitmap_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxBitmapFromIcon(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxBitmap * _result;
|
||||
wxIcon * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "icon", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxBitmapFromIcon",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIcon_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxBitmapFromIcon. Expected _wxIcon_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxBitmap *)wxBitmapFromIcon(*_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxBitmap_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxBitmapFromData(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxBitmap * _result;
|
||||
@ -305,6 +420,59 @@ static PyObject *_wrap_wxMaskColour(PyObject *self, PyObject *args, PyObject *kw
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxEmptyIcon(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxIcon * _result;
|
||||
char *_kwnames[] = { NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxEmptyIcon",_kwnames))
|
||||
return NULL;
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxIcon *)wxEmptyIcon();
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxIcon_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxIconFromXPMData(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxIcon * _result;
|
||||
PyObject * _arg0;
|
||||
PyObject * _obj0 = 0;
|
||||
char *_kwnames[] = { "listOfStrings", NULL };
|
||||
char _ptemp[128];
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIconFromXPMData",_kwnames,&_obj0))
|
||||
return NULL;
|
||||
{
|
||||
_arg0 = _obj0;
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (wxIcon *)wxIconFromXPMData(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} if (_result) {
|
||||
SWIG_MakePtr(_ptemp, (char *) _result,"_wxIcon_p");
|
||||
_resultobj = Py_BuildValue("s",_ptemp);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxStockCursor(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxCursor * _result;
|
||||
@ -1946,6 +2114,33 @@ static PyObject *_wrap_new_wxMask(PyObject *self, PyObject *args, PyObject *kwar
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static void wxMask_Destroy(wxMask *self) { delete self; }
|
||||
static PyObject *_wrap_wxMask_Destroy(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxMask * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMask_Destroy",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMask_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMask_Destroy. Expected _wxMask_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxMask_Destroy(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define new_wxIcon(_swigarg0,_swigarg1,_swigarg2,_swigarg3) (new wxIcon(_swigarg0,_swigarg1,_swigarg2,_swigarg3))
|
||||
static PyObject *_wrap_new_wxIcon(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
@ -2359,6 +2554,42 @@ static PyObject *_wrap_wxIcon_SetSize(PyObject *self, PyObject *args, PyObject *
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxIcon_CopyFromBitmap(_swigobj,_swigarg0) (_swigobj->CopyFromBitmap(_swigarg0))
|
||||
static PyObject *_wrap_wxIcon_CopyFromBitmap(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxIcon * _arg0;
|
||||
wxBitmap * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _argo1 = 0;
|
||||
char *_kwnames[] = { "self","bmp", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxIcon_CopyFromBitmap",_kwnames,&_argo0,&_argo1))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxIcon_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIcon_CopyFromBitmap. Expected _wxIcon_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (_argo1) {
|
||||
if (_argo1 == Py_None) { _arg1 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxBitmap_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxIcon_CopyFromBitmap. Expected _wxBitmap_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxIcon_CopyFromBitmap(_arg0,*_arg1);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define new_wxCursor(_swigarg0,_swigarg1,_swigarg2,_swigarg3) (new wxCursor(_swigarg0,_swigarg1,_swigarg2,_swigarg3))
|
||||
static PyObject *_wrap_new_wxCursor(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
@ -9033,6 +9264,7 @@ static PyMethodDef gdicMethods[] = {
|
||||
{ "wxCursor_GetHandle", (PyCFunction) _wrap_wxCursor_GetHandle, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "delete_wxCursor", (PyCFunction) _wrap_delete_wxCursor, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxCursor", (PyCFunction) _wrap_new_wxCursor, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxIcon_CopyFromBitmap", (PyCFunction) _wrap_wxIcon_CopyFromBitmap, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxIcon_SetSize", (PyCFunction) _wrap_wxIcon_SetSize, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxIcon_SetDepth", (PyCFunction) _wrap_wxIcon_SetDepth, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxIcon_SetHeight", (PyCFunction) _wrap_wxIcon_SetHeight, METH_VARARGS | METH_KEYWORDS },
|
||||
@ -9046,6 +9278,7 @@ static PyMethodDef gdicMethods[] = {
|
||||
{ "wxIcon_LoadFile", (PyCFunction) _wrap_wxIcon_LoadFile, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "delete_wxIcon", (PyCFunction) _wrap_delete_wxIcon, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxIcon", (PyCFunction) _wrap_new_wxIcon, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxMask_Destroy", (PyCFunction) _wrap_wxMask_Destroy, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "new_wxMask", (PyCFunction) _wrap_new_wxMask, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmap_SetQuality", (PyCFunction) _wrap_wxBitmap_SetQuality, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmap_GetQuality", (PyCFunction) _wrap_wxBitmap_GetQuality, METH_VARARGS | METH_KEYWORDS },
|
||||
@ -9075,8 +9308,12 @@ static PyMethodDef gdicMethods[] = {
|
||||
{ "wxFont_SetDefaultEncoding", (PyCFunction) _wrap_wxFont_SetDefaultEncoding, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxFont_GetDefaultEncoding", (PyCFunction) _wrap_wxFont_GetDefaultEncoding, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxStockCursor", (PyCFunction) _wrap_wxStockCursor, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "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 },
|
||||
{ "wxBitmapFromIcon", (PyCFunction) _wrap_wxBitmapFromIcon, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxBitmapFromXPMData", (PyCFunction) _wrap_wxBitmapFromXPMData, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxEmptyBitmap", (PyCFunction) _wrap_wxEmptyBitmap, METH_VARARGS | METH_KEYWORDS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
@ -97,6 +97,9 @@ class wxMaskPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def Destroy(self, *_args, **_kwargs):
|
||||
val = apply(gdic.wxMask_Destroy,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxMask instance at %s>" % (self.this,)
|
||||
class wxMask(wxMaskPtr):
|
||||
@ -147,6 +150,9 @@ class wxIconPtr :
|
||||
def SetSize(self, *_args, **_kwargs):
|
||||
val = apply(gdic.wxIcon_SetSize,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def CopyFromBitmap(self, *_args, **_kwargs):
|
||||
val = apply(gdic.wxIcon_CopyFromBitmap,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxIcon instance at %s>" % (self.this,)
|
||||
|
||||
@ -976,6 +982,16 @@ def wxEmptyBitmap(*_args, **_kwargs):
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxBitmapFromXPMData(*_args, **_kwargs):
|
||||
val = apply(gdic.wxBitmapFromXPMData,_args,_kwargs)
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxBitmapFromIcon(*_args, **_kwargs):
|
||||
val = apply(gdic.wxBitmapFromIcon,_args,_kwargs)
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxBitmapFromData(*_args, **_kwargs):
|
||||
val = apply(gdic.wxBitmapFromData,_args,_kwargs)
|
||||
if val: val = wxBitmapPtr(val); val.thisown = 1
|
||||
@ -986,6 +1002,16 @@ def wxMaskColour(*_args, **_kwargs):
|
||||
if val: val = wxMaskPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxEmptyIcon(*_args, **_kwargs):
|
||||
val = apply(gdic.wxEmptyIcon,_args,_kwargs)
|
||||
if val: val = wxIconPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxIconFromXPMData(*_args, **_kwargs):
|
||||
val = apply(gdic.wxIconFromXPMData,_args,_kwargs)
|
||||
if val: val = wxIconPtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
def wxStockCursor(*_args, **_kwargs):
|
||||
val = apply(gdic.wxStockCursor,_args,_kwargs)
|
||||
if val: val = wxCursorPtr(val); val.thisown = 1
|
||||
|
@ -121,10 +121,6 @@ static char* wxStringErrorMsg = "string type is required for parameter";
|
||||
wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
|
||||
return new wxImage(bitmap);
|
||||
}
|
||||
|
||||
void wxImage_AddHandler(wxImageHandler *handler) {
|
||||
wxImage::AddHandler(handler);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -283,32 +279,6 @@ static PyObject *_wrap_wxImageFromBitmap(PyObject *self, PyObject *args, PyObjec
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxImage_AddHandler(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxImageHandler * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "handler", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_AddHandler",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxImageHandler_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxImage_AddHandler. Expected _wxImageHandler_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxImage_AddHandler(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxInitAllImageHandlers(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
char *_kwnames[] = { NULL };
|
||||
@ -1210,13 +1180,54 @@ static PyObject *_wrap_wxImage_GetBlue(PyObject *self, PyObject *args, PyObject
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxImage_CanRead(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxString * _arg0;
|
||||
PyObject * _obj0 = 0;
|
||||
char *_kwnames[] = { "name", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_CanRead",_kwnames,&_obj0))
|
||||
return NULL;
|
||||
{
|
||||
#if PYTHON_API_VERSION >= 1009
|
||||
char* tmpPtr; int tmpSize;
|
||||
if (!PyString_Check(_obj0) && !PyUnicode_Check(_obj0)) {
|
||||
PyErr_SetString(PyExc_TypeError, "String or Unicode type required");
|
||||
return NULL;
|
||||
}
|
||||
if (PyString_AsStringAndSize(_obj0, &tmpPtr, &tmpSize) == -1)
|
||||
return NULL;
|
||||
_arg0 = new wxString(tmpPtr, tmpSize);
|
||||
#else
|
||||
if (!PyString_Check(_obj0)) {
|
||||
PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
|
||||
return NULL;
|
||||
}
|
||||
_arg0 = new wxString(PyString_AS_STRING(_obj0), PyString_GET_SIZE(_obj0));
|
||||
#endif
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxImage::CanRead(*_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
{
|
||||
if (_obj0)
|
||||
delete _arg0;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
#define wxImage_LoadFile(_swigobj,_swigarg0,_swigarg1) (_swigobj->LoadFile(_swigarg0,_swigarg1))
|
||||
static PyObject *_wrap_wxImage_LoadFile(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxImage * _arg0;
|
||||
wxString * _arg1;
|
||||
long _arg2 = (long ) wxBITMAP_TYPE_PNG;
|
||||
long _arg2 = (long ) wxBITMAP_TYPE_ANY;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _obj1 = 0;
|
||||
char *_kwnames[] = { "self","name","type", NULL };
|
||||
@ -2069,7 +2080,103 @@ static PyObject *_wrap_wxImage_CountColours(PyObject *self, PyObject *args, PyOb
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxImage_AddHandler(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxImageHandler * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "handler", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_AddHandler",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxImageHandler_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxImage_AddHandler. Expected _wxImageHandler_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxImage::AddHandler(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxImage_InsertHandler(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
wxImageHandler * _arg0;
|
||||
PyObject * _argo0 = 0;
|
||||
char *_kwnames[] = { "handler", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_InsertHandler",_kwnames,&_argo0))
|
||||
return NULL;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxImageHandler_p")) {
|
||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxImage_InsertHandler. Expected _wxImageHandler_p.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
wxImage::InsertHandler(_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} Py_INCREF(Py_None);
|
||||
_resultobj = Py_None;
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyObject *_wrap_wxImage_RemoveHandler(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
PyObject * _resultobj;
|
||||
bool _result;
|
||||
wxString * _arg0;
|
||||
PyObject * _obj0 = 0;
|
||||
char *_kwnames[] = { "name", NULL };
|
||||
|
||||
self = self;
|
||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_RemoveHandler",_kwnames,&_obj0))
|
||||
return NULL;
|
||||
{
|
||||
#if PYTHON_API_VERSION >= 1009
|
||||
char* tmpPtr; int tmpSize;
|
||||
if (!PyString_Check(_obj0) && !PyUnicode_Check(_obj0)) {
|
||||
PyErr_SetString(PyExc_TypeError, "String or Unicode type required");
|
||||
return NULL;
|
||||
}
|
||||
if (PyString_AsStringAndSize(_obj0, &tmpPtr, &tmpSize) == -1)
|
||||
return NULL;
|
||||
_arg0 = new wxString(tmpPtr, tmpSize);
|
||||
#else
|
||||
if (!PyString_Check(_obj0)) {
|
||||
PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
|
||||
return NULL;
|
||||
}
|
||||
_arg0 = new wxString(PyString_AS_STRING(_obj0), PyString_GET_SIZE(_obj0));
|
||||
#endif
|
||||
}
|
||||
{
|
||||
wxPy_BEGIN_ALLOW_THREADS;
|
||||
_result = (bool )wxImage::RemoveHandler(*_arg0);
|
||||
|
||||
wxPy_END_ALLOW_THREADS;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
{
|
||||
if (_obj0)
|
||||
delete _arg0;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
static PyMethodDef imagecMethods[] = {
|
||||
{ "wxImage_RemoveHandler", (PyCFunction) _wrap_wxImage_RemoveHandler, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_InsertHandler", (PyCFunction) _wrap_wxImage_InsertHandler, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_AddHandler", (PyCFunction) _wrap_wxImage_AddHandler, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_CountColours", (PyCFunction) _wrap_wxImage_CountColours, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_Replace", (PyCFunction) _wrap_wxImage_Replace, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_Mirror", (PyCFunction) _wrap_wxImage_Mirror, METH_VARARGS | METH_KEYWORDS },
|
||||
@ -2093,6 +2200,7 @@ static PyMethodDef imagecMethods[] = {
|
||||
{ "wxImage_SaveFile", (PyCFunction) _wrap_wxImage_SaveFile, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_LoadMimeFile", (PyCFunction) _wrap_wxImage_LoadMimeFile, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_LoadFile", (PyCFunction) _wrap_wxImage_LoadFile, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_CanRead", (PyCFunction) _wrap_wxImage_CanRead, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_GetBlue", (PyCFunction) _wrap_wxImage_GetBlue, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_GetGreen", (PyCFunction) _wrap_wxImage_GetGreen, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_GetRed", (PyCFunction) _wrap_wxImage_GetRed, METH_VARARGS | METH_KEYWORDS },
|
||||
@ -2120,7 +2228,6 @@ static PyMethodDef imagecMethods[] = {
|
||||
{ "wxImageHandler_GetExtension", (PyCFunction) _wrap_wxImageHandler_GetExtension, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImageHandler_GetName", (PyCFunction) _wrap_wxImageHandler_GetName, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxInitAllImageHandlers", (PyCFunction) _wrap_wxInitAllImageHandlers, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImage_AddHandler", (PyCFunction) _wrap_wxImage_AddHandler, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImageFromBitmap", (PyCFunction) _wrap_wxImageFromBitmap, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxImageFromMime", (PyCFunction) _wrap_wxImageFromMime, METH_VARARGS | METH_KEYWORDS },
|
||||
{ "wxEmptyImage", (PyCFunction) _wrap_wxEmptyImage, METH_VARARGS | METH_KEYWORDS },
|
||||
|
@ -284,9 +284,15 @@ def wxImageFromBitmap(*_args, **_kwargs):
|
||||
if val: val = wxImagePtr(val); val.thisown = 1
|
||||
return val
|
||||
|
||||
wxInitAllImageHandlers = imagec.wxInitAllImageHandlers
|
||||
|
||||
wxImage_CanRead = imagec.wxImage_CanRead
|
||||
|
||||
wxImage_AddHandler = imagec.wxImage_AddHandler
|
||||
|
||||
wxInitAllImageHandlers = imagec.wxInitAllImageHandlers
|
||||
wxImage_InsertHandler = imagec.wxImage_InsertHandler
|
||||
|
||||
wxImage_RemoveHandler = imagec.wxImage_RemoveHandler
|
||||
|
||||
|
||||
|
||||
|
178
wxPython/tools/img2py.py
Normal file
@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
img2py.py -- Convert an image to XPM format and embed it in a Python
|
||||
module with appropriate code so it can be loaded into
|
||||
a program at runtime. The benefit is that since it is
|
||||
Python source code it can be delivered as a .pyc or
|
||||
'compiled' into the program using freeze, py2exe, etc.
|
||||
|
||||
Usage:
|
||||
|
||||
img2py.py [options] image_file python_file
|
||||
|
||||
Options:
|
||||
|
||||
-m <#rrggbb> If the original image has a mask or transparency defined
|
||||
it will be used by default. You can use this option to
|
||||
override the default or provide a new mask by specifying
|
||||
a colour in the image to mark as transparent.
|
||||
|
||||
-n <name> Normally generic names (getBitmap, etc.) are used for the
|
||||
image access functions. If you use this option you can
|
||||
specify a name that should be used to customize the access
|
||||
fucntions, (getNameBitmap, etc.)
|
||||
|
||||
-a This flag specifies that the python_file should be appended
|
||||
to instead of overwritten. This in combination with -n will
|
||||
allow you to put multiple images in one Python source file.
|
||||
|
||||
-u Don't use compression. Leaves the data uncompressed.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
import sys, os, glob, getopt, tempfile
|
||||
import cPickle, cStringIO, zlib
|
||||
import img2xpm
|
||||
|
||||
|
||||
def crunch_data(data, compressed):
|
||||
# convert the lines to a Python list, pickle it and compress the result.
|
||||
lines = []
|
||||
for line in data[2:]: # skip the first two lines
|
||||
lines.append(line[1:-3]) # chop one char from the front and three from the end
|
||||
|
||||
# chop one extra char from the last line
|
||||
lines[-1] = lines[-1][:-1]
|
||||
|
||||
# pickle, crunch and convert it to a form suitable for embedding in code
|
||||
data = cPickle.dumps(lines)
|
||||
if compressed:
|
||||
data = zlib.compress(data, 9)
|
||||
data = repr(data)
|
||||
|
||||
|
||||
# This next bit is borrowed from PIL. It is used to wrap the text intelligently.
|
||||
fp = cStringIO.StringIO()
|
||||
data = data + " " # buffer for the +1 test
|
||||
c = i = 0
|
||||
word = ""
|
||||
octdigits = "01234567"
|
||||
while i < len(data):
|
||||
if data[i] != "\\":
|
||||
word = data[i]
|
||||
i = i + 1
|
||||
else:
|
||||
if data[i+1] in octdigits:
|
||||
for n in range(2, 5):
|
||||
if data[i+n] not in octdigits:
|
||||
break
|
||||
word = data[i:i+n]
|
||||
i = i + n
|
||||
else:
|
||||
word = data[i:i+2]
|
||||
i = i + 2
|
||||
l = len(word)
|
||||
if c + l >= 78-1:
|
||||
fp.write("\\\n")
|
||||
c = 0
|
||||
fp.write(word)
|
||||
c = c + l
|
||||
|
||||
# return the formatted compressed data
|
||||
return fp.getvalue()
|
||||
|
||||
|
||||
|
||||
def main(args):
|
||||
if not args or ("-h" in args):
|
||||
print __doc__
|
||||
return
|
||||
|
||||
append = 0
|
||||
compressed = 1
|
||||
maskClr = None
|
||||
imgName = ""
|
||||
|
||||
try:
|
||||
opts, fileArgs = getopt.getopt(args, "aun:m:")
|
||||
except getopt.GetoptError:
|
||||
print __doc__
|
||||
return
|
||||
|
||||
for opt, val in opts:
|
||||
if opt == "-a":
|
||||
append = 1
|
||||
elif opt == "-u":
|
||||
compressed = 0
|
||||
elif opt == "-n":
|
||||
imgName = val
|
||||
elif opt == "-m":
|
||||
maskClr = val
|
||||
|
||||
if len(fileArgs) != 2:
|
||||
print __doc__
|
||||
return
|
||||
|
||||
image_file, python_file = fileArgs
|
||||
|
||||
# convert the image file to a temporary file
|
||||
tfname = tempfile.mktemp()
|
||||
ok, msg = img2xpm.convert(image_file, maskClr, None, tfname)
|
||||
if not ok:
|
||||
print msg
|
||||
return
|
||||
|
||||
data = open(tfname, "r").readlines()
|
||||
data = crunch_data(data, compressed)
|
||||
os.unlink(tfname)
|
||||
|
||||
if append:
|
||||
out = open(python_file, "a")
|
||||
else:
|
||||
out = open(python_file, "w")
|
||||
|
||||
out.write("#" + "-" * 70 + "\n")
|
||||
if not append:
|
||||
out.write("# This file was generated by %s\n#\n" % sys.argv[0])
|
||||
out.write("from wxPython.wx import wxBitmapFromXPMData, wxImageFromBitmap\n")
|
||||
if compressed:
|
||||
out.write("import cPickle, zlib\n\n\n")
|
||||
else:
|
||||
out.write("import cPickle\n\n\n")
|
||||
|
||||
if compressed:
|
||||
out.write("def get%sData():\n"
|
||||
" return cPickle.loads(zlib.decompress(\n%s))\n\n"
|
||||
% (imgName, data))
|
||||
else:
|
||||
out.write("def get%sData():\n"
|
||||
" return cPickle.loads(\n%s)\n\n"
|
||||
% (imgName, data))
|
||||
|
||||
|
||||
out.write("def get%sBitmap():\n"
|
||||
" return wxBitmapFromXPMData(get%sData())\n\n"
|
||||
"def get%sImage():\n"
|
||||
" return wxImageFromBitmap(get%sBitmap())\n\n"
|
||||
% tuple([imgName] * 4))
|
||||
|
||||
if imgName:
|
||||
n_msg = ' using "%s"' % imgName
|
||||
else:
|
||||
n_msg = ""
|
||||
if maskClr:
|
||||
m_msg = " with mask %s" % maskClr
|
||||
else:
|
||||
m_msg = ""
|
||||
print "Embedded %s%s into %s%s" % (image_file, n_msg, python_file, m_msg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
|
||||
|
96
wxPython/tools/img2xpm.py
Normal file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
img2xpm.py -- convert several image formats to XPM
|
||||
|
||||
Usage:
|
||||
|
||||
img2xpm.py [options] image_files...
|
||||
|
||||
Options:
|
||||
|
||||
-o <dir> The directory to place the .xmp file(s), defaults to
|
||||
the current directory.
|
||||
|
||||
-m <#rrggbb> If the original image has a mask or transparency defined
|
||||
it will be used by default. You can use this option to
|
||||
override the default or provide a new mask by specifying
|
||||
a colour in the image to mark as transparent.
|
||||
|
||||
-n <name> A filename to write the .xpm data to. Defaults to the
|
||||
basename of the image file + '.xpm' This option overrides
|
||||
the -o option.
|
||||
"""
|
||||
|
||||
|
||||
import sys, os, glob, getopt, string
|
||||
from wxPython.wx import *
|
||||
wxInitAllImageHandlers()
|
||||
|
||||
|
||||
def convert(file, maskClr, outputDir, outputName):
|
||||
if string.lower(os.path.splitext(file)[1]) == ".ico":
|
||||
icon = wxIcon(file, wxBITMAP_TYPE_ICO)
|
||||
img = wxBitmapFromIcon(icon)
|
||||
else:
|
||||
img = wxBitmap(file, wxBITMAP_TYPE_ANY)
|
||||
|
||||
if not img.Ok():
|
||||
return 0, file + " failed to load!"
|
||||
else:
|
||||
if maskClr:
|
||||
om = img.GetMask()
|
||||
mask = wxMaskColour(img, maskClr)
|
||||
img.SetMask(mask)
|
||||
if om is not None:
|
||||
om.Destroy()
|
||||
if outputName:
|
||||
newname = outputName
|
||||
else:
|
||||
newname = os.path.join(outputDir, os.path.basename(os.path.splitext(file)[0]) + ".xpm")
|
||||
if img.SaveFile(newname, wxBITMAP_TYPE_XPM):
|
||||
return 1, file + " converted to " + newname
|
||||
else:
|
||||
return 0, file + " failed to save!"
|
||||
|
||||
|
||||
|
||||
def main(args):
|
||||
if not args or ("-h" in args):
|
||||
print __doc__
|
||||
return
|
||||
|
||||
outputDir = ""
|
||||
maskClr = None
|
||||
outputName = None
|
||||
|
||||
try:
|
||||
opts, fileArgs = getopt.getopt(args, "m:n:o:")
|
||||
except getopt.GetoptError:
|
||||
print __doc__
|
||||
return
|
||||
|
||||
for opt, val in opts:
|
||||
if opt == "-m":
|
||||
maskClr = val
|
||||
elif opt == "-n":
|
||||
outputName = val
|
||||
elif opt == "-o":
|
||||
outputDir = val
|
||||
|
||||
if not fileArgs:
|
||||
print __doc__
|
||||
return
|
||||
|
||||
for arg in fileArgs:
|
||||
for file in glob.glob(arg):
|
||||
if not os.path.isfile(file):
|
||||
continue
|
||||
ok, msg = convert(file, maskClr, outputDir, outputName)
|
||||
print msg
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
||||
|