source: sasview/guiframe/utils.py @ 20d30e9

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 20d30e9 was 4ba846b, checked in by Gervaise Alina <gervyh@…>, 16 years ago

removing white space on textcontrol
removing import history unused

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