This may give you some ideas:
[code]>>> 'abcdefg'.count('a')

import string
s = 'I have to write a program that will decode a Ceasar cypher with any possible rotation length'
dd = dict(zip(string.ascii_lowercase, [s.count(c) for c in string.ascii_lowercase]))

A Tkinter Entry widget can be configured to "show" a character such as "".

I suggest using a dictionary. Using name "seq" instead for "list" avoids masking built-in function [I]list()[/I].[code]>>> seq = ['v', 3.0,1, 'etc']

dd = {}
for item in seq:
... v = dd.get(type(item), 0)
... dd[type(item)] = v+1
[dd[obj] for obj in (int, float, str)]
[1, 1, 2]

We use these conversions to calculate the vertical slope angle and horiz slope angle of a vector in R3. Using these slopes as defaults, we recalculate new points in R3 using the slopes entered into a dialog box. So, we are starting with Point objects, converting to a SphericalPoint object, and back to Point objects. We should not encounter the problem you are describing. Am I wrong?

I know this thread was marked "solved", but I think the following is a somewhat simpler solution:
[code]f.write(",".join(["%s,%s" % (item.real, item.imag) for item in cpl1]))[/code]

Using minidom:
from xml.dom import minidom

doc = '''<?xml version="1.0" ?>

Paris Helsinki Bogota ''' docXML = minidom.parseString(doc) for elem in docXML.getElementsByTagName("city"): elem.removeAttribute("capital") print docXML.toprettyxml(indent=" ", newl="")[/code]

Does this help?[code]>>> import string

dd = dict(zip(string.ascii_lowercase, [str(i) for i in range(1,27)]))
"".join([dd[s] for s in "abcdejz"])

Excellent snippet vegaseat. The expanded event handler solves a common problem.

Here's another working example using the default argument trick:[code=Python]from Tkinter import *
from itertools import cycle

class SpinLabel(Frame):
def init(self, master=None):
Frame.init(self, master)
self.pack(fill=BOTH, expand=1)
self.master.title("Spin Characters")
self.textList = ["/", "--", "\", "--", "|"]
buttonFrame = Frame(self)
self.btnList = []
for i, name in enumerate(["Start", "Stop", "Exit"]):
btn = Button(buttonFrame, text=name, padx=5, pady=5,
bd=4, bg='#ff0', fg="#00f",
activebackground = "#00f",
activeforeground = "#ff0",
font=("Arial", 12, "bold"),
btn.pack(side="left", fill=BOTH, expand=1)

        def handler(event, i=i):
            return self.manage_spin(i)
        btn.bind("<ButtonRelease-1>", handler)
    buttonFrame.pack(fill=BOTH, expand=1)

    self.spin = Label(self, font=("Courier New", 24, 'bold'),fg='#000')
    self.spin.pack(side="top", fill=BOTH, expand=1)
    self.spinChrs = cycle(self.textList)

def manage_spin(self, idx):
    if idx == 0:
        self.spinning = True
    elif idx == 1:
        self.spinning = False
    elif idx == 2:

def loopchrs(self):
    if self.spinning:
        self.spin.after(100, self.loopchrs)

if name == "main":
app = SpinLabel()

One more example:[code]import Tkinter
import random
"""Start with a grid of buttons with blank labels. When clicked, change the
text to a random number between 1 and 100."""

textFont3 = ("Arial", 12, "bold")

class App(Tkinter.Tk):
def init(self, cols, rows):
self.title("Grid of Buttons")
self.cols = cols
self.rows = rows

    self.mainFrame = Tkinter.Frame(self)
    self.mainFrame.config(padx='3.0m', pady='3.0m')
    # initialize button array
    self.buttonList = [[None for j in range(cols)] for i in range(rows)]

def create_buttons(self):
    for i in range(self.cols):
        for j in range(self.rows):
            btn = Tkinter.Button(self.mainFrame,text="",
                             activebackground = "#000000fff",
                             activeforeground = "#ffffff000",
                             state='normal', width=6)

            btn.grid(row=j, column=i)
            def handler(event, ...

[QUOTE=smithy40000;1163710]Ok, i am putting alot of effort into this i just dont have a clue what you mean by change one of them, and i dont even have a top level menu all i have is buttons and labels, i just used the word top because thats what the examples had.[/QUOTE]
def startMenu():
top = Tk()
[COLOR="Red"][B]top_canvas[/B][/COLOR] = Canvas(width="800", height="800")[/code]"top" is the top level window, is it not? I renamed the canvas "top_canvas". You had the canvas named "top" also which prevented you from adding a menubar to the top level window.

[I][B]str[/B][/I] method [I]strip()[/I] will remove leading and trailing whitespace characters. If a string only has whitespace characters, [I][B]strip()[/B][/I] will remove them all and it will evaluate False. Example:[code]>>> not 'abcdefg12345 '.strip()

not ' '.strip()

Following is an example where I already have defined a list of text strings (self.btnList) to be displayed on buttons. When a button is selected (actually, the sequence is ButtonRelease), the button text is assigned to instance attribute "value" and the app is destroyed. In your case, you want to "set" the value of the string variable (Tkinter.StringVar) that was assigned to an entry widget [I]textvariable[/I].[code] def singleChoice(self, parent):

Create button frame and buttons
    self.buttonFrame = Tkinter.LabelFrame(parent, text="Available options", labelanchor="n")
    self.buttonFrame.config(relief="ridge", bd=3)
    self.value = None
    self.buttonList = []
    for i, t in enumerate(self.btnList):
        btn = Tkinter.Button(self.buttonFrame,
                             activebackground = "#000000fff",
                             activeforeground = "#ffffff000",
        self.buttonList.append((btn, t))
        if not i%self.columns:
            j += 1
        btn.grid(row=j, column=i%self.columns)
        def handler(event, i=i):
            return self.__buttonHandler(event, i)
        btn.bind(sequence="<ButtonRelease-1>", func=handler)

def __buttonHandler(self, event, btnNumber):
    setattr(self, 'value', self.buttonList[btnNumber][1])

[QUOTE=smithy40000;1161172]I tried you code but i am now getting

[COLOR="Red"]'top_canvas' is not defined.[/COLOR][/QUOTE]Look back through your code. You assigned the name "top" to your canvas. Your top level window is also named "top". To get it to work, I changed the name of the canvas to "top_canvas". Gees, show some effort.

You are assigning the name [I]top[/I] to the top level window and the Canvas. Change the name of one of them. I messed with part of your code until it worked.[code] menuframe = Frame(top, relief=GROOVE, borderwidth=2)
mb = Menubutton(top) = Menu(mb)
mb['menu'] ="text")
top_canvas.create_window(300,300, window=menuframe, anchor=SE)[/code]

You cannot place a menubar inside a canvas. A menubar goes on the top level window by design. You can place Tkinter widgets on a canvas by using a canvas window object.

[QUOTE=evstevemd;1156467]But not everyone uses/have ever use TKinter. One of them is myself.
Unless I see import TkInter, pack(), I will barely understand ;)[/QUOTE] And I'm the same way with any GUI toolkit other than Tkinter, unless I see the import of course.

He is using Tkinter. I recognized the methods and keywords.

[code] self.mb["menu"] ="Exit", command=self.quit)[/code]quit() stops the mainloop and destroy() destroys the parent window and it's descendants.

Create a Tkinter.Frame to hold the checker board and another frame to hold the buttons. Pack the frames "top". If you want the buttons along the bottom, pack "left". Add internal padding to each frame to get the desired space.

To eliminate duplication, initialize a list and iterate on columns and rows.[code] size = 50
cols = 8
rows = 8
squareList = []
for i in range(cols):
for j in range(rows):
if j%2: colors = ["black", "white"]
else: colors = ["white", "black"]
squareList.append(top.create_rectangle(isize, jsize,
isize+size, jsize+size,

I used this answer on another forum.
Try the following. It may not work on child windows spawned by the process.
[code]import subprocess

info = subprocess.STARTUPINFO()
info.dwFlags = 1
info.wShowWindow = 0
subprocess.Popen("notepad.exe", startupinfo=info)[/code][/quote]

[QUOTE=cnuzzo;1139768]So with the MakeFrame class in the first example, what do I do if I have frames with different widget configurations? Do I make several classes and then add each instance of those classes to my dictionary before calling any frames?[/QUOTE] You don't have to do it that way. Instead of a loop, you can create the frames linearly and add them to the frame dictionary upon creation.

I made some changes to your code. It's best to iterate on the file object. I skipped the first line in the file.[code]fileObj = open('input1.txt')
dd = {}
for line in fileObj:
codes = line.split()
x = int(codes[2])
if codes[1] not in dd or dd[codes[1]] > x:
dd[codes[1]] = x

keys = dd.keys()
for key in keys:
print "Minimum value for key '%s' = %s" % (key, dd[key])


f = open('output1.txt', 'w')
f.write('\n'.join(["Minimum value for key '%s' = %s" % (key, dd[key]) for key in keys]))
f.close()[/code]You mixed up some of what I posted with what IsharaComix posted.

The following prints the results twice:[code]s = '''ID1 ID2 Dist
1 a 50
2 b 20
3 c 10
2 c 100
4 c 80
4 a 70
1 a 90
2 a 34
3 b 5
2 b 6
1 a 12
1 c 12
4 a 14'''

datalist = s.split('\n')

headers = datalist.pop(0)
dd = {}
for line in datalist:
linelist = line.split()
dd.setdefault(linelist[1], []).append(int(linelist[2]))

keys = dd.keys()
for key in keys:
print "Minimum value for key '%s' = %s" % (key, min(dd[key]))

print '\n'.join(["Minimum value for key '%s' = %s" % (key, min(dd[key])) for key in keys])[/code]Post the code you are trying to use if you are receiving an error or unexpected results.

Catch the EOFError with a try/except block.[code]dict = {}
print "Frequency list:"
while True:
poem = raw_input()
except EOFError, e:
print "Reached the end of the file"
if poem == 'END':
for letter in poem:
if letter.isalpha():
if letter in dict:
dict[letter] = dict[letter] + 1
dict[letter] = 1[/code]Why not read the file directly as in:[code]for letter in open(file_name).read():[/code]

You don't need to initialize a StringVar() using a Tkinter.Text widget. Here's an example using "ping":[code]import Tkinter
import os

ip = ''

def get_info(arg):
print tfield.get("1.0", "current lineend")

root = Tkinter.Tk()
tfield = Tkinter.Text(root)
f = os.popen('ping %s' % (ip))
for line in f:
line = line.strip()
if line:
tfield.insert("end", line+"\n")

tfield.get("current linestart", "current lineend")

tfield.bind("", get_info)

f.close()[/code]In the example, get_info() retrieves all the text in the Text window.

Using the code I posted:[code]f = open(file_name, 'w')
f.write('\n'.join(["Minimum value for key '%s' = %s" % (key, min(dd[key])) for key in keys]))

To simplify the loop on [I]fileObj[/I]:[code]for line in fileObj:[/code]The for loop will terminate when a StopIteration is encountered which is typical for iterable objects.

[QUOTE=Stubaan;1137863]The data is quite large, though for now I've broken it up into smaller pieces just to work with. Do you know what the maximum number of rows one might be able to work with in this way is?

THANK YOU! About to give it a try.[/QUOTE] There is no limit that I am aware of except system memory.

Initialize your widget attribute [I]textvariable[/I] with [I]StringVar()[/I]. Use [I]w.set()[/I] to set the value and [I]w.get()[/I] to get the value.

I assume variable [I]char[/I] is a series of words. Iterate on [I]chars[/I] as in:[code]for letter in char:
if letter.isalpha():
if letter in dict:
dict[letter] = dict[letter] + 1
dict[letter] = 1[/code]

BTW, please use code tags next time.

If the data isn't too large, consider storing it in a dictionary. It could work like this:[code]s = '''ID1 ID2 Dist
1 a 50
2 b 20
3 c 10
2 c 100
4 c 80
4 a 70
1 a 90
2 a 34
3 b 5
2 b 6
1 a 12
1 c 12
4 a 14'''

datalist = s.split('\n')

fileObj = open(file_name)
if reading the file, use fileObj.readline()

headers = datalist.pop(0)

dd = {}

if reading the file, iterate on fileObj instead of datalist

for line in datalist:
linelist = line.split()
dd.setdefault(linelist[1], []).append(int(linelist[2]))

keys = dd.keys()
for key in keys:
print "Minimum value for key '%s' = %s" % (key, min(dd[key]))[/code]
The output:[code]>>> Minimum value for key 'a' = 12
Minimum value for key 'b' = 5
Minimum value for key 'c' = 10