WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-13-2008, 11:50 PM
John P John P is offline
Member
 
Join Date: Jun 2006
Posts: 8
tkinter window focus

I've read some posts about getting the tkinter library working within the vizard gui and have some further questions.

1 - Can a tkinter dialog be displayed in front of a vizard window? I haven't had any luck with this in either window or fullscreen mode.

2 - Until a tkinter window is closed the vizard thread events are blocked. I don't really see any way around that. Key press events (and i assume any other vizard events) actually build up and all trigger at the time the tkinter dialog is closed.

I know there are some vizard dialog alternatives but at this point I would really like to get tkinter running. Any suggestions would be welcomed.
Reply With Quote
  #2  
Old 08-14-2008, 04:14 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm pretty sure Tkinter has a call to bring a window to the foreground. However, to solve the issues you are experiencing the dialog window needs to be a child of the vizard window. The problem is that there is no way to specify an existing non-tk window as the parent of a tk dialog. I'm not very familiar with Tkinter, so I don't know of any workaround.

Using raw win32 calls I have been able to display a modal dialog over a vizard window, so I know this is technically possible.
Reply With Quote
  #3  
Old 08-28-2009, 06:52 AM
sircedric4 sircedric4 is offline
Member
 
Join Date: Aug 2009
Posts: 22
Quote:
Originally Posted by farshizzo View Post
I'm pretty sure Tkinter has a call to bring a window to the foreground. However, to solve the issues you are experiencing the dialog window needs to be a child of the vizard window. The problem is that there is no way to specify an existing non-tk window as the parent of a tk dialog. I'm not very familiar with Tkinter, so I don't know of any workaround.

Using raw win32 calls I have been able to display a modal dialog over a vizard window, so I know this is technically possible.
I am using the win32ui to create a standard "browse" for a file dialog box for my gui but the dialog box comes in under the Vizard window and everything is frozen waiting on the dialog box to finish. You mentioned you were able to display the modal over the vizard window, could you please tell me how you were able to do this?

Thank you.
Reply With Quote
  #4  
Old 08-28-2009, 03:27 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a sample script that shows how to display modal file/color dialogs over the Vizard window:
Code:
import viz
import win32ui
import win32con

viz.go()

color_button = viz.addButtonLabel('color change')
color_button.translate(0.285,0.59)

file_button = viz.addButtonLabel('choose file')
file_button.translate(0.5,0.59)

def ChooseColor():
	"""You can find documentation for CreateColorDialog at the following site:
		http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/pywin32/win32ui__CreateColorDialog_meth.html"""
	parent = win32ui.CreateWindowFromHandle(viz.window.getHandle())
	dlg = win32ui.CreateColorDialog(0,win32con.CC_FULLOPEN,parent)
	if dlg.DoModal() == win32con.IDOK:
		clr = dlg.GetColor()
		r = win32con.GetRValue(clr) / 255.0
		g = win32con.GetGValue(clr) / 255.0
		b = win32con.GetBValue(clr) / 255.0
		print r,g,b

vizact.onbuttonup(color_button,ChooseColor)


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:
		print dlg.GetFileName()
	
vizact.onbuttonup(file_button,ChooseFile)
Reply With Quote
  #5  
Old 08-31-2009, 05:51 AM
sircedric4 sircedric4 is offline
Member
 
Join Date: Aug 2009
Posts: 22
Thanks, that worked like a charm.
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
How to make a glass window in Vizard Frank Verberne Vizard 9 07-27-2011 03:47 PM
Using Window Buttons Uttama_vizard Vizard 2 01-16-2008 10:25 AM
Full screen window changes to small window tacbob Vizard 1 04-04-2007 09:30 AM
How to get the window handle Joran Vizard 1 06-16-2006 11:01 AM
The error window that couldn't FlyingWren Vizard 2 12-02-2003 08:23 AM


All times are GMT -7. The time now is 08:00 AM.


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