1
我有這個簡單的對話外:wxPython的:從對話框獲取值,並且使用它的對話框類
import wx
import wx.lib.sized_controls as sc
import time
import datetime
class Dialog(sc.SizedDialog):
def __init__(self, parent, id):
sc.SizedDialog.__init__(self, None, -1, "AuTel", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
pane = self.GetContentsPane()
pane.SetSizerType("form")
wx.StaticText(pane, -1, "N1:")
N1_BOX = wx.SpinCtrl(pane, -1, "", (40,40), (60,-1))
N1_BOX.SetRange(1,1000)
N1_BOX.SetValue(2)
wx.StaticText(pane, -1, "N2:")
N2_BOX = wx.SpinCtrl(pane, -1, "", (40,40), (60,-1))
N2_BOX.SetRange(1,1000)
N2_BOX.SetValue(10)
wx.StaticText(pane, -1, "T1:")
T1_BOX = wx.SpinCtrl(pane, -1, "", (40,40), (60,-1))
T1_BOX.SetRange(1,60)
T1_BOX.SetValue(4)
wx.StaticText(pane, -1, "T2:")
T2_BOX = wx.SpinCtrl(pane, -1, "", (40,40), (60,-1))
T2_BOX.SetRange(1,60)
T2_BOX.SetValue(5)
RUN_BUTTON = self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
self.Fit()
self.SetMinSize(self.GetSize())
app = wx.PySimpleApp()
dlg = Dialog(None, -1)
dlgrslt = dlg.ShowModal()
if dlgrslt != wx.ID_OK:
print ('Exiting..')
exit
else:
pass
print (N1+N2/T1-T2)
dlg.Destroy()
app.MainLoop()
當我點擊確定,N1_BOX,N2_BOX,T1_BOX和T2_BOX的價值觀,我需要採取,那麼稍後我可以在腳本中使用它們作其他用途。爲了達到這個目的,我在劇本中應該做什麼?另外,如何讓另一個窗口顯示N1 + N2/T1-T2的結果?我需要把這個窗口添加到對話窗口,但我不知道我該怎麼做。 對不起我的基本問題,但我是編程世界的新手。
問候, 阿姆魯