Package: bittorrent / 3.4.2-11.6

wxpy3.0-compat.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
Description: Make compatible with wxPython 3.0
 Many of these changes update code which wasn't even compatible with wxPython
 2.8 (wxEXPAND, wxID_OK, etc).
Author: Olly Betts <olly@survex.com>
Forwarded: no
Last-Update: 2014-08-08

--- a/btcompletedirgui.py
+++ b/btcompletedirgui.py
@@ -9,17 +9,21 @@
 from threading import Event, Thread
 from os.path import join, split
 from sys import argv
-from wxPython.wx import *
+import wxversion
+wxversion.select("3.0")
+import wx
+from wx import EVT_BUTTON, EVT_CLOSE
+
 from traceback import print_exc
 
-wxEVT_INVOKE = wxNewEventType()
+wxEVT_INVOKE = wx.NewEventType()
 
 def EVT_INVOKE(win, func):
     win.Connect(-1, -1, wxEVT_INVOKE, func)
 
-class InvokeEvent(wxPyEvent):
+class InvokeEvent(wx.PyEvent):
     def __init__(self, func, args, kwargs):
-        wxPyEvent.__init__(self)
+        wx.PyEvent.__init__(self)
         self.SetEventType(wxEVT_INVOKE)
         self.func = func
         self.args = args
@@ -27,62 +31,62 @@
 
 class DownloadInfo:
     def __init__(self):
-        frame = wxFrame(None, -1, 'BitTorrent complete dir 1.1', size = wxSize(550, 250))
+        frame = wx.Frame(None, -1, 'BitTorrent complete dir 1.1', size = wx.Size(550, 250))
         self.frame = frame
-        frame.SetIcon(wxIcon(join(split(argv[0])[0], 'bittorrent.ico'), wxBITMAP_TYPE_ICO))
+        frame.SetIcon(wx.Icon(join(split(argv[0])[0], 'bittorrent.ico'), wx.BITMAP_TYPE_ICO))
 
-        panel = wxPanel(frame, -1)
+        panel = wx.Panel(frame, -1)
 
-        gridSizer = wxFlexGridSizer(cols = 2, rows = 2, vgap = 15, hgap = 8)
+        gridSizer = wx.FlexGridSizer(cols = 2, vgap = 15, hgap = 8)
         
-        gridSizer.Add(wxStaticText(panel, -1, 'Files to make .torrents for:'))
-        self.dirCtl = wxTextCtrl(panel, -1, '')
+        gridSizer.Add(wx.StaticText(panel, -1, 'Files to make .torrents for:'))
+        self.dirCtl = wx.TextCtrl(panel, -1, '')
 
-        b = wxBoxSizer(wxHORIZONTAL)
-        b.Add(self.dirCtl, 1, wxEXPAND)
-        b.Add((10, 10), 0, wxEXPAND)
-        button = wxButton(panel, -1, 'add file')
-        b.Add(button, 0, wxEXPAND)
+        b = wx.BoxSizer(wx.HORIZONTAL)
+        b.Add(self.dirCtl, 1, wx.EXPAND)
+        b.Add((10, 10), 0, wx.EXPAND)
+        button = wx.Button(panel, -1, 'add file')
+        b.Add(button, 0, wx.EXPAND)
         EVT_BUTTON(frame, button.GetId(), self.select)
-        b.Add((5, 5), 0, wxEXPAND)
-        c = wxButton(panel, -1, 'add dir')
-        b.Add(c, 0, wxEXPAND)
+        b.Add((5, 5), 0, wx.EXPAND)
+        c = wx.Button(panel, -1, 'add dir')
+        b.Add(c, 0, wx.EXPAND)
         EVT_BUTTON(frame, c.GetId(), self.selectdir)
 
-        gridSizer.Add(b, 0, wxEXPAND)
+        gridSizer.Add(b, 0, wx.EXPAND)
 
-        gridSizer.Add(wxStaticText(panel, -1, 'announce url:'))
-        self.annCtl = wxTextCtrl(panel, -1, 'http://my.tracker:6969/announce')
-        gridSizer.Add(self.annCtl, 0, wxEXPAND)
+        gridSizer.Add(wx.StaticText(panel, -1, 'announce url:'))
+        self.annCtl = wx.TextCtrl(panel, -1, 'http://my.tracker:6969/announce')
+        gridSizer.Add(self.annCtl, 0, wx.EXPAND)
 
-        gridSizer.Add(wxStaticText(panel, -1, 'piece size:'))
-        self.piece_length = wxChoice(panel, -1, choices = ['2 ** 21', '2 ** 20', '2 ** 19', 
+        gridSizer.Add(wx.StaticText(panel, -1, 'piece size:'))
+        self.piece_length = wx.Choice(panel, -1, choices = ['2 ** 21', '2 ** 20', '2 ** 19', 
             '2 ** 18', '2 ** 17', '2 ** 16', '2 ** 15'])
         self.piece_length.SetSelection(3)
         gridSizer.Add(self.piece_length)
 
         gridSizer.AddGrowableCol(1)
  
-        border = wxBoxSizer(wxVERTICAL)
-        border.Add(gridSizer, 0, wxEXPAND | wxNORTH | wxEAST | wxWEST, 25)
-        b2 = wxButton(panel, -1, 'make')
-        border.Add((10, 10), 1, wxEXPAND)
-        border.Add(b2, 0, wxALIGN_CENTER | wxSOUTH, 20)
+        border = wx.BoxSizer(wx.VERTICAL)
+        border.Add(gridSizer, 0, wx.EXPAND | wx.NORTH | wx.EAST | wx.WEST, 25)
+        b2 = wx.Button(panel, -1, 'make')
+        border.Add((10, 10), 1, wx.EXPAND)
+        border.Add(b2, 0, wx.ALIGN_CENTER | wx.SOUTH, 20)
         EVT_BUTTON(frame, b2.GetId(), self.complete)
         panel.SetSizer(border)
         panel.SetAutoLayout(True)
 
     def select(self, x):
-        dl = wxFileDialog(self.frame, "Choose files", '/', "", '*.*', wxOPEN | wxMULTIPLE)
-        if dl.ShowModal() == wxID_OK:
+        dl = wx.FileDialog(self.frame, "Choose files", '/', "", '*.*', wx.FD_OPEN | wx.FD_MULTIPLE)
+        if dl.ShowModal() == wx.ID_OK:
             x = self.dirCtl.GetValue() + ';' + ';'.join(dl.GetPaths())
             if x[0] == ';':
                 x = x[1:]
             self.dirCtl.SetValue(x)
 
     def selectdir(self, x):
-        dl = wxDirDialog(self.frame, 'Choose directories', '/')
-        if dl.ShowModal() == wxID_OK:
+        dl = wx.DirDialog(self.frame, 'Choose directories', '/')
+        if dl.ShowModal() == wx.ID_OK:
             x = self.dirCtl.GetValue() + ';' + dl.GetPath()
             if x[0] == ';':
                 x = x[1:]
@@ -90,8 +94,8 @@
 
     def complete(self, x):
         if self.dirCtl.GetValue() == '':
-            dlg = wxMessageDialog(self.frame, message = 'You must select a directory', 
-                caption = 'Error', style = wxOK | wxICON_ERROR)
+            dlg = wx.MessageDialog(self.frame, message = 'You must select a directory', 
+                caption = 'Error', style = wx.OK | wx.ICON_ERROR)
             dlg.ShowModal()
             dlg.Destroy()
             return
@@ -108,25 +112,25 @@
         self.a = a
         self.pl = pl
         self.flag = Event()
-        frame = wxFrame(None, -1, 'BitTorrent make .torrent', size = wxSize(550, 250))
+        frame = wx.Frame(None, -1, 'BitTorrent make .torrent', size = wx.Size(550, 250))
         self.frame = frame
 
-        panel = wxPanel(frame, -1)
+        panel = wx.Panel(frame, -1)
 
-        gridSizer = wxFlexGridSizer(cols = 1, vgap = 15, hgap = 8)
+        gridSizer = wx.FlexGridSizer(cols = 1, vgap = 15, hgap = 8)
 
-        self.currentLabel = wxStaticText(panel, -1, 'checking file sizes')
-        gridSizer.Add(self.currentLabel, 0, wxEXPAND)
-        self.gauge = wxGauge(panel, -1, range = 1000, style = wxGA_SMOOTH)
-        gridSizer.Add(self.gauge, 0, wxEXPAND)
-        gridSizer.Add((10, 10), 1, wxEXPAND)
-        self.button = wxButton(panel, -1, 'cancel')
-        gridSizer.Add(self.button, 0, wxALIGN_CENTER)
+        self.currentLabel = wx.StaticText(panel, -1, 'checking file sizes')
+        gridSizer.Add(self.currentLabel, 0, wx.EXPAND)
+        self.gauge = wx.Gauge(panel, -1, range = 1000, style = wx.GA_SMOOTH)
+        gridSizer.Add(self.gauge, 0, wx.EXPAND)
+        gridSizer.Add((10, 10), 1, wx.EXPAND)
+        self.button = wx.Button(panel, -1, 'cancel')
+        gridSizer.Add(self.button, 0, wx.ALIGN_CENTER)
         gridSizer.AddGrowableRow(2)
         gridSizer.AddGrowableCol(0)
 
-        g2 = wxFlexGridSizer(cols = 1, vgap = 15, hgap = 8)
-        g2.Add(gridSizer, 1, wxEXPAND | wxALL, 25)
+        g2 = wx.FlexGridSizer(cols = 1, vgap = 15, hgap = 8)
+        g2.Add(gridSizer, 1, wx.EXPAND | wx.ALL, 25)
         g2.AddGrowableRow(0)
         g2.AddGrowableCol(0)
         panel.SetSizer(g2)
@@ -147,8 +151,8 @@
         except (OSError, IOError), e:
             self.currentLabel.SetLabel('Error!')
             self.button.SetLabel('Close')
-            dlg = wxMessageDialog(self.frame, message = 'Error - ' + str(e), 
-                caption = 'Error', style = wxOK | wxICON_ERROR)
+            dlg = wx.MessageDialog(self.frame, message = 'Error - ' + str(e), 
+                caption = 'Error', style = wx.OK | wx.ICON_ERROR)
             dlg.ShowModal()
             dlg.Destroy()
 
@@ -170,13 +174,13 @@
 
     def invokeLater(self, func, args = [], kwargs = {}):
         if not self.flag.isSet():
-            wxPostEvent(self.frame, InvokeEvent(func, args, kwargs))
+            wx.PostEvent(self.frame, InvokeEvent(func, args, kwargs))
 
     def done(self, event):
         self.flag.set()
         self.frame.Destroy()
 
-class btWxApp(wxApp):
+class btWxApp(wx.App):
     def OnInit(self):
         d = DownloadInfo()
         d.frame.Show(True)
@@ -185,3 +189,4 @@
 
 if __name__ == '__main__':
     btWxApp().MainLoop()
+
--- a/btdownloadgui.py
+++ b/btdownloadgui.py
@@ -10,7 +10,11 @@
 from threading import Event, Thread
 from os.path import join, split, exists
 from os import getcwd
-from wxPython.wx import *
+import wxversion
+wxversion.select("3.0")
+import wx
+from wx import EVT_BUTTON, EVT_CLOSE, EVT_LEFT_DOWN
+
 from time import strftime, time
 from webbrowser import open_new
 from traceback import print_exc
@@ -30,19 +34,19 @@
     else:
         return '%d min %02d sec' % (m, sec)
 
-wxEVT_INVOKE = wxNewEventType()
+wxEVT_INVOKE = wx.NewEventType()
 
 def EVT_INVOKE(win, func):
     win.Connect(-1, -1, wxEVT_INVOKE, func)
 
-class InvokeEvent(wxPyEvent):
+class InvokeEvent(wx.PyEvent):
     def __init__(self):
-        wxPyEvent.__init__(self)
+        wx.PyEvent.__init__(self)
         self.SetEventType(wxEVT_INVOKE)
 
 class DownloadInfoFrame:
     def __init__(self, flag):
-        frame = wxFrame(None, -1, 'BitTorrent ' + version + ' download', size = wxSize(400, 250))
+        frame = wx.Frame(None, -1, 'BitTorrent ' + version + ' download', size = wx.Size(400, 250))
         self.frame = frame
         self.flag = flag
         self.uiflag = Event()
@@ -52,67 +56,67 @@
         self.event = InvokeEvent()
         self.funclist = []
 
-        panel = wxPanel(frame, -1)
-        colSizer = wxFlexGridSizer(cols = 1, vgap = 3)
+        panel = wx.Panel(frame, -1)
+        colSizer = wx.FlexGridSizer(cols = 1, vgap = 3)
 
-        fnsizer = wxBoxSizer(wxHORIZONTAL)
+        fnsizer = wx.BoxSizer(wx.HORIZONTAL)
 
-        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.fileNameText = wx.StaticText(panel, -1, '', style = wx.ALIGN_LEFT)
+        fnsizer.Add(self.fileNameText, 1, wx.ALIGN_BOTTOM)
+        self.aboutText = wx.StaticText(panel, -1, 'about', style = wx.ALIGN_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)
+        self.aboutText.SetFont(wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL, True))
+        fnsizer.Add(self.aboutText, 0, wx.EXPAND)
+        colSizer.Add(fnsizer, 0, wx.EXPAND)
+
+        self.gauge = wx.Gauge(panel, -1, range = 1000, style = wx.GA_SMOOTH)
+        colSizer.Add(self.gauge, 0, wx.EXPAND)
+
+        gridSizer = wx.FlexGridSizer(cols = 2, vgap = 3, hgap = 8)
+        
+        gridSizer.Add(wx.StaticText(panel, -1, 'Estimated time left:'))
+        self.timeEstText = wx.StaticText(panel, -1, '')
+        gridSizer.Add(self.timeEstText, 0, wx.EXPAND)
+
+        gridSizer.Add(wx.StaticText(panel, -1, 'Download to:'))
+        self.fileDestText = wx.StaticText(panel, -1, '')
+        gridSizer.Add(self.fileDestText, 0, wx.EXPAND)
         
         gridSizer.AddGrowableCol(1)
 
-        rategridSizer = wxFlexGridSizer(cols = 4, vgap = 3, hgap = 8)
+        rategridSizer = wx.FlexGridSizer(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(wx.StaticText(panel, -1, 'Download rate:'))
+        self.downRateText = wx.StaticText(panel, -1, '')
+        rategridSizer.Add(self.downRateText, 0, wx.EXPAND)
 
-        rategridSizer.Add(wxStaticText(panel, -1, 'Downloaded:'))
-        self.downTotalText = wxStaticText(panel, -1, '')
-        rategridSizer.Add(self.downTotalText, 0, wxEXPAND)
+        rategridSizer.Add(wx.StaticText(panel, -1, 'Downloaded:'))
+        self.downTotalText = wx.StaticText(panel, -1, '')
+        rategridSizer.Add(self.downTotalText, 0, wx.EXPAND)
         
-        rategridSizer.Add(wxStaticText(panel, -1, 'Upload rate:'))
-        self.upRateText = wxStaticText(panel, -1, '')
-        rategridSizer.Add(self.upRateText, 0, wxEXPAND)
+        rategridSizer.Add(wx.StaticText(panel, -1, 'Upload rate:'))
+        self.upRateText = wx.StaticText(panel, -1, '')
+        rategridSizer.Add(self.upRateText, 0, wx.EXPAND)
         
         
-        rategridSizer.Add(wxStaticText(panel, -1, 'Uploaded:'))
-        self.upTotalText = wxStaticText(panel, -1, '')
-        rategridSizer.Add(self.upTotalText, 0, wxEXPAND)
+        rategridSizer.Add(wx.StaticText(panel, -1, 'Uploaded:'))
+        self.upTotalText = wx.StaticText(panel, -1, '')
+        rategridSizer.Add(self.upTotalText, 0, wx.EXPAND)
        
         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.Add(gridSizer, 0, wx.EXPAND)
+        colSizer.Add(rategridSizer, 0, wx.EXPAND)
+        colSizer.Add((50, 50), 0, wx.EXPAND)
+        self.cancelButton = wx.Button(panel, -1, 'Cancel')
+        colSizer.Add(self.cancelButton, 0, wx.ALIGN_CENTER)
         colSizer.AddGrowableCol(0)
         colSizer.AddGrowableRow(3)
 
-        border = wxBoxSizer(wxHORIZONTAL)
-        border.Add(colSizer, 1, wxEXPAND | wxALL, 4)
+        border = wx.BoxSizer(wx.HORIZONTAL)
+        border.Add(colSizer, 1, wx.EXPAND | wx.ALL, 4)
         panel.SetSizer(border)
         panel.SetAutoLayout(True)
         
@@ -120,7 +124,7 @@
         EVT_CLOSE(frame, self.done)
         EVT_BUTTON(frame, self.cancelButton.GetId(), self.done)
         EVT_INVOKE(frame, self.onInvoke)
-        self.frame.SetIcon(wxIcon(join(split(argv[0])[0], 'bittorrent.ico'), wxBITMAP_TYPE_ICO))
+        self.frame.SetIcon(wx.Icon(join(split(argv[0])[0], 'bittorrent.ico'), wx.BITMAP_TYPE_ICO))
         self.frame.Show()
 
     def donate(self, event):
@@ -138,7 +142,7 @@
         if not self.uiflag.isSet():
             self.funclist.append((func, args, kwargs))
             if len(self.funclist) == 1:
-                wxPostEvent(self.frame, self.event)
+                wx.PostEvent(self.frame, self.event)
 
     def updateStatus(self, d):
         if (self.last_update_time + 0.1 < time() and not self.showing_error) or d.get('fractionDone') in (0.0, 1.0) or d.has_key('activity'):
@@ -203,8 +207,8 @@
 
     def onErrorEvent(self, errormsg):
         self.showing_error = True
-        dlg = wxMessageDialog(self.frame, message = errormsg, 
-            caption = 'Download Error', style = wxOK | wxICON_ERROR)
+        dlg = wx.MessageDialog(self.frame, message = errormsg, 
+            caption = 'Download Error', style = wx.OK | wx.ICON_ERROR)
         dlg.Fit()
         dlg.Center()
         dlg.ShowModal()
@@ -220,11 +224,11 @@
     def onChooseFile(self, default, bucket, f, size, dir, saveas):
         if not saveas:
             if dir:
-                dl = wxDirDialog(self.frame, 'Choose a directory to save to, pick a partial download to resume', 
-                    join(getcwd(), default), style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON)
+                dl = wx.DirDialog(self.frame, 'Choose a directory to save to, pick a partial download to resume', 
+                    join(getcwd(), default), style = wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
             else:
-                dl = wxFileDialog(self.frame, 'Choose file to save as, pick a partial download to resume', '', default, '*', wxSAVE)
-            if dl.ShowModal() != wxID_OK:
+                dl = wx.FileDialog(self.frame, 'Choose file to save as, pick a partial download to resume', '', default, '*', wx.FD_SAVE)
+            if dl.ShowModal() != wx.ID_OK:
                 self.done(None)
                 f.set()
                 return
@@ -245,10 +249,10 @@
         self.flag.set()
         self.frame.Destroy()
 
-class btWxApp(wxApp):
+class btWxApp(wx.App):
     def __init__(self, x, params):
         self.params = params
-        wxApp.__init__(self, x)
+        wx.App.__init__(self, x)
 
     def OnInit(self):
         doneflag = Event()