Thread: FileChooser
View Single Post
  #2  
Old 03-30-2011, 10:29 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
If you plan on upgrading to Vizard 4, you can use the vizinput module to display file open/save dialogs:
Code:
import vizinput
filename = vizinput.fileOpen()
filename = vizinput.fileSave()
If you need code that works with Vizard 3, then you can use the win32gui module that comes with Vizard:
Code:
import win32gui
import win32con
import pywintypes

def OpenFileDialog():
	try:
		value = win32gui.GetOpenFileNameW(
				hwndOwner = viz.window.getHandle(),
				InitialDir = '',
				Flags = win32con.OFN_EXPLORER|win32con.OFN_FILEMUSTEXIST|win32con.OFN_NOCHANGEDIR,
				File = '',
				Filter = '' )
	except pywintypes.error:
		return ''
	else:
		return value[0]

def SaveFileDialog():
	try:
		value = win32gui.GetSaveFileNameW(
				hwndOwner = viz.window.getHandle(),
				InitialDir = '',
				Flags = win32con.OFN_EXPLORER|win32con.OFN_NOCHANGEDIR,
				File = '',
				Filter = '' )
	except pywintypes.error:
		return ''
	else:
		return value[0]
Reply With Quote