- #-*-coding:utf-8 -*-
- import wx,os,time,webbrowser
- class MyFrame(wx.Frame):
- """docstring for Frame"""
- def __init__(self):
- wx.Frame.__init__(self,None,id=-1,title="Ginwyboo",size=(410,100))
- #面板
- panel = wx.Panel(self,-1)
- #创建按钮文本框
- self.startbutton = wx.Button(panel,-1,label="start")
- self.getext = wx.TextCtrl(panel,-1,"enter a web address")
- self.contents = wx.StaticText(panel,-1,style=wx.TE_MULTILINE|wx.HSCROLL)
- #self.contents = wx.TextCtrl(panel,-1,style=wx.TE_MULTILINE|wx.HSCROLL)
- #self.jindu = wx.Gauge()
- #创建左右布局
- hbox = wx.BoxSizer()
- #添加部件
- hbox.Add(self.getext,proportion=1,flag=wx.EXPAND)
- hbox.Add(self.startbutton,proportion=0,flag=wx.LEFT,border=5)
- #创建上下布局
- vbox = wx.BoxSizer(wx.VERTICAL)
- #添加部件
- vbox.Add(hbox,proportion=0,flag=wx.EXPAND | wx.ALL,border=5)
- vbox.Add(self.contents,proportion=1,flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT,border=5)
- panel.SetSizer(vbox)
- #添加event
- self.Bind(wx.EVT_BUTTON, self.OnClick,self.startbutton)
- self.startbutton.SetDefault()
- #按钮
- def OnClick(self,event):
- self.startbutton.SetLabel("begin")
- #获取文本框内输入的内容
- addd=self.getext.GetValue()
- while 1:
- i=0
- while i<10:
- i=i+1
- webbrowser.open(addd)
- time.sleep(3)
- os.system("taskkill /f /im chrome.exe")#改成自己的浏览器
- if __name__=='__main__':
- app = wx.PySimpleApp()
- frame = MyFrame()
- frame.Show(True)
- app.MainLoop()
- #后面还会加入一些功能...
- #该片段来自于http://www.codesnippet.cn/detail/2904201512442.html
来源: http://www.codesnippet.cn/detail/2904201512442.html