"""plug_2initprog.py An example plugin for Visual APT. This example helps set up some things that are common to apt programs. Module names must be plug_*.py where * is any valid unix name Modules will be searched for in ~/.vapt/plugins To see what methods VaptPlugin offers: pydoc vapt.vapt_plugin.VaptPlugin """ __author__ = 'Dan Falck ' __date__ = '05/06/2007' import Tkinter as Tk import tkMessageBox as tkmb from vapt.vapt_plugin import VaptPlugin class Proginit(Tk.Toplevel): def __init__(self, master, plug, **kw): self.plug = plug Tk.Toplevel.__init__(self, master, **kw) self.transient(master) #self.resizable(0, 0) self.title("Prog Init") self.p_label=Tk.Label(self, text="part #").pack() self.p_num=Tk.Entry(self) self.p_num.pack() self.m_label=Tk.Label(self, text="post processor").pack() self.m_num=Tk.Entry(self) self.m_num.pack() Tk.Button(self, text="Write", command=self.on_button).pack() def on_button(self): plug = self.plug editor = plug.raise_apt() p=self.p_num.get() editor.insert(Tk.INSERT,'partno/ ') editor.insert(Tk.INSERT, p) editor.insert(Tk.INSERT, '\n') m=self.m_num.get() editor.insert(Tk.INSERT, 'machin/') editor.insert(Tk.INSERT, m) editor.insert(Tk.INSERT, '\n') editor.insert(Tk.INSERT, 'print/on\n') editor.insert(Tk.INSERT, 'clprnt\n') editor.insert(Tk.INSERT, '\n') editor.insert(Tk.INSERT, 'fini\n') editor.mark_set(Tk.INSERT, "5.0") self.destroy() # You must have a class derived from VaptPlugin. class CutterPlugin(VaptPlugin): def __init__(self, mainframe): # must call the base class VaptPlugin.__init__(self, mainframe) # This will be the string show in the vapt Plugin menu. self.menu_name = 'Prog Init' # anything else here def run(self): """This will be called when the menu is clicked. """ Proginit(self.mf, self) def unload(self): """This is called just before vapt shuts down. You dont have to implement this if you dont need it. VaptPlugin.unload() will be called, which does nothing. """ # anything else here pass