user interface - Existing Tkinter Code that Takes an Input String to Another String -


i posted this, however, purpose here different. believe there should code around similar this. hoping might have idea of examples (interfaces of functions act on strings). better, have block of code have available? i'm looking template base mine off of. in advance.

to give idea of mean, here's function have in mind:

 def psi_j(x, j):       rtn = []       n2 in range(0, len(x) * j - 2):         n = n2 / j         r = n2 - n * j         rtn.append(j * x[n] + r * (x[n + 1] - x[n]))         print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn       return rtn 

this code takes string x = [0,1,1,1,2] example (it must begin 0) , parameter j, 2, , outputs string (x = [0, 1, 2, 2, 2, 2, 2, 3] in example).

it in 2 steps: first decomposes number m multiple of j , remainder. runs decomposition through function on rtn.append line.

notice has cj - 1 terms c number of terms in input string , j parameter. normally, able calculate cj terms. issue function more happy put aside moment.

my key interest able make program usable has no knowledge of programming. in particular, need kind of user interface prompts user input string (ideally putting in numbers in form 011123334 example) , parameter.

edit:

the error on third line, , python highlights space right of (self, master) in orange way end of row.

if you're interested in making user interface of tkinter can use following code:

from tkinter import *  class app(frame):     def __init__(self, master):         frame.__init__(self, master)         self.grid()         self.create_widgets()      def create_widgets(self):         self.entrylabel = label(self, text="please enter list of numbers (no commas):")         self.entrylabel.grid(row=0, column=0, columnspan=2)          self.listentry = entry(self)         self.listentry.grid(row=0, column=2, sticky=e)          self.entrylabel = label(self, text="please enter index value:")         self.entrylabel.grid(row=1, column=0, columnspan=2, sticky=e)          self.indexentry = entry(self)         self.indexentry.grid(row=1, column=2)          self.runbttn = button(self, text="run function", command=self.psifunction)         self.runbttn.grid(row=2, column=0, sticky=w)          self.answerlabel = label(self, text="output list:")         self.answerlabel.grid(row=2, column=1, sticky=w)      def psifunction(self):         j = int(self.indexentry.get())         valuelist = list(self.listentry.get())         x = map(int, valuelist)         if x[0] != 0:             x.insert(0, 0)         rtn = []         n2 in range(0, len(x) * j - 2):             n = n2 / j             r = n2 - n * j             rtn.append(j * x[n] + r * (x[n + 1] - x[n]))         self.answer = label(self, text=rtn)         self.answer.grid(row=2, column=2, sticky=w)   if __name__ == "__main__":     root = tk()     app = app(root)     root.mainloop() 

if have questions let me know; works in python 2.7.

this program automatically adds 0 if user forgets , format input is, example, 01112.

you can use rtn later on well; list of results.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -