#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
Quote:
Thank you. |
#4
|
|||
|
|||
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) |
#5
|
|||
|
|||
Thanks, that worked like a charm.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to make a glass window in Vizard | Frank Verberne | Vizard | 9 | 07-27-2011 04:47 PM |
Using Window Buttons | Uttama_vizard | Vizard | 2 | 01-16-2008 11:25 AM |
Full screen window changes to small window | tacbob | Vizard | 1 | 04-04-2007 10:30 AM |
How to get the window handle | Joran | Vizard | 1 | 06-16-2006 12:01 PM |
The error window that couldn't | FlyingWren | Vizard | 2 | 12-02-2003 09:23 AM |