#!/usr/bin/python
# myconfig.py
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
self.cfg = wx.Config('myconfig')
if self.cfg.Exists('width'):
w, h = self.cfg.ReadInt('width'), self.cfg.ReadInt('height')
else:
(w, h) = (250, 250)
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(w, h))
wx.StaticText(self, -1, 'Width:', (20, 20))
wx.StaticText(self, -1, 'Height:', (20, 70))
self.sc1 = wx.SpinCtrl(self, -1, str(w), (80, 15), (60, -1), min=200, max=500)
self.sc2 = wx.SpinCtrl(self, -1, str(h), (80, 65), (60, -1), min=200, max=500)
wx.Button(self, 1, 'Save', (20, 120))
self.Bind(wx.EVT_BUTTON, self.OnSave, id=1)
self.statusbar = self.CreateStatusBar()
self.Centre()
def OnSave(self, event):
self.cfg.WriteInt("width", self.sc1.GetValue())
self.cfg.WriteInt("height", self.sc2.GetValue())
self.statusbar.SetStatusText('Configuration saved, %s ' % wx.Now())
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'myconfig.py')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
如何在用戶命中超過最大值或最小值時彈出窗口?在wxpython中彈出窗口創建
請幫助創建一個彈出式窗口,這對我真正的項目工作來說非常重要。 – sooraj1990
你是在問一些人爲你寫信還是隻是不工作?如果後者向我們展示代碼,我們可以嘗試幫助.. – Sir
其實我試圖運行示例代碼,但是在那裏我不能提出彈出窗口,如果有人把負值,所以我問專家(你人)來幫助我如何做到這一點,我的意思是請爲我寫樣本代碼。 – sooraj1990