# -*- coding: utf-8 -*- PDIR = 'D:/free_soft/python25' import Tkinter as Tk import Dialog as Dlog import ScrolledText class GuiMixin: def question(self,title,text,bitmap='question',string=('Yes','No')): return Dlog.Dialog(self,title=title,bitmap=bitmap,default=1,strings=strings) def infobox(self,title,text,bitmap='',string=('OK',)): Dlog.Dialog(self,title=title,bitmap=bitmap,default=0,strings=strings) def quit(self): ans = self.question('Verift quit','Are you sure you want to quit?') if ans == 0: Tk.Frame.quit(self) def notdone(self): self.infobox('Not implemented','Option not availanle','error') def help(self): self.infobox('RTEM','See figure 1...','info') def errorbox(self, text): self.infobox('Error!','text','error') def clone(self): new = Tk.Toplevel() myclass = self.__class__ myclass(new) def spawn(self,domo,fork=0): import os try: pbase = os.environ['PYTHONBASE'] except: pbase = PDIR python = pbase + '/python' if not fork: os.system('%s %s/Demo/tkinter/%s' % (python,pbase,demo)) else: pid = os.fork() if pid == 0: os.execv(python, (python,pbase+'Deo/tkinter/'+demo)) def browser(self, file): new = Tk.Toplevel() text = ScrolledText.ScrolledText(new,height=30,width=90) text.Pack() #? new.title("Poor-man's Text Editor") new.iconname("browser") text.insert('0.0',open('file','r').read()) if __name__ == '__main__': class TestMixin(GuiMixin, Tk.Frame): def __init__(self,parent=None): Tk.Frame.__init__(self, parent) self.pack(); Tk.Button(self, text='quit',command=self.quit).pack(fill=Tk.X) Tk.Button(self, text='help',command=self.help).pack(fill=Tk.X) Tk.Button(self,text='clone',command=self.clone).pack(fill=Tk.X) TestMixin().mainloop()