From 9ba926e16543036945741c5a0be77608ef7501a9 Mon Sep 17 00:00:00 2001 From: RichieStacker Date: Sat, 14 Dec 2013 15:27:32 +0000 Subject: [PATCH] First commit --- README | 23 ++++++ README.md | 23 ++++++ construct_insult.py | 55 ++++++++++++++ insult_constructor.py | 28 +++++++ insult_constructor_ui.py | 61 ++++++++++++++++ insults | 153 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 343 insertions(+) create mode 100644 README create mode 100644 README.md create mode 100644 construct_insult.py create mode 100644 insult_constructor.py create mode 100644 insult_constructor_ui.py create mode 100644 insults diff --git a/README b/README new file mode 100644 index 0000000..1ee43cb --- /dev/null +++ b/README @@ -0,0 +1,23 @@ +The Shakespearean Insult Constructor +==================================== +Constructs an insult based on three components, the final string preceded by "Thou" +Based on and uses content from the Shakespearean Insult Kit at: http://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html + +What it needs +============= +This game requires Python 2.7 on your system. Most Linux distributions include this out of the box, but if not, you can install it from your package manage if your distro has one. Windows and Mac OSX users will need to download it from python.org/download and install it on your system. Be sure to pick the right download for your operating system and processor architecture and remember, version 2.7, not 3. + +How to run +========== + +Extract the contents of this ZIP file somewhere you can easily find it, for example, your home folder (if using Linux) or your C:\ drive (if using Windows). Make sure to extract ALL files when you do so. It's so easy to get caught out by your ZIP program and wind up extracting only the selected file. Done that? Great. + +Open a command prompt (Windows) or terminal window (Linux/Mac OSX) and navigate to the correct folder using "dir" (Windows) or "cd" (Linux/Mac). Once there, type "python insult_constructor.py" for the CLI-based version or "python insult_constructor_ui.py" for the GUI version and it should run. Otherwise, I don't know what to say. + +How to use +========== +In the CLI version: Just run the program and it'll immediately construct an insult. You're then asked if you wish to quit. Type "y" to quit or "n" to get a new insult. + +In the GUI version: Click the button labelled "Construct thy insult". A new insult will be constructed and displayed, and another button, labelled "Copy to thy clipboard" will be enabled. This button does exactly what it says on the tin: copies the current insult to the clipboard. + +NOTE: If running in Linux, be sure to paste your insult BEFORE closing the program. When you close the program, the clipboard jettisons the copied insult for some reason. In Windows, though, the insult stays in the clipboard, even after closing the program. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1ee43cb --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +The Shakespearean Insult Constructor +==================================== +Constructs an insult based on three components, the final string preceded by "Thou" +Based on and uses content from the Shakespearean Insult Kit at: http://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html + +What it needs +============= +This game requires Python 2.7 on your system. Most Linux distributions include this out of the box, but if not, you can install it from your package manage if your distro has one. Windows and Mac OSX users will need to download it from python.org/download and install it on your system. Be sure to pick the right download for your operating system and processor architecture and remember, version 2.7, not 3. + +How to run +========== + +Extract the contents of this ZIP file somewhere you can easily find it, for example, your home folder (if using Linux) or your C:\ drive (if using Windows). Make sure to extract ALL files when you do so. It's so easy to get caught out by your ZIP program and wind up extracting only the selected file. Done that? Great. + +Open a command prompt (Windows) or terminal window (Linux/Mac OSX) and navigate to the correct folder using "dir" (Windows) or "cd" (Linux/Mac). Once there, type "python insult_constructor.py" for the CLI-based version or "python insult_constructor_ui.py" for the GUI version and it should run. Otherwise, I don't know what to say. + +How to use +========== +In the CLI version: Just run the program and it'll immediately construct an insult. You're then asked if you wish to quit. Type "y" to quit or "n" to get a new insult. + +In the GUI version: Click the button labelled "Construct thy insult". A new insult will be constructed and displayed, and another button, labelled "Copy to thy clipboard" will be enabled. This button does exactly what it says on the tin: copies the current insult to the clipboard. + +NOTE: If running in Linux, be sure to paste your insult BEFORE closing the program. When you close the program, the clipboard jettisons the copied insult for some reason. In Windows, though, the insult stays in the clipboard, even after closing the program. \ No newline at end of file diff --git a/construct_insult.py b/construct_insult.py new file mode 100644 index 0000000..68ece6f --- /dev/null +++ b/construct_insult.py @@ -0,0 +1,55 @@ +# Shakespearean Insult Constructor (construction module) +# Code Copyright (C) 2013 Jonathan Humphreys +# Using content from the Shakespearean Insult Kit at: http://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import random + +def construct_insult(): + insult_select = 0 # Will be assigned a random number between 0 and 49 and used to select from each collection of components. + read_insult = "" # Accepts each line from the insult list file and passes it to insult_list. + insult_list = [] # Stores one or more sub-lists, each one a collection of components from which to assemble an insult. + built_insult = "Thou " # The string that each component will be appended to to form a complete insult. Always begins with "Thou ". + + insults = open("insults", "r") # Opens the insult list file for reading. + + for line in insults: + read_insult = line.strip("\n") # Gets rid of the carriage return from each line read. + + # If the line read reads "[NEW]", creates a new sub_list within insult_list. + # Otherwise just adds the newly-read string to the newest existing sub-list. + if read_insult == "[NEW]": + insult_list.append([]) + else: + insult_list[-1].append(read_insult) + + insults.close() # Closes the file, to prevent the risk of the OS treating it as already open after the program has ended. + + for insult_column in range(len(insult_list)): + # Generates a random number with which to select each insult component. + insult_select = random.randint(0, len(insult_list[insult_column]) - 1) + #print insult_column, insult_select + + # Appends the selected insult component to built_insult. + built_insult = built_insult + insult_list[insult_column][insult_select] + + # If the current insult column is before the last one, append a space, else append an exclamation mark. + if insult_column < 2: + built_insult = built_insult + " " + else: + built_insult = built_insult + "!" + + return built_insult # Send the completed insult back to the variable that called this function! diff --git a/insult_constructor.py b/insult_constructor.py new file mode 100644 index 0000000..5c3b03d --- /dev/null +++ b/insult_constructor.py @@ -0,0 +1,28 @@ +# Shakespearean Insult Constructor (CLI version) +# Code Copyright (C) 2013 Jonathan Humphreys +# Using content from the Shakespearean Insult Kit at: http://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#!/usr/bin/env python + +import os +from construct_insult import construct_insult +exit_prompt = "n" + +while exit_prompt != "y": + os.system("cls" if os.name == "nt" else "clear") # Clears the screen in both Windows and Unix-likes. + print construct_insult() + exit_prompt = raw_input("Art thou done? (y/n)").lower() # Unless this is set to "y" when asked, the loop will repeat again. diff --git a/insult_constructor_ui.py b/insult_constructor_ui.py new file mode 100644 index 0000000..daf20a5 --- /dev/null +++ b/insult_constructor_ui.py @@ -0,0 +1,61 @@ +# Shakespearean Insult Constructor (UI version) +# Code Copyright (C) 2013 Jonathan Humphreys +# Using content from the Shakespearean Insult Kit at: http://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#!/usr/bin/env python + +import Tkinter +from construct_insult import construct_insult + +# Creates a new Tkinter window. +main = Tkinter.Tk() +main.geometry("500x160") +main.wm_title("Shakespearean Insult Kit") + +# Calls upon construct_insult to generate an insult. +def draw_insult(): + lblInsult["text"] = construct_insult() + btnClipboard["state"] = "normal" + +# Event-handler to copy the existing insult to the clipboard. +def send_to_clipboard(): + main.clipboard_clear() + main.clipboard_append(lblInsult["text"]) + +# This label will display the insult created by the program. +lblInsult = Tkinter.Label(main, bg = "#999999") +lblInsult.pack() +lblInsult.place(bordermode = "outside", x = 10, y = 10, width = 480, height = 25) + +# Button to click to generate an insult. +btnConstruct = Tkinter.Button(main, bg = "#AAAAAA", text = "Construct thy insult", command = draw_insult) +btnConstruct.pack() +btnConstruct.place(bordermode = "outside", x = 10, y = 40, width = 480, height = 25) + +# Button to click in order to copy to clipboard. When the program first runs, this button is disabled, +# what with nothing for it to copy yet. +btnClipboard = Tkinter.Button(main, bg = "#AAAAAA", text = "Copy to thy clipboard", command = send_to_clipboard, state = "disabled") +btnClipboard.pack() +btnClipboard.place(bordermode = "outside", x = 10, y = 70, width = 480, height = 25) + +# Label to give credit to the source of the insult components. +lblCredit = Tkinter.Label(main, text = "Based on the Shakespeare Insult Kit at:\nhttp://web.mit.edu/dryfoo/Funny-pages/shakespeare-insult-kit.html") +lblCredit.pack() +lblCredit.place(bordermode = "outside", x = 10, y = 100, width = 480, height = 50) + +# Commences the event-loop. +main.mainloop() diff --git a/insults b/insults new file mode 100644 index 0000000..308b979 --- /dev/null +++ b/insults @@ -0,0 +1,153 @@ +[NEW] +artless +bawdy +beslubbering +bootless +churlish +cockered +clouted +craven +currish +dankish +dissembling +droning +errant +fawning +fobbing +froward +frothy +gleeking +goatish +gorbellied +impertinent +infectious +jarring +loggerheaded +lumpish +mammering +mangled +mewling +paunchy +pribbling +puking +puny +qualling +rank +reeky +roguish +ruttish +saucy +spleeny +spongy +surly +tottering +unmuzzled +vain +venomed +villainous +warped +wayward +weedy +yeasty +[NEW] +base-court +bat-fowling +beef-witted +beetle-headed +boil-brained +clapper-clawed +clay-brained +common-kissing +crook-pated +dismal-dreaming +dizzy-eyed +doghearted +dread-bolted +earth-vexing +elf-skinned +fat-kidneyed +fen-sucked +flap-mouthed +fly-bitten +folly-fallen +fool-born +full-gorged +guts-griping +half-faced +hasty-witted +hedge-born +hell-hated +idle-headed +ill-breeding +ill-nurtured +knotty-pated +milk-livered +motley-minded +onion-eyed +plume-plucked +pottle-deep +pox-marked +reeling-ripe +rough-hewn +rude-growing +rump-fed +shard-borne +sheep-biting +spur-galled +swag-bellied +tardy-gaited +tickle-brained +toad-spotted +unchin-snouted +weather-bitten +[NEW] +apple-john +baggage +barnacle +bladder +boar-pig +bugbear +bum-bailey +canker-blossom +clack-dish +clotpole +coxcomb +codpiece +death-token +dewberry +flap-dragon +flax-wench +flirt-gill +foot-licker +fustilarian +giglet +gudgeon +haggard +harpy +hedge-pig +horn-beast +hugger-mugger +joithead +lewdster +lout +maggot-pie +malt-worm +mammet +measle +minnow +miscreant +moldwarp +mumble-news +nut-hook +pigeon-egg +pignut +puttock +pumpion +ratsbane +scut +skainsmate +strumpet +varlot +vassal +whey-face +wagtail