#! / usr / bin / env python
# Written by bram cohen and myers carpenter # see license.txt for license information # # file name: btdownloadgui.py # reading diary: 2004-9-2 # author: zfive5 (马 不 不 之 [蓑, So-fishing cold river Snow] # # Today, I decided that the system opens the seed file to analyze the BT client. This is a good understanding, I analyze the source code is done in the Window2000 environment, double click under the resource manager .torrent # File, will then see the BT client that we are familiar with, let us choose the file directory. . . . # 知 知, 文件 文件 文件 调 入 入 入 入 入 入 注 入 入 打 打 打 打 打 打 如 打 打 打 打 如 打 打 如 如 打 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如 如"#" Content Type "=" Application / X-Bittorrent "# [HKEY_CLASS_ROOT / BITTORENT] # @ =" Torrent File "#" EditFlags "= HEX: 00, 00, 01, 100 # # [HKEY_CLASS_ROOT / BITTORRENT / shell ] # @ = "open" # [HKEY_CLASS_ROOT / BITTORRENT / shell / edit] # @ = "Edit Torrent with Torrentedit" # [HKEY_CLASES_ROOT / BITTORRENT / Shell / Edit / Command] n = int (n) h, r = Divmod (n, 60 * 60) m, sec = divmod (r, 60) IF H> 1000000: Return '' IF H> 0: Return '% D Hour% 02D min% 02D sec'% (H, M, SEC ELSE: RETURN '% D min% 02D sec'% (M, SEC)
WXEVT_INVOKE = wxneWeventType ()
# 东东, 东东, I am not clear, you can skip Def evt_invoke (win, func): win.connect (-1, -1, wxevt_invoke, func)
# Ditto class InvokeEvent (wxPyEvent): def __init __ (self, func, args, kwargs): wxPyEvent .__ init __ (self) self.SetEventType (wxEVT_INVOKE) self.func = func self.args = args self.kwargs = kwargs
# Download the main form class, this, I also passed the consciousness, actually the correct Class DownloadInfoframe:
# This is the constructor of the class DEF __INIT __ (Self, Flag): frame = wxframe (none, -1, 'bittorrent' version 'Download', size = wxsize (400, 250)) self.frame = frame self. Flag = flag self.uiflag = Event () self.fin = false self.last_update_time = 0 self.showing_error = falsepanel = wxpanel (frame, -1) Colsizer = wxflexgridsizer (cols = 1, vgap = 3)
Fnsizer = wxboxsizer (wxhorizontal)
self.fileNameText = wxStaticText (panel, -1, '', style = wxALIGN_LEFT) fnsizer.Add (self.fileNameText, 1, wxALIGN_BOTTOM) self.aboutText = wxStaticText (panel, -1, 'about', style = wxALIGN_RIGHT) self .aboutText.SetForegroundColour ( 'Blue') self.aboutText.SetFont (wxFont (14, wxNORMAL, wxNORMAL, wxNORMAL, True)) fnsizer.Add (self.aboutText, 0, wxEXPAND) colSizer.Add (fnsizer, 0, wxEXPAND)
Self.gauge = wxgauge (Panel, -1, Range = 1000, Style = wxga_smooth) Colsizer.add (Self.gauge, 0, WXExpand)
Gridsizer = wxflexgridsizer (COLS = 2, VGAP = 3, HGAP = 8) Gridsizer.add (WxStaticText (Panel, -1, 'Estimated Time Left:')) Self.TimeestText = WxStaticText (panel, -1, ') Gridsizer .Add (Self.TimeestText, 0, WXExpand)
gridSizer.Add (wxStaticText (panel, -1, 'Download to:')) self.fileDestText = wxStaticText (panel, -1, '') gridSizer.Add (self.fileDestText, 0, wxEXPAND) gridSizer.AddGrowableCol (1)
Rategridsizer = wxflexgridsizer (COLS = 4, VGAP = 3, HGAP = 8)
rategridSizer.Add (wxStaticText (panel, -1, 'Download rate:')) self.downRateText = wxStaticText (panel, -1, '') rategridSizer.Add (self.downRateText, 0, wxEXPAND) rategridSizer.Add (wxStaticText ( Panel, -1, 'Downloaded:')) Self.Downtotaltext = wxStaticText (Panel, -1, ') rategridsizer.add (self.downtotaltext, 0, wxexpand) Rategridsizer.add (WxStaticText (Panel, -1,' Upload Rate: ')) Self.upratetext = wxStaticText (Panel, -1,') rategridsizer.add (self.uprattext, 0, wxexpand) Rategridsizer.add (wxStaticText (Panel, -1, 'uploaded:') Self. UptotalText = wxStaticText (Panel, -1, ') rategridsizer.add (self.uptotaltext, 0, wxexpand) Rategridsizer.addgrowablecol (1) Rategridsizer.addgrowablecol (3)
Colsizer.add (Gridsizer, 0, WxExpand) Colsizer.add (Rategridsizer, 0, WxExpand) Colsizer.Add (50, 50, 0, wxexpand) Self.cancelButton = wxbutton (Panel, -1, 'Cancel') colsizer.add (Self.cancelButton, 0, wxalign_center) Colsizer.addgrowablecol (0) Colsizer.addgrowableRow (3)
border = wxBoxSizer (wxHORIZONTAL) border.Add (colSizer, 1, wxEXPAND | wxALL, 4) panel.SetSizer (border) panel.SetAutoLayout (True) EVT_LEFT_DOWN (self.aboutText, self.donate) EVT_CLOSE (frame, self.done) EVT_Button (frame, self.cancelbutton.getID (), self.done) evt_invoke (frame, self.onInvoke) self.frame.show ()
# 上 上 上 上 上 上 上 上 上 上 上 上 上
Def donate2 (Self): Open_new ('http://bitconjurer.org/bittorrent/donate.html') Def OnInvoke (Self, Event): if not self.uiflag.isset (): Apply (event.func, event. Args, Event.kwargs)
Def Invokelater (Self, Func, Args = [], kwargs = {}: if not self.uiflag.isset (): wxpostevent (Self.Frame, InvokeEvent (Func, Args, Kwargs))
Def UpdateStatus (Self, D): IF (self.last_update_time 0.1