[tkinter] question about correct use of validation

steve stefano at stalksoftINVALID.com
Tue Jan 15 08:37:10 EST 2019


On 15/01/2019 14:16, Rick Johnson wrote:
> steve wrote:
> 
> Then it's just a matter of passing a keyword argument:
> 
>      myEntry = MyEntry(master, maxlen=20)
> 
> What you have above is a tightly coiled, steaming dogpile that will litter your code base. Encapsulate that stench, would ya?
> 

sure, everything will go into a "label_entry" function

It's similar to this:

def __label_entry (self, frame, text_label, width_label, width_entry, 
maxlen):
          '' 'Private utility function for a couple of labels + entry.
              Return istance of entry itself.
          '' '
          Label (frame, padx=10, pady=10, width=width_label,
                 text=text_label) .Pack (side=LEFT)
          entry = Entry (frame, width=width_entry)
          entry.configure (highlightcolor='blue')
          entry.pack (side=LEFT)
         ......
          return entry

I wrote voluntarily in order to better understand the question



More information about the Python-list mailing list