473,509 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: [Tkinter-discuss] WxPython -> Tkinter

On 10/29/08, Olrik Lenstra <o.*******@gmail.comwrote:
Hello everyone,

A while ago I joined the Tutor mailing list, and they helped me out with a
question regarding wxPython.
Now however, I have tried a program in Tkinter and I would like to see if
there is a similar command to "wx.SafeYield(self, True)".
It will be a combination of commands, not a single one. Initially I
considered this as "probably without solution", since tcl acquired a
yield command just in the 8.6a3 release, but then I looked at
wx.SafeYield code and apparently it is possible to replicate it.

Here is an initial cut, it is very possible to contain something not
equivalent to wx.SafeYield (besides it could be improved):
import ttk

inside_tkyield = False
disabled_wins = {}

def safe_yield(window, only_if_needed=False):
window_disabler(window)

try:
return tk_yield(window, only_if_needed)
finally:
for widget, flags in disabled_wins.iteritems():
ttk.Widget.state(widget, flags)
disabled_wins.clear()
def window_disabler(window):
widgets = window.children.values()
widgets.append(window)

for widget in widgets:
if widget.instate(['!disabled']):
prev_flags = widget.state(['disabled'])
disabled_wins[widget] = prev_flags
def tk_yield(window, only_if_needed=False):
# wx implements this differently based on the backend it is using
global inside_tkyield
if inside_tkyield:
if not only_if_needed:
raise RuntimeError("safe_yield called recursively")

return False

inside_tkyield = True;

window.update()
window.update_idletasks()

inside_tkyield = False;

return True
Note that this depends on ttk widgets
(http://pypi.python.org/pypi/pyttk) since it uses widget.state to
disable and reenable the widgets. On windows the "wm" command supports
disabling the entire window, so it is easier if you can use it.
Below is a copy of the message to the tutor list.
Dear Mailing list,

a while ago a few of you helped me solve an issue I had with a GUI / scan
program that I made.
The problem was that when I tried to move the frame it would hang until
the
scan was finished.
To solve this I had to add "wx.SafeYield(self, True)" to the scan and the
GUI wouldn't hang any more.
Now I have redone the program and have written it with Tkinter instead of
WxPython.

So is there a similar command for Tkinter as there is for WxPython?

Thanks in advance.
Regards,
Olrik

_______________________________________________
Tkinter-discuss mailing list
Tk*************@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


--
-- Guilherme H. Polo Goncalves
Oct 29 '08 #1
0 1778

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
3321
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
8
4468
by: Erik Johnson | last post by:
I am looking for some input on GUI libraries. I want to build a Python-driven GUI, but don't really understand the playing field very well. I have generally heard good things about wxPython. I...
0
1144
by: It's me | last post by:
I've built a Python application using PythonCard 1.9 and Python 2.3 running under Windows XP. Everything works except that when I use the keyboard instead of the mouse to do certain operations in...
5
1990
by: Tuvas | last post by:
Is there a way to put an image loaded from PIL into a TKinter GUI? Without converting the image to a .bmp, and using a canvas? If that's the only way it'll work, I'll take it, but... It would be...
4
2362
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
2
3944
by: Kevin Walzer | last post by:
I'm porting a Tkinter application to wxPython and had a question about wxPython's event loop. The Tkinter app provides a GUI to a command-line tool. It gathers user input, and opens an...
2
1467
by: whatazor | last post by:
Hi all, I migrate some code from tkinter to wxpython. I need the equivalent Tkinter method Tkinter.Tk.after in wxPython, but I'm not able to find it. It exist or there are other trick to emulate...
8
2638
by: Sean DiZazzo | last post by:
Is there something special you have to do to get a wxPython app to run remotely under xwindows? My Tkinter apps always automatically work that way, so I was surprised to even be confronted with...
0
188
by: Guilherme Polo | last post by:
On 10/29/08, Guilherme Polo <ggpolo@gmail.comwrote: oops, wrong list. -- -- Guilherme H. Polo Goncalves
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.