コード例 #1
0
ファイル: bt-t-make.py プロジェクト: hjwsm1989/BitTornado
    def save_thost(self, x):
        if not self.annCtl.GetValue():
            dlg = wx.wxMessageDialog(
                self.frame,
                message='You must specify a\nsingle tracker url',
                caption='Error',
                style=wx.wxOK | wx.wxICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return
        try:
            metainfo = {}
            metainfo['announce'] = self.annCtl.GetValue()
            annlist = self.getannouncelist()
            if len(annlist) > 0:
                warnings = ''
                for tier in annlist:
                    if len(tier) > 1:
                        warnings += 'WARNING: You should not specify ' \
                            'multiple trackers\n     on the same line of ' \
                            'the tracker list unless\n     you are certain ' \
                            'they share peer data.\n'
                        break
                if not self.annCtl.GetValue() in annlist[0]:
                    warnings += 'WARNING: The single tracker url is not ' \
                        'present in\n     the first line of the tracker ' \
                        'list.  This\n     may produce a dysfunctional ' \
                        'torrent.\n'
                if warnings:
                    warnings += 'Are you sure you wish to save a torrent ' \
                        'host\nwith these parameters?'
                    dlg = wx.wxMessageDialog(self.frame,
                                             message=warnings,
                                             caption='Warning',
                                             style=wx.wxYES_NO
                                             | wx.wxICON_QUESTION)
                    if dlg.ShowModal() != wx.wxID_YES:
                        dlg.Destroy()
                        return
                metainfo['announce-list'] = annlist
        except:
            return

        if self.thostselectnum:
            d = self.thostselection
        else:
            d = '.thost'
        dl = wx.wxFileDialog(self.frame, 'Save tracker data as',
                             os.path.join(basepath, 'thosts'), d, '*.thost',
                             wx.wxSAVE | wx.wxOVERWRITE_PROMPT)
        if dl.ShowModal() != wx.wxID_OK:
            return
        d = dl.GetPath()

        try:
            metainfo.write(d)
            garbage, self.thostselection = os.path.split(d)
        except:
            pass
        self.refresh_thostlist()
コード例 #2
0
ファイル: wxplt.py プロジェクト: mbentz80/jzigbeercp
 def file_save_as(self, event):
     import os
     wildcard = "PNG files (*.png)|*.png|" \
                "BMP files (*.bmp)|*.bmp|" \
                "JPEG files (*.jpg)|*.jpg|" \
                "PCX files (*.pcx)|*.pcx|" \
                "TIFF files (*.tif)|*.tif|" \
                "All Files |*|"
     dlg = wx.wxFileDialog(self, "Save As", ".", "", wildcard, wx.wxSAVE)
     if dlg.ShowModal() == wx.wxID_OK:
         f = dlg.GetPath()
         dummy, ftype = os.path.splitext(f)
         # strip .
         ftype = ftype[1:]
         if ftype in image_type_map.keys():
             self.client.save(dlg.GetPath(),ftype)
         else:
             msg = "Extension is currently used to determine file type." \
                   "'%s' is not a valid extension."  \
                   "You may use one of the following extensions. %s" \
                       % (ftype,image_type_map.keys())
             d = wx.wxMessageDialog(self,msg,style=wx.wxOK)
             d.ShowModal()
             d.Destroy()
     dlg.Destroy()
コード例 #3
0
ファイル: bt-t-make.py プロジェクト: Konubinix/BitTornado
 def selectfile(self, x=None):
     self.calls["dropTargetHovered"]()
     dl = wx.wxFileDialog(self.frame, "Choose file to use", "", "", "", wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         self.dirCtl.SetValue(dl.GetPath())
         self.calls["dropTargetDropped"]()
     else:
         self.calls["dropTargetUnhovered"]()
コード例 #4
0
ファイル: bt-t-make.py プロジェクト: hjwsm1989/BitTornado
 def selectfile(self, x=None):
     self.calls['dropTargetHovered']()
     dl = wx.wxFileDialog(self.frame, 'Choose file to use', '', '', '',
                          wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         self.dirCtl.SetValue(dl.GetPath())
         self.calls['dropTargetDropped']()
     else:
         self.calls['dropTargetUnhovered']()
コード例 #5
0
ファイル: fileopen.py プロジェクト: neurodebian/pymeg
def open():
    application = wxPySimpleApp()
    dialog = wxFileDialog(None, style=wxOPEN)

    if dialog.ShowModal() == wxID_OK:
        print "Selected:", dialog.GetPath()
        return str(dialog.GetPath())

    # The user did not select anything

    else:
        print "Nothing was selected."
コード例 #6
0
ファイル: file.py プロジェクト: badbytes/pymeg
def open():
    application = wxPySimpleApp()
    dialog = wxFileDialog(None, "Select a file(s)", os.getcwd(), "*", "*", wxMULTIPLE)
    l = []
    if dialog.ShowModal() == wxID_OK:
        dialog.Destroy()
        for i in range(0, len(dialog.GetPaths())):
            l.append(str(dialog.GetPaths()[i]))
        print 'Selected:', l
        return l
    else:
       print 'Nothing was selected.'
    dialog.Destroy()
コード例 #7
0
ファイル: file.py プロジェクト: badbytes/pymeg
def save(text=None, suffix='*', filter='*'):
    application = wxPySimpleApp()
    if text == None: text = "Select a save file name"
    dialog = wxFileDialog(None, text, os.getcwd(), suffix, filter, wxSAVE)
    l = []
    if dialog.ShowModal() == wxID_OK:
        for i in range(0, len(dialog.GetPaths())):
            l.append(str(dialog.GetPaths()[i]))
        print 'Selected:', l
        return l[0]
    else:
       print 'Nothing was choosen'
    dialog.Destroy()
コード例 #8
0
ファイル: bt-t-make.py プロジェクト: hjwsm1989/BitTornado
 def selectDropTarget(self, x):
     dl = wx.wxFileDialog(
         self.frame, 'Choose image to use',
         os.path.join(basepath, 'targets'),
         os.path.join(basepath, 'targets', self.config['target']),
         'Supported images (*.bmp, *.gif)|*.*',
         wx.wxOPEN | wx.wxHIDE_READONLY)
     if dl.ShowModal() == wx.wxID_OK:
         try:
             self.calls['changeDropTarget'](dl.GetPath())
             self.config['target'] = dl.GetPath()
         except:
             pass
コード例 #9
0
ファイル: btmaketorrentgui.py プロジェクト: weedy/BitTornado
 def announcecopy(self, x):
     dl = wx.wxFileDialog(self.frame, 'Choose .torrent file to use', '', '',
                          '*.torrent', wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         try:
             metainfo = MetaInfo.read(dl.GetPath())
             self.annCtl.SetValue(metainfo['announce'])
             if 'announce-list' in metainfo:
                 self.annListCtl.SetValue(
                     '\n'.join(', '.join(tier) for tier in
                               metainfo['announce-list']) + '\n' * 3)
             else:
                 self.annListCtl.SetValue('')
         except:
             return
コード例 #10
0
ファイル: bt-t-make.py プロジェクト: Konubinix/BitTornado
 def selectDropTarget(self, x):
     dl = wx.wxFileDialog(
         self.frame,
         "Choose image to use",
         os.path.join(basepath, "targets"),
         os.path.join(basepath, "targets", self.config["target"]),
         "Supported images (*.bmp, *.gif)|*.*",
         wx.wxOPEN | wx.wxHIDE_READONLY,
     )
     if dl.ShowModal() == wx.wxID_OK:
         try:
             self.calls["changeDropTarget"](dl.GetPath())
             self.config["target"] = dl.GetPath()
         except:
             pass
コード例 #11
0
ファイル: DSV.py プロジェクト: gamesun/MyTerm-for-WangH
            def OnInit(self):
                dlg = wx.wxFileDialog(None, "Choose a file", ".", "",
                                   "CSV files (*.csv)|*.csv|Text files (*.txt)|*.txt|All files (*.*)|*.*",
                                   wx.wxOPEN)
                if dlg.ShowModal() == wx.wxID_OK:
                    path = dlg.GetPath()
                    dlg.Destroy()

                    errorLog = open('import_error.log', 'a+') 
                    def logErrors(linenumber, oldrow, newrow, expectedColumns, maxColumns, file = errorLog):
                        # log the bad row to a file
                        file.write("LINE %d: %s\n" % (linenumber, oldrow))

                    dlg = ImportWizardDialog(None, -1, 'CSV Import Wizard (v.%s)' % __version__, path)
                    if dlg.ShowModal() == wx.wxID_OK:
                        results = dlg.ImportData(errorHandler = logErrors)
                        dlg.Destroy()
                        errorLog.close()

                        if results is not None:
                            headers, data = results
                            if 0: # print the output to stdout
                                if headers:
                                    print headers
                                    print 80*'='
                                for row in data:
                                    print row

                            if 0: # for testing export functionality
                                if headers:
                                    print exportDSV([headers] + data)
                                else:
                                    print exportDSV(data)
                    else:
                        dlg.Destroy()

                else:
                    dlg.Destroy()

                return wx.true
コード例 #12
0
ファイル: fileopen.py プロジェクト: badbytes/pymeg
def open():
    
    application = wxPySimpleApp()
    #dialog = wxFileDialog ( None, style = wxOPEN )
    dialog = wxFileDialog(None, "Select a file(s)", os.getcwd(), "*", "*", wxMULTIPLE)
    l = []
    if dialog.ShowModal() == wxID_OK:
        #print 'Selected:', dialog.GetPaths()
        #return eval(str(dialog.GetPaths()))
        for i in range(0, len(dialog.GetPaths())):
            l.append(str(dialog.GetPaths()[i]))
        print 'Selected:', l
        return l

    # The user did not select anything

    else:
       print 'Nothing was selected.'

    # Destroy the dialog

    dialog.Destroy()
コード例 #13
0
ファイル: btmaketorrentgui.py プロジェクト: weedy/BitTornado
 def selectfile(self, x):
     dl = wx.wxFileDialog(self.frame, 'Choose file or directory to use', '',
                          '', '', wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         self.dirCtl.SetValue(dl.GetPath())
コード例 #14
0
ファイル: bt-t-make.py プロジェクト: hjwsm1989/BitTornado
 def announcecopy(self, x):
     dl = wx.wxFileDialog(self.frame, 'Choose .torrent file to use', '', '',
                          '*.torrent', wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         self._announcecopy(dl.GetPath(), True)
コード例 #15
0
ファイル: bt-t-make.py プロジェクト: Konubinix/BitTornado
    def save_thost(self, x):
        if not self.annCtl.GetValue():
            dlg = wx.wxMessageDialog(
                self.frame,
                message="You must specify a\nsingle tracker url",
                caption="Error",
                style=wx.wxOK | wx.wxICON_ERROR,
            )
            dlg.ShowModal()
            dlg.Destroy()
            return
        try:
            metainfo = {}
            metainfo["announce"] = self.annCtl.GetValue()
            annlist = self.getannouncelist()
            if len(annlist) > 0:
                warnings = ""
                for tier in annlist:
                    if len(tier) > 1:
                        warnings += (
                            "WARNING: You should not specify "
                            "multiple trackers\n     on the same line of "
                            "the tracker list unless\n     you are certain "
                            "they share peer data.\n"
                        )
                        break
                if not self.annCtl.GetValue() in annlist[0]:
                    warnings += (
                        "WARNING: The single tracker url is not "
                        "present in\n     the first line of the tracker "
                        "list.  This\n     may produce a dysfunctional "
                        "torrent.\n"
                    )
                if warnings:
                    warnings += "Are you sure you wish to save a torrent " "host\nwith these parameters?"
                    dlg = wx.wxMessageDialog(
                        self.frame, message=warnings, caption="Warning", style=wx.wxYES_NO | wx.wxICON_QUESTION
                    )
                    if dlg.ShowModal() != wx.wxID_YES:
                        dlg.Destroy()
                        return
                metainfo["announce-list"] = annlist
        except:
            return

        if self.thostselectnum:
            d = self.thostselection
        else:
            d = ".thost"
        dl = wx.wxFileDialog(
            self.frame,
            "Save tracker data as",
            os.path.join(basepath, "thosts"),
            d,
            "*.thost",
            wx.wxSAVE | wx.wxOVERWRITE_PROMPT,
        )
        if dl.ShowModal() != wx.wxID_OK:
            return
        d = dl.GetPath()

        try:
            metainfo.write(d)
            garbage, self.thostselection = os.path.split(d)
        except:
            pass
        self.refresh_thostlist()
コード例 #16
0
ファイル: bt-t-make.py プロジェクト: Konubinix/BitTornado
 def announcecopy(self, x):
     dl = wx.wxFileDialog(self.frame, "Choose .torrent file to use", "", "", "*.torrent", wx.wxOPEN)
     if dl.ShowModal() == wx.wxID_OK:
         self._announcecopy(dl.GetPath(), True)