Skip to content

Instantly share code, notes, and snippets.

@ToxicFrog
Created June 26, 2012 02:10
Show Gist options
  • Save ToxicFrog/2992754 to your computer and use it in GitHub Desktop.
Save ToxicFrog/2992754 to your computer and use it in GitHub Desktop.
rdesktop-launcher
#!/usr/bin/python
from __future__ import print_function
TITLE = "RDesktop Frontend"
RDESKTOP_COMMAND = "rdesktop"
RDESKTOP_OPTIONS = [ "-d", "MY_DOMAIN", "-g", "1024x768", "-z" ]
LEGAL = """
*** start of legal notice ***
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*** end of legal notice ***
"""
from Tkinter import *
import os
class App:
def button_cancel(self):
sys.exit(0)
def button_accept(self):
self.legal.grid_forget()
self.ok.configure(text = "Connect", command = self.button_connect)
Label(self.root, text = "Username").grid(row=0)
self.username = Entry(self.root, width = 32)
self.username.grid(row=0, column=1, columnspan=3)
Label(self.root, text = "Password").grid(row=1)
self.password = Entry(self.root, width = 32)
self.password.grid(row=1, column=1, columnspan=3)
Label(self.root, text = "Hostname").grid(row=2)
self.hostname = Entry(self.root, width = 32)
self.hostname.grid(row=2, column=1, columnspan=3)
def button_connect(self):
if (len(self.username.get()) == 0 or len(self.password.get()) == 0 or len(self.hostname.get()) == 0):
return
args = ["-u", self.username.get(), "-p", self.password.get(), self.hostname.get()]
print("Launching:", RDESKTOP_COMMAND, *(RDESKTOP_OPTIONS + args))
os.execlp(RDESKTOP_COMMAND, *([RDESKTOP_COMMAND] + RDESKTOP_OPTIONS + args))
def __init__(self):
self.root = Tk()
self.root.title(TITLE)
self.root.columnconfigure(1, weight = 1)
self.legal = Message(self.root, text = LEGAL)
self.legal.grid(columnspan = 4)
self.cancel = Button(self.root, text = "Decline", command = self.button_cancel)
self.cancel.grid(row=3, column=2)
self.ok = Button(self.root, text = "Accept", command = self.button_accept)
self.ok.grid(row=3, column=3)
self.root.mainloop()
App()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment