473,785 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pygtk window.hide() imidetly

8 New Member
when i say window.hide(), window dont hide imidetly

i want to hide it for a few seconds, do something and then show it back
how can i do this?

i have this example:
Expand|Select|Wrap|Line Numbers
  1. import pygtk,time
  2. pygtk.require('2.0')
  3. import gtk
  4.  
  5. class HelloWorld:
  6.     def click_hide(self, widget, data=None):
  7.         print "hide"
  8.         self.window.hide()
  9.         time.sleep(4)
  10.         print "show"
  11.         self.window.show()
  12.         time.sleep(4)
  13.  
  14.     def delete_event(self, widget, event, data=None):
  15.         print "delete event occurred"
  16.         return False
  17.  
  18.     def destroy(self, widget, data=None):
  19.         print "destroy signal occurred"
  20.         gtk.main_quit()
  21.  
  22.     def __init__(self):
  23.         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  24.         self.window.connect("delete_event", self.delete_event)
  25.         self.window.connect("destroy", self.destroy)
  26.         self.button = gtk.Button("hide")
  27.         self.button.connect("clicked", self.click_hide, None)
  28.         self.window.add(self.button)
  29.         self.window.show_all()
  30.  
  31.     def main(self):
  32.         gtk.main()
  33.  
  34. if __name__ == "__main__":
  35.     hello = HelloWorld()
  36.     hello.main()
Feb 9 '07 #1
5 8968
bartonc
6,596 Recognized Expert Expert
when i say window.hide(), window dont hide imidetly

i want to hide it for a few seconds, do something and then show it back
how can i do this?

i have this example:
Expand|Select|Wrap|Line Numbers
  1. import pygtk,time
  2. pygtk.require('2.0')
  3. import gtk
  4.  
  5. class HelloWorld:
  6.     def click_hide(self, widget, data=None):
  7.         print "hide"
  8.         self.window.hide()
  9.         time.sleep(4)
  10.         print "show"
  11.         self.window.show()
  12.         time.sleep(4)
  13.  
  14.     def delete_event(self, widget, event, data=None):
  15.         print "delete event occurred"
  16.         return False
  17.  
  18.     def destroy(self, widget, data=None):
  19.         print "destroy signal occurred"
  20.         gtk.main_quit()
  21.  
  22.     def __init__(self):
  23.         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  24.         self.window.connect("delete_event", self.delete_event)
  25.         self.window.connect("destroy", self.destroy)
  26.         self.button = gtk.Button("hide")
  27.         self.button.connect("clicked", self.click_hide, None)
  28.         self.window.add(self.button)
  29.         self.window.show_all()
  30.  
  31.     def main(self):
  32.         gtk.main()
  33.  
  34. if __name__ == "__main__":
  35.     hello = HelloWorld()
  36.     hello.main()
I looks to me like you have not subclassed properly; In the other Gui Too Kits that I have used it's always something like this:
Expand|Select|Wrap|Line Numbers
  1. class HelloWorld(GTK.TopLevelWindow):
  2.     # call the superclass __init__() IFF you override it
  3.     # the superclass has all of the gui commands including main()
Feb 9 '07 #2
xrado
8 New Member
i dont think this is the problem...
i added the print lines to observe what is going on

it prints "hide" and waits for 4 sec, then prints "show" and waits for 4 sec
only after that window hides in shows again in less then sec
Feb 9 '07 #3
bartonc
6,596 Recognized Expert Expert
i dont think this is the problem...
i added the print lines to observe what is going on

it prints "hide" and waits for 4 sec, then prints "show" and waits for 4 sec
only after that window hides in shows again in less then sec
Ok. That explains a lot. This sounds like gtk is running the interpeter that is getting the print command in a separte thread from the one running your GUI app. Look and see if gtk has a timer class that generates events. The thing is that once you have a gui app, the best practice is to use only gui events for timing puposes.
Feb 9 '07 #4
xrado
8 New Member
gtk.gdk.flush() ..do the trick :)
Feb 10 '07 #5
bartonc
6,596 Recognized Expert Expert
gtk.gdk.flush() ..do the trick :)
Thanks for keeping us up to date. This will, no doubt, help someone else down the line.
Feb 10 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3356
by: Samuele Giovanni Tonon | last post by:
hi, i'm trying to develop a trivial application which random copy files from a directory to another one. i made it using pygtk for the graphical interface, however i find some problem with progressbar and ListStore: basically i need to make pulse the progressbar while i'm copying files and write filenames copied on the ListStore on to the window.
2
6651
by: Nick Atkins | last post by:
Hi all, I am writing an application using pyGTK that has several pop-up dialogs that show and hide in succession. I would like to prevent the user from closing the dialog and if possible I'd like to use a "title bar-less" window with a normal border so the X is not even available to click. Is this possible? I have tried using window.set_decorated(FALSE) but this also removes the border making the window look quite strange.
0
1364
by: Johan | last post by:
Hello! I'm trying to figure out how to use PYGTK to implement a rudimentary UI: I want to have an Image as the background, and then be able to put buttons (eventually icons, but buttons for now) The PyGTK FAQ (pygtk.org) has some suggestions, but they have failed to clear up the issue. Using their suggestions as a starting point, I've arrived at the below. However, it fails in that I can't seem to
6
1594
by: sapo | last post by:
Hi all, i ve started learning pygtk with glade, i m just making some test stuff. but i got some problems with simple things. I designed 2 windows on glade, then exported it and loaded in the python script, the second window is hidden by default, then i wrote a function to show it up, ok it shows, them i wrote another function to hide it.. ok it hides... But in the second time i show the window.. the window appear EMPTY, with just the...
2
2570
by: Tim N. van der Leeuw | last post by:
I tried to create a windows executable of a pygtk program. My first attempt worked, kinda, except that no themes were applied and no readable fonts were found by pango; so all letters where just empty squares. But the program worked. I looked up some docs, found the following recipe on the PyGTK Wiki site: http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK I followed those instructions to convert my setup.py file;...
0
1806
by: Peter TB Brett | last post by:
Hi folks, I'm currently trying to work out how to detect when a PyGTK window receives the focus from the window manager -- I assume that it must receive some kind of X event, but I can't work out which signal it generates. Searching around the subject on the web doesn't seem to pull up anything useful. I tried the "focus" signal, but that doesn't work the way I'd like it to. For example, the following code only prints the message...
1
1585
by: manatlan | last post by:
I was a fan of "SimpleGladeApp/tepache way" to build a pygtk app. I've build a new efficient/dynamic way to build a pygtk app ... Here is an example : ================================================= class Fen(GladeApp): """ Window win .title="Hello" @delete_event
0
1786
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for pyGTK applications at http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.