WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   FileChooser (https://forum.worldviz.com/showthread.php?t=3667)

disbeat 03-30-2011 10:09 AM

FileChooser
 
Hi,

Is there a built in way to provide a file choosing window or something?

If no, is vizard compatible with libraries like gtk, so I can use its implementation, like in:

http://www.eurion.net/python-snippet...20Chooser.html

Thanks in advance

farshizzo 03-30-2011 10:29 AM

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]



All times are GMT -7. The time now is 06:16 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC