码迷,mamicode.com
首页 > 编程语言 > 详细

wxPython:文本对话框TextEntryDialog

时间:2018-06-10 15:15:30      阅读:753      评论:0      收藏:0      [点我收藏+]

标签:string   对话   LTP   win   dal   func   button   input   for   

wxTextEntryDialog(wxWindowparentconst wxStringmessageconst wxStringcaption = "Please enter text"const wxStringdefaultValue = ""long style = wxOK | wxCANCEL | wxCENTREconst wxPointpos = 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

标签:string   对话   LTP   win   dal   func   button   input   for   

原文地址:https://www.cnblogs.com/fzuhyj/p/9162703.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!