473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

PyGTK + Glade = weird problem

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 title and NOTHING inside..

This is well explained here:

http://ubuntuforums.org/showthread.php?p=768219

Hope someone can help me, i tried irc, forums, googled a lot.. but
nothing solves my problem, even rewriting the code by hand results on
the same thing!

thanx for any help

Feb 25 '06 #1
6 1574
We'd need to see your "scc.glade" file to be sure, but basically,
calling the "show" method on the "w_cadcli" object only shows it, not
the objects it contains. Again, to be clear, showing a container
object doesn't automatically show the objects it contains. In glade,
use the "common" tab of the property editor to make sure that the
"visible" property is set to "Yes" for all of the widgets in the
windows you want to show. In general, if you always do that, you'll be
able to show or hide the entire window by simply calling "show" or
"hide" on the window object, like you're trying to do.

But this is just a guess; post your "scc.glade" file if the above
advice doesn't work.

Greg

Feb 25 '06 #2
Oops- I didn't read your question carefully enough. That's probably
not the problem.

Greg

Feb 25 '06 #3
Sorry about that. Your problem is that the show_hide_janela method is
setup to be called both on a gtk signal ("destroy") and an
event("delete_event"). Callback methods for events take a slightly
different signature than signals; they take one extra argument, which
represents the triggering event. When you close the window, the
delete_event is triggered, which calls show_hide_janella, but the call
fails, because show_hide_janella is called with 3 arguments, when its
only expecting 2. So, to fix the code you have posted in the thread
you linked, replace the line

def show_hide_janela(self,obj):

with the line

def show_hide_janela(self,obj, event=None):

The modified code works on my machine. Hope this helps,

Greg

Feb 25 '06 #4
Man, you saved my day.

I spent all day writing and rewriting stuff, i asked several times on
the #python channel on irc.freenode.org, asked in the ubuntuforums,
asked all people i know that uses python.. and nobody solved it.

And it was a very simple and stupid thing!

thanx a lot it worked perfectly!

Feb 25 '06 #5
Anyway, now i tried in my glade app and i m getting this error when i
try to show the window:

GtkWarning: gtk_paint_flat_box: assertion `style->depth ==
gdk_drawable_get_depth (window)' failed

here is the code:

class main:
def __init__(self):
self.principal = gtk.glade.XML("scc.glade")
self.w_cadcli = self.principal.get_widget("w_cadcli")
dic = {"on_principal_destroy" : self.DestroyFunction,
"on_sair_activate" : self.DestroyFunction,
"on_w_cadcli_destroy" : self.show_hide_window,
"on_cadcli_activate" : self.show_hide_window}
self.principal.signal_autoconnect(dic)
principal = self.principal.get_widget("principal")
gtk.main()

def DestroyFunction(self,*args):
gtk.main_quit()

def show_hide_window(self,obj,event=None):
#if the second window is open hide it, if dont show it
if self.w_cadcli.get_property("visible") == True:
self.w_cadcli.hide()
else:
self.w_cadcli.show()
return True

Feb 25 '06 #6
Finally solved this stuff, the problem wasnt with glade, the problem
was that i was using the "destroy" event in glade, i just changed the
"destroy" to "delete-event" and it worked like a charm.

thanx :)

Feb 25 '06 #7

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

Similar topics

4
by: j_mckitrick | last post by:
Hi all. Here is a tiny container for one of each combo box, along with the glade file. Just 2 widgets, so hopefully not too large. How the heck do I get the selection from the ComboBox, as...
22
by: dcrespo | last post by:
Hi all... I think wxPython is much better than PyGTK. First of all, PyGTK needs the GTK runtime installed, whereas wxPython is entirely Python's modules, so It facilitates the apps'...
6
by: seb | last post by:
Hi, I am using pygtk for the first times. I am wondering what would be the best "pattern" to interface pygtk with a thread. The thread is collecting informations (over the network for...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.