source: sasview/guiframe/utils.py @ 25c8653

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 25c8653 was 2bd9927, checked in by Gervaise Alina <gervyh@…>, 16 years ago

move welcome panel

  • Property mode set to 100644
File size: 2.3 KB
Line 
1"""
2     Contains common classes
3"""
4import wx,re
5
6def format_number(value, high=False):
7    """
8        Return a float in a standardized, human-readable formatted string
9    """
10    try: 
11        value = float(value)
12    except:
13        print "returning 0"
14        return "0"
15   
16    if high:
17        return "%-6.4g" % value
18    else:
19        return "%-5.3g" % value
20   
21class PanelMenu(wx.Menu):
22    plots = None
23    graph = None
24   
25    def set_plots(self, plots):
26        self.plots = plots
27   
28    def set_graph(self, graph):
29        self.graph = graph
30       
31
32def split_list(separator, mylist, n=0):
33    """
34        @return a list of string without white space of separator
35        @param separator: the string to remove
36    """
37    list=[]
38    for item in mylist:
39        if re.search( separator,item)!=None:
40            if n >0:
41                word =re.split(separator,item,int(n))
42            else:
43                word =re.split( separator,item)
44            for new_item in word: 
45                if new_item.lstrip().rstrip() !='':
46                    list.append(new_item.lstrip().rstrip())
47    return list
48def split_text(separator, string1, n=0):
49    """
50        @return a list of string without white space of separator
51        @param separator: the string to remove
52    """
53    list=[]
54    if re.search( separator,string1)!=None:
55        if n >0:
56            word =re.split(separator,string1,int(n))
57        else:
58            word =re.split(separator,string1)
59        for item in word: 
60            if item.lstrip().rstrip() !='':
61                list.append(item.lstrip().rstrip())
62    return list
63def look_for_tag( string1,begin, end=None ):
64    """
65        @note: this method  remove the begin and end tags given by the user
66        from the string .
67        @param begin: the initial tag
68        @param end: the final tag
69        @param string: the string to check
70        @return: begin_flag==True if begin was found,
71         end_flag==if end was found else return false, false
72         
73    """
74    begin_flag= False
75    end_flag= False
76    if  re.search( begin,string1)!=None:
77        begin_flag= True
78    if end !=None:
79        if  re.search(end,string1)!=None:
80            end_flag= True
81    return begin_flag, end_flag
82
83
Note: See TracBrowser for help on using the repository browser.