#! /usr/bin/python #James Parks #remoteMEL.py # #A python/Tkinter appllication to send arbitrary text to #a remote maya session from Tkinter import * import tkMessageBox #import FileDialog as tkFileDialog import socket import os import sys sys.path.append(os.getcwd()) import genericText_sender class jpRemoteMel_GUI(Tk): def __init__(self, master=None): Tk.__init__(self, master) self.version = "v0.2e" self.title(("Remote MEL " + self.version + " -- James Parks")) self.grid() self.createWidgets() def createWidgets(self): menubar = Menu(self) # create a pulldown menu, and add it to the menu bar filemenu = Menu(menubar, tearoff=0) filemenu.add_command(label="Open", command = self.openFile) filemenu.add_command(label="Save", command = self.saveFile) filemenu.add_command(label="Save As...", command = self.saveAsFile) filemenu.add_separator() filemenu.add_command(label="Send", command = self.send) filemenu.add_separator() filemenu.add_command(label="Exit", command=self.quit) menubar.add_cascade(label="File", menu=filemenu) # create more pulldown menus editmenu = Menu(menubar, tearoff=0) editmenu.add_command(label="Cut") editmenu.add_command(label="Copy") editmenu.add_command(label="Paste") menubar.add_cascade(label="Edit", menu=editmenu) helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="About", command = self.about) menubar.add_cascade(label="Help", menu=helpmenu) # display the menu self.config(menu = menubar) destFrame = Frame(self) destFrame.pack(side=TOP, anchor=NW) codeFrame = Frame(self) codeFrame.pack(side=TOP) buttonFrame = Frame(self) buttonFrame.pack(side=BOTTOM, anchor=SW) self.hostLabel = Label(destFrame, text="Host: ", justify=LEFT, anchor=W) self.hostLabel.pack(side=LEFT) self.host = Entry(destFrame) self.host.pack(side=LEFT) self.portLabel = Label(destFrame, text="Port: ", justify=LEFT, anchor=W) self.portLabel.pack(side=LEFT) self.port = Entry(destFrame) self.port.pack(side=LEFT) self.codeBox = Text(codeFrame) self.codeBox.pack(side=LEFT) self.send = Button(buttonFrame, text="Send", command=self.send) self.send.pack(side=LEFT) self.batchSend = Button(buttonFrame, text="Batch...") self.batchSend.pack(side=LEFT) self.quit = Button(buttonFrame, text="QUIT", fg="red", command=self.quit) self.quit.pack(side=LEFT) def openFile(self): print "Open File Method" pass def saveFile(self): print "Save File Method" pass def saveAsFile(self): print "Save As File Method" pass def about(self): print "About Method" pass def send(self): hostString = self.host.get() portString = self.port.get() codeString = self.codeBox.get("1.0",END) if hostString == "": tkMessageBox.showwarning("Host", "No Host Specified") elif portString == "": tkMessageBox.showwarning("Port", "No Port Specified") elif codeString == "": tkMessageBox.showwarning("Code", "No Code to Execute") else: print (hostString + " " + portString + " : " + codeString) genericText_sender.genericText_sender(codeString, hostString, portString) app = jpRemoteMel_GUI() app.mainloop()