Example #1
0
    def OnCornerLabelPaint(self, evt):
        if not self.corner_logo:
            return evt.Skip()
        if not self._corner_logo:
            self._corner_logo = graphics.bitmap(self.corner_logo)
        window = self.GetGridCornerLabelWindow()
        rect = window.GetClientRect()
        dc = wx.PaintDC(window)
        pen = dc.GetPen()
        dc.SetPen(self.GRAY_PEN)
        dc.DrawLine(rect[0], rect[1] + rect[3] - 1, rect[0] + rect[2],
                    rect[1] + rect[3] - 1)

        def label_rect(position, col):
            return rect

        def get_bitmap(index):
            return self._corner_logo

        self._LabelPaint(
            dc,
            co=0,
            amount=1,
            label_rect=label_rect,
            get_size=self.GetColSize,
            get_label=None,  # self.GetColLabelValue,
            get_bitmap=get_bitmap,
            border=False,
            center_bitmap=True,
            pen=pen)
Example #2
0
 def EnableBackgroundPainting(self, object, state=True, color=wx.WHITE):
     if state:
         if self.paint_logo:
             self._paint_logo = graphics.bitmap(self.paint_logo)
         object.SetBackgroundColour(color)
         object.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
     else:
         object.Unbind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
Example #3
0
 def EnableBackgroundPainting(self, object, state=True, color=wx.WHITE):
     if state:
         if self.paint_logo:
             self._paint_logo = graphics.bitmap(self.paint_logo)
         object.SetBackgroundColour(color)
         object.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
     else:
         object.Unbind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
Example #4
0
    def OnCornerLabelPaint(self, evt):
        if not self.corner_logo:
            return evt.Skip()
        if not self._corner_logo:
            self._corner_logo = graphics.bitmap(self.corner_logo)
        window = self.GetGridCornerLabelWindow()
        rect = window.GetClientRect()
        dc = wx.PaintDC(window)
        pen = dc.GetPen()
        dc.SetPen(self.GRAY_PEN)
        dc.DrawLine(rect[0], rect[1] + rect[3] - 1,
            rect[0] + rect[2], rect[1] + rect[3] - 1)

        def label_rect(position, col):
            return rect

        def get_bitmap(index):
            return self._corner_logo

        self._LabelPaint(dc, co=0, amount=1,
            label_rect=label_rect, get_size=self.GetColSize,
            get_label=None,  # self.GetColLabelValue,
            get_bitmap=get_bitmap, border=False, center_bitmap=True,
            pen=pen)
Example #5
0
 def CreateImageList(self, icon_size):
     self.image_list = wx.ImageList(*icon_size)
     icon_disabled = graphics.bitmap(ICON_DISABLED)
     for form in self.form_factory.values():
         self._AddFormToImageList(form, icon_size, icon_disabled)
     self.SetImageList(self.image_list)
Example #6
0
        def __init__(self,
                     parent,
                     id,
                     value,
                     style,
                     choices,
                     colNames=None,
                     multiChoices=None,
                     showHead=True,
                     dropDownClick=True,
                     colFetch=-1,
                     colSearch=0,
                     hideOnNoMatch=True,
                     selectCallback=None,
                     entryCallback=None,
                     matchFunction=None,
                     **therest):
            '''
            Constructor works just like wx.TextCtrl except you can pass in a
            list of choices.  You can also change the choice list at any time
            by calling setChoices.
            '''

            if 'style' in therest:
                therest['style'] = wx.TE_PROCESS_ENTER | therest['style']
            else:
                therest['style'] = wx.TE_PROCESS_ENTER

            wx.TextCtrl.__init__(self, parent, **therest)

            #Some variables
            self._dropDownClick = dropDownClick
            self._colNames = colNames
            self._multiChoices = multiChoices
            self._showHead = showHead
            self._choices = choices
            self._lastinsertionpoint = 0
            self._hideOnNoMatch = hideOnNoMatch
            self._selectCallback = selectCallback
            self._entryCallback = entryCallback
            self._matchFunction = matchFunction

            self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)

            #sort variable needed by listmix
            self.itemDataMap = dict()

            #Load and sort data
            if not (self._multiChoices or self._choices):
                raise ValueError(
                    "Pass me at least one of multiChoices OR choices")

            #widgets

            #Control the style
            self.dropdown = wx.PopupWindow(self, wx.SIMPLE_BORDER)
            flags = wx.NO_BORDER | wx.LC_ICON | wx.LC_SINGLE_SEL \
                | wx.LC_SORT_ASCENDING
            #if not (showHead and multiChoices) :
            #    flags = flags | wx.LC_NO_HEADER

            #Create the list and bind the events
            size = (64, 64)
            self.il = wx.ImageList(*size)
            self.sm_dn = self.il.Add(graphics.bitmap('ART_FOLDER', size))
            self.sm_up = self.il.Add(graphics.bitmap('ART_FOLDER', size))

            self.dropdownlistbox = wx.ListCtrl(self.dropdown,
                                               style=flags,
                                               pos=wx.Point(0, 0))

            self.dropdownlistbox.SetImageList(self.il, wx.IMAGE_LIST_NORMAL)

            if sys.platform.startswith('linux'):
                self.dropdownlistbox.SetBackgroundColour(
                    wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK))
            #initialize the parent
            if multiChoices:
                ln = len(multiChoices)
            else:
                ln = 1
            #else: ln = len(choices)

            #load the data
            if multiChoices:
                self.SetMultipleChoices(multiChoices,
                                        colSearch=colSearch,
                                        colFetch=colFetch)
            else:
                self.SetChoices(choices)

            gp = wx.GetTopLevelParent(self)
            #while ( gp != None ) :
            gp.Bind(wx.EVT_MOVE, self.onControlChanged, gp)
            gp.Bind(wx.EVT_SIZE, self.onControlChanged, gp)
            #gp = gp.GetParent()

            self.Bind(wx.EVT_KILL_FOCUS, self.onControlChanged, self)
            self.Bind(wx.EVT_TEXT, self.onEnteredText, self)
            self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown, self)

            #If need drop down on left click
            if dropDownClick:
                self.Bind(wx.EVT_LEFT_DOWN, self.onClickToggleDown, self)
                self.Bind(wx.EVT_LEFT_UP, self.onClickToggleUp, self)

            self.dropdown.Bind(wx.EVT_LISTBOX, self.onListItemSelected,
                               self.dropdownlistbox)
            self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.onListClick)
            self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.onListDClick)
            self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK,
                                      self.onListColClick)

            self._ascending = True

            self.initialize(value, choices)

            self.dropdown.SetSize((self.dropdown.GetSize()[0], 500))
Example #7
0
 def CreateImageList(self, icon_size):
     self.image_list = wx.ImageList(*icon_size)
     icon_disabled = graphics.bitmap(ICON_DISABLED)
     for form in self.form_factory.values():
         self._AddFormToImageList(form, icon_size, icon_disabled)
     self.SetImageList(self.image_list)
        def __init__(self, parent, id, value, style, choices,
                colNames=None, multiChoices=None, showHead=True,
                dropDownClick=True, colFetch=-1, colSearch=0,
                hideOnNoMatch=True, selectCallback=None, entryCallback=None,
                matchFunction=None, **therest):
            '''
            Constructor works just like wx.TextCtrl except you can pass in a
            list of choices.  You can also change the choice list at any time
            by calling setChoices.
            '''

            if 'style' in therest:
                therest['style'] = wx.TE_PROCESS_ENTER | therest['style']
            else:
                therest['style'] = wx.TE_PROCESS_ENTER

            wx.TextCtrl.__init__(self, parent, **therest)

            #Some variables
            self._dropDownClick = dropDownClick
            self._colNames = colNames
            self._multiChoices = multiChoices
            self._showHead = showHead
            self._choices = choices
            self._lastinsertionpoint = 0
            self._hideOnNoMatch = hideOnNoMatch
            self._selectCallback = selectCallback
            self._entryCallback = entryCallback
            self._matchFunction = matchFunction

            self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)

            #sort variable needed by listmix
            self.itemDataMap = dict()

            #Load and sort data
            if not (self._multiChoices or self._choices):
                raise ValueError(
                    "Pass me at least one of multiChoices OR choices")

            #widgets

            #Control the style
            self.dropdown = wx.PopupWindow(self, wx.SIMPLE_BORDER)
            flags = wx.NO_BORDER | wx.LC_ICON | wx.LC_SINGLE_SEL \
                | wx.LC_SORT_ASCENDING
            #if not (showHead and multiChoices) :
            #    flags = flags | wx.LC_NO_HEADER

            #Create the list and bind the events
            size = (64, 64)
            self.il = wx.ImageList(*size)
            self.sm_dn = self.il.Add(graphics.bitmap('ART_FOLDER', size))
            self.sm_up = self.il.Add(graphics.bitmap('ART_FOLDER', size))

            self.dropdownlistbox = wx.ListCtrl(self.dropdown, style=flags,
                                     pos=wx.Point(0, 0))

            self.dropdownlistbox.SetImageList(self.il, wx.IMAGE_LIST_NORMAL)

            if sys.platform.startswith('linux'):
                self.dropdownlistbox.SetBackgroundColour(
                    wx.SystemSettings_GetColour(wx.SYS_COLOUR_INFOBK))
            #initialize the parent
            if multiChoices:
                ln = len(multiChoices)
            else:
                ln = 1
            #else: ln = len(choices)

            #load the data
            if multiChoices:
                self.SetMultipleChoices(multiChoices, colSearch=colSearch,
                    colFetch=colFetch)
            else:
                self.SetChoices(choices)

            gp = wx.GetTopLevelParent(self)
            #while ( gp != None ) :
            gp.Bind(wx.EVT_MOVE, self.onControlChanged, gp)
            gp.Bind(wx.EVT_SIZE, self.onControlChanged, gp)
                #gp = gp.GetParent()

            self.Bind(wx.EVT_KILL_FOCUS, self.onControlChanged, self)
            self.Bind(wx.EVT_TEXT, self.onEnteredText, self)
            self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown, self)

            #If need drop down on left click
            if dropDownClick:
                self.Bind(wx.EVT_LEFT_DOWN, self.onClickToggleDown, self)
                self.Bind(wx.EVT_LEFT_UP, self.onClickToggleUp, self)

            self.dropdown.Bind(wx.EVT_LISTBOX, self.onListItemSelected,
                self.dropdownlistbox)
            self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.onListClick)
            self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.onListDClick)
            self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK,
                self.onListColClick)

            self._ascending = True

            self.initialize(value, choices)

            self.dropdown.SetSize((self.dropdown.GetSize()[0], 500))