Changeset 2569 for trunk/GSASIIpy3.py


Ignore:
Timestamp:
Dec 9, 2016 3:17:43 PM (5 years ago)
Author:
vondreele
Message:

add 'f' or 'g' to maxdigits in FormatValue? in G2py3 - should be revised some more
do a lot of TextCtrl? --> ValidatedTextCtrl? replacements
note that ValidatedTextCtrl? only checks val <= max & not val < max
added tc.event to ValidatedTextCtrl? as some things needed that
G2imgGui - mostly done
G2restrGUI - done
G2pwdGUI - started

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpy3.py

    r2546 r2569  
    6868    :param float val: number to be formatted.
    6969
    70     :param list maxdigits: the number of digits & places after decimal to be used for display of the
    71       number (defaults to [10,2]).
     70    :param list maxdigits: the number of digits, places after decimal and 'f' or 'g' to be used for display of the
     71      number (defaults to [10,2,'f']).
    7272
    7373    :returns: a string with <= maxdigits characters (usually). 
     
    7676        return val       
    7777    if maxdigits is None:
    78         digits = [10,2]
     78        digits = [10,2,'f']
    7979    else:
    8080        digits = list(maxdigits)
    81     fmt="{:."+str(digits[1])+"f}"
     81    if len(digits) == 2:
     82        digits.append('g')
     83    if not val:
     84        digits[2] = 'f'
     85    fmt="{:"+str(digits[0])+"."+str(digits[1])+digits[2]+"}"
    8286    string = fmt.format(float(val)).strip() # will standard .f formatting work?
    8387    if len(string) <= digits[0]:
Note: See TracChangeset for help on using the changeset viewer.