examples homework pytools

# example 5M.py by skole www.pi+ppo.org

filename = 'En_HomeWork.txt'

#filename = 'It_HomeWork.txt'

Myf = open('myfile.txt', 'w')

fp = open(filename)

lineInput=''

lineOutput=''

column=0

stringacheck=''

counterror=0

i=0

while True:

line = fp.readline()

for item in line:

i = i + 1

if (column < 3): # Numero colonna da visualizzare da 0 a 3=RISULTATO

    lineInput = lineInput + item

if (item == "|"): # identificatore colonna

    column = column + 1

if (item == "\r"): # rimuove il ritorno a capo

break

if (column == 3) and (item != "|") and (item != " "): # colonna per il controllo

    stringacheck = stringacheck + item

if (column == 3) and (item == " ") and line[i + 1] != ' ': # spazio e/o valore end

stringacheck = stringacheck + ' '       

lineOutput = lineOutput + item

stringa=raw_input(lineInput)

if (stringa +'  ' != stringacheck): # controlla le parole inserite...

counterror = counterror + 1     # i due spazi finali per end string...

stringacheck = 'ERROR N.%d' % counterror

else:

stringacheck = 'OK'

if (lineOutput > ' '): #nuovo controllo su righe vuote evita di scrivere counterror

    Myf.write(lineOutput + stringa + '\t' + stringacheck + '\n')

column=0

i=0

lineInput=''

lineOutput=''

stringacheck=''

if ("" == line):

print "end file"

break

Myf.close()   

print 'end program...'


you continue... OK.

Make your homework use python...

1...file homework output: ID strings: A, B, B check

2...file myfile input: = file output+Ktouch'Rfree'+check+error/OK+total error...

skole pi+ppo use P.A.L....

 

# example 5MViewer.py by skole www.pi+ppo.org

import Tkinter

from Tkinter import *

from ScrolledText import *

import tkFileDialog

import tkMessageBox

FILEOPENOPTIONS = dict(defaultextension='.txt',

                       filetypes=[('myfile file','*.txt'), ('All files','*.*')])

                   

Viewer = Tkinter.Tk(className="Viewer 5M.2017 myfile")

textPad = ScrolledText(Viewer, width=160, height=40)


def open_command():

textPad.config(state=NORMAL)

        file = tkFileDialog.askopenfile(parent=Viewer,mode='rb',title='file...', **FILEOPENOPTIONS)

        if file != None:

            myfile = file.read()

            textPad.insert('1.0',myfile)

            textPad.config(state=DISABLED)

            file.close()

         

def exit_command():

    if tkMessageBox.askokcancel("you exit"):

        Viewer.destroy()

 

def about_command():

    label = tkMessageBox.showinfo("About", "Viewer 5M.2017 \nby skole www.pi+ppo.org")

         

def dummy():

    print "I am a Dummy Command, I will be removed in the next step"

menu = Menu(Viewer)

Viewer.config(menu=menu)

filemenu = Menu(menu)

menu.add_cascade(label="File", menu=filemenu)

filemenu.add_command(label="Open and insert myfile...", command=open_command)

filemenu.add_separator()

filemenu.add_command(label="Exit", command=exit_command)

helpmenu = Menu(menu)

menu.add_cascade(label="Help", menu=helpmenu)

helpmenu.add_command(label="About...", command=about_command)


textPad.pack()

Viewer.mainloop()


YOUR progress MEMORY... my memory needs of many writing sequences and yours?

You rename your myfile.txt to myfileYMDay001.2..3.txt ecc.. use

5MViewer...to open insert all files...lines for control your error...


 

# example 5MEditHomeWork.py by skole www.pi+ppo.org

import Tkinter

from Tkinter import *

from ScrolledText import *

import tkFileDialog

import tkMessageBox


FILEOPENOPTIONS = dict(defaultextension='.txt',

                       filetypes=[('homework file','*.txt'), ('All files','*.*')])

                       

Viewer = Tkinter.Tk(className="Edit HomeWork 5M.2017")

textPad = ScrolledText(Viewer, width=160, height=40)


def open_command():

        file = tkFileDialog.askopenfile(parent=Viewer,mode='rb',title='file...', **FILEOPENOPTIONS)

        if file != None:

            myfile = file.read()

            textPad.insert('1.0',myfile)

            file.close()

     

def saveas_command():

    filename = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt")

    if filename is None: # asksaveasfile return `None`

        return

    text2save = str(textPad.get(1.0, END)) # starts from `1.0`, not `0.0`

    filename.write(text2save)

    filename.close()

    print filename

         

def exit_command():

    if tkMessageBox.askokcancel("you exit"):

        Viewer.destroy()

 

def about_command():

    label = tkMessageBox.showinfo("About", "HomeWork 5M.2017 \nby skole www.pi+ppo.org")

         

def dummy():

    print "I am a Dummy Command, I will be removed in the next step"

menu = Menu(Viewer)

Viewer.config(menu=menu)

filemenu = Menu(menu)

menu.add_cascade(label="File", menu=filemenu)

filemenu.add_command(label="Open and edit homework...", command=open_command)

filemenu.add_command(label="Save as homework...", command=saveas_command)

filemenu.add_separator()

filemenu.add_command(label="Exit", command=exit_command)

helpmenu = Menu(menu)

menu.add_cascade(label="Help", menu=helpmenu)

helpmenu.add_command(label="About...", command=about_command)


textPad.pack()

Viewer.mainloop()


with this example... to open the homework.txt file select items crtC=copy and crtV=paste for

append new items to increase change value saveas new name test your new items...5M.py

# example 5MRunYourCode.py by skole www.pi+ppo.org

# sorry this example it'is more the 50 items...

import Tkinter

from Tkinter import *

from ScrolledText import *

import tkFileDialog

import tkMessageBox

import os

#os.system('ls') esecute bash command for list...


FILEOPENOPTIONS = dict(defaultextension='.py',

                       filetypes=[('homework make python code...','*.py'), ('All files','*.*')])

                       

Viewer = Tkinter.Tk(className="Run myfile.py python code 5M.2017")

textPad = ScrolledText(Viewer, width=160, height=40)


def open_command():

        file = tkFileDialog.askopenfile(parent=Viewer,mode='rb',title='file...', **FILEOPENOPTIONS)

        if file != None:

            myfilepy = file.read()

            textPad.insert('1.0',myfilepy)

            file.close()

     

def saveas_command():

    filename = tkFileDialog.asksaveasfile(mode='w', defaultextension=".py")

    if filename is None: # asksaveasfile return `None` if dialog closed with "cancel".

        return

    text2save = str(textPad.get(1.0, END)) # starts from `1.0`, not `0.0`

    filename.write(text2save)

    filename.close()

    print filename


def runpy_command():

myfilename = tkFileDialog.askopenfilename(initialdir="lists/custom/", filetypes=(("code py","*.py"), ("All py files", "*.py")))

if tkMessageBox.askokcancel("run myfile.py"):

os.system('python %s' % myfilename) # run myfile.py


def exit_command():

    if tkMessageBox.askokcancel("you exit"):

        Viewer.destroy()

 

def about_command():

    label = tkMessageBox.showinfo("About", "Run myfile.py python code 5M.2017 \nby skole www.pi+ppo.org")

         

def dummy():

    print "I am a Dummy Command, I will be removed in the next step"

   

menu = Menu(Viewer)

Viewer.config(menu=menu)

filemenu = Menu(menu)

menu.add_cascade(label="File", menu=filemenu)

filemenu.add_command(label="Open and edit homework.py...", command=open_command)

filemenu.add_command(label="Save as homework.py...", command=saveas_command)

filemenu.add_command(label="Run myfile.py python code...", command=runpy_command)

filemenu.add_separator()

filemenu.add_command(label="Exit", command=exit_command)

helpmenu = Menu(menu)

menu.add_cascade(label="Help", menu=helpmenu)

helpmenu.add_command(label="About...", command=about_command)


textPad.pack()

Viewer.mainloop()


Si... hai ragione questo esempio e più grande di 50 linee ma ti permette di aprire i tuoi myfile.py

modificarli e salvarli tramite saveas in un altro myfile.py evitando di dannegiare il myfile.py

aperto, puoi eseguire il tuo nuovo clone...myfile.py e terminata la tua verifica puoi eseguire

una altro myfile.py sorry... traduci tu questo in Inglese oggi... OK

Obbietive of 5Memory is

to create python code using python exclusively from small

reusable programs adding new features to new clones ...

This program has been completely cloned

from the previous version, the new functions has been added,

that will be handled later by mylibtk library attached

to this program, the new clones of this program will be able

to view, the functions verify through the previous clones

and create new ones.

The purpose of reuse and more possible code and

create our mental scheme... to solve tasks

not only at home using the Python language ...

Thanks python ...

5Memory ... "python is the index of your book ... mental"


Obbiettivo di 5Memory è

quello di creare codice python utilizzando esclusivamente

python partendo da piccoli programmi aggiungendo nuove

funzioni riutilizzabili da nuovi cloni...

Questo programma è stato clonato completamente

dalla versione precedente, sono state inserite nuove

funzioni che saranno gestite in seguito dalla libreria

mylibtk collegata a questo programma, i nuovi cloni di

questo programma potranno visionare, verificare tramite

i cloni precedenti le funzioni e crearne di nuove.

Lo scopo e di riutilizzare più codice possibile e

creare il nostro schema mentale... per risolvere compiti

non solo a casa utilizzando il linguaggio python...

Grazie python...

5Memory..."python è lindice del tuo libro...mentale"


# example 5MRunMyfileCodeClone002.py by skole www.pi+ppo.org

import Tkinter

from Tkinter import *

from ScrolledText import *

import tkFileDialog

import tkMessageBox

import os

os.system('ls *.py')


FILEOPENOPTIONS = dict(defaultextension='.py',

                       filetypes=[('homework make python code...','*.py'), ('All files','*.*')])

                       

Viewer = Tkinter.Tk(className="Run myfile.py python code clone002 5M.2017")

textPad = ScrolledText(Viewer, width=100, height=100)


fontname = "Monospace"

size = "16"

font = fontname + " " + size


textPad.config(

    borderwidth=0,

    font=font,

    foreground="green",

    background="black",

    insertbackground="white", # cursor

    selectforeground="blue", # selection

    selectbackground="#008000",

    wrap="word",

    width=64,

    undo=True, #Config like Xterminal...

    )

   

def open_command():

        file = tkFileDialog.askopenfile(parent=Viewer,mode='rb',title='file...', **FILEOPENOPTIONS)

        if file != None:

            myfilepy = file.read()

            textPad.insert('1.0',myfilepy)

            file.close()

     

def saveas_command():

    filename = tkFileDialog.asksaveasfile(mode='w', defaultextension=".py")

    if filename is None: # asksaveasfile return `None` if dialog closed with "cancel".

        return

    text2save = str(textPad.get(1.0, END)) # starts from `1.0`, not `0.0`

    filename.write(text2save)

    filename.close()

    print filename


def runpy_command():

myfilename = tkFileDialog.askopenfilename(initialdir="lists/custom/", filetypes=(("code py","*.py"), ("All py files", "*.py")))

if tkMessageBox.askokcancel("run myfile.py"):

os.system('python %s' % myfilename) # run myfile.py


def clear_command(): # clear all items textPad to create a new code

textPad.delete('1.0', END+'-1c')


def exit_command():

    if tkMessageBox.askokcancel("you exit"):

        Viewer.destroy()


def ossys_command():

    if tkMessageBox.askokcancel("run shell"):

        print ('%s' % OSsys.get('0.0',END))

        os.system('%s' % OSsys.get('0.0',END))


def about_command():

    label = tkMessageBox.showinfo("About", "Run myfile.py python code 5M.2017 \nby skole www.pi+ppo.org")

         

def dummy():

    print "I am a Dummy Command, I will be removed in the next step"

   

menu = Menu(Viewer)

Viewer.config(menu=menu)

filemenu = Menu(menu)

menu.add_cascade(label="File", menu=filemenu)

filemenu.add_command(label="Open and edit homework.py...", command=open_command)

filemenu.add_command(label="Save as homework.py...", command=saveas_command)

filemenu.add_command(label="Run myfile.py python code...", command=runpy_command)

filemenu.add_command(label="Clear python code...", command=clear_command)

filemenu.add_command(label="Run shell system...", command=ossys_command)

filemenu.add_separator()

filemenu.add_command(label="Exit", command=exit_command)

helpmenu = Menu(menu)

menu.add_cascade(label="Help", menu=helpmenu)

helpmenu.add_command(label="About...", command=about_command)


OSsys = Text(Viewer, height=1, width=100)

OSsys.pack()

OSsys.insert(END, "insert shell command OS...")

textPad.pack(side="left", fill="both", expand=True)# expand textPad all windows

Viewer.mainloop()


CONTACT US

 

  Tel: .....

FOLLOW US

PROFILE

Profile ...

© Copyright 2016-2019 All Rights Reserved.