Bonjour, je souhaite avoir un frame sans bordure (c'est le premier point) et avec une forme personnalisée. Pour cela je veux utiliser un wx.frame avec un style FRAME_SHAPED et faire un SetShape d'une Region définie par un Bitmap (l'image utilisée est jointe, elle représente une ellipse blanche sur fond noir) tel qu'indiqué dans la doc:
Mon problème est que j'ai un message d'erreur comme quoi le premier argument de Region doit etre un int:wxRegion(const wxBitmap& bmp, const wxColour& transColour, int tolerance = 0)
Constructs a region using the non-transparent pixels of a bitmap.
voici le code exemple:Traceback (most recent call last):
File "C:\Documents and Settings\VEGA\Bureau\wxShapedWindow.py", line 13, in <module>
r = wx.Region(bmp, wx.BLACK, 0)
File "C:\Python25\lib\site-packages\wx-2.8-msw-ansi\wx\_gdi.py", line 1459, in __init__
_gdi_.Region_swiginit(self,_gdi_.new_Region(*args, **kwargs))
TypeError: in method 'new_Region', expected argument 1 of type 'int'
Quelqu'un sait il comment faire?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #!/usr/bin/python # -*- coding: iso-8859-1 -*- try: import wx except ImportError: raise ImportError,"The wxPython module is required to run this program" if __name__ == "__main__": app = wx.App() frame = wx.Frame(None,-1,'my application', style=wx.FRAME_SHAPED) bmp = wx.Bitmap("im2.png", wx.BITMAP_TYPE_PNG) r = wx.Region(bmp, wx.BLACK, 0) frame.SetShape(r) frame.Show(True) app.MainLoop()
Merci.
Partager