예제 #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()
예제 #2
0
    def __init__(self, d, a, params):
        self.d = d
        self.a = a
        self.params = params
        self.flag = threading.Event()
        self.separatetorrents = False

        if os.path.isdir(d):
            self.choicemade = threading.Event()
            frame = wx.wxFrame(None, -1, 'BitTorrent make torrent',
                               size=(1, 1))
            self.frame = frame
            panel = wx.wxPanel(frame, -1)
            gridSizer = wx.wxFlexGridSizer(cols=1, vgap=8, hgap=8)
            gridSizer.AddGrowableRow(1)
            gridSizer.Add(wx.wxStaticText(
                panel, -1, 'Do you want to make a separate .torrent'), 0,
                wx.wxALIGN_CENTER)
            gridSizer.Add(wx.wxStaticText(
                panel, -1, 'for every item in this directory?'), 0,
                wx.wxALIGN_CENTER)
            gridSizer.Add(wx.wxStaticText(panel, -1, ''))

            b = wx.wxFlexGridSizer(cols=3, hgap=10)
            yesbut = wx.wxButton(panel, -1, 'Yes')

            def saidyes(e, self=self):
                self.frame.Destroy()
                self.separatetorrents = True
                self.begin()
            wx.EVT_BUTTON(frame, yesbut.GetId(), saidyes)
            b.Add(yesbut, 0)

            nobut = wx.wxButton(panel, -1, 'No')

            def saidno(e, self=self):
                self.frame.Destroy()
                self.begin()
            wx.EVT_BUTTON(frame, nobut.GetId(), saidno)
            b.Add(nobut, 0)

            cancelbut = wx.wxButton(panel, -1, 'Cancel')

            def canceled(e, self=self):
                self.frame.Destroy()
            wx.EVT_BUTTON(frame, cancelbut.GetId(), canceled)
            b.Add(cancelbut, 0)
            gridSizer.Add(b, 0, wx.wxALIGN_CENTER)
            border = wx.wxBoxSizer(wx.wxHORIZONTAL)
            border.Add(gridSizer, 1, wx.wxEXPAND | wx.wxALL, 4)

            panel.SetSizer(border)
            panel.SetAutoLayout(True)
            frame.Show()
            border.Fit(panel)
            frame.Fit()

        else:
            self.begin()
예제 #3
0
 def OnInit(self):
     frame = wxFrame(None, wxNewId(), "wxApp")
     frame.Show(true)
     self.frame = frame
     self.SetTopWindow(frame)
     btn = wxButton(frame, wxNewId(), "Click to Start")
     EVT_BUTTON(self, btn.GetId(), self.OnClick)
     return true
예제 #4
0
 def OnInit(self):
     frame = wxFrame(None, wxNewId(), "wxApp")
     frame.Show(true)
     self.frame = frame
     self.SetTopWindow(frame)
     btn = wxButton(frame, wxNewId(), "Click to Start")
     EVT_BUTTON(self, btn.GetId(), self.OnClick)
     return true
예제 #5
0
        def OnInit(self):
            frame = wx.wxFrame(NULL, -1, 'simple colour chooser')

            chooser = MyColourChooser(frame, -1)
            sizer = wxBoxSizer(wxVERTICAL)
            sizer.Add(chooser, 0, 0)
            frame.SetAutoLayout(true)
            frame.SetSizer(sizer)
            sizer.Fit(frame)

            frame.Show(true)
            self.SetTopWindow(frame)
            return true
예제 #6
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()
예제 #7
0
    def __init__(self):
        frame = wx.wxFrame(None, -1, 'BitTorrent complete dir 1.0.1',
                           size=wx.wxSize(550, 250))
        self.frame = frame

        panel = wx.wxPanel(frame, -1)

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

        gridSizer.Add(wx.wxStaticText(panel, -1, 'directory to build:'))
        self.dirCtl = wx.wxTextCtrl(panel, -1, '')

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        b.Add(self.dirCtl, 1, wx.wxEXPAND)
#        b.Add(10, 10, 0, wxEXPAND)
        button = wx.wxButton(panel, -1, 'select')
        b.Add(button, 0, wx.wxEXPAND)
        wx.EVT_BUTTON(frame, button.GetId(), self.select)

        gridSizer.Add(b, 0, wx.wxEXPAND)

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

        gridSizer.Add(wx.wxStaticText(panel, -1, 'piece size:'))
        self.piece_length = wx.wxChoice(
            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 = wx.wxBoxSizer(wx.wxVERTICAL)
        border.Add(gridSizer, 0,
                   wx.wxEXPAND | wx.wxNORTH | wx.wxEAST | wx.wxWEST, 25)
        b2 = wx.wxButton(panel, -1, 'make')
#        border.Add(10, 10, 1, wxEXPAND)
        border.Add(b2, 0, wx.wxALIGN_CENTER | wx.wxSOUTH, 20)
        wx.EVT_BUTTON(frame, b2.GetId(), self.complete)
        panel.SetSizer(border)
        panel.SetAutoLayout(True)
예제 #8
0
    def moveCopy(self, event):
        print "Moving"
        destPath = self.path
        frame = wxFrame(self.ilist, wxNewId(), "Move/Copy Items?")

        mSizer = wxBoxSizer(wxVERTICAL)

        frame.SetAutoLayout(true)
        frame.SetSizer(mSizer)

        count = self.ilist.GetSelectedItemCount()  # number of selected items
        mSizer.Add(30, 10, 0, wxEXPAND)
        mSizer.Add(
            wxStaticText(frame, wxNewId(), "Move/Copy %d item(s)?" % count), 0,
            0)
        mSizer.Add(30, 10, 0, wxEXPAND)

        bSizer = wxBoxSizer(wxHORIZONTAL)
        mSizer.Add(bSizer, 0, 0)
        mSizer.Add(30, 10, 0, wxEXPAND)

        btnMv = wxButton(frame, self.btnMv, "Move")
        btnCp = wxButton(frame, self.btnCp, "Copy")
        btnCancel = wxButton(frame, self.btnCancel, "Cancel")
        for b in (btnMv, btnCp, btnCancel):
            EVT_BUTTON(b, b.GetId(), self.OnButtonPress)

        bSizer.Add(btnMv, 1, 0)
        bSizer.Add(30, 10, 0, wxEXPAND)
        bSizer.Add(btnCp, 1, 0)
        bSizer.Add(30, 10, 0, wxEXPAND)
        bSizer.Add(btnCancel, 1, 0)

        frame.MakeModal(true)
        frame.Show(true)

        self.frame = frame
        EVT_CLOSE(frame, self.OnCloseWindow)
예제 #9
0
파일: fsmenu.py 프로젝트: liranal/wxnodebox
    def moveCopy(self, event):
        print "Moving"
        destPath = self.path
        frame = wxFrame(self.ilist, wxNewId(), "Move/Copy Items?")

        mSizer = wxBoxSizer(wxVERTICAL)

        frame.SetAutoLayout(true)
        frame.SetSizer(mSizer)

        count = self.ilist.GetSelectedItemCount() # number of selected items
        mSizer.Add(30, 10, 0, wxEXPAND)
        mSizer.Add(wxStaticText(frame, wxNewId(), "Move/Copy %d item(s)?" % count), 0, 0)
        mSizer.Add(30, 10, 0, wxEXPAND)

        bSizer = wxBoxSizer(wxHORIZONTAL)
        mSizer.Add(bSizer, 0, 0)
        mSizer.Add(30, 10, 0, wxEXPAND)

        btnMv = wxButton(frame, self.btnMv, "Move")
        btnCp = wxButton(frame, self.btnCp, "Copy")
        btnCancel = wxButton(frame, self.btnCancel, "Cancel")
        for b in (btnMv, btnCp, btnCancel):
            EVT_BUTTON(b, b.GetId(), self.OnButtonPress)

        bSizer.Add(btnMv, 1, 0)
        bSizer.Add(30, 10, 0, wxEXPAND)
        bSizer.Add(btnCp, 1, 0)
        bSizer.Add(30, 10, 0, wxEXPAND)
        bSizer.Add(btnCancel, 1, 0)

        frame.MakeModal(true)
        frame.Show(true)

        self.frame = frame
        EVT_CLOSE(frame, self.OnCloseWindow)
예제 #10
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)
예제 #11
0
    def __init__(self):
        frame = wx.wxFrame(None, -1, 'BitTorrent Torrent File Maker',
                           size=wx.wxSize(550, 410))
        self.frame = frame

        panel = wx.wxPanel(frame, -1)

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

        gridSizer.Add(wx.wxStaticText(panel, -1, 'make torrent of:'))

        b = wx.wxBoxSizer(wx.wxHORIZONTAL)
        self.dirCtl = wx.wxTextCtrl(panel, -1, '')
        b.Add(self.dirCtl, 1, wx.wxEXPAND)
#        b.Add(10, 10, 0, wxEXPAND)

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

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

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

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

        a = wx.wxFlexGridSizer(cols=1)
        a.Add(wx.wxStaticText(panel, -1, 'announce list:'))
        a.Add(wx.wxStaticText(panel, -1, ''))
        abutton = wx.wxButton(panel, -1, 'copy\nannounces\nfrom\ntorrent',
                              size=(50, 70))
        wx.EVT_BUTTON(frame, abutton.GetId(), self.announcecopy)
        a.Add(abutton, 0, wx.wxEXPAND)
        gridSizer.Add(a, 0, wx.wxEXPAND)

        self.annListCtl = wx.wxTextCtrl(
            panel, -1, '\n\n\n\n\n', wx.wxPoint(-1, -1), (400, 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 announces separated by commas or whitespace '
            'and on several lines -\ntrackers on the same line will be tried '
            '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)

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

        gridSizer.Add(wx.wxStaticText(panel, -1, 'piece size:'))
        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, ''))
        gridSizer.Add(wx.wxStaticText(panel, -1, ''))

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

        gridSizer.AddGrowableCol(1)

        border = wx.wxBoxSizer(wx.wxVERTICAL)
        border.Add(gridSizer, 0,
                   wx.wxEXPAND | wx.wxNORTH | wx.wxEAST | wx.wxWEST, 25)
        b2 = wx.wxButton(panel, -1, 'make')
#        border.Add(10, 10, 1, wxEXPAND)
        border.Add(b2, 0, wx.wxALIGN_CENTER | wx.wxSOUTH, 20)
        wx.EVT_BUTTON(frame, b2.GetId(), self.complete)
        panel.SetSizer(border)
        panel.SetAutoLayout(True)
예제 #12
0
def OpenFile(parent, path):
    #FIXME: support: svg, sgvz, svg.gz with rsvg or batik (render to temporary
    #file /tmp/<PID><time()><atime(f.svg>.png and then open a frame)

    if not os.path.exists(path) or os.path.isdir(path): return
    frame = wxFrame(parent, -1, "File view: " + path, wxDefaultPosition, wxSize(500, 400))

    handled = 0
    needFrame = 1
    lowerPath = string.lower(path)
    #for animations or to see if count is > 0:
    #wxImage_GetImageCount(path)
    if lowerPath[-3:] in ("ani", "bmp", "cur", "gif", "ico", "iff", "jpg", "pcx", "png", "pnm", \
                          "tif", "xpm") or lowerPath[-4:] in ("jpeg", "tiff"):
        #f = open(path, "rb"); data = f.read(); f.close()
        #stream = StringIO(data)
        #img = wxImageFromStream(stream)
        img = wxEmptyImage()
        img.LoadFile(path)
        bmp = wxBitmapFromImage(img)
        #wxStaticBitmap(frame, -1, bmp) #, (15, 45))

        width, height = img.GetWidth(), img.GetHeight()
        if width and height:
            sw = wxScrolledWindow(frame, -1, wxDefaultPosition, wxDefaultSize,
                                  wxHSCROLL | wxVSCROLL)
            #sw.SetScrollbars(20, 20, img.GetWidth()/20, img.GetHeight()/20)
            sw.SetVirtualSize(wxSize(width, height))
            sw.SetScrollRate(20, 20)
            wxStaticBitmap(sw, -1, bmp) #, (15, 45))
            w, h = 800, 600 #frame.GetSize()
            w, h = min(w, width), min(h, height)
            minSize, b = 100, 10
            if w < minSize: w = minSize
            if h < minSize: h = minSize
            frame.SetSize(wxSize(w+b, h+b))
            handled = 1
    elif "html" == lowerPath[-4:] or "htm" == path[-3:]:
        htmlWin = wxHtmlWindow(frame)
        htmlWin.LoadPage(path)
        handled = 1
    elif "pdf" == lowerPath[-3:]:
        for cmd in ("xpdf", "acroread"):
            #FIXME: handle names that contain spaces etc.
            status, output = commands.getstatusoutput(cmd + " " + path)
            if 0 == status:
                handled = 1
                needFrame = 0
                break
    #FIXME: mplayer cannot run in background; same goes for Python calling mplayer externally - probably stdin dependence
    elif "mpeg" == lowerPath[-4:] or \
         lowerPath[-3:] in ("asf", "avi", "mov", "mpa", "mpg", "wmv"):
        for cmd in ("mplayer -quiet",):
            #FIXME: handle names that contain spaces etc.
            status, output = commands.getstatusoutput(cmd + " " + path)
            if 0 == status:
                handled = 1
                needFrame = 0
                break

    elif "ps" == lowerPath[-2:] or "ps.gz" == lowerPath[-5:]:
        pid = os.fork()
        if 0 == pid:
            for cmd in ("ggv", "gv"):
                try:
                    os.execlp(cmd, cmd, path)
                except OSError:
                    pass
            os.exit(1)
        handled = 1
        needFrame = 0

    if not handled:
        minSize = 65536
        try:
            f = open(path, "rb"); data = f.read(minSize); f.close()
        except IOError, ex:
            MsgOS(ex)
            return None
        txt = wxTextCtrl(frame, -1, data,
                         style=wxTE_READONLY|wxTE_MULTILINE|wxTE_DONTWRAP|wxHSCROLL)
        if len(data) == minSize:
            sizer = wxBoxSizer(wxVERTICAL)
            frame.SetAutoLayout(true)
            frame.SetSizer(sizer)
            frame.sizer = sizer
            b = wxButton(frame, -1, "Show entire file")
            sizer.Add(txt, 1, wxEXPAND|wxALL, 0)
            sizer.Add(b, 0, wxALIGN_CENTRE, 0)
            sizer.Layout()
예제 #13
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)
예제 #14
0
def OpenFile(parent, path):
    #FIXME: support: svg, sgvz, svg.gz with rsvg or batik (render to temporary
    #file /tmp/<PID><time()><atime(f.svg>.png and then open a frame)

    if not os.path.exists(path) or os.path.isdir(path): return
    frame = wxFrame(parent, -1, "File view: " + path, wxDefaultPosition,
                    wxSize(500, 400))

    handled = 0
    needFrame = 1
    lowerPath = string.lower(path)
    #for animations or to see if count is > 0:
    #wxImage_GetImageCount(path)
    if lowerPath[-3:] in ("ani", "bmp", "cur", "gif", "ico", "iff", "jpg", "pcx", "png", "pnm", \
                          "tif", "xpm") or lowerPath[-4:] in ("jpeg", "tiff"):
        #f = open(path, "rb"); data = f.read(); f.close()
        #stream = StringIO(data)
        #img = wxImageFromStream(stream)
        img = wxEmptyImage()
        img.LoadFile(path)
        bmp = wxBitmapFromImage(img)
        #wxStaticBitmap(frame, -1, bmp) #, (15, 45))

        width, height = img.GetWidth(), img.GetHeight()
        if width and height:
            sw = wxScrolledWindow(frame, -1, wxDefaultPosition, wxDefaultSize,
                                  wxHSCROLL | wxVSCROLL)
            #sw.SetScrollbars(20, 20, img.GetWidth()/20, img.GetHeight()/20)
            sw.SetVirtualSize(wxSize(width, height))
            sw.SetScrollRate(20, 20)
            wxStaticBitmap(sw, -1, bmp)  #, (15, 45))
            w, h = 800, 600  #frame.GetSize()
            w, h = min(w, width), min(h, height)
            minSize, b = 100, 10
            if w < minSize: w = minSize
            if h < minSize: h = minSize
            frame.SetSize(wxSize(w + b, h + b))
            handled = 1
    elif "html" == lowerPath[-4:] or "htm" == path[-3:]:
        htmlWin = wxHtmlWindow(frame)
        htmlWin.LoadPage(path)
        handled = 1
    elif "pdf" == lowerPath[-3:]:
        for cmd in ("xpdf", "acroread"):
            #FIXME: handle names that contain spaces etc.
            status, output = commands.getstatusoutput(cmd + " " + path)
            if 0 == status:
                handled = 1
                needFrame = 0
                break
    #FIXME: mplayer cannot run in background; same goes for Python calling mplayer externally - probably stdin dependence
    elif "mpeg" == lowerPath[-4:] or \
         lowerPath[-3:] in ("asf", "avi", "mov", "mpa", "mpg", "wmv"):
        for cmd in ("mplayer -quiet", ):
            #FIXME: handle names that contain spaces etc.
            status, output = commands.getstatusoutput(cmd + " " + path)
            if 0 == status:
                handled = 1
                needFrame = 0
                break

    elif "ps" == lowerPath[-2:] or "ps.gz" == lowerPath[-5:]:
        pid = os.fork()
        if 0 == pid:
            for cmd in ("ggv", "gv"):
                try:
                    os.execlp(cmd, cmd, path)
                except OSError:
                    pass
            os.exit(1)
        handled = 1
        needFrame = 0

    if not handled:
        minSize = 65536
        try:
            f = open(path, "rb")
            data = f.read(minSize)
            f.close()
        except IOError, ex:
            MsgOS(ex)
            return None
        txt = wxTextCtrl(frame,
                         -1,
                         data,
                         style=wxTE_READONLY | wxTE_MULTILINE | wxTE_DONTWRAP
                         | wxHSCROLL)
        if len(data) == minSize:
            sizer = wxBoxSizer(wxVERTICAL)
            frame.SetAutoLayout(true)
            frame.SetSizer(sizer)
            frame.sizer = sizer
            b = wxButton(frame, -1, "Show entire file")
            sizer.Add(txt, 1, wxEXPAND | wxALL, 0)
            sizer.Add(b, 0, wxALIGN_CENTRE, 0)
            sizer.Layout()
예제 #15
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)
예제 #16
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)
예제 #17
0
파일: wx1.py 프로젝트: kliegeois/progs
#! /usr/bin/env python
# -*- coding: latin-1 -*-

from wxPython.wx import wxPySimpleApp, wxFrame
app = wxPySimpleApp()
frame = wxFrame(None, -1, "Hello World")
frame.Show(1)
app.MainLoop()