A Dangling Tk Entry

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed Mar 11 07:09:48 CET 2009

On Mon, 09 Mar 2009 21:14:51 -0700, W. eWatson wrote:

>>>      def Set_Enter_Data(self):
>>>          sdict = {}
>>>          sdict[ "ok" ] = False
>>>          sdict[ "anumber" ] = self.anumber
>>>          dialog = Enter_Data_Dialog( self.master, sdict ) <---
>>>          returning
>> That's not a call to the `body()` method so that ``return`` is
>> irrelevant here.  Here an instance of `Enter_Data_Dialog` is created. 
>> No ``return`` involved.
>> BTW if this is really just a dialog to enter a number, the functions
>> `askinteger()` or `askfloat()` from the `tkSimpleDialog` module can be
>> used.
> What you are seeing here as an example, is a paired down version of the
> 2000 line program to focus on the particular problem at hand. The full
> code uses up to 20 variable of various types, via the dialog object. It
> uses them successfully to get the values the user has entered. How can
> it be irrelevant if it works?

The ``return`` in `body()` has nothing to do with the source line you 

> The author thought this was the way to do it.

And he thought wrong because his `body()` method returns `None`.  That 
"works" but not the way it is intended.

> It's not my invention. It's no fluke. He does the same thing in
> another dialog that brings back about 6 values.
>      def body(self,master):
>          self.title("Box Settings")
>          print "body from BSD"
>               ...
>          frame_delay = Entry( master,
>                 textvariable=self.frame_delay_var,
>                 width=10 ).grid( row=2, column=1, sticky=W )
> 	...
>          Entry( master,
>                 textvariable=self.untrigger_threshold_var, width=10
>                 ).grid( row=4, column=1, sticky=W )
>          self.untrigger_threshold_var.set( "%d" %
>                         self.sdict["untrigger_threshold"] )
>          return frame_delay

Then he did it consequently wrong.  `frame_delay` is always `None` here 
so the ``return`` is useless.

You asked what this code means and now you don't like the answer that 
it's somewhat useless code!?

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list