def expRemoveFunc(self, event): next = self.list_exp.GetNextSelected(-1) while next != -1: if self.verbose: transit_tools.transit_message("Removing experimental item (%d): %s" % (next, self.list_exp.GetItem(next, 0).GetText())) self.list_exp.DeleteItem(next) next = self.list_exp.GetNextSelected(-1) self.index_exp-=1
def ctrlRemoveFunc(self, event): next = self.list_ctrl.GetNextSelected(-1) while next != -1: if self.verbose: transit_tools.transit_message("Removing control item (%d): %s" % (next, self.list_ctrl.GetItem(next, 0).GetText())) self.list_ctrl.DeleteItem(next) next = self.list_ctrl.GetNextSelected(-1) self.index_ctrl-=1
def loadExpFileFunc(self, event): try: dlg = wx.FileDialog( self, message="Choose a file", defaultDir=self.wxobj.workdir, defaultFile="", wildcard=u"Read Files (*.wig)|*.wig;|\nRead Files (*.txt)|*.txt;|\nRead Files (*.dat)|*.dat;|\nAll files (*.*)|*.*", style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() print "You chose the following Experimental file(s):" for fullpath in paths: print "\t%s" % fullpath self.loadExpFile(fullpath) dlg.Destroy() except Exception as e: transit_tools.transit_message("Error: %s" % e) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)
def main(*args, **kwargs): #If no arguments, show GUI: DEBUG = "--debug" in sys.argv if DEBUG: sys.argv.remove("--debug") kwargs.pop("-debug") if (not args and 'h' in kwargs): print "For commandline mode, please use one of the known methods (or see documentation to add a new one):" for m in all_methods: print "\t - %s" % m print "Usage: python %s <method>" % sys.argv[0] sys.exit(0) # Check if running in GUI Mode if not (args or kwargs) and hasWx: import matplotlib matplotlib.use("WXAgg") import matplotlib.pyplot import pytransit.transit_gui as transit_gui transit_tools.transit_message("Running in GUI Mode") app = wx.App(False) #create an object of CalcFrame frame = transit_gui.TnSeekFrame(None, DEBUG) #show the frame frame.Show(True) frame.Maximize(True) #start the applications app.MainLoop() # Tried GUI mode but has no wxPython elif not (args or kwargs) and not hasWx: print "Please install wxPython to run in GUI Mode." print "To run in Console Mode please follow these instructions:" print "" print "Usage: python %s <method>" % sys.argv[0] print "List of known methods:" for m in methods: print "\t - %s" % m # Running in Console mode else: import matplotlib matplotlib.use("Agg") method_name = args[0] if method_name not in all_methods: if method_name.lower() == "export": export_method_name = "" if len(args) > 1: export_method_name = args[1] if export_method_name not in export_methods: print "Error: Need to specify the export method." print "Please use one of the known methods (or see documentation to add a new one):" for m in export_methods: print "\t - %s" % m print "Usage: python %s export <method>" % sys.argv[0] else: methodobj = export_methods[ export_method_name].method.fromconsole() methodobj.Run() else: print "Error: The '%s' method is unknown." % method_name print "Please use one of the known methods (or see documentation to add a new one):" for m in all_methods: print "\t - %s" % m print "Usage: python %s <method>" % sys.argv[0] else: methodobj = all_methods[method_name].method.fromconsole() methodobj.Run()
def track_message(self, text, time=3000): transit_tools.transit_message(text, track_prefix) self.statusBar.SetStatusText(text) if time > 0: self.timer.Start(time)
def main(*args, **kwargs): # Check python version if (sys.version_info[0] < 3): print( "TRANSIT v3.0+ requires python3.6+. To use with python2, please install TRANSIT version < 3.0" ) sys.exit(0) #If no arguments, show GUI: DEBUG = "--debug" in sys.argv if DEBUG: sys.argv.remove("--debug") kwargs.pop("-debug") if (not args and ('v' in kwargs or '-version' in kwargs)): print("Version: {0}".format(pytransit.__version__)) sys.exit(0) if (not args and ('h' in kwargs or '-help' in kwargs)): print( "For commandline mode, please use one of the known methods (or see documentation to add a new one):" ) print("Analysis methods: ") for m in all_methods: ## TODO :: Move normalize to separate subcommand? if (m == "normalize"): continue print("\t - %s" % m) print("Other functions: ") print("\t - normalize") print("\t - convert") print("\t - export") print("Usage: python %s <method>" % sys.argv[0]) sys.exit(0) # Check if running in GUI Mode if not (args or kwargs) and hasWx: import matplotlib matplotlib.use("WXAgg") import matplotlib.pyplot import pytransit.transit_gui as transit_gui transit_tools.transit_message("Running in GUI Mode") app = wx.App(False) #create an object of CalcFrame frame = transit_gui.TnSeekFrame(None, DEBUG) #show the frame frame.Show(True) frame.Maximize(True) #start the applications app.MainLoop() # Tried GUI mode but has no wxPython elif not (args or kwargs) and not hasWx: print("Please install wxPython to run in GUI Mode.") print("To run in Console Mode please follow these instructions:") print("") print("Usage: python %s <method>" % sys.argv[0]) print("List of known methods:") for m in methods: print("\t - %s" % m) # Running in Console mode else: import matplotlib matplotlib.use("Agg") method_name = args[0] if method_name not in all_methods: if method_name.lower() == "export": export_method_name = "" if len(args) > 1: export_method_name = args[1] if export_method_name not in export_methods: print("Error: Need to specify the export method.") print( "Please use one of the known methods (or see documentation to add a new one):" ) for m in export_methods: print("\t - %s" % m) print("Usage: python %s export <method>" % sys.argv[0]) else: methodobj = export_methods[ export_method_name].method.fromconsole() methodobj.Run() elif method_name.lower() == "convert": convert_method_name = "" if len(args) > 1: convert_method_name = args[1] if convert_method_name not in convert_methods: print("Error: Need to specify the convert method.") print( "Please use one of the known methods (or see documentation to add a new one):" ) for m in convert_methods: print("\t - %s" % m) print("Usage: python %s convert <method>" % sys.argv[0]) else: methodobj = convert_methods[ convert_method_name].method.fromconsole() methodobj.Run() else: print("Error: The '%s' method is unknown." % method_name) print( "Please use one of the known methods (or see documentation to add a new one):" ) for m in all_methods: print("\t - %s" % m) print("Usage: python %s <method>" % sys.argv[0]) else: methodobj = all_methods[method_name].method.fromconsole() methodobj.Run()
def main(*args, **kwargs): #If no arguments, show GUI: DEBUG = "--debug" in sys.argv if DEBUG: sys.argv.remove("--debug") kwargs.pop("-debug") if (not args and ('v' in kwargs or '-version' in kwargs)): print "Version: {0}".format(pytransit.__version__) sys.exit(0) if (not args and ('h' in kwargs or '-help' in kwargs)): print "For commandline mode, please use one of the known methods (or see documentation to add a new one):" print("Analysis methods: ") for m in all_methods: ## TODO :: Move normalize to separate subcommand? if (m == "normalize"): continue print "\t - %s" % m print("Other functions: ") print("\t - normalize") print("\t - convert") print("\t - export") print "Usage: python %s <method>" % sys.argv[0] sys.exit(0) # Check if running in GUI Mode if not (args or kwargs) and hasWx: import matplotlib matplotlib.use("WXAgg") import matplotlib.pyplot import pytransit.transit_gui as transit_gui transit_tools.transit_message("Running in GUI Mode") app = wx.App(False) #create an object of CalcFrame frame = transit_gui.TnSeekFrame(None, DEBUG) #show the frame frame.Show(True) frame.Maximize(True) #start the applications app.MainLoop() # Tried GUI mode but has no wxPython elif not (args or kwargs) and not hasWx: print "Please install wxPython to run in GUI Mode." print "To run in Console Mode please follow these instructions:" print "" print "Usage: python %s <method>" % sys.argv[0] print "List of known methods:" for m in methods: print "\t - %s" % m # Running in Console mode else: import matplotlib matplotlib.use("Agg") method_name = args[0] if method_name not in all_methods: if method_name.lower() == "export": export_method_name = "" if len(args) > 1: export_method_name = args[1] if export_method_name not in export_methods: print "Error: Need to specify the export method." print "Please use one of the known methods (or see documentation to add a new one):" for m in export_methods: print "\t - %s" % m print "Usage: python %s export <method>" % sys.argv[0] else: methodobj = export_methods[export_method_name].method.fromconsole() methodobj.Run() elif method_name.lower() == "convert": convert_method_name = "" if len(args) > 1: convert_method_name = args[1] if convert_method_name not in convert_methods: print "Error: Need to specify the convert method." print "Please use one of the known methods (or see documentation to add a new one):" for m in convert_methods: print "\t - %s" % m print "Usage: python %s convert <method>" % sys.argv[0] else: methodobj = convert_methods[convert_method_name].method.fromconsole() methodobj.Run() else: print "Error: The '%s' method is unknown." % method_name print "Please use one of the known methods (or see documentation to add a new one):" for m in all_methods: print "\t - %s" % m print "Usage: python %s <method>" % sys.argv[0] else: methodobj = all_methods[method_name].method.fromconsole() methodobj.Run()