WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-09-2009, 08:26 PM
jincheker jincheker is offline
Member
 
Join Date: Oct 2009
Posts: 15
Is there any open file GUI

Can I build a GUI in vizard, like below, that allow user to open and choose some files and import them into vizard?

Click image for larger version

Name:	open.jpg
Views:	844
Size:	54.7 KB
ID:	349
Reply With Quote
  #2  
Old 12-10-2009, 08:42 AM
jincheker jincheker is offline
Member
 
Join Date: Oct 2009
Posts: 15
I mean build a button, and when click the button, it can call an open file GUI in which people can browse and choose files to be open?
Reply With Quote
  #3  
Old 12-10-2009, 02:11 PM
hosier hosier is offline
Member
 
Join Date: Feb 2007
Posts: 31
There's an example over in the Vizard 2.5 forum. Here's a link to it:http://forum.worldviz.com/showthread...light=win32gui

I've tried it under Vizard 3 and it works, no problem.

Aaron
Reply With Quote
  #4  
Old 12-11-2009, 01:53 PM
jincheker jincheker is offline
Member
 
Join Date: Oct 2009
Posts: 15
Thumbs up

Quote:
Originally Posted by hosier View Post
There's an example over in the Vizard 2.5 forum. Here's a link to it:http://forum.worldviz.com/showthread...light=win32gui

I've tried it under Vizard 3 and it works, no problem.

Aaron
Thanks hosier
Reply With Quote
  #5  
Old 07-23-2010, 05:44 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Question

Sorry for bumping this thread but when I attempt to use the code in this example I get this error:
Code:
Traceback (most recent call last):
** Load Time: 0.01 seconds
  File "<string>", line 11, in ?
  File "Vizard2.py", line 3, in ?
    inFileDlg = win32ui.CreateFileDialog(1, '', 'foo.txt')
TypeError: None is not a valid string in this context
I have used the exact code in the given example but still no joy

I really need to be able to navigate to and open various files and this seemed the ideal way to do it except I can't get it to work!! I'd be really grateful for any ideas regarding this,

Cheers
Reply With Quote
  #6  
Old 07-23-2010, 08:07 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Ok, I'm getting somewhere here I think. Here's what I am using now:
Code:
def ChooseFile():
	"""You can find documentation for CreateFileDialog at the following site:
		http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/pywin32/win32ui__CreateFileDialog_meth.html"""
	parent = win32ui.CreateWindowFromHandle(viz.window.getHandle())
	dlg = win32ui.CreateFileDialog(1,'','',0,'',parent)
	if dlg.DoModal() == win32con.IDOK:
		file = dlg.GetFileName()
		inFileName  = dlg.GetPathName()
		print file
		print inFileName
- Thanks farshi

However, what I would really like to do is open the selected file, so I tried adding:
Code:
		FILE = open(file, 'r')
		
		for line in FILE:
			print line
- but all I get is
Code:
ÐÏࡱ


So my question is - what am I doing wrong here, I just want a participant to be able to select a file which is then read in / parsed into useful chunks of data.

Also when exiting winviz after running this I get a - "winviz.exe has encountered a problem and needs to close. We are sorry for the inconvenience." from windoze
Reply With Quote
  #7  
Old 07-23-2010, 08:28 AM
TarkaDahl TarkaDahl is offline
Member
 
Join Date: Mar 2010
Posts: 59
Hi nige777

This is what i use and it seems to work

Code:
	infile = open(file,"r")
	for line in infile.readlines(): 
		#do stuff
	infile.close()
Thanks
Reply With Quote
  #8  
Old 07-28-2010, 06:00 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Red face

@TarkaDahl - thanks for the reply unfortunately it was my bad as I needed to be using the excellent 'xlrd' library to be able to work with Excel files

Nige
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IVEx file extenstion unrecognised. sindi Vizard 2 12-10-2009 01:20 AM
problems with output to a text file within executable Saz Vizard 1 07-01-2009 11:01 AM
Problem generating exe file Anfo Vizard 1 11-17-2008 04:21 PM
Read file....many issues Uttama_vizard Vizard 9 07-08-2008 02:16 PM
File Management Uttama_vizard Vizard 2 07-01-2008 09:44 AM


All times are GMT -7. The time now is 09:49 AM.


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