wxpython 获得poj上自己代码的小工具
scturtle
posted @ 2010年6月30日 16:41
in python
, 2640 阅读
wxFormBuilder +wxPython
# -*-coding: cp936 -*- import urllib,urllib2,cookielib,re import wx import wx.html from wx import xrc class MyApp(wx.App): def OnInit(self): self.res = xrc.XmlResource('noname.xrc') assert self.res self.init_frame() self.username=None self.password=None cookie_support= urllib2.HTTPCookieProcessor(cookielib.CookieJar()) opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler) urllib2.install_opener(opener) return True def init_frame(self): self.frame = self.res.LoadFrame(None, 'MyFrame1') assert self.frame self.panel = xrc.XRCCTRL(self.frame, 'm_panel1') self.m_textCtrlName = xrc.XRCCTRL(self.panel, 'm_textCtrlName') self.m_textCtrlPd = xrc.XRCCTRL(self.panel, 'm_textCtrlPd') self.m_textCtrlNum = xrc.XRCCTRL(self.panel, 'm_textCtrlNum') self.m_buttonLogin = xrc.XRCCTRL(self.panel, 'm_buttonLogin') self.frame.Bind(wx.EVT_BUTTON, self.OnLogin,self.m_buttonLogin) self.m_buttonFind = xrc.XRCCTRL(self.panel, 'm_buttonFind') self.frame.Bind(wx.EVT_BUTTON, self.OnFind,self.m_buttonFind) self.m_listBox = xrc.XRCCTRL(self.panel, 'm_listBox') self.Bind(wx.EVT_LISTBOX_DCLICK, self.ListBoxDClick, self.m_listBox) self.m_htmlWin = xrc.XRCCTRL(self.panel, 'm_htmlWin') self.frame.Show() def OnLogin(self, evt): self.username=self.m_textCtrlName.GetValue() self.password=self.m_textCtrlPd.GetValue() postdata=urllib.urlencode({ 'user_id1':self.username, 'password1':self.password, 'B1':'login', 'url':'/JudgeOnline/status' }) req = urllib2.Request( url = 'http://acm.pku.edu.cn/JudgeOnline/login', data = postdata) result = urllib2.urlopen(req).read() if 'Log Out' in result: wx.MessageBox('登陆成功!', '') def OnFind(self,evt): if(self.username==None): return pid=self.m_textCtrlNum.GetValue() req='http://acm.pku.edu.cn/JudgeOnline/status?problem_id='+str(pid)+'&user_id='+self.username+'&result=&language=' content = urllib2.urlopen(req).read() pattern = re.compile(r'solution_id=\d*') nums=pattern.findall(content) self.m_listBox.Clear() for p in nums: self.m_listBox.Append(p) def ListBoxDClick(self, event): pid=self.m_listBox.GetStringSelection() req = 'http://acm.pku.edu.cn/JudgeOnline/showsource?'+pid content = urllib2.urlopen(req).read() self.m_htmlWin.SetPage(content) if __name__ == '__main__': app = MyApp(False) app.MainLoop()
2021年3月01日 21:29
Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!THANKS!!!!!! 123 movies
2022年9月27日 13:23
Every 10th standard candidates who to know the examination pattern or scheme of exam can download NCERT Term-2 Sample Paper 2023 Class exams of the course. Who downloaded the sample paper suggestions can get complete stretcher of Part-A, Part-B, Part-C and Part-D exam for all formats of SA, FA and Assignments. NCERT Term 2 Sample Paper Class 10 Every 10th standard candidates who to know the examination pattern or scheme of exam can download.Every 10th standard candidates who to know the examination pattern or scheme of exam can download NCERT Term-2 Sample Paper 2023 Class exams of the course. Who downloaded the sample paper suggestions can get complete stretcher of Part-A, Part-B, Part-C and Part-D exam for all formats of SA, FA and Assignments.