Iam in the process of creating a program for converting words in a file to numbers.

Am struck at the input file selection gui script.

i want to create a GUI to open a file from the open file dialog box and to read the words in the file word by word and process it.

Kindly help.

Please post what you have so far and some sample data. There is no point opening the file, etc. if you already know how to do that. Usually you would read the file one line at a time, strip the record of spaces and the newline, and then split the record into words. Give it a try and post back with any problems. Note that for testing you probably want to use a shorter version of the file so you can get to the code corrections quicker.

Iam currently using the code belew to convert the words typed in the dialog box.

But, i want to take multiple words in a file and save the output in a file.

For that, i need code for selecting the input file and read the words and convert them

#! /usr/bin/env python
from Tkinter import *
import tkMessageBox
import string
class GUIFramework(Frame):

def __init__(self,master=None):




def CreateWidgets(self):
self.lbText = Label(self, text="Enter the value")
self.lbText.grid(row=0, column=0)
self.enText = Entry(self)
self.enText.grid(row=0, column=1, columnspan=3)
self.btnDisplay = Button(self, text="Convert!", command=self.Display)
self.btnDisplay.grid(row=0, column=4)

def Display(self):
dd = dict(zip(string.ascii_lowercase, [str(i) for i in range(1,27)]))
tkMessageBox.showinfo("Converted Value","".join([dd[s] for s in self.enText.get()]))
f=open('C:\output.txt', 'a')
f.write("".join([dd[s] for s in self.enText.get()])+' ')

if __name__ == "__main__":
guiFrame = GUIFramework()

This article has been dead for over six months. Start a new discussion instead.