Comments (4)
I am using wxPython3.0-win32-py27 on a windows 7 machine.
Original comment by [email protected]
on 15 Sep 2014 at 4:45
from gui2py.
I realized that I could work around this by hacking together some string
formatting which grabs the decimal, floors the number, rjust to right align,
merge the round number back with the decimal and then insert into the listview.
Feels dirty:
def format_listitem(number,dec=1):
""" Accepts a number (either integer or floating point) and returns a formatted string for use in listviews """
rounded = int(math.floor(float(number)))
if dec == 1:
decimal = "{0:.1f}".format(float(number) - float(rounded))
elif dec == 2:
decimal = "{0:.2f}".format(float(number) - float(rounded))
formatted_string = "%s.%s" % (str(rounded).rjust(3), str(decimal))
formatted_string = formatted_string.replace(".0.",".")
return formatted_string
Original comment by [email protected]
on 15 Sep 2014 at 5:44
from gui2py.
However, rjust trickery can't fix sorting issues if the list contains positive
and negative numbers :(
Original comment by [email protected]
on 15 Sep 2014 at 6:36
from gui2py.
I figure that if I wasn't using gui2py I could set up a ColumnSorterMixin that
made use of something like this:
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
'''
return [ atoi(c) for c in re.split('([-]?\d+)', text) ]
Original comment by [email protected]
on 15 Sep 2014 at 7:06
from gui2py.
Related Issues (15)
- Non ASCII text input raises UnicodeEncodeError in example form HOT 3
- Support for web2py controller action syntax
- Support wxPython hotkeys with the in HTML accesskey attribute HOT 1
- Allow form hidden fields HOT 1
- Support the HTML OBJECT tag for wxPython components inside HTMLWindow
- web2py-like form widgets
- readme.rst outdated
- Segfault on basic startup HOT 2
- model undefined in GridEvent in event.py
- Windows 8.1 - Nothing installed anywhere HOT 2
- import error with 2.9.5.0 gtk2 (classic): No module named adv HOT 6
- UnicodeDecode error whan launching sample.py or the gui
- Install on Mac Fails HOT 1
- ListView sort_order ignored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gui2py.