Learn with me, on my journey of discovery about ... everything, but mainly computers and programming.
Nov 17, 2010
TeXnic Center Starter
First tip: Compile (by clicking on F7) twice if working with a table of contents.
Jan 15, 2010
QDoubleValidator
QDoubleValidator is strange in that it seems to allow data that exceeds its specified range. Actually, it passes with the state 'intermediate', as opposed to 'valid' or 'invalid'. This may seem like a bug, and has been addressed in the C++ language here. Below is my PyQt implementation. It is done by subclassing QDoubleValidator, and making it more strict. (Finally it worked! =P)
class MyDoubleValidator(Qt.QDoubleValidator):
def __init__(self, bottom, top, decimals, parent = None):
Qt.QDoubleValidator.__init__(self, bottom, top, decimals, parent)
def validate(self, input, pos):
state, pos = Qt.QDoubleValidator.validate(self, input, pos)
if input.isEmpty() or input == '.':
return Qt.QValidator.Intermediate, pos
if state != Qt.QValidator.Acceptable:
return Qt.QValidator.Invalid, pos
return Qt.QValidator.Acceptable, pos
You then need to initialize an instance of this class and assign it to the widget, e.g. a lineEdit. E.g:
min = 0
max = 1000
no_decimals = 10
aValidator = MyDoubleValidator(min, max, no_decimals, myLineEdit)
myLineEdit.setValidator(aValidator)
Extra tags:
QDoubleValidator, bug, outside range, not working, QValidator, State
Oct 6, 2009
How to package the PyQt with VTK application
1. Download py2exe from http://sourceforge.net/projects/py2exe/files/
(Download the version that corresponds with your python version.)
(Download the version that corresponds with your python version.)
2. Follow instructions from http://www.py2exe.org/index.cgi/Tutorial
Basically, you need a file called setup.py, like this:
from distutils.core import setup
import py2exe
setup(console=['runui12.py'])
Then run this line in command line:
vtkpython setup.py py2exe
Sep 24, 2009
Navigate Faster with your Keyboard
Hope some of these will help you to navigate faster in typed text. (Thanks to Eugene Isack and Lydia. ^ ^)
Moving Cursor
Home................ = to the beginning of line
End................... = to the end of line
Ctrl + Home..... = to the beginning of page
Ctrl + End........ = to the end of page
Deleting
Ctrl + Backspace......= word to the left
Ctrl + Delete.............= word to the right
Selecting
Shift + left arrow...........................= one character to the left
Ctrl + Shift + left/right arrow......= word to the left/right
Shift + Home/End.........................= Select all till Start/Finish
Internet Browser
Ctrl + Enter..................= when entering URLs automatically adds www & .com
Ctrl + w.........................= close window/tab
Alt + Tab.......................= next tab
Alt + Shift + Tab...........= previous tab
Alt + d.........................= Go to url box
Alt + g..........................=Go to search box
Moving Cursor
Home................ = to the beginning of line
End................... = to the end of line
Ctrl + Home..... = to the beginning of page
Ctrl + End........ = to the end of page
Deleting
Ctrl + Backspace......= word to the left
Ctrl + Delete.............= word to the right
Selecting
Shift + left arrow...........................= one character to the left
Ctrl + Shift + left/right arrow......= word to the left/right
Shift + Home/End.........................= Select all till Start/Finish
Internet Browser
Ctrl + Enter..................= when entering URLs automatically adds www & .com
Ctrl + w.........................= close window/tab
Alt + Tab.......................= next tab
Alt + Shift + Tab...........= previous tab
Alt + d.........................= Go to url box
Alt + g..........................=Go to search box
Windows
Windows + D.........= minimises all windows
Windows + E.........= brings up my computer
Sep 15, 2009
Python loop and modify list
When working with lists, don't modify them as you iterate through.
For example, if you need to remove empty strings in your list, don't delete the strings as you find them, as your loop is still iterating, and some items might be looped through twice, or not at all.
Solution:
Write out another list, or another variable to keep track of what your loop is trying to achieve.
Extra Tags:
Remove whitespace empty string list iterate modify for loop
Subscribe to:
Posts (Atom)