Monday, October 6, 2008

File Dialogs in PyQt4

The following code is an example of how to setup a simple open file dialog prompt. Two versions are shown using the following code, the open file dialog and the open directory dialog. More examples may be found in the PyQt4 source code examples and also from the great general tutorial found at zetcode.


#!/usr/bin/python

from PyQt4 import QtCore, QtGui
import os

class OFD_Class(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.curDir = os.getcwd()

def PyQt4_OFD(self):
directory= QtGui.QFileDialog.getExistingDirectory(self, "Select Folder", self.curDir)
if directory:
#if user selected a directory...do something
print directory
#remember that PyQt returns QStrings which are unicode object and need to be handled appropriately
print type(directory)

dataFileName = QtGui.QFileDialog.getOpenFileName(self,\
"Select File",\
self.curDir, 'X!Tandem XML (*.xml);; HDF5 File (*.h5);;SQLite Database (*.db);;All Files (*.*)')
if dataFileName:
#if file selected...do something
print dataFileName
print type(dataFileName)

def main():

import sys
app = QtGui.QApplication(sys.argv)

OFD = OFD_Class()
OFD.PyQt4_OFD()

sys.exit(app.exec_())



if __name__ == "__main__":
main()

Saturday, October 4, 2008

What is a Mach disk you ask?

This is fantastic image which illustrates the wide range of gas dynamics that occur during a rapid expansion of a gas. In this particular image the Mach disk is visible as a vertical line located just to the right of center. From the perspective of fluid dynamics, after the Mach disk the behavior of a gas can become highly turbulent (observed as the swirling formations in the image). Also of interest is the relative speed and temperature of the particles immediately preceding and following the Mach disk. Prior to the Mach disk, the Mach number of the system ais much greater than 1 and subsonic following the disk. With respect to temperature, the region following the Mach disk is characterized by a rapid increase in temperature.

http://en.wikipedia.org/wiki/Shock_diamond