Exemplo n.º 1
0
    def __init__(self, d, a, pl):
        self.d = d
        self.a = a
        self.pl = pl
        self.flag = threading.Event()
        frame = wx.wxFrame(None, -1, 'BitTorrent make directory',
                           size=wx.wxSize(550, 250))
        self.frame = frame

        panel = wx.wxPanel(frame, -1)

        gridSizer = wx.wxFlexGridSizer(cols=1, vgap=15, hgap=8)

        self.currentLabel = wx.wxStaticText(panel, -1, 'checking file sizes')
        gridSizer.Add(self.currentLabel, 0, wx.wxEXPAND)
        self.gauge = wx.wxGauge(panel, -1, range=1000, style=wx.wxGA_SMOOTH)
        gridSizer.Add(self.gauge, 0, wx.wxEXPAND)
        gridSizer.Add(10, 10, 1, wx.wxEXPAND)
        self.button = wx.wxButton(panel, -1, 'cancel')
        gridSizer.Add(self.button, 0, wx.wxALIGN_CENTER)
        gridSizer.AddGrowableRow(2)
        gridSizer.AddGrowableCol(0)

        g2 = wx.wxFlexGridSizer(cols=1, vgap=15, hgap=8)
        g2.Add(gridSizer, 1, wx.wxEXPAND | wx.wxALL, 25)
        g2.AddGrowableRow(0)
        g2.AddGrowableCol(0)
        panel.SetSizer(g2)
        panel.SetAutoLayout(True)
        wx.EVT_BUTTON(frame, self.button.GetId(), self.done)
        wx.EVT_CLOSE(frame, self.done)
        EVT_INVOKE(frame, self.onInvoke)
        frame.Show(True)
        threading.Thread(target=self.complete).start()
Exemplo n.º 2
0
    def __init__(self, op, fsoList, destPath):
        self.stopped = false
        self.InTransfer = false

        self.op = op
        if self.COPY == op: txt = "Copy"
        else: txt = "Move"

        self.fsoList = fsoList
        self.destPath = os.path.normpath(destPath)

        wxDialog.__init__(self, None, wxNewId(), txt + " operation")
        sizer = wxBoxSizer(wxVERTICAL)
        self.SetAutoLayout(true)
        self.SetSizer(sizer)
        self.sizer = sizer
        btn = wxButton(self, wxNewId(), "Stop")
        EVT_BUTTON(self, btn.GetId(), self.OnClick)

        self.txt1 = wxStaticText(self, wxNewId(), "Destination directory: ")
        self.txt2 = wxStaticText(self, wxNewId(), destPath)
        #self.txt = wxStaticText(self, wxNewId(), "Single object progress:")
        #self.gauge = wxGauge(self, wxNewId(), 100)
        self.txtAll = wxStaticText(self, wxNewId(), "Overall progress:")
        self.gaugeAll = wxGauge(self, wxNewId(), len(fsoList))

        flags = wxEXPAND | wxALL
        border = 0
        bb = 10
        sizer.Add(2 * bb, 2 * bb) # separator
        sizer.Add(self.txt1, 0, wxLEFT, border)
        sizer.Add(self.txt2, 0, wxLEFT, border)
        sizer.Add(bb, bb) # separator
        #sizer.Add(self.txt, 0, wxLEFT, border)
        #sizer.Add(bb, bb) # separator
        #sizer.Add(self.gauge, 0, flags, border)
        #sizer.Add(bb, bb) # separator
        sizer.Add(self.txtAll, 0, wxLEFT, border)
        sizer.Add(bb, bb) # separator
        sizer.Add(self.gaugeAll, 0, flags, border)
        sizer.Add(bb, bb) # separator
        sizer.Add(btn, 0, wxALIGN_CENTRE, border)
        sizer.Add(2 * bb, 2 * bb) # separator
        sizer.Layout()
        self.Refresh()

        EVT_IDLE(self, self.OnIdle)
Exemplo n.º 3
0
    def __init__(self, op, fsoList, destPath):
        self.stopped = false
        self.InTransfer = false

        self.op = op
        if self.COPY == op: txt = "Copy"
        else: txt = "Move"

        self.fsoList = fsoList
        self.destPath = os.path.normpath(destPath)

        wxDialog.__init__(self, None, wxNewId(), txt + " operation")
        sizer = wxBoxSizer(wxVERTICAL)
        self.SetAutoLayout(true)
        self.SetSizer(sizer)
        self.sizer = sizer
        btn = wxButton(self, wxNewId(), "Stop")
        EVT_BUTTON(self, btn.GetId(), self.OnClick)

        self.txt1 = wxStaticText(self, wxNewId(), "Destination directory: ")
        self.txt2 = wxStaticText(self, wxNewId(), destPath)
        #self.txt = wxStaticText(self, wxNewId(), "Single object progress:")
        #self.gauge = wxGauge(self, wxNewId(), 100)
        self.txtAll = wxStaticText(self, wxNewId(), "Overall progress:")
        self.gaugeAll = wxGauge(self, wxNewId(), len(fsoList))

        flags = wxEXPAND | wxALL
        border = 0
        bb = 10
        sizer.Add(2 * bb, 2 * bb)  # separator
        sizer.Add(self.txt1, 0, wxLEFT, border)
        sizer.Add(self.txt2, 0, wxLEFT, border)
        sizer.Add(bb, bb)  # separator
        #sizer.Add(self.txt, 0, wxLEFT, border)
        #sizer.Add(bb, bb) # separator
        #sizer.Add(self.gauge, 0, flags, border)
        #sizer.Add(bb, bb) # separator
        sizer.Add(self.txtAll, 0, wxLEFT, border)
        sizer.Add(bb, bb)  # separator
        sizer.Add(self.gaugeAll, 0, flags, border)
        sizer.Add(bb, bb)  # separator
        sizer.Add(btn, 0, wxALIGN_CENTRE, border)
        sizer.Add(2 * bb, 2 * bb)  # separator
        sizer.Layout()
        self.Refresh()

        EVT_IDLE(self, self.OnIdle)
Exemplo n.º 4
0
    def begin(self):
        if self.separatetorrents:
            frame = wx.wxFrame(None, -1, 'BitTorrent make directory',
                               size=wx.wxSize(550, 250))
        else:
            frame = wx.wxFrame(None, -1, 'BitTorrent make torrent',
                               size=wx.wxSize(550, 250))
        self.frame = frame

        panel = wx.wxPanel(frame, -1)
        gridSizer = wx.wxFlexGridSizer(cols=1, vgap=15, hgap=8)

        if self.separatetorrents:
            self.currentLabel = wx.wxStaticText(panel, -1,
                                                'checking file sizes')
        else:
            self.currentLabel = wx.wxStaticText(
                panel, -1, 'building ' + self.d + '.torrent')
        gridSizer.Add(self.currentLabel, 0, wx.wxEXPAND)
        self.gauge = wx.wxGauge(panel, -1, range=1000, style=wx.wxGA_SMOOTH)
        gridSizer.Add(self.gauge, 0, wx.wxEXPAND)
        gridSizer.Add((10, 10), 1, wx.wxEXPAND)
        self.button = wx.wxButton(panel, -1, 'cancel')
        gridSizer.Add(self.button, 0, wx.wxALIGN_CENTER)
        gridSizer.AddGrowableRow(2)
        gridSizer.AddGrowableCol(0)

        g2 = wx.wxFlexGridSizer(cols=1, vgap=15, hgap=8)
        g2.Add(gridSizer, 1, wx.wxEXPAND | wx.wxALL, 25)
        g2.AddGrowableRow(0)
        g2.AddGrowableCol(0)
        panel.SetSizer(g2)
        panel.SetAutoLayout(True)
        wx.EVT_BUTTON(frame, self.button.GetId(), self.done)
        wx.EVT_CLOSE(frame, self.done)
        EVT_INVOKE(frame, self.onInvoke)
        frame.Show(True)
        threading.Thread(target=self.complete).start()
Exemplo n.º 5
0
    def __init__(self, config, calls):
        self.config = config
        self.calls = calls

        self.uiflag = threading.Event()
        self.cancelflag = threading.Event()
        self.switchlock = threading.Lock()
        self.working = False
        self.queue = []
        wx.wxInitAllImageHandlers()
        self.thostselection = self.calls['getCurrentTHost']()
        self.thostselectnum = 0
        self.choices = None
        self.choices1 = None
        self.announce = ''
        self.announce_list = None

        self.windowStyle = wx.wxSYSTEM_MENU | wx.wxCAPTION | wx.wxMINIMIZE_BOX
        if self.config['stayontop']:
            self.windowStyle |= wx.wxSTAY_ON_TOP
        frame = wx.wxFrame(None,
                           -1,
                           'T-Make',
                           size=wx.wxSize(-1, -1),
                           style=self.windowStyle)
        self.frame = frame
        panel = wx.wxPanel(frame, -1)
        mainSizer = wx.wxBoxSizer(wx.wxVERTICAL)
        groupSizer = wx.wxFlexGridSizer(cols=1, vgap=0, hgap=0)
        #        self.dropTarget = self.calls['newDropTarget']((200, 200))
        self.dropTarget = self.calls['newDropTarget']()
        self.dropTargetPtr = wx.wxStaticBitmap(panel, -1, self.dropTarget)
        self.calls['setDropTargetRefresh'](self.dropTargetPtr.Refresh)
        self.dropTargetWidth = self.dropTarget.GetWidth()
        wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick)
        wx.EVT_ENTER_WINDOW(self.dropTargetPtr,
                            self.calls['dropTargetHovered'])
        wx.EVT_LEAVE_WINDOW(self.dropTargetPtr,
                            self.calls['dropTargetUnhovered'])
        groupSizer.Add(self.dropTargetPtr, 0, wx.wxALIGN_CENTER)
        lowerSizer1 = wx.wxGridSizer(cols=6)
        dirlink = wx.wxStaticText(panel, -1, 'dir')
        dirlink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        dirlink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        lowerSizer1.Add(dirlink, -1, wx.wxALIGN_LEFT)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ''), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ''), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ''), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ''), -1, wx.wxALIGN_CENTER)
        filelink = wx.wxStaticText(panel, -1, 'file')
        filelink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        filelink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(filelink, self.selectfile)
        lowerSizer1.Add(filelink, -1, wx.wxALIGN_RIGHT)

        groupSizer.Add(lowerSizer1, -1, wx.wxALIGN_CENTER)

        self.gauge = wx.wxGauge(panel,
                                -1,
                                range=1000,
                                style=wx.wxGA_HORIZONTAL,
                                size=(-1, 15))
        groupSizer.Add(self.gauge, 0, wx.wxEXPAND)
        self.statustext = wx.wxStaticText(panel,
                                          -1,
                                          'ready',
                                          style=wx.wxALIGN_CENTER
                                          | wx.wxST_NO_AUTORESIZE)
        self.statustext.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxBOLD, False))
        groupSizer.Add(self.statustext, -1, wx.wxEXPAND)
        self.choices = wx.wxChoice(panel,
                                   -1, (-1, -1), (self.dropTargetWidth, -1),
                                   choices=[])
        self.choices.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        wx.EVT_CHOICE(self.choices, -1, self.set_thost)
        groupSizer.Add(self.choices, 0, wx.wxEXPAND)
        cancellink = wx.wxStaticText(panel, -1, 'cancel')
        cancellink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        cancellink.SetForegroundColour('red')
        wx.EVT_LEFT_UP(cancellink, self.cancel)
        groupSizer.Add(cancellink, -1, wx.wxALIGN_CENTER)
        advlink = wx.wxStaticText(panel, -1, 'advanced')
        advlink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        advlink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(advlink, self.calls['switchToAdvanced'])
        groupSizer.Add(advlink, -1, wx.wxALIGN_CENTER)
        mainSizer.Add(groupSizer, 0, wx.wxALIGN_CENTER)

        self.refresh_thostlist()
        self._set_thost()

        if sys.platform == 'win32':
            self.dropTargetPtr.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop)


#        border = wxBoxSizer(wxHORIZONTAL)
#        border.Add(mainSizer, 1, wxEXPAND | wxALL, 0)
        panel.SetSizer(mainSizer)
        panel.SetAutoLayout(True)
        #        border.Fit(panel)
        mainSizer.Fit(panel)
        frame.Fit()
        frame.Show(True)

        EVT_INVOKE(frame, self.onInvoke)
        wx.EVT_CLOSE(frame, self._close)
Exemplo n.º 6
0
    def __init__(self, config, calls):
        self.config = config
        self.calls = calls

        self.uiflag = threading.Event()
        self.cancelflag = threading.Event()
        self.switchlock = threading.Lock()
        self.working = False
        self.queue = []
        wx.wxInitAllImageHandlers()
        self.thostselection = self.calls['getCurrentTHost']()
        self.thostselectnum = 0
        self.choices = None
        self.choices1 = None

        self.windowStyle = wx.wxSYSTEM_MENU | wx.wxCAPTION | wx.wxMINIMIZE_BOX
        if self.config['stayontop']:
            self.windowStyle |= wx.wxSTAY_ON_TOP
        frame = wx.wxFrame(None,
                           -1,
                           'T-Make',
                           size=wx.wxSize(-1, -1),
                           style=self.windowStyle)
        self.frame = frame
        panel = wx.wxPanel(frame, -1)

        fullSizer = wx.wxFlexGridSizer(cols=1, vgap=0, hgap=8)

        colSizer = wx.wxFlexGridSizer(cols=2, vgap=0, hgap=8)
        leftSizer = wx.wxFlexGridSizer(cols=1, vgap=3)

        self.stayontop_checkbox = wx.wxCheckBox(panel, -1, "stay on top")
        self.stayontop_checkbox.SetValue(self.config['stayontop'])
        wx.EVT_CHECKBOX(frame, self.stayontop_checkbox.GetId(),
                        self.setstayontop)
        leftSizer.Add(self.stayontop_checkbox, -1, wx.wxALIGN_CENTER)
        leftSizer.Add(wx.wxStaticText(panel, -1, ''))

        button = wx.wxButton(panel, -1, 'use image...')
        wx.EVT_BUTTON(frame, button.GetId(), self.selectDropTarget)
        leftSizer.Add(button, -1, wx.wxALIGN_CENTER)

        self.groupSizer1Box = wx.wxStaticBox(panel, -1, '')
        groupSizer1 = wx.wxStaticBoxSizer(self.groupSizer1Box, wx.wxHORIZONTAL)
        groupSizer = wx.wxFlexGridSizer(cols=1, vgap=0)
        self.dropTarget = self.calls['newDropTarget']((200, 200))
        #        self.dropTarget = self.calls['newDropTarget']()
        self.dropTargetPtr = wx.wxStaticBitmap(panel, -1, self.dropTarget)
        self.calls['setDropTargetRefresh'](self.dropTargetPtr.Refresh)
        self.dropTargetWidth = self.dropTarget.GetWidth()
        wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick)
        wx.EVT_ENTER_WINDOW(self.dropTargetPtr,
                            self.calls['dropTargetHovered'])
        wx.EVT_LEAVE_WINDOW(self.dropTargetPtr,
                            self.calls['dropTargetUnhovered'])
        groupSizer.Add(self.dropTargetPtr, 0, wx.wxALIGN_CENTER)
        lowerSizer1 = wx.wxGridSizer(cols=3)
        dirlink = wx.wxStaticText(panel, -1, 'dir')
        dirlink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        dirlink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        lowerSizer1.Add(dirlink, -1, wx.wxALIGN_LEFT)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ''), -1, wx.wxALIGN_CENTER)
        filelink = wx.wxStaticText(panel, -1, 'file')
        filelink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        filelink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(filelink, self.selectfile)
        lowerSizer1.Add(filelink, -1, wx.wxALIGN_RIGHT)

        groupSizer.Add(lowerSizer1, -1, wx.wxALIGN_CENTER)

        self.gauge = wx.wxGauge(panel,
                                -1,
                                range=1000,
                                style=wx.wxGA_HORIZONTAL,
                                size=(-1, 15))
        groupSizer.Add(self.gauge, 0, wx.wxEXPAND)
        self.statustext = wx.wxStaticText(panel,
                                          -1,
                                          'ready',
                                          style=wx.wxALIGN_CENTER
                                          | wx.wxST_NO_AUTORESIZE)
        self.statustext.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxBOLD, False))
        groupSizer.Add(self.statustext, -1, wx.wxEXPAND)
        self.choices = wx.wxChoice(panel,
                                   -1, (-1, -1), (self.dropTargetWidth, -1),
                                   choices=[])
        self.choices.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        wx.EVT_CHOICE(self.choices, -1, self.set_thost)
        groupSizer.Add(self.choices, 0, wx.wxEXPAND)
        cancellink = wx.wxStaticText(panel, -1, 'cancel')
        cancellink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        cancellink.SetForegroundColour('red')
        wx.EVT_LEFT_UP(cancellink, self.cancel)
        groupSizer.Add(cancellink, -1, wx.wxALIGN_CENTER)
        dummyadvlink = wx.wxStaticText(panel, -1, 'advanced')
        dummyadvlink.SetFont(
            wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        dummyadvlink.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        groupSizer.Add(dummyadvlink, -1, wx.wxALIGN_CENTER)
        groupSizer1.Add(groupSizer)
        leftSizer.Add(groupSizer1, -1, wx.wxALIGN_CENTER)

        leftSizer.Add(wx.wxStaticText(panel, -1, 'make torrent of:'), 0,
                      wx.wxALIGN_CENTER)

        self.dirCtl = wx.wxTextCtrl(panel, -1, '', size=(250, -1))
        leftSizer.Add(self.dirCtl, 1, wx.wxEXPAND)

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        button = wx.wxButton(panel, -1, 'dir')
        wx.EVT_BUTTON(frame, button.GetId(), self.selectdir)
        b.Add(button, 0)

        button2 = wx.wxButton(panel, -1, 'file')
        wx.EVT_BUTTON(frame, button2.GetId(), self.selectfile)
        b.Add(button2, 0)

        leftSizer.Add(b, 0, wx.wxALIGN_CENTER)

        leftSizer.Add(wx.wxStaticText(panel, -1, ''))

        simple_link = wx.wxStaticText(panel, -1, 'back to basic mode')
        simple_link.SetFont(
            wx.wxFont(-1, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        simple_link.SetForegroundColour('blue')
        wx.EVT_LEFT_UP(simple_link, self.calls['switchToBasic'])
        leftSizer.Add(simple_link, -1, wx.wxALIGN_CENTER)

        colSizer.Add(leftSizer, -1, wx.wxALIGN_CENTER_VERTICAL)

        gridSizer = wx.wxFlexGridSizer(cols=2, vgap=6, hgap=8)

        gridSizer.Add(wx.wxStaticText(panel, -1, 'Torrent host:'), -1,
                      wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)

        self.choices1 = wx.wxChoice(panel, -1, (-1, -1), (-1, -1), choices=[])
        wx.EVT_CHOICE(self.choices1, -1, self.set_thost1)
        gridSizer.Add(self.choices1, 0, wx.wxEXPAND)

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        button1 = wx.wxButton(panel, -1, 'set default')
        wx.EVT_BUTTON(frame, button1.GetId(), self.set_default_thost)
        b.Add(button1, 0)
        b.Add(wx.wxStaticText(panel, -1, '       '))
        button2 = wx.wxButton(panel, -1, 'delete')
        wx.EVT_BUTTON(frame, button2.GetId(), self.delete_thost)
        b.Add(button2, 0)
        b.Add(wx.wxStaticText(panel, -1, '       '))
        button3 = wx.wxButton(panel, -1, 'save as...')
        wx.EVT_BUTTON(frame, button3.GetId(), self.save_thost)
        b.Add(button3, 0)

        gridSizer.Add(wx.wxStaticText(panel, -1, ''))
        gridSizer.Add(b, 0, wx.wxALIGN_CENTER)

        gridSizer.Add(wx.wxStaticText(panel, -1, ''))
        gridSizer.Add(wx.wxStaticText(panel, -1, ''))

        gridSizer.Add(wx.wxStaticText(panel, -1, 'single tracker url:'), 0,
                      wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)
        self.annCtl = wx.wxTextCtrl(panel, -1,
                                    'http://my.tracker:6969/announce')
        gridSizer.Add(self.annCtl, 0, wx.wxEXPAND)

        a = wx.wxFlexGridSizer(cols=1, vgap=3)
        a.Add(wx.wxStaticText(panel, -1, 'tracker list:'), 0, wx.wxALIGN_RIGHT)
        a.Add(wx.wxStaticText(panel, -1, ''))
        abutton = wx.wxButton(panel,
                              -1,
                              'copy\nannounces\nfrom\ntorrent',
                              size=(70, 70))
        wx.EVT_BUTTON(frame, abutton.GetId(), self.announcecopy)
        a.Add(abutton, -1, wx.wxALIGN_CENTER)
        a.Add(wx.wxStaticText(panel, -1, DROP_HERE), -1, wx.wxALIGN_CENTER)
        gridSizer.Add(a, -1, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)

        self.annListCtl = wx.wxTextCtrl(
            panel, -1, '\n\n\n\n\n', wx.wxPoint(-1, -1), (300, 120),
            wx.wxTE_MULTILINE | wx.wxHSCROLL | wx.wxTE_DONTWRAP)
        gridSizer.Add(self.annListCtl, -1, wx.wxEXPAND)

        gridSizer.Add(wx.wxStaticText(panel, -1, ''))
        exptext = wx.wxStaticText(
            panel, -1, 'a list of tracker urls separated by commas or '
            'whitespace\nand on several lines -trackers on the same line will '
            'be\ntried randomly, and all the trackers on one line\nwill be '
            'tried before the trackers on the next line.')
        exptext.SetFont(
            wx.wxFont(6, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        gridSizer.Add(exptext, -1, wx.wxALIGN_CENTER)

        self.refresh_thostlist()
        self._set_thost()

        if sys.platform == 'win32':
            self.dropTargetPtr.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop)
            self.groupSizer1Box.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.groupSizer1Box, self.selectdrop)
            abutton.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(abutton, self.announcedrop)
            self.annCtl.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.annCtl, self.announcedrop)
            self.annListCtl.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.annListCtl, self.announcedrop)

        gridSizer.Add(wx.wxStaticText(panel, -1, ''))
        gridSizer.Add(wx.wxStaticText(panel, -1, ''))

        gridSizer.Add(wx.wxStaticText(panel, -1, 'piece size:'), 0,
                      wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)
        self.piece_length = wx.wxChoice(panel,
                                        -1,
                                        choices=[
                                            'automatic', '2MiB', '1MiB',
                                            '512KiB', '256KiB', '128KiB',
                                            '64KiB', '32KiB'
                                        ])
        self.piece_length_list = [0, 21, 20, 19, 18, 17, 16, 15]
        self.piece_length.SetSelection(0)
        gridSizer.Add(self.piece_length)

        gridSizer.Add(wx.wxStaticText(panel, -1, 'comment:'), 0,
                      wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)
        self.commentCtl = wx.wxTextCtrl(panel, -1, '')
        gridSizer.Add(self.commentCtl, 0, wx.wxEXPAND)

        gridSizer.Add(wx.wxStaticText(panel, -1, ''))
        gridSizer.Add(wx.wxStaticText(panel, -1, ''))

        b1 = wx.wxButton(panel, -1, 'Cancel', size=(-1, 30))
        wx.EVT_BUTTON(frame, b1.GetId(), self.cancel)
        gridSizer.Add(b1, 0, wx.wxEXPAND)
        b2 = wx.wxButton(panel, -1, 'MAKE TORRENT', size=(-1, 30))
        wx.EVT_BUTTON(frame, b2.GetId(), self.complete)
        gridSizer.Add(b2, 0, wx.wxEXPAND)

        gridSizer.AddGrowableCol(1)
        colSizer.Add(gridSizer, -1, wx.wxALIGN_CENTER_VERTICAL)
        fullSizer.Add(colSizer)

        border = wx.wxBoxSizer(wx.wxHORIZONTAL)
        border.Add(fullSizer, 1, wx.wxEXPAND | wx.wxALL, 15)
        panel.SetSizer(border)
        panel.SetAutoLayout(True)
        border.Fit(panel)
        frame.Fit()
        frame.Show(True)

        EVT_INVOKE(frame, self.onInvoke)
        wx.EVT_CLOSE(frame, self._close)
Exemplo n.º 7
0
    def __init__(self, config, calls):
        self.config = config
        self.calls = calls

        self.uiflag = threading.Event()
        self.cancelflag = threading.Event()
        self.switchlock = threading.Lock()
        self.working = False
        self.queue = []
        wx.wxInitAllImageHandlers()
        self.thostselection = self.calls["getCurrentTHost"]()
        self.thostselectnum = 0
        self.choices = None
        self.choices1 = None
        self.announce = ""
        self.announce_list = None

        self.windowStyle = wx.wxSYSTEM_MENU | wx.wxCAPTION | wx.wxMINIMIZE_BOX
        if self.config["stayontop"]:
            self.windowStyle |= wx.wxSTAY_ON_TOP
        frame = wx.wxFrame(None, -1, "T-Make", size=wx.wxSize(-1, -1), style=self.windowStyle)
        self.frame = frame
        panel = wx.wxPanel(frame, -1)
        mainSizer = wx.wxBoxSizer(wx.wxVERTICAL)
        groupSizer = wx.wxFlexGridSizer(cols=1, vgap=0, hgap=0)
        #        self.dropTarget = self.calls['newDropTarget']((200, 200))
        self.dropTarget = self.calls["newDropTarget"]()
        self.dropTargetPtr = wx.wxStaticBitmap(panel, -1, self.dropTarget)
        self.calls["setDropTargetRefresh"](self.dropTargetPtr.Refresh)
        self.dropTargetWidth = self.dropTarget.GetWidth()
        wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick)
        wx.EVT_ENTER_WINDOW(self.dropTargetPtr, self.calls["dropTargetHovered"])
        wx.EVT_LEAVE_WINDOW(self.dropTargetPtr, self.calls["dropTargetUnhovered"])
        groupSizer.Add(self.dropTargetPtr, 0, wx.wxALIGN_CENTER)
        lowerSizer1 = wx.wxGridSizer(cols=6)
        dirlink = wx.wxStaticText(panel, -1, "dir")
        dirlink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        dirlink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        lowerSizer1.Add(dirlink, -1, wx.wxALIGN_LEFT)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ""), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ""), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ""), -1, wx.wxALIGN_CENTER)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ""), -1, wx.wxALIGN_CENTER)
        filelink = wx.wxStaticText(panel, -1, "file")
        filelink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        filelink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(filelink, self.selectfile)
        lowerSizer1.Add(filelink, -1, wx.wxALIGN_RIGHT)

        groupSizer.Add(lowerSizer1, -1, wx.wxALIGN_CENTER)

        self.gauge = wx.wxGauge(panel, -1, range=1000, style=wx.wxGA_HORIZONTAL, size=(-1, 15))
        groupSizer.Add(self.gauge, 0, wx.wxEXPAND)
        self.statustext = wx.wxStaticText(panel, -1, "ready", style=wx.wxALIGN_CENTER | wx.wxST_NO_AUTORESIZE)
        self.statustext.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxBOLD, False))
        groupSizer.Add(self.statustext, -1, wx.wxEXPAND)
        self.choices = wx.wxChoice(panel, -1, (-1, -1), (self.dropTargetWidth, -1), choices=[])
        self.choices.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        wx.EVT_CHOICE(self.choices, -1, self.set_thost)
        groupSizer.Add(self.choices, 0, wx.wxEXPAND)
        cancellink = wx.wxStaticText(panel, -1, "cancel")
        cancellink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        cancellink.SetForegroundColour("red")
        wx.EVT_LEFT_UP(cancellink, self.cancel)
        groupSizer.Add(cancellink, -1, wx.wxALIGN_CENTER)
        advlink = wx.wxStaticText(panel, -1, "advanced")
        advlink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        advlink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(advlink, self.calls["switchToAdvanced"])
        groupSizer.Add(advlink, -1, wx.wxALIGN_CENTER)
        mainSizer.Add(groupSizer, 0, wx.wxALIGN_CENTER)

        self.refresh_thostlist()
        self._set_thost()

        if sys.platform == "win32":
            self.dropTargetPtr.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop)

        #        border = wxBoxSizer(wxHORIZONTAL)
        #        border.Add(mainSizer, 1, wxEXPAND | wxALL, 0)
        panel.SetSizer(mainSizer)
        panel.SetAutoLayout(True)
        #        border.Fit(panel)
        mainSizer.Fit(panel)
        frame.Fit()
        frame.Show(True)

        EVT_INVOKE(frame, self.onInvoke)
        wx.EVT_CLOSE(frame, self._close)
Exemplo n.º 8
0
    def __init__(self, config, calls):
        self.config = config
        self.calls = calls

        self.uiflag = threading.Event()
        self.cancelflag = threading.Event()
        self.switchlock = threading.Lock()
        self.working = False
        self.queue = []
        wx.wxInitAllImageHandlers()
        self.thostselection = self.calls["getCurrentTHost"]()
        self.thostselectnum = 0
        self.choices = None
        self.choices1 = None

        self.windowStyle = wx.wxSYSTEM_MENU | wx.wxCAPTION | wx.wxMINIMIZE_BOX
        if self.config["stayontop"]:
            self.windowStyle |= wx.wxSTAY_ON_TOP
        frame = wx.wxFrame(None, -1, "T-Make", size=wx.wxSize(-1, -1), style=self.windowStyle)
        self.frame = frame
        panel = wx.wxPanel(frame, -1)

        fullSizer = wx.wxFlexGridSizer(cols=1, vgap=0, hgap=8)

        colSizer = wx.wxFlexGridSizer(cols=2, vgap=0, hgap=8)
        leftSizer = wx.wxFlexGridSizer(cols=1, vgap=3)

        self.stayontop_checkbox = wx.wxCheckBox(panel, -1, "stay on top")
        self.stayontop_checkbox.SetValue(self.config["stayontop"])
        wx.EVT_CHECKBOX(frame, self.stayontop_checkbox.GetId(), self.setstayontop)
        leftSizer.Add(self.stayontop_checkbox, -1, wx.wxALIGN_CENTER)
        leftSizer.Add(wx.wxStaticText(panel, -1, ""))

        button = wx.wxButton(panel, -1, "use image...")
        wx.EVT_BUTTON(frame, button.GetId(), self.selectDropTarget)
        leftSizer.Add(button, -1, wx.wxALIGN_CENTER)

        self.groupSizer1Box = wx.wxStaticBox(panel, -1, "")
        groupSizer1 = wx.wxStaticBoxSizer(self.groupSizer1Box, wx.wxHORIZONTAL)
        groupSizer = wx.wxFlexGridSizer(cols=1, vgap=0)
        self.dropTarget = self.calls["newDropTarget"]((200, 200))
        #        self.dropTarget = self.calls['newDropTarget']()
        self.dropTargetPtr = wx.wxStaticBitmap(panel, -1, self.dropTarget)
        self.calls["setDropTargetRefresh"](self.dropTargetPtr.Refresh)
        self.dropTargetWidth = self.dropTarget.GetWidth()
        wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick)
        wx.EVT_ENTER_WINDOW(self.dropTargetPtr, self.calls["dropTargetHovered"])
        wx.EVT_LEAVE_WINDOW(self.dropTargetPtr, self.calls["dropTargetUnhovered"])
        groupSizer.Add(self.dropTargetPtr, 0, wx.wxALIGN_CENTER)
        lowerSizer1 = wx.wxGridSizer(cols=3)
        dirlink = wx.wxStaticText(panel, -1, "dir")
        dirlink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        dirlink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        lowerSizer1.Add(dirlink, -1, wx.wxALIGN_LEFT)
        lowerSizer1.Add(wx.wxStaticText(panel, -1, ""), -1, wx.wxALIGN_CENTER)
        filelink = wx.wxStaticText(panel, -1, "file")
        filelink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        filelink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(filelink, self.selectfile)
        lowerSizer1.Add(filelink, -1, wx.wxALIGN_RIGHT)

        groupSizer.Add(lowerSizer1, -1, wx.wxALIGN_CENTER)

        self.gauge = wx.wxGauge(panel, -1, range=1000, style=wx.wxGA_HORIZONTAL, size=(-1, 15))
        groupSizer.Add(self.gauge, 0, wx.wxEXPAND)
        self.statustext = wx.wxStaticText(panel, -1, "ready", style=wx.wxALIGN_CENTER | wx.wxST_NO_AUTORESIZE)
        self.statustext.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxBOLD, False))
        groupSizer.Add(self.statustext, -1, wx.wxEXPAND)
        self.choices = wx.wxChoice(panel, -1, (-1, -1), (self.dropTargetWidth, -1), choices=[])
        self.choices.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        wx.EVT_CHOICE(self.choices, -1, self.set_thost)
        groupSizer.Add(self.choices, 0, wx.wxEXPAND)
        cancellink = wx.wxStaticText(panel, -1, "cancel")
        cancellink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        cancellink.SetForegroundColour("red")
        wx.EVT_LEFT_UP(cancellink, self.cancel)
        groupSizer.Add(cancellink, -1, wx.wxALIGN_CENTER)
        dummyadvlink = wx.wxStaticText(panel, -1, "advanced")
        dummyadvlink.SetFont(wx.wxFont(7, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        dummyadvlink.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(dirlink, self.selectdir)
        groupSizer.Add(dummyadvlink, -1, wx.wxALIGN_CENTER)
        groupSizer1.Add(groupSizer)
        leftSizer.Add(groupSizer1, -1, wx.wxALIGN_CENTER)

        leftSizer.Add(wx.wxStaticText(panel, -1, "make torrent of:"), 0, wx.wxALIGN_CENTER)

        self.dirCtl = wx.wxTextCtrl(panel, -1, "", size=(250, -1))
        leftSizer.Add(self.dirCtl, 1, wx.wxEXPAND)

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        button = wx.wxButton(panel, -1, "dir")
        wx.EVT_BUTTON(frame, button.GetId(), self.selectdir)
        b.Add(button, 0)

        button2 = wx.wxButton(panel, -1, "file")
        wx.EVT_BUTTON(frame, button2.GetId(), self.selectfile)
        b.Add(button2, 0)

        leftSizer.Add(b, 0, wx.wxALIGN_CENTER)

        leftSizer.Add(wx.wxStaticText(panel, -1, ""))

        simple_link = wx.wxStaticText(panel, -1, "back to basic mode")
        simple_link.SetFont(wx.wxFont(-1, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, True))
        simple_link.SetForegroundColour("blue")
        wx.EVT_LEFT_UP(simple_link, self.calls["switchToBasic"])
        leftSizer.Add(simple_link, -1, wx.wxALIGN_CENTER)

        colSizer.Add(leftSizer, -1, wx.wxALIGN_CENTER_VERTICAL)

        gridSizer = wx.wxFlexGridSizer(cols=2, vgap=6, hgap=8)

        gridSizer.Add(wx.wxStaticText(panel, -1, "Torrent host:"), -1, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)

        self.choices1 = wx.wxChoice(panel, -1, (-1, -1), (-1, -1), choices=[])
        wx.EVT_CHOICE(self.choices1, -1, self.set_thost1)
        gridSizer.Add(self.choices1, 0, wx.wxEXPAND)

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        button1 = wx.wxButton(panel, -1, "set default")
        wx.EVT_BUTTON(frame, button1.GetId(), self.set_default_thost)
        b.Add(button1, 0)
        b.Add(wx.wxStaticText(panel, -1, "       "))
        button2 = wx.wxButton(panel, -1, "delete")
        wx.EVT_BUTTON(frame, button2.GetId(), self.delete_thost)
        b.Add(button2, 0)
        b.Add(wx.wxStaticText(panel, -1, "       "))
        button3 = wx.wxButton(panel, -1, "save as...")
        wx.EVT_BUTTON(frame, button3.GetId(), self.save_thost)
        b.Add(button3, 0)

        gridSizer.Add(wx.wxStaticText(panel, -1, ""))
        gridSizer.Add(b, 0, wx.wxALIGN_CENTER)

        gridSizer.Add(wx.wxStaticText(panel, -1, ""))
        gridSizer.Add(wx.wxStaticText(panel, -1, ""))

        gridSizer.Add(
            wx.wxStaticText(panel, -1, "single tracker url:"), 0, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL
        )
        self.annCtl = wx.wxTextCtrl(panel, -1, "http://my.tracker:6969/announce")
        gridSizer.Add(self.annCtl, 0, wx.wxEXPAND)

        a = wx.wxFlexGridSizer(cols=1, vgap=3)
        a.Add(wx.wxStaticText(panel, -1, "tracker list:"), 0, wx.wxALIGN_RIGHT)
        a.Add(wx.wxStaticText(panel, -1, ""))
        abutton = wx.wxButton(panel, -1, "copy\nannounces\nfrom\ntorrent", size=(70, 70))
        wx.EVT_BUTTON(frame, abutton.GetId(), self.announcecopy)
        a.Add(abutton, -1, wx.wxALIGN_CENTER)
        a.Add(wx.wxStaticText(panel, -1, DROP_HERE), -1, wx.wxALIGN_CENTER)
        gridSizer.Add(a, -1, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)

        self.annListCtl = wx.wxTextCtrl(
            panel, -1, "\n\n\n\n\n", wx.wxPoint(-1, -1), (300, 120), wx.wxTE_MULTILINE | wx.wxHSCROLL | wx.wxTE_DONTWRAP
        )
        gridSizer.Add(self.annListCtl, -1, wx.wxEXPAND)

        gridSizer.Add(wx.wxStaticText(panel, -1, ""))
        exptext = wx.wxStaticText(
            panel,
            -1,
            "a list of tracker urls separated by commas or "
            "whitespace\nand on several lines -trackers on the same line will "
            "be\ntried randomly, and all the trackers on one line\nwill be "
            "tried before the trackers on the next line.",
        )
        exptext.SetFont(wx.wxFont(6, wx.wxDEFAULT, wx.wxNORMAL, wx.wxNORMAL, False))
        gridSizer.Add(exptext, -1, wx.wxALIGN_CENTER)

        self.refresh_thostlist()
        self._set_thost()

        if sys.platform == "win32":
            self.dropTargetPtr.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop)
            self.groupSizer1Box.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.groupSizer1Box, self.selectdrop)
            abutton.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(abutton, self.announcedrop)
            self.annCtl.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.annCtl, self.announcedrop)
            self.annListCtl.DragAcceptFiles(True)
            wx.EVT_DROP_FILES(self.annListCtl, self.announcedrop)

        gridSizer.Add(wx.wxStaticText(panel, -1, ""))
        gridSizer.Add(wx.wxStaticText(panel, -1, ""))

        gridSizer.Add(wx.wxStaticText(panel, -1, "piece size:"), 0, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)
        self.piece_length = wx.wxChoice(
            panel, -1, choices=["automatic", "2MiB", "1MiB", "512KiB", "256KiB", "128KiB", "64KiB", "32KiB"]
        )
        self.piece_length_list = [0, 21, 20, 19, 18, 17, 16, 15]
        self.piece_length.SetSelection(0)
        gridSizer.Add(self.piece_length)

        gridSizer.Add(wx.wxStaticText(panel, -1, "comment:"), 0, wx.wxALIGN_RIGHT | wx.wxALIGN_CENTER_VERTICAL)
        self.commentCtl = wx.wxTextCtrl(panel, -1, "")
        gridSizer.Add(self.commentCtl, 0, wx.wxEXPAND)

        gridSizer.Add(wx.wxStaticText(panel, -1, ""))
        gridSizer.Add(wx.wxStaticText(panel, -1, ""))

        b1 = wx.wxButton(panel, -1, "Cancel", size=(-1, 30))
        wx.EVT_BUTTON(frame, b1.GetId(), self.cancel)
        gridSizer.Add(b1, 0, wx.wxEXPAND)
        b2 = wx.wxButton(panel, -1, "MAKE TORRENT", size=(-1, 30))
        wx.EVT_BUTTON(frame, b2.GetId(), self.complete)
        gridSizer.Add(b2, 0, wx.wxEXPAND)

        gridSizer.AddGrowableCol(1)
        colSizer.Add(gridSizer, -1, wx.wxALIGN_CENTER_VERTICAL)
        fullSizer.Add(colSizer)

        border = wx.wxBoxSizer(wx.wxHORIZONTAL)
        border.Add(fullSizer, 1, wx.wxEXPAND | wx.wxALL, 15)
        panel.SetSizer(border)
        panel.SetAutoLayout(True)
        border.Fit(panel)
        frame.Fit()
        frame.Show(True)

        EVT_INVOKE(frame, self.onInvoke)
        wx.EVT_CLOSE(frame, self._close)