1. 程式人生 > >wxPython:文本對話框TextEntryDialog

wxPython:文本對話框TextEntryDialog

ini www strong eap imp one odin sem inf

wxTextEntryDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Please enter text", const wxString& defaultValue = "", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)

其支持的方法有:

wxTextEntryDialog::GetValue 獲取文檔框中的值
wxTextEntryDialog::SetValue 設置文本框中的值
wxTextEntryDialog::ShowModal 模態顯示對話框

#!/usr/bin/env python
# -*- coding: utf-8 -*-

‘‘‘
    Function:常用對話框實例
    Input:NONE
    Output: NONE
    author: socrates
    blog:http://www.cnblogs.com/dyx1024/
    date:2012-07-07
‘‘‘  

import wx

class MyFrame(wx.Frame):
    
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, u
測試面板Panel, size = (600, 300)) #創建面板 panel = wx.Panel(self) #在Panel上添加Button button = wx.Button(panel, label = u關閉, pos = (150, 60), size = (100, 60)) #綁定單擊事件 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) # #消息對話框 # def OnCloseMe(self,
event): # dlg = wx.MessageDialog(None, u"消息對話框測試", u"標題信息", wx.YES_NO | wx.ICON_QUESTION) # if dlg.ShowModal() == wx.ID_YES: # self.Close(True) # dlg.Destroy() # def OnCloseMe(self, event): dlg = wx.TextEntryDialog(None, u"請在下面文本框中輸入內容:", u"文本輸入框標題", u"默認內容") if dlg.ShowModal() == wx.ID_OK: message = dlg.GetValue() #獲取文本框中輸入的值 dlg_tip = wx.MessageDialog(None, message, u"標題信息", wx.OK | wx.ICON_INFORMATION) if dlg_tip.ShowModal() == wx.ID_OK: self.Close(True) dlg_tip.Destroy() dlg.Destroy() if __name__ == __main__: app = wx.PySimpleApp() frame = MyFrame(parent = None, id = -1) frame.Show() app.MainLoop()

wxPython:文本對話框TextEntryDialog