473,796 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1596
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_janel a method is
setup to be called both on a gtk signal ("destroy") and an
event("delete_e vent"). 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_janel la, but the call
fails, because show_hide_janel la 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_janel a(self,obj):

with the line

def show_hide_janel a(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.or g, 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_ge t_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_c adcli")
dic = {"on_principal_ destroy" : self.DestroyFun ction,
"on_sair_activa te" : self.DestroyFun ction,
"on_w_cadcli_de stroy" : self.show_hide_ window,
"on_cadcli_acti vate" : self.show_hide_ window}
self.principal. signal_autoconn ect(dic)
principal = self.principal. get_widget("pri ncipal")
gtk.main()

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

def show_hide_windo w(self,obj,even t=None):
#if the second window is open hide it, if dont show it
if self.w_cadcli.g et_property("vi sible") == True:
self.w_cadcli.h ide()
else:
self.w_cadcli.s how()
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
2604
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 opposed to the ComboEntryBox? I'm pulling my hair out over this one! jonathon
22
5773
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' distribution. Also, PyGTK uses specific controls or widgets of GTK, while wxPython uses native controls of the platform where the app is running. I'm learning both, but at a slow step, so I want to know all the comments about this subject in this group.
6
2869
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 example) or is doing some long calculations.
0
1787
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
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
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,...
1
7548
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
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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.