Harlin Seritt wrote:
I've created a ghetto-ized ComboBox that should work nicely for Tkinter
(unfortunately no dropdown capabilities yet).

I've found why it's such a pain in the @ss to create one. You have to
re-create common methods and make sure they're mapped to the right
component (inside this widget are frame, entry, listbox, and scrollbar
widgets). I tried to look for ways I could inherit some methods from
other widgets but couldn't think of how to do it in an efficient way.

If anyone has suggestions to improve it, please respond... Remember...
I'm a traditional c/c++ turned python programmer who forgets that there
usually is a better, faster more graceful way to do things with Python
than with C/C++/Java.

Cheers,

Harlin

######################################################################
# Seritt Extensions:
# Date: 02262005
# Class ComboBox
# Add this section to your Tkinter.py file in 'PYTHONPATH/Lib/lib-tk/'
# Options: width, border, background, foreground, fg, bg, font
#               , relief, cursor, exportselection, selectbackgroun,
selectforeground, height
#
# Methods: activate(int index) => int, curselection() => int,
delete(item=["ALL" or int], start=int, end=["END" or
# int],
#       focus_set()/focus(), get()=>selected string in box, pack(padx=int,
pady=int,  fill(X, Y, BOTH), expand=bool, # side=LEFT,
#       RIGHT, TOP, BOTTOM, CENTER
#

class ComboBox:

Why not extend an existing Tkinter widget? This way you get at least the geometry (pack, grid etc) methods thown in for free!

class ComboBox(Frame):
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)

You could extend Entry above is just an example...

Also worth pointing out are a couple of ComboBox's out there already
Pmw includes one as does Tix (IIRC)

Cheers,
Martin.


-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to