from Tkinter import *
from string import atoi

class RHPhoto(Photo):

    def transparentColor(self, color):
	return self.tk.call('set', 'TRANSPARENT_GIF_COLOR', color)

    def read(self, file):
	return self.tk.call(self._w, 'read', file)

class RHListbox(Listbox):
    def index(self, Index):
	return self.tk.call(self._w, 'index', Index)

class RHEntry(Entry):
    def doBindings(self):
	# I don't know why, but this makes backspace work right
	self.bind_class('Button', '<Delete>', self.backspace)
	self.bind('<Delete>', self.backspace)

    def backspace(self, event):
	where = self.index('insert')
	self.delete("%d" % (where - 1))

    def __init__(self, Master, Config):
	Entry.__init__(self, Master, Config)
	self.doBindings()
	self.pack()

class RHFrame(Frame):

    def quit(self):
	if (self._Master == None):
	    self.quit
	else:
	    self._Master.destroy()
    
    def __init__(self, Master = None):
	Frame.__init__(self, Master)
	self._Master = Master

class Popup(Menu):

    def postev(self, e):
	self.post(e.x_root, e.y_root)
	self.focus()
	self.grab_set_global()

    def __init__(self, Master = None):
	Menu.__init__(self, Master)
	self['tearoff'] = '0'
