def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(500, 300), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer self.oglcanvas = ogl.ShapeCanvas(self) sizer.Add(self.oglcanvas, 1, wx.GROW) self.oglcanvas.SetBackgroundColour("LIGHT BLUE") self.oglcanvas.Bind(wx.EVT_RIGHT_DOWN, self.OnRightButtonEvent) diagram = ogl.Diagram() self.oglcanvas.SetDiagram(diagram) diagram.SetCanvas(self.oglcanvas) shape = ogl.CircleShape(60.0) self.mycircle = shape shape.SetX(25.0) shape.SetY(25.0) self.oglcanvas.AddShape(shape) diagram.ShowAll(1) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1) self.Start()
def __init__(self, parent): wx.Frame.__init__( self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, ) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) bSizer9 = wx.BoxSizer(wx.VERTICAL) self.canvas = ogl.ShapeCanvas(self) diagram = ogl.Diagram() self.canvas.SetDiagram(diagram) diagram.SetCanvas(self.canvas) bSizer9.Add(self.canvas, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer(bSizer9) self.Layout() self.Centre(wx.BOTH)
def __init__(self, parent, _id=-1, pos=wx.DefaultPosition, size=wx.Size(250, 240), style=wx.TAB_TRAVERSAL | wx.NO_BORDER, name=wx.PanelNameStr): super(ShapePreviewPanel, self).__init__(parent, _id, pos, size, style, name) self.shape = None self.pen = wx.Pen(wx.BLACK) self.brush = wx.Brush(wx.BLACK) bSizer = wx.BoxSizer(wx.VERTICAL) self.diagram = ogl.ShapeCanvas(self) bSizer.Add(self.diagram, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) self.SetSizer(bSizer) self.Layout() # fix-ups for event handler self.diagram.Selection = [] self.diagram.SetDiagram(ogl.Diagram()) self.diagram.GetDiagram().SetCanvas(self.diagram) self.Bind(wx.EVT_SIZE, self.OnSize)
def _CreateCanvas(self, parent): self._canvas = ogl.ShapeCanvas(parent) wx.EVT_LEFT_DOWN(self._canvas, self.OnLeftClick) wx.EVT_LEFT_UP(self._canvas, self.OnLeftUp) wx.EVT_MOTION(self._canvas, self.OnLeftDrag) wx.EVT_LEFT_DCLICK(self._canvas, self.OnLeftDoubleClick) wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed) # need this otherwise mouse clicks don't set focus to this view wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus) wx.EVT_SET_FOCUS(self._canvas, self.OnFocus) self._canvas.SetScrollbars(20, 20, self._maxWidth / 20, self._maxHeight / 20) self._canvas.SetBackgroundColour(self._backgroundColor) self._diagram = ogl.Diagram() self._canvas.SetDiagram(self._diagram) self._diagram.SetCanvas(self._canvas) self._canvas.SetFont(NORMALFONT)
def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) def setpos(shape, x, y): width, height = shape.GetBoundingBoxMax() shape.SetX(x + width / 2) shape.SetY(y + height / 2) def getpos(shape): width, height = shape.GetBoundingBoxMax() x = shape.GetX() y = shape.GetY() return (x - width / 2, y - height / 2) shape = ogl.RectangleShape(60, 60) setpos(shape, 0, 0) canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) setpos(shape, 60, 0) canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) setpos(shape, 120, 0) canvas.AddShape(shape) # Next row shape = ogl.RectangleShape(100, 100) setpos(shape, 0, 60) canvas.AddShape(shape) shape = ogl.RectangleShape(100, 100) setpos(shape, 100, 60) canvas.AddShape(shape) print([getpos(shape) for shape in canvas.GetDiagram().GetShapeList()]) diagram.ShowAll(1) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1)
def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(700, 700), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) # shape = ogl.RectangleShape(60, 60) # shape.SetX(30) # shape.SetY(30) # print(shape.GetBoundingBoxMax()) # canvas.AddShape(shape) # shape = ogl.RectangleShape(60, 60) # shape.SetX(90) # shape.SetY(30) # canvas.AddShape(shape) # shape = ogl.RectangleShape(160, 160) # shape.SetX(250) # shape.SetY(130) # canvas.AddShape(shape) # diagram.ShowAll(1) # apply sizer # self.SetSizer(sizer) # self.SetAutoLayout(1) # self.Show(1) # def BootStrap(self): y = 0 # for x in range(0, 1200, 70): for x in range(0, 600, 70): shape = ogl.RectangleShape(60, 60) shape.AddText("%d,%d" % (x, y)) setpos(shape, x, y) diagram.AddShape(shape) y += 70 diagram.ShowAll(1) self.Show(1) canvas.Bind(wx.EVT_LEFT_DCLICK, self.OnXXX) self.diagram = diagram # remember self.canvas = canvas # remember if ASYNC: StartCoroutine(self.YYY, self)
def test_lib_oglCtor(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.RectangleShape(w=50, h=50) aShape.SetCanvas(osc) self.diagram.AddShape(aShape)
def test_lib_oglEllipseShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.EllipseShape(50, 50) aShape.SetCanvas(osc) self.diagram.AddShape(aShape)
def test_lib_oglTextShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.TextShape(50, 50) aShape.SetCanvas(osc) aShape.AddText("Some nice text here") self.diagram.AddShape(aShape)
def add_ogl_canvas(self): # Add OGL sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer self.canvas = canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) def setpos(shape, x, y): width, height = shape.GetBoundingBoxMax() shape.SetX(x + width / 2) shape.SetY(y + height / 2) def getpos(shape): width, height = shape.GetBoundingBoxMax() x = shape.GetX() y = shape.GetY() return (x - width / 2, y - height / 2) shape = ogl.RectangleShape(60, 60) setpos(shape, 0, 0) canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) setpos(shape, 60, 0) canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) setpos(shape, 120, 0) canvas.AddShape(shape) # Next row shape = ogl.RectangleShape(100, 100) setpos(shape, 0, 60) canvas.AddShape(shape) shape = ogl.RectangleShape(100, 100) setpos(shape, 100, 60) canvas.AddShape(shape) print[getpos(shape) for shape in canvas.GetDiagram().GetShapeList()] diagram.ShowAll(1) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1)
def test_lib_oglShapeRegion(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.RectangleShape(w=50, h=50) aShape.SetCanvas(osc) self.diagram.AddShape(aShape) region1 = ogl.ShapeRegion() region1.SetText('DividedShape') region1.SetProportions(0.0, 0.2) region1.SetFormatMode(ogl.FORMAT_CENTRE_HORIZ) aShape.AddRegion(region1)
def test_lib_oglDivisonShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.CompositeShape() aShape.SetCanvas(osc) self.diagram.AddShape(aShape) # create a division in the composite aShape.MakeContainer() # add a shape to the original division shape2 = ogl.RectangleShape(40, 60) aShape.GetDivisions()[0].AddChild(shape2)
def __init__(self, parent, clases=None): '''Constructor de clase''' # Creamos el frame contenedor. wx.Panel.__init__(self, parent) # El sizer que contendrá todo. sizer = wx.BoxSizer(wx.VERTICAL) # Creamos el canvas. self.canvas = ogl.ShapeCanvas(self) # Y lo metemos en el sizer, claro. sizer.Add(self.canvas, 1, wx.GROW) # Le damos un color de fondo al canvas. self.canvas.SetBackgroundColour("WHITE") # Definimos el ancho y alto máximo del shapecanvas, con barras # de desplazamiento. ancho_maximo = proy_por_defecto['ogl_ancho_maximo'] alto_maximo = proy_por_defecto['ogl_alto_maximo'] self.canvas.SetScrollbars(20, 20, ancho_maximo / 20, alto_maximo / 20) # Añadimos al sizer. self.SetSizer(sizer)
def test_lib_oglPolygonShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.PolygonShape() w, h = 60, 60 points = [ (0.0, -h / 2.0), (w / 2.0, 0.0), (0.0, h / 2.0), (-w / 2.0, 0.0), ] aShape.Create(points) aShape.SetCanvas(osc) self.diagram.AddShape(aShape)
def __init__(self, parent, tilesize=32): wx.Panel.__init__(self, parent, -1) self.sizer = wx.BoxSizer(wx.HORIZONTAL) if not TilingWindow.oglInitialized: ogl.OGLInitialize() TilingWindow.oglInitialized = True self.tileset = None self.mapWindow = ogl.ShapeCanvas(self, -1, (400, 400)) self.sizer.Add(self.mapWindow, True, wx.EXPAND) self.map = ogl.Diagram() self.map.SetCanvas(self.mapWindow) self.mapWindow.SetDiagram(self.map) self.area = None self.tilelist = None self.mapWindow.SetBackgroundColour("LIGHT BLUE") self.map.SetGridSpacing(tilesize) self.map.SetSnapToGrid(True) self.map.ShowAll(True) self.vertSizer = wx.BoxSizer(wx.VERTICAL) self.tileListCtrl = wx.ListCtrl(self, style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL) self.vertSizer.Add(self.tileListCtrl, True, wx.EXPAND) self.modelWindow = ModelWindow(self) self.modelWindow.SetSize((150, 150)) self.vertSizer.Add(self.modelWindow, False, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) self.sizer.Add(self.vertSizer, False, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(self.sizer) self.sizer.Fit(self) self.Layout() self.Update() self.tilesize = tilesize self.tileshapes = [] self.tileImageList = wx.ImageList(self.tilesize, self.tilesize) self.tileImageMap = {} self.tilelist = []
def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) shape = ogl.RectangleShape(60, 60) shape.SetX(30) shape.SetY(30) print shape.GetBoundingBoxMax() canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) shape.SetX(90) shape.SetY(30) canvas.AddShape(shape) shape = ogl.RectangleShape(60, 60) shape.SetX(150) shape.SetY(30) canvas.AddShape(shape) diagram.ShowAll(1) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1)
def test_lib_oglLineShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) fromShape = ogl.RectangleShape(w=50, h=50) fromShape.SetCanvas(osc) self.diagram.AddShape(fromShape) toShape = ogl.RectangleShape(w=50, h=50) toShape.SetCanvas(osc) self.diagram.AddShape(toShape) lShape = ogl.LineShape() lShape.SetCanvas(osc) lShape.MakeLineControlPoints(2) fromShape.AddLine(lShape, toShape) self.diagram.AddShape(lShape) lShape.Show(True)
def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) shape = ogl.CircleShape(20.0) # shape.SetX(25.0) # shape.SetY(25.0) # canvas.AddShape(shape) # diagram.ShowAll(1) # # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1) # test TextEntryDialog dlg = wx.TextEntryDialog( self, 'What is your favorite programming language?', 'Eh??', 'Python') dlg.SetValue("Python is the best!") if dlg.ShowModal() == wx.ID_OK: print('You entered: %s\n' % dlg.GetValue()) dlg.Destroy()
def test_lib_oglCompositeShape(self): ogl.OGLInitialize() osc = ogl.ShapeCanvas(self.frame) self.diagram = ogl.Diagram() osc.SetDiagram(self.diagram) self.diagram.SetCanvas(osc) aShape = ogl.CompositeShape() aShape.SetCanvas(osc) self.diagram.AddShape(aShape) constraining_shape = ogl.RectangleShape(120, 100) constrained_shape1 = ogl.CircleShape(50) constrained_shape2 = ogl.RectangleShape(80, 20) aShape.AddChild(constraining_shape) aShape.AddChild(constrained_shape1) aShape.AddChild(constrained_shape2) constraint = ogl.Constraint(ogl.CONSTRAINT_MIDALIGNED_BOTTOM, constraining_shape, [constrained_shape1, constrained_shape2]) aShape.AddConstraint(constraint) aShape.Recompute()
def __init__(self, parent): wx.Frame.__init__( self, parent, id=wx.ID_ANY, title="PyIdea UML", pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, ) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) self.m_mgr = wx.aui.AuiManager() self.m_mgr.SetManagedWindow(self) self.m_code = PythonSTC(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.WANTS_CHARS) self.m_mgr.AddPane( self.m_code, wx.aui.AuiPaneInfo().Name("pane_code").Right().Caption( "Source Code").MaximizeButton(False).MinimizeButton( False).PinButton(True).Dock().Resizable().FloatingSize( wx.DefaultSize).DockFixed(False), ) self.m_menubar4 = wx.MenuBar(0) self.m_menu2 = wx.Menu() self.m_menuItem15 = wx.MenuItem( self.m_menu2, wx.ID_ANY, "Import Python Source..." + "\t" + "Ctrl+I", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu2.AppendItem(self.m_menuItem15) self.m_menu2.AppendSeparator() self.m_menuItem16 = wx.MenuItem(self.m_menu2, wx.ID_ANY, "New" + "\t" + "Ctrl+N", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.AppendItem(self.m_menuItem16) self.m_menuItem17 = wx.MenuItem(self.m_menu2, wx.ID_ANY, "Open..." + "\t" + "Ctrl-O", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.AppendItem(self.m_menuItem17) self.m_menuItem18 = wx.MenuItem(self.m_menu2, wx.ID_ANY, "Save" + "\t" + "Ctrl-S", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.AppendItem(self.m_menuItem18) self.m_menuItem21 = wx.MenuItem(self.m_menu2, wx.ID_ANY, "Save As...", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.AppendItem(self.m_menuItem21) self.m_menu2.AppendSeparator() self.m_menuItem20 = wx.MenuItem( self.m_menu2, wx.ID_ANY, "Print / Print Preview..." + "\t" + "Ctrl-P", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu2.AppendItem(self.m_menuItem20) self.m_menu2.AppendSeparator() self.m_menuItem19 = wx.MenuItem(self.m_menu2, wx.ID_ANY, "Exit" + "\t" + "Alt+F4", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu2.AppendItem(self.m_menuItem19) self.m_menubar4.Append(self.m_menu2, "File") self.m_menu6 = wx.Menu() self.m_menuItem26 = wx.MenuItem( self.m_menu6, wx.ID_ANY, "Add Class..." + "\t" + "Ctrl+Ins", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu6.AppendItem(self.m_menuItem26) self.m_menuItem14 = wx.MenuItem( self.m_menu6, wx.ID_ANY, "Delete Class" + "\t" + "Ctrl+Del", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu6.AppendItem(self.m_menuItem14) self.m_menu6.AppendSeparator() self.m_menuItem29 = wx.MenuItem( self.m_menu6, wx.ID_ANY, "Class Properties..." + "\t" + "Ctrl+T", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu6.AppendItem(self.m_menuItem29) self.m_menuItem28 = wx.MenuItem( self.m_menu6, wx.ID_ANY, "Class Source Code..." + "\t" + "Ctrl+E", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu6.AppendItem(self.m_menuItem28) self.m_menubar4.Append(self.m_menu6, "Edit") self.m_menu7 = wx.Menu() self.m_menuItem81 = wx.MenuItem(self.m_menu7, wx.ID_ANY, "Layout" + "\t" + "Ctrl+L", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu7.AppendItem(self.m_menuItem81) self.m_menuItem35 = wx.MenuItem(self.m_menu7, wx.ID_ANY, "Layout Optimal (slower)", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu7.AppendItem(self.m_menuItem35) self.m_menu7.AppendSeparator() self.m_menuItem31 = wx.MenuItem( self.m_menu7, wx.ID_ANY, "Decrease Node Spread" + "\t" + "Ctrl+1", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu7.AppendItem(self.m_menuItem31) self.m_menuItem30 = wx.MenuItem( self.m_menu7, wx.ID_ANY, "Increase Node Spread" + "\t" + "Ctrl+2", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu7.AppendItem(self.m_menuItem30) self.m_menu7.AppendSeparator() self.m_menuItem24 = wx.MenuItem(self.m_menu7, wx.ID_ANY, "UML", wx.EmptyString, wx.ITEM_CHECK) self.m_menu7.AppendItem(self.m_menuItem24) self.m_menuItem24.Enable(False) self.m_menuItem24.Check(True) self.m_menuItem22 = wx.MenuItem(self.m_menu7, wx.ID_ANY, "Ascii Art Uml", wx.EmptyString, wx.ITEM_CHECK) self.m_menu7.AppendItem(self.m_menuItem22) self.m_menuItem23 = wx.MenuItem(self.m_menu7, wx.ID_ANY, "yUml", wx.EmptyString, wx.ITEM_CHECK) self.m_menu7.AppendItem(self.m_menuItem23) self.m_menu7.AppendSeparator() self.m_menuItem7 = wx.MenuItem( self.m_menu7, wx.ID_ANY, "Redraw Screen" + "\t" + "Ctrl+R", wx.EmptyString, wx.ITEM_NORMAL, ) self.m_menu7.AppendItem(self.m_menuItem7) self.m_menubar4.Append(self.m_menu7, "View") self.m_menu8 = wx.Menu() self.m_menuItem9 = wx.MenuItem(self.m_menu8, wx.ID_ANY, "Help..." + "\t" + "F1", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu8.AppendItem(self.m_menuItem9) self.m_menuItem11 = wx.MenuItem(self.m_menu8, wx.ID_ANY, "Visit PyNSource Website...", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu8.AppendItem(self.m_menuItem11) self.m_menu8.AppendSeparator() self.m_menuItem12 = wx.MenuItem(self.m_menu8, wx.ID_ANY, "Check for Updates...", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu8.AppendItem(self.m_menuItem12) self.m_menuItem13 = wx.MenuItem(self.m_menu8, wx.ID_ANY, "About...", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu8.AppendItem(self.m_menuItem13) self.m_menubar4.Append(self.m_menu8, "Help") self.m_menu5 = wx.Menu() self.m_menuItem8 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Show Pane", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem8) self.m_menuItem2 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Add Pane", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem2) self.m_menuItem6 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Add Pane (float)", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem6) self.m_menuItem3 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Fold1", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem3) self.m_menuItem4 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Fold All", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem4) self.m_menuItem5 = wx.MenuItem(self.m_menu5, wx.ID_ANY, "Hier", wx.EmptyString, wx.ITEM_NORMAL) self.m_menu5.AppendItem(self.m_menuItem5) self.m_menubar4.Append(self.m_menu5, "Debug") self.SetMenuBar(self.m_menubar4) self.m_statusBar1 = self.CreateStatusBar(1, wx.ST_SIZEGRIP, wx.ID_ANY) self.canvas = ogl.ShapeCanvas(self) diagram = ogl.Diagram() self.canvas.SetDiagram(diagram) diagram.SetCanvas(self.canvas) self.m_mgr.AddPane( self.canvas, wx.aui.AuiPaneInfo().Left().Caption("UML").MaximizeButton( False).MinimizeButton(False).PinButton( True).Dock().Resizable().FloatingSize( wx.DefaultSize).DockFixed(False).CentrePane(), ) self.m_auiToolBar2 = wx.aui.AuiToolBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.aui.AUI_TB_HORZ_LAYOUT) self.m_auiToolBar2.AddTool( wx.ID_ANY, "sssddddd", wx.Bitmap("icons22/kcmscsi.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, "ssss", wx.EmptyString, None, ) self.m_auiToolBar2.AddTool( wx.ID_ANY, "tool", wx.Bitmap("icons22/kmoon.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, wx.EmptyString, wx.EmptyString, None, ) self.m_auiToolBar2.AddTool( wx.ID_ANY, "tool", wx.Bitmap("icons22/kalzium.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, wx.EmptyString, wx.EmptyString, None, ) self.m_auiToolBar2.AddSeparator() self.m_auiToolBar2.AddTool( wx.ID_ANY, "tool", wx.Bitmap("icons22/kedit.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, wx.EmptyString, wx.EmptyString, None, ) self.m_auiToolBar2.AddTool( wx.ID_ANY, "tool", wx.Bitmap("icons22/kcmprocessor.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, wx.EmptyString, wx.EmptyString, None, ) self.m_auiToolBar2.AddTool( wx.ID_ANY, "tool", wx.Bitmap("icons22/kcmmidi.png", wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL, wx.EmptyString, wx.EmptyString, None, ) self.m_auiToolBar2.Realize() self.m_mgr.AddPane( self.m_auiToolBar2, wx.aui.AuiPaneInfo().Top().CaptionVisible(False).CloseButton( False).MaximizeButton(False).MinimizeButton(False).PinButton( False).PaneBorder(False).Movable(False).Dock().Fixed(). DockFixed(False).Floatable(False).Layer(1), ) self.m_mgr.Update() self.Centre(wx.BOTH) # Connect Events self.Bind(wx.EVT_MENU, self.OnShowPane, id=self.m_menuItem8.GetId()) self.Bind(wx.EVT_MENU, self.OnAddPane, id=self.m_menuItem2.GetId()) self.Bind(wx.EVT_MENU, self.OnAddPaneFloat, id=self.m_menuItem6.GetId()) self.Bind(wx.EVT_MENU, self.OnFold1, id=self.m_menuItem3.GetId()) self.Bind(wx.EVT_MENU, self.OnFoldAll, id=self.m_menuItem4.GetId()) self.Bind(wx.EVT_MENU, self.OnHier, id=self.m_menuItem5.GetId())
def __init__(self): wx.Frame.__init__(self, None, -1, "Demo", size=(500, 400), style=wx.DEFAULT_FRAME_STYLE) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer canvas = ogl.ShapeCanvas(self) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("LIGHT BLUE") # diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) def setpos(shape, x, y): width, height = shape.GetBoundingBoxMax() shape.SetX(x + width / 2) shape.SetY(y + height / 2) def getpos(shape): width, height = shape.GetBoundingBoxMax() x = shape.GetX() y = shape.GetY() return (x - width / 2, y - height / 2) shape = ogl.RectangleShape(60, 60) setpos(shape, 0, 0) canvas.AddShape(shape) shape = ogl.RectangleShape(160, 60) shape.SetTextColour('RED') setpos(shape, 160, 50) canvas.AddShape(shape) shape.AddText("Hello there") print[getpos(shape) for shape in canvas.GetDiagram().GetShapeList()] F = 'img_uml01.png' # wx.ImageFromBitmap(bitmap) and wx.BitmapFromImage(image) shape = ogl.BitmapShape() img = wx.Image(F, wx.BITMAP_TYPE_ANY) bmp = wx.BitmapFromImage(img) shape.SetBitmap(bmp) setpos(shape, 100, 260) canvas.AddShape(shape) shape = DiamondShape() setpos(shape, 10, 260) canvas.AddShape(shape) shape = Andy1Shape(100, 40) setpos(shape, 11, 111) canvas.AddShape(shape) shape = ogl.EllipseShape(120, 70) setpos(shape, 81, 150) shape.SetBrush(wx.Brush("WHEAT", wx.TRANSPARENT)) shape.AddText("<<Pattern>>") shape.AddText("Observer") shape.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1, wx.DOT)) canvas.AddShape(shape) diagram.ShowAll(1) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1)
def __init__(self): wx.Frame.__init__(self, None, -1, self.title, size=(640, 480), style=wx.DEFAULT_FRAME_STYLE) sys.excepthook = self.except_hook self.filename = "" # Create a toolbar: tsize = (16, 16) self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT) artBmp = wx.ArtProvider.GetBitmap self.toolbar.AddSimpleTool(wx.ID_NEW, artBmp(wx.ART_NEW, wx.ART_TOOLBAR, tsize), "New") self.toolbar.AddSimpleTool( wx.ID_OPEN, artBmp(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize), "Open") self.toolbar.AddSimpleTool( wx.ID_SAVE, artBmp(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, tsize), "Save") self.toolbar.AddSimpleTool( wx.ID_SAVEAS, artBmp(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, tsize), "Save As...") #------- self.toolbar.AddSeparator() self.toolbar.AddSimpleTool(wx.ID_UNDO, artBmp(wx.ART_UNDO, wx.ART_TOOLBAR, tsize), "Undo") self.toolbar.AddSimpleTool(wx.ID_REDO, artBmp(wx.ART_REDO, wx.ART_TOOLBAR, tsize), "Redo") self.toolbar.AddSeparator() #------- self.toolbar.AddSimpleTool(wx.ID_CUT, artBmp(wx.ART_CUT, wx.ART_TOOLBAR, tsize), "Remove") self.toolbar.AddSimpleTool(wx.ID_COPY, artBmp(wx.ART_COPY, wx.ART_TOOLBAR, tsize), "Duplicate") self.toolbar.AddSimpleTool(wx.ID_PASTE, artBmp(wx.ART_PASTE, wx.ART_TOOLBAR, tsize), "Insert") self.toolbar.AddSeparator() self.toolbar.AddSimpleTool(wx.ID_FIND, artBmp(wx.ART_FIND, wx.ART_TOOLBAR, tsize), "Find") self.toolbar.AddSimpleTool( wx.ID_REPLACE, artBmp(wx.ART_FIND_AND_REPLACE, wx.ART_TOOLBAR, tsize), "Modify") self.toolbar.AddSeparator() self.toolbar.AddSimpleTool(wx.ID_PRINT, artBmp(wx.ART_PRINT, wx.ART_TOOLBAR, tsize), "Print") self.toolbar.AddSimpleTool(wx.ID_ABOUT, artBmp(wx.ART_HELP, wx.ART_TOOLBAR, tsize), "About") self.toolbar.Realize() self.toolbar.EnableTool(wx.ID_SAVEAS, False) self.toolbar.EnableTool(wx.ID_UNDO, False) self.toolbar.EnableTool(wx.ID_REDO, False) menu_handlers = [ (wx.ID_NEW, self.do_new), (wx.ID_OPEN, self.do_open), (wx.ID_SAVE, self.do_save), (wx.ID_PRINT, self.do_print), (wx.ID_FIND, self.do_find), (wx.ID_REPLACE, self.do_modify), (wx.ID_CUT, self.do_cut), (wx.ID_COPY, self.do_copy), (wx.ID_PASTE, self.do_paste), (wx.ID_ABOUT, self.do_about), ] for menu_id, handler in menu_handlers: self.Bind(wx.EVT_MENU, handler, id=menu_id) sizer = wx.BoxSizer(wx.VERTICAL) # put stuff into sizer self.CreateStatusBar() canvas = self.canvas = ogl.ShapeCanvas(self) maxWidth = 2000 maxHeight = 2000 canvas.SetScrollbars(20, 20, maxWidth / 20, maxHeight / 20) sizer.Add(canvas, 1, wx.GROW) canvas.SetBackgroundColour("WHITE") # diagram = self.diagram = ogl.Diagram() canvas.SetDiagram(diagram) diagram.SetCanvas(canvas) diagram.SetSnapToGrid(False) # apply sizer self.SetSizer(sizer) self.SetAutoLayout(1) self.Show(1) self.Bind(wx.EVT_CHAR_HOOK, self.on_key_event) self.elements = []
def __init__(self, parent): wx.Frame.__init__(self, parent, title="Maciej Borzyszkowski 165407") # ogl.OGLInitialize() self.controller = None self.pref_size_w = 800 self.pref_size_h = 600 self.sideMapLenght = 20 self.beforeStart = True self.saveFileName = "saveWorld.pck" self.worldMap = None self.panel = wx.Panel(self, wx.ID_ANY) self.logger = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY, size=(270, 400)) self.canvas = ogl.ShapeCanvas(self.panel) self.canvas.SetBackgroundColour("white") self.diagram = ogl.Diagram() self.canvas.SetDiagram(self.diagram) self.diagram.SetCanvas(self.canvas) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown) glownySizer = wx.BoxSizer(wx.VERTICAL) outputSizer = wx.BoxSizer(wx.HORIZONTAL) outStaticBoxSizer = wx.BoxSizer(wx.VERTICAL) drawBoxSizer = wx.BoxSizer(wx.VERTICAL) labelSizer = wx.BoxSizer(wx.HORIZONTAL) buttonSizer = wx.BoxSizer(wx.HORIZONTAL) glownySizer.AddStretchSpacer(1) outputSizer.AddStretchSpacer(1) labelSizer.AddStretchSpacer(1) drawBoxSizer.Add(self.canvas, proportion=1, flag=wx.EXPAND | wx.GROW) outputSizer.Add(drawBoxSizer, proportion=60, flag=wx.EXPAND | wx.ALIGN_LEFT | wx.ALIGN_TOP) outStaticBoxSizer.Add(self.logger, proportion=1, flag=wx.EXPAND | wx.ALIGN_TOP) outputSizer.Add(outStaticBoxSizer, proportion=30, flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.ALIGN_TOP) outputSizer.AddStretchSpacer(1) self.nextTurn = wx.Button(self.panel, -1, "Start") self.nextTurn.Bind(wx.EVT_BUTTON, self.nextTurnOnClicked) self.saveBtn = wx.Button(self.panel, -1, "Save") self.saveBtn.Bind(wx.EVT_BUTTON, self.saveOnClick) self.loadBtn = wx.Button(self.panel, -1, "Load") self.loadBtn.Bind(wx.EVT_BUTTON, self.loadOnClick) self.humanAbilityBtn = wx.Button(self.panel, -1, "Human ability: 0") self.humanAbilityBtn.Bind(wx.EVT_BUTTON, self.humanAbilityClick) self.labelOrgStatus = wx.StaticText(self.panel, wx.ID_ANY, 'Info:') self.labelHumanStatus = wx.StaticText(self.panel, wx.ID_ANY, 'Human status: Start') self.labelTurnNum = wx.StaticText(self.panel, wx.ID_ANY, 'Turn number: 0') buttonSizer.Add(self.nextTurn, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.Add(self.saveBtn, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.Add(self.loadBtn, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.Add(self.humanAbilityBtn, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.AddStretchSpacer(1) buttonSizer.Add(self.labelHumanStatus, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.AddStretchSpacer(1) buttonSizer.Add(self.labelTurnNum, proportion=0, flag=wx.ALL | wx.ALIGN_LEFT) buttonSizer.AddStretchSpacer(5) labelSizer.Add(self.labelOrgStatus, proportion=0, flag=wx.ALL | wx.EXPAND | wx.ALIGN_LEFT) labelSizer.AddStretchSpacer(10) glownySizer.Add(outputSizer, proportion=70, flag=wx.ALL | wx.EXPAND) glownySizer.AddStretchSpacer(1) glownySizer.Add(labelSizer, proportion=10, flag=wx.ALL | wx.EXPAND | wx.ALIGN_LEFT) glownySizer.Add(buttonSizer, proportion=10, flag=wx.ALL | wx.EXPAND) self.panel.SetSizer(glownySizer) glownySizer.Fit(self) self.panel.Bind(wx.EVT_CHAR_HOOK, self.onKeyPress) self.Centre() self.Show(1)