Python wx.DefaultValidator() Examples

The following are 12 code examples of wx.DefaultValidator(). 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: core.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, id=-1, colour=wx.BLACK,
                         pos=wx.DefaultPosition, size=wx.DefaultSize,
                         style = CLRP_DEFAULT_STYLE,
                         validator = wx.DefaultValidator,
                         name = "colourpickerwidget"):
                
                wx.BitmapButton.__init__(self, parent, id, wx.Bitmap(1,1), 
                                         pos, size, style, validator, name)
                self.SetColour(colour)
                self.InvalidateBestSize()
                self.SetInitialSize(size)
                self.Bind(wx.EVT_BUTTON, self.OnButtonClick)
                
                global _colourData
                if _colourData is None:
                    _colourData = wx.ColourData()
                    _colourData.SetChooseFull(True)
                    grey = 0
                    for i in range(16):
                        c = wx.Colour(grey, grey, grey)
                        _colourData.SetCustomColour(i, c)
                        grey += 16 
Example #2
Source File: listviews.py    From pyFileFixity with MIT License 6 votes vote down vote up
def __init__(
        self, parent,
        id=-1,
        pos=wx.DefaultPosition, size=wx.DefaultSize,
        style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_VRULES|wx.LC_SINGLE_SEL,
        validator=wx.DefaultValidator,
        columns=None,
        sortOrder=None,
        name=_("ProfileView"),
    ):
        wx.ListCtrl.__init__(self, parent, id, pos, size, style, validator,
                             name)

        if columns is not None:
            self.columns = columns

        if not sortOrder:
            sortOrder = [(x.defaultOrder,x) for x in self.columns if x.sortDefault]
        self.sortOrder = sortOrder or []
        self.sorted = []
        self.CreateControls() 
Example #3
Source File: ColourSelectButton.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        parent,
        value=(255, 255, 255),
        pos=wx.DefaultPosition,
        size=(40, wx.Button.GetDefaultSize()[1]),
        style=wx.BU_AUTODRAW,
        validator=wx.DefaultValidator,
        name="ColourSelectButton",
        title = "Colour Picker"
    ):
        self.value = value
        self.title = title
        wx.BitmapButton.__init__(
            self, parent, -1, wx.NullBitmap, pos, size, style, validator, name
        )
        self.SetValue(value)
        self.Bind(wx.EVT_BUTTON, self.OnButton) 
Example #4
Source File: FontSelectButton.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(
        self,
        parent,
        id=-1,
        pos=wx.DefaultPosition,
        size=(40, wx.Button.GetDefaultSize()[1]),
        style=wx.BU_AUTODRAW,
        validator=wx.DefaultValidator,
        name="FontSelectButton",
        value=None
    ):
        self.value = value
        wx.BitmapButton.__init__(
            self,
            parent,
            id,
            GetInternalBitmap("font"),
            pos,
            size,
            style,
            validator,
            name
        )
        self.Bind(wx.EVT_BUTTON, self.OnButton) 
Example #5
Source File: core.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, id=-1, colour=wx.BLACK,
                     pos=wx.DefaultPosition, size=wx.DefaultSize,
                     style = CLRP_DEFAULT_STYLE,
                     validator = wx.DefaultValidator,
                     name = "colourpicker"):
            if type(colour) != wx.Colour:
                colour = wx.Colour(colour)
            wx.PickerBase.__init__(self)
            self.CreateBase(parent, id, colour.GetAsString(),
                            pos, size, style, validator, name)
            widget = ColourPickerCtrl.ColourPickerButton(
                self, -1, colour, style=self.GetPickerStyle(style))
            self.SetPickerCtrl(widget)
            widget.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChange)
            self.PostCreation() 
Example #6
Source File: recipe-577951.py    From code with MIT License 5 votes vote down vote up
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition,
                 size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator,
                 name="roundbutton"):
        """
        Default class constructor.

        :param `parent`: the L{RoundButton} parent;
        :param `id`: window identifier. A value of -1 indicates a default value;
        :param `label`: the button text label;
        :param `pos`: the control position. A value of (-1, -1) indicates a default position,
         chosen by either the windowing system or wxPython, depending on platform;
        :param `size`: the control size. A value of (-1, -1) indicates a default size,
         chosen by either the windowing system or wxPython, depending on platform;
        :param `style`: the button style (unused);
        :param `validator`: the validator associated to the button;
        :param `name`: the button name.
        """
        
        wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda event: None)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
        self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
        self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
        self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)

        self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)

        self._mouseAction = None
        self._hasFocus = False
        self._buttonRadius = 0
        
        self.SetLabel(label)
        self.InheritAttributes()
        self.SetInitialSize(size) 
Example #7
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
            size=wx.DefaultSize, choices=[], style=0, validator=wx.DefaultValidator, name=NAME):
        super(ListBoxWithHeaders, self).__init__(parent, id, pos, size, [], style, validator, name)
        self.__headers = set()

        # Ignore all key events i'm bored to handle the header selection
        self.Bind(wx.EVT_KEY_DOWN, lambda event: None)

        # Make sure that a header is never selected
        self.Bind(wx.EVT_LISTBOX, self._on_listbox)
        for event in self.EVENTS:
            self.Bind(event, self._disable_header_selection)

        # Append the items in our own way in order to add the TEXT_PREFIX
        self.AppendItems(choices) 
Example #8
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def __init__(self, parent, id=wx.ID_ANY, value="", pos=wx.DefaultPosition,
            size=wx.DefaultSize, choices=[], style=0, validator=wx.DefaultValidator, name=NAME):
        super(CustomComboBox, self).__init__(parent, id, pos, size, 0, name)

        assert style == self.CB_READONLY or style == 0

        # Create components
        self.textctrl = wx.TextCtrl(self, wx.ID_ANY, style=style, validator=validator)
        tc_height = self.textctrl.GetSize()[1]

        self.button = wx.Button(self, wx.ID_ANY, "▾", size=(tc_height, tc_height))

        # Create the ListBoxPopup in two steps
        self.listbox = ListBoxPopup(self)
        self.listbox.Init()
        self.listbox.Create(self.listbox)

        # Set layout
        sizer = wx.BoxSizer()
        sizer.Add(self.textctrl, 1, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(self.button)
        self.SetSizer(sizer)

        # Bind events
        self.button.Bind(wx.EVT_BUTTON, self._on_button)

        for event in ListBoxPopup.EVENTS_TABLE.values():
            self.listbox.Bind(wx.PyEventBinder(event.GetEventType()), self._propagate)

        # Append items since the ListBoxPopup does not have the 'choices' arg
        self.listbox.GetControl().AppendItems(choices)
        self.SetStringSelection(value) 
Example #9
Source File: RadioBox.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(
        self,
        parent = None,
        id = -1,
        label = "",
        pos = (-1, -1),
        size = (-1, -1),
        choices = (),
        majorDimension = 0,
        style = wx.RA_SPECIFY_COLS,
        validator = wx.DefaultValidator,
        name = "radioBox"
    ):
        self.value = 0
        wx.Panel.__init__(self, parent, id, pos, size, name=name)
        sizer = self.sizer = wx.GridSizer(len(choices), 1, 6, 6)
        style = wx.RB_GROUP
        for i, choice in enumerate(choices):
            radioButton = wx.RadioButton(self, i, choice, style=style)
            style = 0
            self.sizer.Add(radioButton, 0, wx.EXPAND)
            radioButton.Bind(wx.EVT_RADIOBUTTON, self.OnSelect)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.Layout()
        self.SetMinSize(self.GetSize())
        self.Bind(wx.EVT_SIZE, self.OnSize) 
Example #10
Source File: ControlProviderMixin.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def TextCtrl(
        self,
        value="",
        pos=wx.DefaultPosition,
        size=(150, -1),
        style=0,
        validator=wx.DefaultValidator,
        name=wx.TextCtrlNameStr
    ):
        """
        Returns a wx.TextCtrl control.
        """
        return wx.TextCtrl(self, -1, value, pos, size, style, validator, name) 
Example #11
Source File: SmartSpinNumCtrl.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(
        self,
        parent,
        id=-1,
        value=0.0,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.TE_RIGHT,
        validator=wx.DefaultValidator,
        name="eg.SmartSpinNumCtrl",
        **kwargs
    ):
        self.initValue = value
        self.value = value
        self.parent = parent
        self.kwargs = kwargs
        self.name = name
        self.nW = size[0] if size[0] != -1 else 60
        self.tW = size[0] if size[0] != -1 else 120
        if 'numWidth' in self.kwargs:
            self.nW = self.kwargs['numWidth']
            del self.kwargs['numWidth']
        if 'textWidth' in self.kwargs:
            self.tW = self.kwargs['textWidth']
            del self.kwargs['textWidth']

        wx.Window.__init__(self, parent, id, pos, size, 0)
        self.SetThemeEnabled(True)
        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(self.sizer)
        self.ctrl = self.CreateCtrl(int(not isinstance(value, (int, float))))
        self.Bind(wx.EVT_SIZE, self.OnSize) 
Example #12
Source File: Registry.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def __init__(
        self,
        parent,
        id=-1,
        key = _winreg.HKEY_CURRENT_USER,
        subkey = "Software",
        valueName = None,
        pos = wx.DefaultPosition,
        size = wx.DefaultSize,
        style = wx.TR_HAS_BUTTONS,
        validator = wx.DefaultValidator,
        name="RegistryLazyTree",
        text = None
    ):
        self.text = text
        wx.TreeCtrl.__init__(
            self, parent, id, pos, size, style, validator, name
        )

        self.imageList = imageList = wx.ImageList(16, 16)
        rootIcon = imageList.Add(eg.Icons.GetInternalBitmap("root"))
        self.folderIcon = imageList.Add(eg.Icons.GetInternalBitmap("folder"))
        self.valueIcon = imageList.Add(eg.Icons.GetInternalBitmap("action"))
        self.SetImageList(imageList)
        self.SetMinSize((-1, 200))
        self.treeRoot = self.AddRoot(
            "Registry",
            image = rootIcon,
            data = wx.TreeItemData((True, None, None, None))
        )
        #Adding keys
        for item in regKeys:
            #a tupel of 4 values is assigned to every item
            #1) stores if the key has yet to be queried for subkey, when
            #   selected
            #2) _winreg.hkey constant
            #3) name of the key
            #4) value name, None if just a key, empty string for default value
            tmp = self.AppendItem(
                self.treeRoot,
                item[1],
                image = self.folderIcon,
                data =wx.TreeItemData((False, item[0], "", None))
            )
            self.SetItemHasChildren(tmp, True)
            if item[0] == key:
                self.SelectItem(tmp)

        #select old value in tree
        self.OnTreeChange(wx.CommandEvent(), key, subkey, valueName)
        self.EnsureVisible(self.GetSelection())

        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeChange)
        self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnExpandNode)