def CreateControls(self, propgrid, property, pos, sz):
        """
        Create the actual wxPython controls here for editing the
            property value.

            You must use propgrid.GetPanel() as parent for created controls.

            Return value is either single editor control or tuple of two
            editor controls, of which first is the primary one and second
            is usually a button.
        """
        # log_func.debug(u'Create controls <%s>' % self.__class__.__name__)
        try:
            x, y = pos
            w, h = sz

            # Make room for button
            bw = propgrid.GetRowHeight()
            w -= bw

            s = property.GetDisplayedString()

            self.tc = wx.TextCtrl(propgrid.GetPanel(), wx.ID_ANY, s, (x, y),
                                  (w, h), wx.TE_PROCESS_ENTER)
            btn = wx.Button(propgrid.GetPanel(), wx.ID_ANY, '...', (x + w, y),
                            (bw, h), wx.WANTS_CHARS)
            return wx.propgrid.PGWindowList(self.tc, btn)
        except:
            log_func.fatal(u'Create the actual controls error <%s>' %
                           self.__class__.__name__)
Пример #2
0
    def CreateControls(self, propgrid, property, pos, size):

        # Since it is not possible (yet) to create a read-only combo box in
        # the same sense that wxTextCtrl is read-only, simply do not create
        # the control in this case.

        if property.HasFlag(wx.propgrid.PG_PROP_READONLY):
            return

        choices = property.GetChoices()

        index = property.GetChoiceSelection()

        argFlags = 0

        if (not property.HasFlag(wx.propgrid.PG_PROP_READONLY)) and (
                not property.IsValueUnspecified()):
            argFlags |= wx.propgrid.PG_EDITABLE_VALUE

        defString = property.GetValueAsString(argFlags)

        labels = choices.GetLabels()

        po = wx.Point(pos)
        si = wx.Size(size)
        po.y -= 3
        si.y += 6

        po.x -= 3
        si.x += 6
        ctrlParent = propgrid.GetPanel()

        odcbFlags = wx.BORDER_NONE | wx.TE_PROCESS_ENTER

        # if property.HasFlag(wx.propgrid.PG_PROP_USE_DCC): #and wxDynamicCast(property, wxBoolProperty) )
        # 	odcbFlags |= wxODCB_DCLICK_CYCLES
        #

        # If common value specified, use appropriate index
        cmnVals = property.GetDisplayedCommonValueCount()
        if cmnVals:
            if not property.IsValueUnspecified():
                cmnVal = property.GetCommonValue()
                if cmnVal >= 0:
                    index = labels.size() + cmnVal

            for i in range(0, cmnVals):
                labels.Add(propgrid.GetCommonValueLabel(i))

        cb = wx.ComboBox()

        cb.Create(ctrlParent, wx.ID_ANY, wx.EmptyString, po, si, labels,
                  odcbFlags)

        # cb.SetButtonPosition(si.y, 0, wx.RIGHT)

        # cb.SetMargins(wxPG_XBEFORETEXT-1)

        # Set hint text
        # cb.SetHint(property.GetHintText())

        #  wxPGChoiceEditor_SetCustomPaintWidth( propGrid, cb,
        #                                           property->GetCommonValue() );

        if index >= 0 and index < cb.GetCount():
            cb.SetSelection(index)
            if defString:
                cb.SetValue(defString)
            #  else if ( !(extraStyle & wxCB_READONLY) && !defString.empty() )
            #     {
            #         propGrid->SetupTextCtrlValue(defString);
            #         cb->SetValue( defString );
            #     }
            else:
                cb.SetSelection(-1)

        cb.Show()

        return cb

        PGWindowList = wx.propgrid.PGComboBoxEditor.CreateControls(
            self, propgrid, property, pos, size)
        print(PGWindowList)
        print(PGWindowList.m_primary)
        return PGWindowList