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()
def complete(self, x): if not self.dirCtl.GetValue(): dlg = wx.wxMessageDialog( self.frame, message='You must select a\nfile or directory', caption='Error', style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy() return 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 params = { 'piece_size_pow2': self.piece_length_list[self.piece_length.GetSelection()] } 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 produce a .torrent\n' + 'with 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 params['real_announce_list'] = annlist comment = self.commentCtl.GetValue() if comment != '': params['comment'] = comment self.statustext.SetLabel('working') self.queue.append( (self.dirCtl.GetValue(), self.annCtl.GetValue(), params)) self.go_queue()
def complete(self, x): if not self.dirCtl.GetValue(): dlg = wx.wxMessageDialog( self.frame, message="You must select a\nfile or directory", caption="Error", style=wx.wxOK | wx.wxICON_ERROR, ) dlg.ShowModal() dlg.Destroy() return 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 params = {"piece_size_pow2": self.piece_length_list[self.piece_length.GetSelection()]} 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 produce a .torrent\n" + "with 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 params["real_announce_list"] = annlist comment = self.commentCtl.GetValue() if comment != "": params["comment"] = comment self.statustext.SetLabel("working") self.queue.append((self.dirCtl.GetValue(), self.annCtl.GetValue(), params)) self.go_queue()
def print_preview(self): """Print-preview current plot.""" printout = graph_printout(self) printout2 = graph_printout(self) self.preview = wx.wxPrintPreview(printout, printout2, self.print_data) if not self.preview.Ok(): wx.wxMessageDialog(self, "Print Preview failed.\n" \ "Check that default printer is configured\n", \ "Print error", wx.wxOK|wx.wxCENTRE).ShowModal() else: frame = wx.wxPreviewFrame(self.preview, self.parent, "Preview") frame.Initialize() frame.SetPosition(self.GetPosition()) frame.SetSize(self.GetSize()) frame.Show(wx.true)
def OnAbout(self, event): # Create a message dialog box dialog = wxMessageDialog(self, " slashManager is a Unix-oriented file manager\n" " written in wxPython.", "About slashManager", wxOK | wxICON_INFORMATION) dialog.ShowModal() # Shows it dialog.Destroy() # finally destroy it when finished
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()
def __wxpython(title, message): from wxPython.wx import wxApp, wxMessageDialog, wxOK, wxICON_EXCLAMATION class LameApp(wxApp): def OnInit(self): return 1 app = LameApp() dlg = wxMessageDialog(None, message, title, wxOK|wxICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy()
def failed(self, e): e = str(e) self.call.build_failed(e) dlg = wx.wxMessageDialog(self.frame, message='Error - ' + e, caption='Error', style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy()
def on_buildfailed(self, e): dlg = wx.wxMessageDialog(self.frame, message='Error - ' + e, caption='Error', style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy() self.gauge.SetValue(0) self.statustext.SetLabel('ERROR') self.calls['dropTargetError']() self.working = False self.go_queue()
def __wxpythonbox(title, message): import wxPython.wx as wx class LameApp(wx.wxApp): def OnInit(self): return 1 LameApp() dlg = wx.wxMessageDialog(None, message, title, wx.wxOK | wx.wxICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy()
def delete_thost(self, x): dlg = wx.wxMessageDialog(self.frame, message='Are you sure you want to delete\n' + self.thostselection[:-6] + '?', caption='Warning', style=wx.wxYES_NO | wx.wxICON_EXCLAMATION) if dlg.ShowModal() != wx.wxID_YES: dlg.Destroy() return dlg.Destroy() os.remove(os.path.join(basepath, 'thosts', self.thostselection)) self.thostselection = None self.refresh_thostlist()
def complete(self, x): if self.dirCtl.GetValue() == '': dlg = wx.wxMessageDialog( self.frame, message='You must select a directory', caption='Error', style=(wx.wxOK | wx.wxICON_ERROR)) dlg.ShowModal() dlg.Destroy() return try: ps = 2 ** (21 - self.piece_length.GetSelection()) CompleteDir(self.dirCtl.GetValue(), self.annCtl.GetValue(), ps) except: print_exc()
def delete_thost(self, x): dlg = wx.wxMessageDialog( self.frame, message="Are you sure you want to delete\n" + self.thostselection[:-6] + "?", caption="Warning", style=wx.wxYES_NO | wx.wxICON_EXCLAMATION, ) if dlg.ShowModal() != wx.wxID_YES: dlg.Destroy() return dlg.Destroy() os.remove(os.path.join(basepath, "thosts", self.thostselection)) self.thostselection = None self.refresh_thostlist()
def complete(self): params = {'piece_size_pow2': self.pl} try: completedir(self.d, self.a, params, self.flag, self.valcallback, self.filecallback) if not self.flag.isSet(): self.currentLabel.SetLabel('Done!') self.gauge.SetValue(1000) self.button.SetLabel('Close') except (OSError, IOError) as e: self.currentLabel.SetLabel('Error!') self.button.SetLabel('Close') dlg = wx.wxMessageDialog( self.frame, message='Error - ' + str(e), caption='Error', style=(wx.wxOK | wx.wxICON_ERROR)) dlg.ShowModal() dlg.Destroy()
def complete(self): try: if self.separatetorrents: completedir(self.d, self.a, self.params, self.flag, self.valcallback, self.filecallback) else: make_meta_file(self.d, self.a, self.params, self.flag, self.valcallback, progress_percent=1) if not self.flag.isSet(): self.currentLabel.SetLabel('Done!') self.gauge.SetValue(1000) self.button.SetLabel('Close') self.frame.Refresh() except (OSError, IOError) as e: self.currentLabel.SetLabel('Error!') self.button.SetLabel('Close') dlg = wx.wxMessageDialog( self.frame, message='Error - ' + str(e), caption='Error', style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy()
def complete(self, x): if self.dirCtl.GetValue() == '': dlg = wx.wxMessageDialog( self.frame, message='You must select a\n file or directory', caption='Error', style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy() return params = { 'piece_size_pow2': self.piece_length_list[ self.piece_length.GetSelection()] } annlist = self.getannouncelist() if len(annlist) > 0: params['real_announce_list'] = annlist comment = self.commentCtl.GetValue() if comment != '': params['comment'] = comment try: CompleteDir(self.dirCtl.GetValue(), self.annCtl.GetValue(), params) except: print_exc()
def failed(self, e): e = str(e) self.call.build_failed(e) dlg = wx.wxMessageDialog(self.frame, message="Error - " + e, caption="Error", style=wx.wxOK | wx.wxICON_ERROR) dlg.ShowModal() dlg.Destroy()
def OnAbout(self,e): d= wxMessageDialog(self, " Aksy, controlling your Z48 sampler\n", "About Aksy", wxOK) d.ShowModal() d.Destroy()
def show(self,msg): app = _GetApp() dlg = wxMessageDialog(NULL, msg, self.caption,self.style,self.pos) val = dlg.ShowModal() dlg.Destroy() return self.retval[val]
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()
def OnAbout(self, e): d = wxMessageDialog(self, " Aksy, controlling your Z48 sampler\n", "About Aksy", wxOK) d.ShowModal() d.Destroy()