Shawn Driscoll's Tech Blog
Stuff That Happened in the Past
Tuesday, March 25, 2014
Python: How Do I Display a List From PyQt4's QListWidgetItem()?
You may have to change self.listWidget.item() to PyQt4.QtGui.QListWidgetItem() for your situation.
Tuesday, March 18, 2014
Monday, March 17, 2014
Thursday, March 13, 2014
Python 2.5: Let's Program a Small PyQt GUI Project Together Using Qt Designer
View on YouTube for more instructions and access to files.
Friday, February 28, 2014
Monday, February 17, 2014
Wednesday, February 5, 2014
Getting Py2exe to Work With Matplotlib for Python 2.5
The problem I was having was with the Matplotlib data files not being included/found when running the EXE. At the CMD prompt, I enter setup.py py2exe as usual.
The setup.py code is below:
# Used successfully in Python 2.5.4 for py2exe and matplotlib from distutils.core import setup import py2exe import glob opts = {'py2exe': {'includes': ['matplotlib.backends', 'matplotlib.backends.backend_qt4agg', 'matplotlib.figure', 'pylab', 'numpy', 'matplotlib.backends.backend_tkagg'], 'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg', '_fltkagg', '_gtk', '_gtkcairo'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'] } } data_files = [(r'mpl-data', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\*.*')), (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']), (r'mpl-data\images', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')), (r'mpl-data\fonts', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))] # for console program use "console = [{'script': '3d6_line_bar.py'}]" # for windows program use "windows = [{'script': '3d6_line_bar.pyw'}]" setup(windows = [{'script': '3d6_line_bar.pyw'}], options=opts, data_files=data_files)
Wednesday, January 29, 2014
Python Programming: Building Character
The source code is below:
from random import randint char_name = ['STR', 'DEX', 'END', 'INT', 'EDU', 'SOC', 'PSI'] char = [0,0,0,0,0,0,0] for i in range(len(char_name)): char[i] = randint(1,6) + randint(1,6) for i in range(len(char_name)): print '%s: %d' % (char_name[i], char[i])
I may do more such posts here in the future, now that I've recently learned how to properly post program code.
Thursday, January 16, 2014
Monday, January 13, 2014
Python 3 is not Python
There was a time when Python was mature enough as a language for me to leave other languages I didn't care for and program strictly in Python. There was a time when Python programming was fresh and fun, yada yada. A time when print was a statement and not a function. A time when all the more interesting modules were written for Python, etc etc.
That time was Python 2.5.
Now Python has regulated itself to being updated just for the sake of being updated, making it less compatible or interesting for those that enjoyed the programming language enough to leave other languages.
Python 2.5 is for the computer programmer.
Python 3.x is for the software developer.
It's an entirely different mindset that Python 3 users come from. It's a job now, rather than a hobby. It's a corporate regulation rather than a computer artist's tool. Python 2.5 follows the Zen of Python, while Python 3 does not.
If I had my way, Python 3 would be renamed to something else. Because it is a different language, I mean, different development solution. And it doesn't run Python 2.5 code. Period.
That time was Python 2.5.
Now Python has regulated itself to being updated just for the sake of being updated, making it less compatible or interesting for those that enjoyed the programming language enough to leave other languages.
Python 2.5 is for the computer programmer.
Python 3.x is for the software developer.
It's an entirely different mindset that Python 3 users come from. It's a job now, rather than a hobby. It's a corporate regulation rather than a computer artist's tool. Python 2.5 follows the Zen of Python, while Python 3 does not.
If I had my way, Python 3 would be renamed to something else. Because it is a different language, I mean, different development solution. And it doesn't run Python 2.5 code. Period.
Friday, January 10, 2014
Lessons From '70s Star Trek Arrays
Star Trek: The Mainframe Game was based on two-dimensional arrays. One for mapping sectors. And one for mapping quadrants. These were the short and long-range sensor scans that were routinely performed. These 2D arrays were stored as DIM S(8,8) and DIM Q(8,8) in the HP-2000F computer which ran its own version of BASIC.
Now fast-forward 40 years.
Star Trek: The Python Game is now in the works. And arrays have been poo-poo'd on over the years, but that doesn't matter. Arrays are a non-issue for Python. Its format may look different is all, as it uses [ ][ ] for its indexing.
Here is some Python code to get started with:
It seems pretty straight forward, as it initializes a ten by ten array with zeros. Then assigns an integer value of 807 to a location in the array. The program refers to the array as "grid". This is the output from the Python code:
And there you have it. The makings of an old-school 2D array using Python.
Now fast-forward 40 years.
Star Trek: The Python Game is now in the works. And arrays have been poo-poo'd on over the years, but that doesn't matter. Arrays are a non-issue for Python. Its format may look different is all, as it uses [ ][ ] for its indexing.
Here is some Python code to get started with:
It seems pretty straight forward, as it initializes a ten by ten array with zeros. Then assigns an integer value of 807 to a location in the array. The program refers to the array as "grid". This is the output from the Python code:
And there you have it. The makings of an old-school 2D array using Python.
Subscribe to:
Posts (Atom)