08提示框

本文通过wxPython创建了一个简单的应用程序,演示了不同类型的提示框,包括信息提示、Yes/No选择框及OK/CANCEL选择框等,并展示了如何通过按钮触发这些对话框。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码演示

import wx
class MyApp(wx.App):
	def OnInit(self):
		frame = wx.Frame(parent=None, title="提示框")
		panel = wx.Panel(frame, -1)
		
		self.button1 = wx.Button(panel, -1, "hahaha1", (10, 0))
        self.Bind(wx.EVT_BUTTON, self.get_message, self.button1)

        self.button2 = wx.Button(panel, -1, "hahaha2", (10, 30))
        self.Bind(wx.EVT_BUTTON, self.yes_no, self.button2)

        self.button3 = wx.Button(panel, -1, "hahaha3", (10, 60))
        self.Bind(wx.EVT_BUTTON, self.ok_cancel, self.button3)

        self.button4 = wx.Button(panel, -1, "hahaha4", (10, 90))
        self.Bind(wx.EVT_BUTTON, self.ok_cancel_2, self.button4)

        self.button5 = wx.Button(panel, -1, "hahaha5", (10, 120))
        self.Bind(wx.EVT_BUTTON, self.yes_no_2, self.button5)

        frame.Show()
        return True
	
    def get_message(self, event):
       '''弹出信息'''
       wx.MessageBox("information", "hahaha1", wx.OK | wx.ICON_INFORMATION)

    def yes_no(self, event):
        '''弹出选择yes或no的框'''
        wx.MessageBox("are you ready", "提示框", wx.YES_NO | wx.ICON_QUESTION)

    def ok_cancel(self, event):
        '''弹出选择ok或cancel的提示框'''
        wx.MessageBox("OK", "info", wx.OK | wx.CANCEL | wx.ICON_ERROR)

    def ok_cancel_2(self, event):
        '''弹出选择ok或cancel的提示框'''
        wx.MessageBox("OK", "info", wx.OK | wx.CANCEL | wx.ICON_EXCLAMATION)

    def yes_no_2(self, event):
        '''弹出yes或no的提示框'''
        wx.MessageBox("OK", "info", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_HAND)


app = MyApp()
app.MainLoop()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值