Python wx.lib() Examples

The following are 26 code examples of wx.lib(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def SetPen(self, LineColor, LineStyle, LineWidth):
        """
        Set the Pen for this DrawObject
        
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid entries
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
         for valid entries
        :param integer `LineWidth`: the width in pixels 
        """
        if (LineColor is None) or (LineStyle is None):
            self.Pen = wx.TRANSPARENT_PEN
            self.LineStyle = 'Transparent'
        else:
            self.Pen = self.PenList.setdefault(
                (LineColor, LineStyle, LineWidth),
                wx.Pen(LineColor, LineWidth, self.LineStyleList[LineStyle])) 
Example #2
Source File: mounting.py    From kicad_mmccoo with Apache License 2.0 6 votes vote down vote up
def OnOKCB(self):
        self.SetValue()
        if (self.configname != None):
            save_config.SaveConfigComplex(self.configname, self.value)



# dlg = MountingDialog(configname = "mountingmap")
# res = dlg.ShowModal()

# print("lib {} footprint {}".format(dlg.value))

# print("nets {}".format(dlg.nets.value))
# print("mods {}".format(dlg.mods.value))
# #print("file {}".format(dlg.file_picker.filename))
# #print("basic layer {}".format(dlg.basic_layer.value))
# if res == wx.ID_OK:
#     print("ok")
# else:
#     print("cancel") 
Example #3
Source File: mounting.py    From kicad_mmccoo with Apache License 2.0 6 votes vote down vote up
def AddOption(self, size, lib, foot):

        s = wx.SpinCtrlDouble(self.grid, value=str(size), inc=0.1)
        self.gridSizer.Add(s)

        print("lib {} foot {}".format(lib, foot))
        l = wx.StaticText(self.grid, label=lib)
        self.gridSizer.Add(l, proportion=1)

        f = wx.StaticText(self.grid, label=foot)
        self.gridSizer.Add(f, proportion=1)

        b = wx.Button(self.grid, label="remove")
        self.gridSizer.Add(b)
        b.Bind(wx.EVT_BUTTON, self.OnRemove)

        self.therows[b.GetId()] = (s,l,f,b) 
Example #4
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, Point, Color="Black", Size=4, InForeground=False):
        """
        Default class constructor.
        
        :param `Point`: takes a 2-tuple, or a (2,)
         `NumPy <http://www.numpy.org/>`_ array of point coordinates
        :param `Color`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param integer `Size`: the size of the square point
        :param boolean `InForeground`: should object be in foreground
        
        """
        DrawObject.__init__(self, InForeground)

        self.XY = N.array(Point, N.float)
        self.XY.shape = (2,) # Make sure it is a length 2 vector
        self.CalcBoundingBox()
        self.SetColor(Color)
        self.Size = Size

        self.HitLineWidth = self.MinHitLineWidth 
Example #5
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, Points, Color="Black", Diameter=1, InForeground=False):
        """
        Default class constructor.
        
        :param `Points`: takes a 2-tuple, or a (2,)
         `NumPy <http://www.numpy.org/>`_ array of point coordinates
        :param `Color`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param integer `Diameter`: the points diameter
        :param boolean `InForeground`: should object be in foreground
        
        """
        DrawObject.__init__(self, InForeground)

        self.Points = N.array(Points,N.float)
        self.Points.shape = (-1,2) # Make sure it is a NX2 array, even if there is only one point
        self.CalcBoundingBox()
        self.Diameter = Diameter

        self.HitLineWidth = min(self.MinHitLineWidth, Diameter)
        self.SetColor(Color) 
Example #6
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def SetBrush(self, FillColor, FillStyle):
        """
        Set the brush for this DrawObject
        
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid entries
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
         for valid entries
        """
        if FillColor is None or FillStyle is None:
            self.Brush = wx.TRANSPARENT_BRUSH
            ##fixme: should I really re-set the style?
            self.FillStyle = "Transparent"
        else:
            self.Brush = self.BrushList.setdefault(
                (FillColor, FillStyle),
                wx.Brush(FillColor, self.FillStyleList[FillStyle]))
            #print("Setting Brush, BrushList length:", len(self.BrushList)) 
Example #7
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetHitPen(self, HitColor, LineWidth):
        """
        Set the pen used for hit test, do not call directly.
        
        :param `HitColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param integer `LineWidth`: the line width in pixels
        
        """
        if not self.HitLine:
            self.HitPen = wx.TRANSPARENT_PEN
        else:
            self.HitPen = self.PenList.setdefault( (HitColor, "solid", self.HitLineWidth),  wx.Pen(HitColor, self.HitLineWidth, self.LineStyleList["Solid"]) )

    ## Just to make sure that they will always be there
    ##   the appropriate ones should be overridden in the subclasses 
Example #8
Source File: mounting.py    From kicad_mmccoo with Apache License 2.0 5 votes vote down vote up
def SetValue(self):
        self.value = {}
        for id in self.therows:
            row = self.therows[id]
            size = row[0].GetValue()
            lib  = row[1].GetLabel()
            foot = row[2].GetLabel()
            self.value[str(size)] = (lib, foot) 
Example #9
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetHitBrush(self, HitColor):
        """
        Set the brush used for hit test, do not call directly.
        
        :param `HitColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        
        """
        if not self.HitFill:
            self.HitBrush = wx.TRANSPARENT_BRUSH
        else:
            self.HitBrush = self.BrushList.setdefault(
                (HitColor,"solid"),
                wx.Brush(HitColor, self.FillStyleList["Solid"])) 
Example #10
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetFillStyle(self, FillStyle):
        """
        Set the FillStyle
        
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
         for valid values
         
        """
        for o in self.ObjectList:
            o.SetFillStyle(FillStyle) 
Example #11
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetFillColor(self, Color):
        """
        Set the FillColor
        
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        for o in self.ObjectList:
            o.SetFillColor(Color) 
Example #12
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetLineColor(self, Color):
        """
        Set the LineColor
        
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        for o in self.ObjectList:
            o.SetLineColor(Color) 
Example #13
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetColor(self, Color):
        """
        Set the Color
        
        :param `Color`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        for o in self.ObjectList:
            o.SetColor(Color) 
Example #14
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, XY, Diameter, 
                 LineColor = "Black",
                 LineStyle = "Solid",
                 LineWidth    = 1,
                 FillColor    = None,
                 FillStyle    = "Solid",
                 InForeground = False):
        """
        Default class constructor.
        
        :param `XY`: the (x, y) coordinate of the center of the circle, or a 2-tuple,
         or a (2,) `NumPy <http://www.numpy.org/>`_ array
        :param integer `Diameter`: the diameter for the object
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
        :param `LineWidth`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineWidth`
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
        :param boolean `InForeground`: should object be in foreground
        
        """
        DrawObject.__init__(self, InForeground)

        self.XY = N.array(XY, N.float)
        self.WH = N.array((Diameter/2, Diameter/2), N.float) # just to keep it compatible with others
        self.CalcBoundingBox()

        self.LineColor = LineColor
        self.LineStyle = LineStyle
        self.LineWidth = LineWidth
        self.FillColor = FillColor
        self.FillStyle = FillStyle

        self.HitLineWidth = max(LineWidth,self.MinHitLineWidth)

        # these define the behaviour when zooming makes the objects really small.
        self.MinSize = 1
        self.DisappearWhenSmall = True

        self.SetPen(LineColor,LineStyle,LineWidth)
        self.SetBrush(FillColor,FillStyle) 
Example #15
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, XY, WH,
                 LineColor = "Black",
                 LineStyle = "Solid",
                 LineWidth    = 1,
                 FillColor    = None,
                 FillStyle    = "Solid",
                 InForeground = False):
        """
        Default class constructor.
        
        :param `XY`: the (x, y) coordinate of the corner of RectEllipse, or a 2-tuple,
         or a (2,) `NumPy <http://www.numpy.org/>`_ array
        :param `WH`: a tuple with the Width and Height for the object
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
        :param `LineWidth`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineWidth`
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
        :param `InForeground`: put object in foreground
        
        """

        DrawObject.__init__(self,InForeground)

        self.SetShape(XY, WH)
        self.LineColor = LineColor
        self.LineStyle = LineStyle
        self.LineWidth = LineWidth
        self.FillColor = FillColor
        self.FillStyle = FillStyle

        self.HitLineWidth = max(LineWidth,self.MinHitLineWidth)

        # these define the behaviour when zooming makes the objects really small.
        self.MinSize = 1
        self.DisappearWhenSmall = True

        self.SetPen(LineColor,LineStyle,LineWidth)
        self.SetBrush(FillColor,FillStyle) 
Example #16
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetColor(self, Color):
        """
        Set the Color
        
        :param `Color`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        self.SetPen(Color,"Solid",1)
        self.SetBrush(Color,"Solid") 
Example #17
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetLineColor(self, LineColor):
        """
        Set the LineColor - this method is overridden in the subclasses
        
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        pass 
Example #18
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 Points,
                 LineColor = "Black",
                 LineStyle = "Solid",
                 LineWidth    = 1,
                 ArrowHeadSize = 8,
                 ArrowHeadAngle = 30,
                 InForeground = False):
        """
        Default class constructor.

        :param `Points`: takes a 2-tuple, or a (2,)
         `NumPy <http://www.numpy.org/>`_ array of point coordinates
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
        :param `LineWidth`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineWidth`
        :param `ArrowHeadSize`: size of arrow head in pixels
        :param `ArrowHeadAngle`: angle of arrow head in degrees
        :param boolean `InForeground`: should object be in foreground
        
        """

        DrawObject.__init__(self, InForeground)

        self.Points = N.asarray(Points,N.float)
        self.Points.shape = (-1,2) # Make sure it is a NX2 array, even if there is only one point
        self.ArrowHeadSize = ArrowHeadSize
        self.ArrowHeadAngle = float(ArrowHeadAngle)

        self.CalcArrowPoints()
        self.CalcBoundingBox()

        self.LineColor = LineColor
        self.LineStyle = LineStyle
        self.LineWidth = LineWidth

        self.SetPen(LineColor,LineStyle,LineWidth)

        self.HitLineWidth = max(LineWidth,self.MinHitLineWidth) 
Example #19
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        """
        Default class constructor.
        
        see :class:`~lib.floatcanvas.FloatCanvas.Line`
        
        """
        Line.__init__(self, *args, **kwargs) 
Example #20
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, Points,
                 LineColor = "Black",
                 LineStyle = "Solid",
                 LineWidth    = 1,
                 InForeground = False):
        """
        Default class constructor.
        
        :param `Points`: takes a 2-tuple, or a (2,)
         `NumPy <http://www.numpy.org/>`_ array of point coordinates
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
        :param `LineWidth`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineWidth`
        :param boolean `InForeground`: should object be in foreground
        
        """
        DrawObject.__init__(self, InForeground)


        self.Points = N.array(Points,N.float)
        self.CalcBoundingBox()

        self.LineColor = LineColor
        self.LineStyle = LineStyle
        self.LineWidth = LineWidth

        self.SetPen(LineColor,LineStyle,LineWidth)

        self.HitLineWidth = max(LineWidth,self.MinHitLineWidth) 
Example #21
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetFillStyle(self, FillStyle):
        """
        Set the FillStyle
        
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
         for valid values
         
        """
        self.FillStyle = FillStyle
        self.SetBrush(self.FillColor,FillStyle) 
Example #22
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetFillColor(self, FillColor):
        """
        Set the FillColor
        
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        self.FillColor = FillColor
        self.SetBrush(FillColor, self.FillStyle) 
Example #23
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetLineStyle(self, LineStyle):
        """
        Set the LineStyle
        
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
         for valid values
         
        """
        self.LineStyle = LineStyle
        self.SetPen(self.LineColor,LineStyle,self.LineWidth) 
Example #24
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetLineColor(self, LineColor):
        """
        Set the LineColor
        
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid values
         
        """
        self.LineColor = LineColor
        self.SetPen(LineColor,self.LineStyle,self.LineWidth) 
Example #25
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self,
                 XY,
                 Length,
                 Direction,
                 LineColor = "Black",
                 LineStyle = "Solid",
                 LineWidth    = 2,
                 ArrowHeadSize = 8,
                 ArrowHeadAngle = 30,
                 InForeground = False):
        """
        Default class constructor.

        :param `XY`: the (x, y) coordinate of the starting point, or a 2-tuple,
         or a (2,) `NumPy <http://www.numpy.org/>`_ array
        :param integer `Length`: length of arrow in pixels
        :param integer `Direction`: angle of arrow in degrees, zero is straight
          up `+` angle is to the right
        :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle`
        :param `LineWidth`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineWidth`
        :param `ArrowHeadSize`: size of arrow head in pixels
        :param `ArrowHeadAngle`: angle of arrow head in degrees
        :param boolean `InForeground`: should object be in foreground
        
        """

        DrawObject.__init__(self, InForeground)

        self.XY = N.array(XY, N.float)
        self.XY.shape = (2,) # Make sure it is a length 2 vector
        self.Length = Length
        self.Direction = float(Direction)
        self.ArrowHeadSize = ArrowHeadSize
        self.ArrowHeadAngle = float(ArrowHeadAngle)

        self.CalcArrowPoints()
        self.CalcBoundingBox()

        self.LineColor = LineColor
        self.LineStyle = LineStyle
        self.LineWidth = LineWidth

        self.SetPen(LineColor,LineStyle,LineWidth)

        ##fixme: How should the HitTest be drawn?
        self.HitLineWidth = max(LineWidth,self.MinHitLineWidth) 
Example #26
Source File: mounting.py    From kicad_mmccoo with Apache License 2.0 4 votes vote down vote up
def __init__(self, configname=None):
        super(MountingDialog, self).__init__("mounting hole dialog", onok=self.OnOKCB)

        homedir = os.path.expanduser("~")
        self.file_picker = DialogUtils.FilePicker(self, homedir,
                                                  wildcard="DXF files (.dxf)|*.dxf",
                                                  configname="mountingdialog")
        self.AddLabeled(item=self.file_picker, label="DXF file",
                        proportion=0, flag=wx.EXPAND|wx.ALL, border=2)

        self.grid = wx.Panel(self)
        self.gridSizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=0)
        self.grid.SetSizer(self.gridSizer)

        self.configname = configname

        self.therows = {}

        self.mappings = []
        if self.configname != None:
            self.mappings = save_config.GetConfigComplex(self.configname, [])

        for size in self.mappings:
            lib,foot = self.mappings[size]
            self.AddOption(size, lib, foot)

        self.AddLabeled(self.grid, "diameter to footprint mappings",
                        proportion=1,
                        flag=wx.EXPAND|wx.ALL,
                        border=0)


        w = wx.Window(self)
        s = wx.BoxSizer(wx.HORIZONTAL)
        w.SetSizer(s)

        self.flip = wx.CheckBox(w, label="Flip to backside")
        s.Add(self.flip)

        self.add = wx.Button(w, label="Add Row")
        self.add.Bind(wx.EVT_BUTTON, self.OnAdd)
        s.Add(self.add, proportion=1)


        self.Add(w, flag=wx.EXPAND|wx.ALL, border=0)


        #self.IncSize(width=25, height=10)
        self.Fit()