Python wx 模块,EVT_KILL_FOCUS 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用wx.EVT_KILL_FOCUS

项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def __init__(self, parent=None, default_url=""):
        wx.Panel.__init__(self, parent)
        self._sizer = wx.BoxSizer(wx.HORIZONTAL)

        self._url = wx.TextCtrl(self)
        self._url.Bind(wx.EVT_KILL_FOCUS, self._field_changed)
        self._url.SetValue(default_url)

        self._status_label = ProcessingPlaceholderText(self)

        label = wx.StaticText(self, label="Server URL")
        label.SetToolTipString("URL for the IRIDA server API.")
        self._sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=5, proportion=0)
        self._sizer.Add(self._url, flag=wx.EXPAND, proportion=1)
        self._sizer.Add(self._status_label, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border=5, proportion=0)

        self.SetSizerAndFit(self._sizer)
        self.Layout()

        self.Bind(wx.EVT_CLOSE, self._on_close)
        pub.subscribe(self._status_label.SetError, APIConnectorTopics.connection_error_url_topic)
        pub.subscribe(self._status_label.SetSuccess, APIConnectorTopics.connection_success_topic)
        pub.subscribe(self._status_label.SetSuccess, APIConnectorTopics.connection_success_valid_url)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def initChoices(self):
        choiceControlBox = widgets.ControlBox(self, label='Choices', orient=wx.VERTICAL)

        choiceGridSizer = wx.GridSizer(1, 2, 10, 10)

        self.leftChoiceTextCtrl = wx.TextCtrl(parent=self, value=self.pg.choices[0],
                style=wx.TE_PROCESS_ENTER)
        self.Bind(wx.EVT_TEXT_ENTER, self.setChoices, self.leftChoiceTextCtrl)
        self.leftChoiceTextCtrl.Bind(wx.EVT_KILL_FOCUS, self.setChoices, self.leftChoiceTextCtrl)
        self.offlineControls += [self.leftChoiceTextCtrl]
        choiceGridSizer.Add(self.leftChoiceTextCtrl, proportion=0,
                             flag=wx.ALL | wx.EXPAND, border=10)

        self.rightChoiceTextCtrl = wx.TextCtrl(parent=self, value=self.pg.choices[1],
                style=wx.TE_PROCESS_ENTER)
        self.Bind(wx.EVT_TEXT_ENTER, self.setChoices, self.rightChoiceTextCtrl)
        self.rightChoiceTextCtrl.Bind(wx.EVT_KILL_FOCUS, self.setChoices, self.rightChoiceTextCtrl)
        self.offlineControls += [self.rightChoiceTextCtrl]
        choiceGridSizer.Add(self.rightChoiceTextCtrl, proportion=0,
                             flag=wx.ALL | wx.EXPAND, border=10)

        choiceControlBox.Add(choiceGridSizer, proportion=1,
                             flag=wx.ALL | wx.EXPAND, border=0)

        self.sizer.Add(choiceControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def __init__(self, parent=None, default_post_process=""):
        wx.Panel.__init__(self, parent)
        self._sizer = wx.BoxSizer(wx.HORIZONTAL)

        task_label = wx.StaticText(self, label="Task to run on successful upload")
        task_label.SetToolTipString("Post-processing job to run after a run has been successfully uploaded to IRIDA.")
        self._sizer.Add(task_label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=5, proportion=0)

        task = wx.TextCtrl(self)
        task.Bind(wx.EVT_KILL_FOCUS, lambda evt: send_message(SettingsDialog.field_changed_topic, field_name="completion_cmd", field_value=task.GetValue()))
        task.SetValue(default_post_process)
        self._sizer.Add(task, flag=wx.EXPAND, proportion=1)

        self.SetSizerAndFit(self._sizer)
        self.Layout()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def initChoices(self):
        choiceControlBox = widgets.ControlBox(self, label='Choices', orient=wx.VERTICAL)

        self.choiceTextCtrl = wx.TextCtrl(parent=self, value=', '.join(self.pg.choices),
                style=wx.TE_PROCESS_ENTER)
        self.Bind(wx.EVT_TEXT_ENTER, self.setChoices, self.choiceTextCtrl)
        self.choiceTextCtrl.Bind(wx.EVT_KILL_FOCUS, self.setChoices, self.choiceTextCtrl)
        self.offlineControls += [self.choiceTextCtrl]
        choiceControlBox.Add(self.choiceTextCtrl, proportion=1,
                             flag=wx.ALL | wx.EXPAND, border=10)

        self.sizer.Add(choiceControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def initChoices(self):
        choiceControlBox = widgets.ControlBox(self, label='Choices', orient=wx.VERTICAL)

        self.choiceTextCtrl = wx.TextCtrl(parent=self, value=', '.join(self.pg.choices),
                style=wx.TE_PROCESS_ENTER)
        choiceControlBox.Add(self.choiceTextCtrl, proportion=1,
                             flag=wx.ALL | wx.EXPAND, border=10)
        self.choiceTextCtrl.Bind(wx.EVT_KILL_FOCUS, self.setChoices, self.choiceTextCtrl)
        self.offlineControls += [self.choiceTextCtrl]

        self.sizer.Add(choiceControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddSizerParams(self, parent, sizer, params):
        for idx, (name, label) in enumerate(params):
            border = 0
            if idx == 0:
                border |= wx.TOP
            elif idx == len(params) - 1:
                border |= wx.BOTTOM

            st = wx.StaticText(parent, label=label)
            sizer.AddWindow(st, border=10,
                            flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT)

            tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER)
            setattr(self, name, tc)
            callback = self.GetTextCtrlChangedFunction(tc, name)
            self.Bind(wx.EVT_TEXT_ENTER, callback, tc)
            tc.Bind(wx.EVT_KILL_FOCUS, callback)
            sizer.AddWindow(tc, border=10,
                            flag=wx.GROW | border | wx.RIGHT)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, choices=None, dropDownClick=True,
                 element_path=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.
        """

        therest['style'] = wx.TE_PROCESS_ENTER | therest.get('style', 0)

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

        # Some variables
        self._dropDownClick = dropDownClick
        self._lastinsertionpoint = None
        self._hasfocus = False

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

        self.listbox = None

        self.SetChoices(choices)

        # gp = 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.Bind(wx.EVT_TEXT_ENTER, self.OnControlChanged)
        self.Bind(wx.EVT_TEXT, self.OnEnteredText)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        # If need drop down on left click
        if dropDownClick:
            self.Bind(wx.EVT_LEFT_DOWN, self.OnClickToggleDown)
            self.Bind(wx.EVT_LEFT_UP, self.OnClickToggleUp)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: Add_Student.__set_properties
        self.SetTitle("Add Student")
        self.SetSize((485, 100))
        self.SetFocus()

        self.text_ctrl_1.SetMinSize((50, 32))
        self.text_ctrl_1.Value="Roll"
        self.text_ctrl_1.SetForegroundColour('#9CA998')


        self.text_ctrl_2.SetMinSize((80, 32))
        self.text_ctrl_2.Value="Admsn No"
        self.text_ctrl_2.SetForegroundColour('#9CA998')


        self.text_ctrl_3.SetMinSize((220, 32))
        self.text_ctrl_3.Value="Name"
        self.text_ctrl_3.SetForegroundColour('#9CA998')


        self.button_1.SetMinSize((85, 32))

        self.text_ctrl_1.SetName("roll")
        self.text_ctrl_2.SetName("ad_no")
        self.text_ctrl_3.SetName("name")

        self.Bind(wx.EVT_BUTTON, self.Add_Clicked, self.button_1)
        self.text_ctrl_1.Bind(wx.EVT_SET_FOCUS,self.OnFocus)
        self.text_ctrl_1.Bind(wx.EVT_KILL_FOCUS,self.OffFocus)
        self.text_ctrl_2.Bind(wx.EVT_SET_FOCUS,self.OnFocus)
        self.text_ctrl_2.Bind(wx.EVT_KILL_FOCUS,self.OffFocus)
        self.text_ctrl_3.Bind(wx.EVT_SET_FOCUS,self.OnFocus)
        self.text_ctrl_3.Bind(wx.EVT_KILL_FOCUS,self.OffFocus)
        # end wxGlade
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self):
        wx.Frame.__init__(self, None, title="Losing Focus")

        # Add a panel so it looks the correct on all platforms
        panel = wx.Panel(self, wx.ID_ANY)

        txt = wx.TextCtrl(panel, value="")
        txt.Bind(wx.EVT_SET_FOCUS, self.onFocus)
        txt.Bind(wx.EVT_KILL_FOCUS, self.onKillFocus)
        btn = wx.Button(panel, wx.ID_ANY, "Test")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(txt, 0, wx.ALL, 5)
        sizer.Add(btn, 0, wx.ALL, 5)
        panel.SetSizer(sizer)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def __init__(self, parent=None, default_user="", default_pass=""):
        wx.Panel.__init__(self, parent)
        border = wx.StaticBox(self, label="User authorization")
        sizer = wx.StaticBoxSizer(border, wx.VERTICAL)
        self._status_label_user = ProcessingPlaceholderText(self)
        self._status_label_pass = ProcessingPlaceholderText(self)

        username_sizer = wx.BoxSizer(wx.VERTICAL)
        username_label = wx.StaticText(self, label="Username")
        username_label.SetToolTipString("Your IRIDA username")
        username_sizer.Add(username_label, flag=wx.EXPAND | wx.BOTTOM, border=2)

        username_input_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._username = wx.TextCtrl(self)
        self._username.Bind(wx.EVT_KILL_FOCUS, self._username_changed)
        self._username.SetValue(default_user)
        username_input_sizer.Add(self._username, flag=wx.EXPAND, proportion=1)
        username_input_sizer.Add(self._status_label_user, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border=5, proportion=0)
        username_sizer.Add(username_input_sizer, flag=wx.EXPAND)
        sizer.Add(username_sizer, flag=wx.EXPAND | wx.ALL, border=5)

        password_sizer = wx.BoxSizer(wx.VERTICAL)
        password_label = wx.StaticText(self, label="Password")
        password_label.SetToolTipString("Your IRIDA password")
        password_sizer.Add(password_label, flag=wx.EXPAND | wx.BOTTOM, border=2)

        password_input_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._password = wx.TextCtrl(self, style=wx.TE_PASSWORD)
        self._password.Bind(wx.EVT_KILL_FOCUS, self._password_changed)
        self._password.SetValue(default_pass)
        password_input_sizer.Add(self._password, flag=wx.EXPAND, proportion=1)
        password_input_sizer.Add(self._status_label_pass, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border=5, proportion=0)
        password_sizer.Add(password_input_sizer, flag=wx.EXPAND)
        sizer.Add(password_sizer, flag=wx.EXPAND | wx.ALL, border=5)

        self.SetSizerAndFit(sizer)
        self.Layout()

        pub.subscribe(self._handle_connection_error, APIConnectorTopics.connection_error_user_credentials_topic)
        pub.subscribe(self._status_label_user.SetSuccess, APIConnectorTopics.connection_success_topic)
        pub.subscribe(self._status_label_pass.SetSuccess, APIConnectorTopics.connection_success_topic)
        self.Bind(wx.EVT_CLOSE, self._on_close)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def __init__(self, parent=None, default_client_id="", default_client_secret=""):
        wx.Panel.__init__(self, parent)
        border = wx.StaticBox(self, label="Client authorization")
        sizer = wx.StaticBoxSizer(border, wx.VERTICAL)
        self._client_id_status_label = ProcessingPlaceholderText(self)
        self._client_secret_status_label = ProcessingPlaceholderText(self)

        client_id_sizer = wx.BoxSizer(wx.VERTICAL)
        client_id_label = wx.StaticText(self, label="Client ID")
        client_id_label.SetToolTipString("Your IRIDA client ID")
        client_id_sizer.Add(client_id_label, flag=wx.EXPAND | wx.BOTTOM, border=2)

        client_id_input_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._client_id = wx.TextCtrl(self)
        self._client_id.Bind(wx.EVT_KILL_FOCUS, self._client_id_changed)
        self._client_id.SetValue(default_client_id)
        client_id_input_sizer.Add(self._client_id, flag=wx.EXPAND, proportion=1)
        client_id_input_sizer.Add(self._client_id_status_label, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border=5, proportion=0)
        client_id_sizer.Add(client_id_input_sizer, flag=wx.EXPAND)
        sizer.Add(client_id_sizer, flag=wx.EXPAND | wx.ALL, border=5)

        client_secret_sizer = wx.BoxSizer(wx.VERTICAL)
        client_secret_label = wx.StaticText(self, label="Client Secret")
        client_secret_label.SetToolTipString("Your IRIDA client secret")
        client_secret_sizer.Add(client_secret_label, flag=wx.EXPAND | wx.BOTTOM, border=2)

        client_secret_input_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._client_secret = wx.TextCtrl(self)
        self._client_secret.Bind(wx.EVT_KILL_FOCUS, self._client_secret_changed)
        self._client_secret.SetValue(default_client_secret)
        client_secret_input_sizer.Add(self._client_secret, flag=wx.EXPAND, proportion=1)
        client_secret_input_sizer.Add(self._client_secret_status_label, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT, border=5, proportion=0)
        client_secret_sizer.Add(client_secret_input_sizer, flag=wx.EXPAND)
        sizer.Add(client_secret_sizer, flag=wx.EXPAND | wx.ALL, border=5)

        self.SetSizerAndFit(sizer)
        self.Layout()

        pub.subscribe(self._client_id_status_label.SetError, APIConnectorTopics.connection_error_client_id_topic)
        pub.subscribe(self._client_secret_status_label.SetError, APIConnectorTopics.connection_error_client_secret_topic)
        pub.subscribe(self._client_id_status_label.SetSuccess, APIConnectorTopics.connection_success_topic)
        pub.subscribe(self._client_secret_status_label.SetSuccess, APIConnectorTopics.connection_success_topic)
        pub.subscribe(self._client_id_status_label.SetSuccess, APIConnectorTopics.connection_success_valid_client_id)
        pub.subscribe(self._client_secret_status_label.SetSuccess, APIConnectorTopics.connection_success_valid_client_secret)

        self.Bind(wx.EVT_CLOSE, self._on_close)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: add_div.__init__

        kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.STAY_ON_TOP
        wx.Dialog.__init__(self, *args, **kwds)
        self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
        self.label_1 = wx.StaticText(self.panel_1, -1, "YEAR")


        self.combo_box_1 = wx.ComboBox(self.panel_1, -1, choices=[], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT)
        self.label_2 = wx.StaticText(self.panel_1, -1, "CLASS")
        self.combo_box_2 = wx.ComboBox(self.panel_1, -1, choices=["Select","8","9","10"], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT)
        self.sizer_4_staticbox = wx.StaticBox(self.panel_1, -1, "Specify Class ")
        self.list_box_1 = wx.ListBox(self.panel_1, -1, choices=[], style=wx.LB_SINGLE | wx.LB_SORT)
        self.button_1 = wx.Button(self.panel_1, -1, "Remove Divison")
        self.text_ctrl_1 = wx.TextCtrl(self.panel_1, -1, "")
        self.button_2 = wx.Button(self.panel_1, -1, "Add Division")
        self.sizer_9_staticbox = wx.StaticBox(self.panel_1, -1, "New Division")
        self.button_3 = wx.Button(self.panel_1, -1, "Close")
        self.hyperlink_1 = wx.HyperlinkCtrl(self.panel_1, wx.ID_ANY, "", "Add Academic Year")


        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_COMBOBOX, self.on_year, self.combo_box_1)
        self.Bind(wx.EVT_COMBOBOX, self.on_class, self.combo_box_2)
        self.Bind(wx.EVT_LISTBOX, self.on_list, self.list_box_1)
        self.Bind(wx.EVT_BUTTON, self.on_remove, self.button_1)
        self.Bind(wx.EVT_TEXT, self.on_text, self.text_ctrl_1)

        self.Bind(wx.EVT_BUTTON, self.on_add, self.button_2)
        self.Bind(wx.EVT_BUTTON, self.on_close, self.button_3)

        self.text_ctrl_1 .Bind(wx.EVT_SET_FOCUS,self.onfocus)
        self.text_ctrl_1 .Bind(wx.EVT_KILL_FOCUS,self.offocus)
        self.text_ctrl_1.Bind(wx.EVT_KEY_DOWN, self.on_keypress)

        self.Bind(wx.EVT_HYPERLINK, self.on_hlink, self.hyperlink_1)

        self.YEAR=''
        self.CLASS=''

        self.DB=db_operations()
        self.load_year()

        # end wxGlade