コード例 #1
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.history = history = HistoryControl(value=self.value,
                                                entries=self.factory.entries,
                                                auto_set=self.factory.auto_set)
        self.control = history.create_control(parent)

        self.set_tooltip()
コード例 #2
0
ファイル: file_editor.py プロジェクト: raphmur/traitsui
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = panel = TraitsUIPanel(parent, -1)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        factory = self.factory

        if factory.entries > 0:
            from history_control import HistoryControl

            self.history = HistoryControl(entries=factory.entries,
                                          auto_set=factory.auto_set)
            control = self.history.create_control(panel)
            pad = 3
            button = wx.Button(panel, -1, '...',
                               size=wx.Size(28, -1))
        else:
            if factory.enter_set:
                control = wx.TextCtrl(panel, -1, '',
                                      style=wx.TE_PROCESS_ENTER)
                wx.EVT_TEXT_ENTER(panel, control.GetId(), self.update_object)
            else:
                control = wx.TextCtrl(panel, -1, '')

            wx.EVT_KILL_FOCUS(control, self.update_object)

            if factory.auto_set:
                wx.EVT_TEXT(panel, control.GetId(), self.update_object)

            bmp = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN,
                                           size=(15, 15))
            button = wx.BitmapButton(panel, -1, bitmap=bmp)

            pad = 8

        self._file_name = control
        sizer.Add(control, 1, wx.EXPAND | wx.ALIGN_CENTER)
        sizer.Add(button, 0, wx.LEFT | wx.ALIGN_CENTER, pad)
        wx.EVT_BUTTON(panel, button.GetId(), self.show_file_dialog)
        panel.SetDropTarget(FileDropTarget(self))
        panel.SetSizerAndFit(sizer)
        self._button = button

        self.set_tooltip(control)