日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

wxpython bind自定义_wxPython的 - 如何从自定义对话框WX

發布時間:2023/12/19 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 wxpython bind自定义_wxPython的 - 如何从自定义对话框WX 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

跟進的問題,我已經創建了定制dialog.It會彈出當我們從另一個函數調用的函數,如果用戶點擊“不要繼續“按鈕在對話框窗口我需要得到真/假值,以確定是否按下特定按鈕,并將該值傳遞給函數調用以進一步處理。

但隨著wx自定義對話框,我不能任何返回值,因為對話框一旦我們按任何按鈕被破壞。

有沒有什么辦法通過按鈕點擊事件從自定義對話框類中獲得返回值,并且即使它被銷毀也可以從類外部訪問。

在此先感謝。

def main():

print "start execution"

ret = getUserInput("Do you want to proceed?")

if ret:

print "proceed"

else:

print "exit"

def getUserInput(msg):

class Busy(wx.Dialog):

def __init__(self, parent, msg):

wx.Dialog.__init__(self, parent, wx.ID_ANY, "Message", size=(420, 200))

self.panel = wx.Panel(self, wx.ID_ANY)

self.label = wx.StaticText(self.panel, label=msg, pos=(20, 20))

self.gauge = wx.Gauge(self.panel, size=(300, 20), pos=(50, 50), style=wx.GA_HORIZONTAL)

self.livelabel = wx.StaticText(self.panel, label="Time to live:", pos=(50, 80))

self.lltime = wx.StaticText(self.panel, label="30", pos=(130, 80))

self.notProceedButton = wx.Button(self.panel, label="Don't proceed", pos=(50, 100))

self.timeoutButton = wx.Button(self.panel, label="Timer Off", pos=(250, 100))

self.notProceedButton.Bind(wx.EVT_BUTTON, self.notProceed)

self.timeoutButton.Bind(wx.EVT_BUTTON, self.OnNoTimeout)

self.Bind(wx.EVT_CLOSE, self.OnQuit)

self.timer = wx.Timer(self)

self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)

self.lifetimer = wx.Timer(self)

self.Bind(wx.EVT_TIMER, self.OnLifeTimer, self.lifetimer)

self.timer.Start(100)

self.lifetimer.Start(1000)

self.timeoutbutton_pressed = False

self.gauge.SetBackgroundColour(wx.Colour(0, 127, 255, 255)) # Slate Blue

self.gauge.SetRange(100)

self.gauge.SetValue(0)

self.life = 30

self.direction = 1

self.result_text = True

def OnTimer(self, evt): # Update gauge

x = int(self.gauge.GetValue())

if x == 0:

self.direction = 1

elif x == 100:

self.direction = -1

x += self.direction

self.gauge.SetValue(x)

def OnLifeTimer(self, evt): # Update time to live

if self.timeoutbutton_pressed == True:

return

self.life -= 1

self.lltime.SetLabelText(str(self.life))

if self.life < 1:

self.OnQuit(None)

def OnNoTimeout(self, evt): # toggle time to live

if self.timeoutbutton_pressed == False:

self.timeoutbutton_pressed = True

self.timeoutButton.SetLabel("Timer On")

else:

self.timeoutbutton_pressed = False

self.timeoutButton.SetLabel("Timer Off")

def OnQuit(self, event):

self.timer.Stop()

self.lifetimer.Stop()

self.Destroy()

def notProceed(self, event): # return input

self.result_text = False

self.timer.Stop()

self.lifetimer.Stop()

self.Destroy()

app = wx.App()

dlg = Busy(parent = None, msg=msg)

dlg.ShowModal()

return dlg.result_text

2017-03-14

Nithya

總結

以上是生活随笔為你收集整理的wxpython bind自定义_wxPython的 - 如何从自定义对话框WX的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。