def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.log = log if 0: # a test case for catching wx.PyAssertionError #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG) try: bmp = wx.Bitmap("nosuchfile.bmp", wx.BITMAP_TYPE_BMP) mask = wx.Mask(bmp, wx.BLUE) except wx.PyAssertionError: self.log.write( "Caught wx.PyAssertionError! I will fix the problem.\n") bmp = images.getTest2Bitmap() mask = wx.MaskColour(bmp, wx.BLUE) else: bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b = wx.BitmapButton(self, 30, bmp, (20, 20), (bmp.GetWidth() + 10, bmp.GetHeight() + 10)) b.SetToolTipString("This is a bitmap button.") self.Bind(wx.EVT_BUTTON, self.OnClick, b)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.log = log if 0: # a test case for catching wx.PyAssertionError #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG) #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG) try: bmp = wx.Bitmap("nosuchfile.bmp", wx.BITMAP_TYPE_BMP) mask = wx.Mask(bmp, wx.BLUE) except wx.PyAssertionError: self.log.write("Caught wx.PyAssertionError! I will fix the problem.\n") bmp = images.getTest2Bitmap() mask = wx.MaskColour(bmp, wx.BLUE) else: bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b = wx.BitmapButton(self, 30, bmp, (20, 20), (bmp.GetWidth()+10, bmp.GetHeight()+10)) b.SetToolTipString("This is a bitmap button.") self.Bind(wx.EVT_BUTTON, self.OnClick, b)
def __init__(self, parent, id = -1, size = wx.DefaultSize): wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) self.lines = [] self.maxWidth = 1000 self.maxHeight = 1000 self.x = self.y = 0 self.curLine = [] self.drawing = False self.SetBackgroundColour("WHITE") self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL)) bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) self.bmp = bmp self.SetVirtualSize((self.maxWidth, self.maxHeight)) self.SetScrollRate(20,20) if BUFFERED: # Initialize the buffer bitmap. No real DC is needed at this point. self.buffer = wx.EmptyBitmap(self.maxWidth, self.maxHeight) dc = wx.BufferedDC(None, self.buffer) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() self.DoDrawing(dc) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftButtonEvent) self.Bind(wx.EVT_LEFT_UP, self.OnLeftButtonEvent) self.Bind(wx.EVT_MOTION, self.OnLeftButtonEvent) self.Bind(wx.EVT_PAINT, self.OnPaint)
def __init__(self, parent, log, frame): wxShapeCanvas.__init__(self, parent) maxWidth = 1000 maxHeight = 1000 self.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20) self.log = log self.frame = frame self.SetBackgroundColour("LIGHT BLUE") #wxWHITE) self.diagram = wxDiagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.shapes = [] self.save_gdi = [] rRectBrush = wxBrush("MEDIUM TURQUOISE", wxSOLID) dsBrush = wxBrush("WHEAT", wxSOLID) self.MyAddShape(wxCircleShape(80), 100, 100, wxPen(wxBLUE, 3), wxGREEN_BRUSH, "Circle") self.MyAddShape(wxRectangleShape(85, 50), 305, 60, wxBLACK_PEN, wxLIGHT_GREY_BRUSH, "Rectangle") ds = self.MyAddShape(DividedShape(140, 150, self), 495, 145, wxBLACK_PEN, dsBrush, '') self.MyAddShape(DiamondShape(90, 90), 345, 235, wxPen(wxBLUE, 3, wxDOT), wxRED_BRUSH, "Polygon") self.MyAddShape(RoundedRectangleShape(95, 70), 140, 255, wxPen(wxRED, 2), rRectBrush, "Rounded Rect") bmp = images.getTest2Bitmap() mask = wxMaskColour(bmp, wxBLUE) bmp.SetMask(mask) s = wxBitmapShape() s.SetBitmap(bmp) self.MyAddShape(s, 225, 150, None, None, "Bitmap") dc = wxClientDC(self) self.PrepareDC(dc) for x in range(len(self.shapes)): fromShape = self.shapes[x] if x + 1 == len(self.shapes): toShape = self.shapes[0] else: toShape = self.shapes[x + 1] line = wxLineShape() line.SetCanvas(self) line.SetPen(wxBLACK_PEN) line.SetBrush(wxBLACK_BRUSH) line.AddArrow(ARROW_ARROW) line.MakeLineControlPoints(2) fromShape.AddLine(line, toShape) self.diagram.AddShape(line) line.Show(True) # for some reason, the shapes have to be moved for the line to show up... fromShape.Move(dc, fromShape.GetX(), fromShape.GetY()) EVT_WINDOW_DESTROY(self, self.OnDestroy)
def __init__(self, parent, id=-1, size=wx.DefaultSize): wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) self.lines = [] self.maxWidth = 1000 self.maxHeight = 1000 self.x = self.y = 0 self.curLine = [] self.drawing = False self.SetBackgroundColour("WHITE") self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL)) bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) self.bmp = bmp self.SetScrollbars(20, 20, self.maxWidth / 20, self.maxHeight / 20) if BUFFERED: # Initialize the buffer bitmap. No real DC is needed at this point. self.buffer = wx.EmptyBitmap(self.maxWidth, self.maxHeight) dc = wx.BufferedDC(None, self.buffer) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() self.DoDrawing(dc) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftButtonEvent) self.Bind(wx.EVT_LEFT_UP, self.OnLeftButtonEvent) self.Bind(wx.EVT_MOTION, self.OnLeftButtonEvent) self.Bind(wx.EVT_PAINT, self.OnPaint)
def __init__(self, parent, id, log, size = wx.DefaultSize): wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) self.lines = [] self.maxWidth = W self.maxHeight = H self.x = self.y = 0 self.curLine = [] self.drawing = False self.SetBackgroundColour("WHITE") bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) self.bmp = bmp self.SetVirtualSize((self.maxWidth, self.maxHeight)) self.SetScrollRate(20,20) # create a PseudoDC to record our drawing self.pdc = wx.PseudoDC() self.pen_cache = {} self.brush_cache = {} self.DoDrawing(self.pdc) log.write('Created PseudoDC draw list with %d operations!'%self.pdc.GetLen()) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x:None) self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse) # vars for handling mouse clicks self.dragid = -1 self.lastpos = (0,0)
def __init__(self, parent, log, frame): wxShapeCanvas.__init__(self, parent) maxWidth = 1000 maxHeight = 1000 self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20) self.log = log self.frame = frame self.SetBackgroundColour("LIGHT BLUE") #wxWHITE) self.diagram = wxDiagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.shapes = [] self.save_gdi = [] rRectBrush = wxBrush("MEDIUM TURQUOISE", wxSOLID) dsBrush = wxBrush("WHEAT", wxSOLID) self.MyAddShape(wxCircleShape(80), 100, 100, wxPen(wxBLUE, 3), wxGREEN_BRUSH, "Circle") self.MyAddShape(wxRectangleShape(85, 50), 305, 60, wxBLACK_PEN, wxLIGHT_GREY_BRUSH, "Rectangle") ds = self.MyAddShape(DividedShape(140, 150, self), 495, 145, wxBLACK_PEN, dsBrush, '') self.MyAddShape(DiamondShape(90, 90), 345, 235, wxPen(wxBLUE, 3, wxDOT), wxRED_BRUSH, "Polygon") self.MyAddShape(RoundedRectangleShape(95,70), 140, 255, wxPen(wxRED, 2), rRectBrush, "Rounded Rect") bmp = images.getTest2Bitmap() mask = wxMaskColour(bmp, wxBLUE) bmp.SetMask(mask) s = wxBitmapShape() s.SetBitmap(bmp) self.MyAddShape(s, 225, 150, None, None, "Bitmap") dc = wxClientDC(self) self.PrepareDC(dc) for x in range(len(self.shapes)): fromShape = self.shapes[x] if x+1 == len(self.shapes): toShape = self.shapes[0] else: toShape = self.shapes[x+1] line = wxLineShape() line.SetCanvas(self) line.SetPen(wxBLACK_PEN) line.SetBrush(wxBLACK_BRUSH) line.AddArrow(ARROW_ARROW) line.MakeLineControlPoints(2) fromShape.AddLine(line, toShape) self.diagram.AddShape(line) line.Show(True) # for some reason, the shapes have to be moved for the line to show up... fromShape.Move(dc, fromShape.GetX(), fromShape.GetY()) EVT_WINDOW_DESTROY(self, self.OnDestroy)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15)) bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight())) bmp = images.getRobinBitmap() StaticBitmap(self, -1, bmp, (80, 150)) StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175))
def OnButtonTestAddBitmapItem( self, event ): ch = self.ch2 itemCount = ch.GetItemCount() if (itemCount <= 8): itemIndex = ch.GetSelectedItem() if (itemIndex < 0): itemIndex = itemCount ch.AddItem( itemIndex, "", wx.colheader.CH_JUST_Center, 40, 0, 0, 1 ) ch.SetItemAttribute( itemIndex, wx.colheader.CH_ITEM_ATTR_FixedWidth, 1 ) testBmp = images.getTest2Bitmap() ch.SetBitmapRef( itemIndex, testBmp ) ch.SetSelectedItem( itemIndex ) ch.ResizeToFit() self.baseWidth2 += 40 self.l0.SetLabel( "(%d): added bitmap item (%d)" %(ch.GetId(), itemIndex) ) else: self.l0.SetLabel( "(%d): enough items!" %(ch.GetId()) )
def OnButtonTestAddBitmapItem(self, event): ch = self.ch2 itemCount = ch.GetItemCount() if (itemCount <= 8): itemIndex = ch.GetSelectedItem() if (itemIndex < 0): itemIndex = itemCount ch.AddItem(itemIndex, "", wx.colheader.CH_JUST_Center, 40, 0, 0, 1) ch.SetItemAttribute(itemIndex, wx.colheader.CH_ITEM_ATTR_FixedWidth, 1) testBmp = images.getTest2Bitmap() ch.SetBitmapRef(itemIndex, testBmp) ch.SetSelectedItem(itemIndex) ch.ResizeToFit() self.baseWidth2 += 40 self.l0.SetLabel("(%d): added bitmap item (%d)" % (ch.GetId(), itemIndex)) else: self.l0.SetLabel("(%d): enough items!" % (ch.GetId()))
def __init__(self, parent, id, log, size=wx.DefaultSize): wx.ScrolledWindow.__init__(self, parent, id, (0, 0), size=size, style=wx.SUNKEN_BORDER) self.lines = [] self.maxWidth = W self.maxHeight = H self.x = self.y = 0 self.curLine = [] self.drawing = False self.SetBackgroundColour("WHITE") bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) self.bmp = bmp self.SetVirtualSize((self.maxWidth, self.maxHeight)) self.SetScrollRate(20, 20) # create a PseudoDC to record our drawing self.pdc = wx.PseudoDC() self.pen_cache = {} self.brush_cache = {} self.DoDrawing(self.pdc) log.write('Created PseudoDC draw list with %d operations!' % self.pdc.GetLen()) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None) self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse) # vars for handling mouse clicks self.dragid = -1 self.lastpos = (0, 0)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") sizer = wx.FlexGridSizer(1, 3, 20, 20) # A regular button, selected as the default button b = wx.Button(self, -1, "A real button") b.SetDefault() self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # Same thing, but NOT set as the default button b = wx.Button(self, -1, "non-default") self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) sizer.Add((10,10)) # Plain old text button based off GenButton() b = buttons.GenButton(self, -1, 'Hello') self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # Plain old text button, disabled. b = buttons.GenButton(self, -1, 'disabled') self.Bind(wx.EVT_BUTTON, self.OnButton, b) b.Enable(False) sizer.Add(b) # This time, we let the botton be as big as it can be. # Also, this one is fancier, with custom colors and bezel size. b = buttons.GenButton(self, -1, 'bigger') self.Bind(wx.EVT_BUTTON, self.OnBiggerButton, b) b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) b.SetMinSize(wx.DefaultSize) b.SetBackgroundColour("Navy") b.SetForegroundColour(wx.WHITE) b.SetToolTipString("This is a BIG button...") # let the sizer set best size sizer.Add(b, flag=wx.ADJUST_MINSIZE) # An image button bmp = images.getTest2Bitmap() b = buttons.GenBitmapButton(self, -1, bmp) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # An image button, disabled. bmp = images.getTest2Bitmap() b = buttons.GenBitmapButton(self, -1, bmp) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) b.Enable(False) # An image button, using a mask to get rid of the # undesireable part of the image b = buttons.GenBitmapButton(self, -1, None) self.Bind(wx.EVT_BUTTON, self.OnButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetInitialSize() sizer.Add(b) # A toggle button b = buttons.GenToggleButton(self, -1, "Toggle Button") self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b) sizer.Add(b) # An image toggle button b = buttons.GenBitmapToggleButton(self, -1, None) self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetToggle(True) b.SetInitialSize() sizer.Add(b) # A bitmap button with text. b = buttons.GenBitmapTextButton(self, -1, None, "Bitmapped Text", size = (200, 45)) self.Bind(wx.EVT_BUTTON, self.OnButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetUseFocusIndicator(False) b.SetInitialSize() sizer.Add(b) # a flat text button b = buttons.GenButton(self, -1, 'Flat buttons too!', style=wx.BORDER_NONE) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b, flag=wx.ALIGN_CENTER_VERTICAL) # A flat image button bmp = images.getTest2Bitmap() bmp.SetMaskColour("blue") b = buttons.GenBitmapButton(self, -1, bmp, style=wx.BORDER_NONE) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) ##b.SetBackgroundColour("sky blue") ##b.SetBackgroundColour("pink") b = buttons.ThemedGenButton(self, -1, 'Drawn with native renderer') self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) border = wx.BoxSizer(wx.VERTICAL) border.Add(sizer, 0, wx.ALL, 25) self.SetSizer(border)
def __init__(self, parent, log, frame): ogl.ShapeCanvas.__init__(self, parent) maxWidth = 1000 maxHeight = 1000 self.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20) self.log = log self.frame = frame self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE) self.diagram = ogl.Diagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.shapes = [] self.save_gdi = [] rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID) dsBrush = wx.Brush("WHEAT", wx.SOLID) self.MyAddShape(CompositeDivisionShape(self), 270, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division") self.MyAddShape(CompositeShape(self), 100, 260, wx.BLACK_PEN, wx.RED_BRUSH, "Composite") self.MyAddShape(ogl.CircleShape(80), 75, 110, wx.Pen(wx.BLUE, 3), wx.GREEN_BRUSH, "Circle") self.MyAddShape(ogl.TextShape(120, 45), 160, 35, wx.GREEN_PEN, wx.LIGHT_GREY_BRUSH, "OGL is now a\npure Python lib!") self.MyAddShape(ogl.RectangleShape(85, 50), 305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle") self.MyAddShape(DrawnShape(), 500, 80, wx.BLACK_PEN, wx.BLACK_BRUSH, "DrawnShape") ds = self.MyAddShape(DividedShape(140, 150, self), 520, 265, wx.BLACK_PEN, dsBrush, '') self.MyAddShape(DiamondShape(90, 90), 355, 260, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon") self.MyAddShape(RoundedRectangleShape(95, 70), 345, 145, wx.Pen(wx.RED, 2), rRectBrush, "Rounded Rect") bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) s = ogl.BitmapShape() s.SetBitmap(bmp) self.MyAddShape(s, 225, 130, None, None, "Bitmap") dc = wx.ClientDC(self) self.PrepareDC(dc) for x in range(len(self.shapes)): fromShape = self.shapes[x] if x + 1 == len(self.shapes): toShape = self.shapes[0] else: toShape = self.shapes[x + 1] line = ogl.LineShape() line.SetCanvas(self) line.SetPen(wx.BLACK_PEN) line.SetBrush(wx.BLACK_BRUSH) line.AddArrow(ogl.ARROW_ARROW) line.MakeLineControlPoints(2) fromShape.AddLine(line, toShape) self.diagram.AddShape(line) line.Show(True)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log ##self.SetBackgroundColour("sky blue") sizer = wx.FlexGridSizer(1, 3, 20, 20) # A regular button, selected as the default button b = wx.Button(self, -1, "A real button") b.SetDefault() self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # Same thing, but NOT set as the default button b = wx.Button(self, -1, "non-default") self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) sizer.Add((10, 10)) # Plain old text button based off GenButton() b = buttons.GenButton(self, -1, 'Hello') self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # Plain old text button, disabled. b = buttons.GenButton(self, -1, 'disabled') self.Bind(wx.EVT_BUTTON, self.OnButton, b) b.Enable(False) sizer.Add(b) # This time, we let the botton be as big as it can be. # Also, this one is fancier, with custom colors and bezel size. b = buttons.GenButton(self, -1, 'bigger') self.Bind(wx.EVT_BUTTON, self.OnBiggerButton, b) b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False)) b.SetBezelWidth(5) ###b.SetBestSize() b.SetMinSize(wx.DefaultSize) b.SetBackgroundColour("Navy") b.SetForegroundColour(wx.WHITE) b.SetToolTipString("This is a BIG button...") # let the sizer set best size sizer.Add(b, flag=wx.ADJUST_MINSIZE) # An image button bmp = images.getTest2Bitmap() b = buttons.GenBitmapButton(self, -1, bmp) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) # An image button, disabled. bmp = images.getTest2Bitmap() b = buttons.GenBitmapButton(self, -1, bmp) self.Bind(wx.EVT_BUTTON, self.OnButton, b) sizer.Add(b) b.Enable(False) # An image button, using a mask to get rid of the # undesireable part of the image b = buttons.GenBitmapButton(self, -1, None) self.Bind(wx.EVT_BUTTON, self.OnButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetBestSize() sizer.Add(b) # A toggle button b = buttons.GenToggleButton(self, -1, "Toggle Button") self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b) sizer.Add(b) # An image toggle button b = buttons.GenBitmapToggleButton(self, -1, None) self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetToggle(True) b.SetBestSize() sizer.Add(b) # A bitmap button with text. b = buttons.GenBitmapTextButton(self, -1, None, "Bitmapped Text", size=(200, 45)) self.Bind(wx.EVT_BUTTON, self.OnButton, b) bmp = images.getBulb1Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapLabel(bmp) bmp = images.getBulb2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) b.SetBitmapSelected(bmp) b.SetUseFocusIndicator(False) b.SetBestSize() sizer.Add(b) border = wx.BoxSizer(wx.VERTICAL) border.Add(sizer, 0, wx.ALL, 25) self.SetSizer(border)
def __init__(self, parent, log, frame): ogl.ShapeCanvas.__init__(self, parent) maxWidth = 1000 maxHeight = 1000 self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20) self.log = log self.frame = frame self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE) self.diagram = ogl.Diagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.shapes = [] self.save_gdi = [] rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID) dsBrush = wx.Brush("WHEAT", wx.SOLID) self.MyAddShape( CompositeDivisionShape(self), 270, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division" ) self.MyAddShape( CompositeShape(self), 100, 260, wx.BLACK_PEN, wx.RED_BRUSH, "Composite" ) self.MyAddShape( ogl.CircleShape(80), 75, 110, wx.Pen(wx.BLUE, 3), wx.GREEN_BRUSH, "Circle" ) self.MyAddShape( ogl.TextShape(120, 45), 160, 35, wx.GREEN_PEN, wx.LIGHT_GREY_BRUSH, "OGL is now a\npure Python lib!" ) self.MyAddShape( ogl.RectangleShape(85, 50), 305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle" ) self.MyAddShape( DrawnShape(), 500, 80, wx.BLACK_PEN, wx.BLACK_BRUSH, "DrawnShape" ) ds = self.MyAddShape( DividedShape(140, 150, self), 520, 265, wx.BLACK_PEN, dsBrush, '' ) self.MyAddShape( DiamondShape(90, 90), 355, 260, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon" ) self.MyAddShape( RoundedRectangleShape(95, 70), 345, 145, wx.Pen(wx.RED, 2), rRectBrush, "Rounded Rect" ) bmp = images.getTest2Bitmap() mask = wx.Mask(bmp, wx.BLUE) bmp.SetMask(mask) s = ogl.BitmapShape() s.SetBitmap(bmp) self.MyAddShape(s, 225, 130, None, None, "Bitmap") dc = wx.ClientDC(self) self.PrepareDC(dc) for x in range(len(self.shapes)): fromShape = self.shapes[x] if x+1 == len(self.shapes): toShape = self.shapes[0] else: toShape = self.shapes[x+1] line = ogl.LineShape() line.SetCanvas(self) line.SetPen(wx.BLACK_PEN) line.SetBrush(wx.BLACK_BRUSH) line.AddArrow(ogl.ARROW_ARROW) line.MakeLineControlPoints(2) fromShape.AddLine(line, toShape) self.diagram.AddShape(line) line.Show(True)