Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5301 > unrolled thread

problem with GKT module?

Started byalister ware <alister.ware@ntlworld.com>
First post2011-05-13 13:13 +0000
Last post2011-05-16 23:02 +0300
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  problem with GKT module? alister ware <alister.ware@ntlworld.com> - 2011-05-13 13:13 +0000
    Re: problem with GKT module? Alister Ware <alister.ware@ntlworld.com> - 2011-05-15 11:13 +0000
      Re: problem with GKT module? harrismh777 <harrismh777@charter.net> - 2011-05-15 20:42 -0500
        Re: problem with GKT module? alister ware <alister.ware@ntlworld.com> - 2011-05-16 12:29 +0000
          Re: problem with GKT module? harrismh777 <harrismh777@charter.net> - 2011-05-16 14:56 -0500
            Re: problem with GKT module? Alister Ware <alister.ware@ntlworld.com> - 2011-05-17 19:26 +0000
      Re: problem with GKT module? Anssi Saari <as@sci.fi> - 2011-05-16 23:02 +0300

#5301 — problem with GKT module?

Fromalister ware <alister.ware@ntlworld.com>
Date2011-05-13 13:13 +0000
Subjectproblem with GKT module?
Message-ID<w7azp.13536$IL2.10719@newsfe04.ams2>
I am using gtk.builder with a glade generated GUI

I have a simple call back defined for a radio button widget when I use 
widget.name in linux I get a value of None, windows returns the widget 
name as I would expect.

is this a bug?
if not how should i find the name of the widget that has triggered a call 
back?

(I would like all my radio buttons to go to the same callback routine if 
possible to make code maintenance easier)


-- 
101-ism:
	The tendency to pick apart, often in minute detail, all
aspects of life using half-understood pop psychology as a tool.
		-- Douglas Coupland, "Generation X: Tales for an 
Accelerated
		   Culture"






-- 
You may my glories and my state dispose,
But not my griefs; still am I king of those.
		-- William Shakespeare, "Richard II"

[toc] | [next] | [standalone]


#5422

FromAlister Ware <alister.ware@ntlworld.com>
Date2011-05-15 11:13 +0000
Message-ID<hzOzp.4673$2E6.769@newsfe18.ams2>
In reply to#5301
On Fri, 13 May 2011 13:13:00 +0000, alister ware wrote:

> I am using gtk.builder with a glade generated GUI
> 
> I have a simple call back defined for a radio button widget when I use
> widget.name in linux I get a value of None, windows returns the widget
> name as I would expect.
> 
> is this a bug?
> if not how should i find the name of the widget that has triggered a
> call back?
> 
> (I would like all my radio buttons to go to the same callback routine if
> possible to make code maintenance easier)
> 
So nobody has any Ideas on this at all?



-- 
I never failed to convince an audience that the best thing they
could do was to go away.

[toc] | [prev] | [next] | [standalone]


#5457

Fromharrismh777 <harrismh777@charter.net>
Date2011-05-15 20:42 -0500
Message-ID<qi%zp.1052$dj2.973@newsfe20.iad>
In reply to#5422
Alister Ware wrote:
> I have a simple call back defined for a radio button widget when I use
>>  widget.name in linux I get a value of None, windows returns the widget
>>  name as I would expect.
>>

First, not familiar with your issue...

... but might be able to help you think through it...

I am assuming that you are building a Python script using a glade 
interface that provides the widgets drag-an-drop style and then allowing 
you to take the default code, add to it, or otherwise modify it.

I am also assuming that the /call back/ is returning a Python None, on 
the linux platform... otherwise you're getting the widget name from the 
same script on the windows platform??  right?

It might be helpful to examine both scripts to see where (if any) they 
differ. More likely than not, this little snag is a difference in the 
way that the windows version of gtk+ libraries are working, than the 
original ones on the linux platform.

On the other hand, the Python wrappers for the gtk+ library on the linux 
platform may be hiding the return values. Python functions return 'None' 
if the 'return' is not explicitly coded. The gtk+ libraries may be 
returning a value but the 'builder' is not generating the right Python 
wrapper. I'm making this up, but you get the idea, and you can probably 
check from here.

On the other hand, folks here can enter into a discussion with you 
regarding the generated Python code (output from the builder) if you 
provide relevant code snippets.


Kind regards,
m harris

[toc] | [prev] | [next] | [standalone]


#5515

Fromalister ware <alister.ware@ntlworld.com>
Date2011-05-16 12:29 +0000
Message-ID<XM8Ap.541$t41.164@newsfe25.ams2>
In reply to#5457
On Sun, 15 May 2011 20:42:46 -0500, harrismh777 wrote:

> Alister Ware wrote:
>> I have a simple call back defined for a radio button widget when I use
>>>  widget.name in linux I get a value of None, windows returns the
>>>  widget name as I would expect.
>>>
>>>
> First, not familiar with your issue...
> 
> ... but might be able to help you think through it...
> 
> I am assuming that you are building a Python script using a glade
> interface that provides the widgets drag-an-drop style and then allowing
> you to take the default code, add to it, or otherwise modify it.
> 
> I am also assuming that the /call back/ is returning a Python None, on
> the linux platform... otherwise you're getting the widget name from the
> same script on the windows platform??  right?
> 
> It might be helpful to examine both scripts to see where (if any) they
> differ. More likely than not, this little snag is a difference in the
> way that the windows version of gtk+ libraries are working, than the
> original ones on the linux platform.
> 
> On the other hand, the Python wrappers for the gtk+ library on the linux
> platform may be hiding the return values. Python functions return 'None'
> if the 'return' is not explicitly coded. The gtk+ libraries may be
> returning a value but the 'builder' is not generating the right Python
> wrapper. I'm making this up, but you get the idea, and you can probably
> check from here.
> 
> On the other hand, folks here can enter into a discussion with you
> regarding the generated Python code (output from the builder) if you
> provide relevant code snippets.
> 
> 
> Kind regards,
> m harris

glade generates an xml file that is processed by the python script

it is the same ml file & the same python script running on both platforms

the basic structure of my call back for testing is:-

import gtk
class GUI:
	def __init__(self):
		builder=gtk.Builder()
		builder.add_from_file('glade.test') # xml file from glade
		builder.get_object('window1').show()
		builder.connect_signals(self)


	def callback(self,widget,data=None):
		print widget	#gives reference to radio button ok
		print widget.name #widget name on windoze, None on linux
	def main (self):
		gtk.main()

def main():
	gui=GUI()
	gui.main()

if __name__ =='__main__':main()

I can provide more detailed sample code if required (including the xml 
from glade)


-- 
Has everyone noticed that all the letters of the word "database" are
typed with the left hand?  Now the layout of the QWERTYUIOP typewriter
keyboard was designed, among other things, to facilitate the even use
of both hands.  It follows, therefore, that writing about databases is
not only unnatural, but a lot harder than it appears.

[toc] | [prev] | [next] | [standalone]


#5533

Fromharrismh777 <harrismh777@charter.net>
Date2011-05-16 14:56 -0500
Message-ID<YjfAp.4143$eb4.1206@newsfe02.iad>
In reply to#5515
alister ware wrote:
> 	def callback(self,widget,data=None):
> 		print widget	              #gives reference to radio button ok
> 		print widget.name             #widget name on windoze, None on linux

Well, you're obviously using Python 2.x ...

    ... have you tried this in Python 3.x ?


Neither here nor there...  you need to know who/what is generating 
'widget'.  Is widget buried in gtk where you can't see how it works, or 
is widget a Python class (or wrapper) where you can see what its doing?

The fact that widget.name returns None on the linux platform tells me 
that widget is a Python class (or wrapper) ... so you probably have a 
widget.py file somewhere... or some other module that widget is a class 
definition in... who knows... (at this point).

It seems to me that the 'builder' is behaving differently on the two 
platforms (rather than Python is behaving differently on the two platforms).

What happens if you change the data=None pair?

What happens if you omit data=None pair?

Do you see this difference with *all* widgets, or just radio buttons?



kind regards,
m harris

[toc] | [prev] | [next] | [standalone]


#5601

FromAlister Ware <alister.ware@ntlworld.com>
Date2011-05-17 19:26 +0000
Message-ID<6_zAp.5859$6K4.49@newsfe14.ams2>
In reply to#5533
On Mon, 16 May 2011 14:56:38 -0500, harrismh777 wrote:

> alister ware wrote:
>> 	def callback(self,widget,data=None):
>> 		print widget	              #gives reference to radio 
button ok print
>> 		widget.name             #widget name on windoze, None on 
linux
> 
> Well, you're obviously using Python 2.x ...
> 
>     ... have you tried this in Python 3.x ?
> 
> 
> Neither here nor there...  you need to know who/what is generating
> 'widget'.  Is widget buried in gtk where you can't see how it works, or
> is widget a Python class (or wrapper) where you can see what its doing?
> 
> The fact that widget.name returns None on the linux platform tells me
> that widget is a Python class (or wrapper) ... so you probably have a
> widget.py file somewhere... or some other module that widget is a class
> definition in... who knows... (at this point).
> 
> It seems to me that the 'builder' is behaving differently on the two
> platforms (rather than Python is behaving differently on the two
> platforms).
> 
> What happens if you change the data=None pair?
> 
> What happens if you omit data=None pair?
> 
> Do you see this difference with *all* widgets, or just radio buttons?
> 
> 
> 
> kind regards,
> m harris

It seems it was introduced in pygtk 2.1.7 as a side effect of correcting 
something to do with widget id's and the fact that widget names do not 
have to be unique (although glade insists that they are).

looks like i have to modify my code & use gtk.buildable.get_name(widget) 
instead, not really a big change but may break someone else's code 



-- 
If you're not careful, you're going to catch something.

[toc] | [prev] | [next] | [standalone]


#5535

FromAnssi Saari <as@sci.fi>
Date2011-05-16 23:02 +0300
Message-ID<vg3boz25s8d.fsf@pepper.modeemi.fi>
In reply to#5422
Alister Ware <alister.ware@ntlworld.com> writes:

> On Fri, 13 May 2011 13:13:00 +0000, alister ware wrote:
>
>> I am using gtk.builder with a glade generated GUI
>> 
>> I have a simple call back defined for a radio button widget when I use
>> widget.name in linux I get a value of None, windows returns the widget
>> name as I would expect.
>> 
>> is this a bug?
>> if not how should i find the name of the widget that has triggered a
>> call back?
>> 
>> (I would like all my radio buttons to go to the same callback routine if
>> possible to make code maintenance easier)
>> 
> So nobody has any Ideas on this at all?

You may want to post runnable code demonstrating your problem.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web