sneekula 969 Nearly a Posting Maven

So you want to test drive some wxPython widgets without all that OOP stuff, here are some examples how to do this:

# test a wxPython combobox selection

import wx

def combo_select(event):
    color = combo.GetValue()
    frame.SetTitle(color)


app = wx.App(0)
frame = wx.Frame(None, -1, "wx.ComboBox", size=(220, 40))

# set up the choices for the listbox part of the combobox
choice_list = ['red', 'green', 'blue', 'yellow','white', 'magenta']
# create a combobox widget
combo = wx.ComboBox( frame, -1, choices=choice_list)
# set initial value
combo.SetValue('red')
# click on a dropdown choice to select it
combo.Bind(wx.EVT_COMBOBOX, combo_select)

frame.Center()
frame.Show()
app.MainLoop()

One more for the Gipper:

# test wxPython checkbox selections

import wx

def on_action(event):
    s = ""
    if cb1.IsChecked():
        s += "cb1 (red) is checked  "
    if cb2.IsChecked():
        s += "cb2 (blue) is checked  "
    if not cb1.IsChecked() and not cb2.IsChecked():
        s = "none is checked"
    frame.SetTitle(s)


app = wx.App(0)
frame = wx.Frame(None, -1, "wx.CheckBox", size=(450, 79))

cb1 = wx.CheckBox(frame, -1, 'red', pos=(10, 10))
cb2 = wx.CheckBox(frame, -1, 'blue', pos=(10, 40))
# set checkbox cb1 to checked
cb1.SetValue(True)
# bind checkbox mouse click to an action
cb1.Bind(wx.EVT_CHECKBOX, on_action)
cb2.Bind(wx.EVT_CHECKBOX, on_action)
# initial call
on_action(None)

frame.Center()
frame.Show()
app.MainLoop()
sneekula 969 Nearly a Posting Maven

Do us all a favor and don't use tabs for indentations!

sneekula 969 Nearly a Posting Maven

Should you decide to have fun with Python, be aware that the language has been modernized starting with version 3. I would recommend to start with the present version Python 3.1.1

Some examples of the older Python2 code will give you problems, but a number of good tutorials have been rewritten for version 3.

Dive Into Python is Mark Pilgrim's free online book, novice to pro, updated constantly, and rewritten for Python3 (check appendix A for 2to3 diffs). Get it at:

http://diveintopython3.org/


Another online book rewritten vor Python3 is at:
http://www.swaroopch.com/notes/Python_en:Table_of_Contents

Python has a commandline based interpreter called the the interactive shell, good for short one-line explorations. The books use it a lot, but the code looks goofy with lots of '>>>' and '...', so don't get too confused! Real Python code looks a lot more readable when written in an editor, saved as a .py file and run.

Right now Python3 gives you only two GUI toolkit choices, one is Tkinter (TCL based) and the other is PyQT (C++ based). PyGame (SDL/C++ based) is another GUI toolkit mostly used or games. It just came out for Python31. The popular wxPython (C++ based) has not been rewritten yet to work with Python3.

Here is a collection of coding examples that compare the GUI toolkits:
http://www.daniweb.com/forums/post866067.html#post866067

sneekula 969 Nearly a Posting Maven

Oh, well I can't find it in 2.6 or newer, maybe as sravan said that its outdated python org decided not to include it anymore

The binary windows installer of Pyhon26 or Python31 both have tkinter. In fact in Python31 Tkinter has been spruced up with the module ttk.

Vegaseat left this example somewhere on this forum:

'''
Python31 includes the Tkinter Tile extension module ttk.

Ttk comes with 17 widgets, 11 of which already exist in Tkinter:
Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton, 
PanedWindow, Radiobutton, Scale and Scrollbar 

The 6 new widget classes are:
Combobox, Notebook, Progressbar, Separator, Sizegrip and Treeview

You have to do some detective work on file
C:/Python31/Lib/tkinter/test/test_ttk/test_widgets.py
to figure out how these widgets work
'''

# ttk_notebook1.py
# exploring the Tkinter expansion module ttk notebook
# tested with Python 3.1 and Tkinter 8.5   by  vegaseat

import tkinter as tk
import tkinter.ttk as ttk

root = tk.Tk()
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (300, 200, 100, 50))
root.title('test the ttk.Notebook')

nb = ttk.Notebook(root)
nb.pack(fill='both', expand='yes')

# create a child wdget for each page
f1 = tk.Frame(bg='red')
f2 = tk.Frame(bg='blue')
f3 = tk.Frame(bg='green')

# create the pages
nb.add(f1, text='page1')
nb.add(f2, text='page2')
nb.add(f3, text='page3')

# put a button widget on child f1
btn1 = tk.Button(f1, text='button1')
btn1.pack(side='left', anchor='nw', padx=3, pady=5)

root.mainloop()

Tkinter is small but powerful. The included Python IDE called 'IDLE' is based on Tkinter, as is the module turtle.

sneekula 969 Nearly a Posting Maven

The Python module re is your friend:

# finding a search word in a text file using regex module re

import re

search = 'like'
# also matches 'like!', but not 'likely'
pattern = r"\b%s\b" % search
#print(pattern)  # for testing only --> \blike\b
rc = re.compile(pattern, re.IGNORECASE)

test_text = """\
the word like has a very flexible range of uses
With LIKE you can use two likely wildcard characters in the pattern
Official site for People Like Us and Vicki Bennett
Celebs and Famous People who looks like other, um, things and stuff
There is most likely a sentence without the search word
This is what the test file looks like!
"""

fname = "SearchFile.txt"
# save the test text  to a file
fout = open(fname, "w")
fout.write(test_text)
fout.close()

# read the file back line by line
word_list = []
for line in open(fname):
    match = rc.search(line)
    if match:
        print(match.group(0))  # for test
        print(line)

"""my output -->
like
the word like has a very flexible range of uses

LIKE
With LIKE you can use two likely wildcard characters in the pattern

Like
Official site for People Like Us and Vicki Bennett

like
Celebs and Famous People who looks like other, um, things and stuff

like
This is what the test file looks like!
"""
sneekula 969 Nearly a Posting Maven

You have to read up on the slicing operator in the Python Manual.

Generally you can slice a sequence with [start: end: step]
By default start=0, end=len(seq), step=1
step=-1 goes from the end to the beginning of the sequence, hence your reverse.

For some nice slicing examples see post #4 at;
http://www.daniweb.com/forums/post104865.html#post104865

nunos commented: very clarifying post. link to good examples. +1
sneekula 969 Nearly a Posting Maven

Oops, DaniWeb is behaving goofy and made two copies of my code!

sneekula 969 Nearly a Posting Maven

I would stay away from module cturtle and use Python's own thoroughly tested module turtle. Here is a small code sample that shows you how to handle the turtle direction properly:

import math
import turtle as tu

base_length = 200
# the two sides are equal in an Isoceles triangle
side_length = 300

# angle shared by base and side
base_angle = math.degrees( math.acos((base_length/2.0)/side_length) )
# angle shared by sides
side_angle = 180 - base_angle*2

# values for speed are 'fastest' (no delay), 'fast', (delay 5ms),
# 'normal' (delay 10ms), 'slow' (delay 15ms), 'slowest' (delay 20ms)
#tu.speed('fastest')

# turtle by default starts at (x=0, y=0) center of display
# to center the triangle lift the pen up then move
# to the left by base_length/2 and down side_length/2 units
# now drop the pen down to start drawing
tu.up()
tu.goto(-base_length/2, -side_length/2)
tu.down()

tu.forward(base_length)
tu.left(180 - base_angle)
tu.forward(side_length)
tu.left(180 - side_angle)
tu.forward(side_length)

# keep showing until corner x is clicked
tu.done()
sneekula 969 Nearly a Posting Maven

If you are used to Python2 code, then Python3 is full of surprises. However they all make the language better! So, keep an open mind, use the 2to3.py utility and try to make the old code work.

sneekula 969 Nearly a Posting Maven

This approach should work:

# 

def replace_one_two(name):
    """Switch letters in 2nd and 3rd position"""
    left = name[1]
    right = name[2]
    name.remove(left)
    name.remove(right)
    name.insert(1, right)
    name.insert(2, left)
    return name


def replace_three_four(name):
    """Switch letters in 3rd and 4th position"""
    left = name[2]
    right = name[3]
    name.remove(left)
    name.remove(right)
    name.insert(2, right)
    name.insert(3, left)
    return name

LETTERS = ["a", "b", "c", "d"]
letters = ["a", "b", "c", "d"]

while True:
    iterations = replace_three_four(letters)
    print letters
    iterations = replace_one_two(letters)
    print letters
    if letters == LETTERS:
        break

"""my output -->

['a', 'b', 'd', 'c']
['a', 'd', 'b', 'c']
['a', 'd', 'c', 'b']
['a', 'c', 'd', 'b']
['a', 'c', 'b', 'd']
['a', 'b', 'c', 'd']

"""
sneekula 969 Nearly a Posting Maven

Grid does not have anchor, but it has sticky:

rb[i].grid(row=i, column=0, sticky='w')
sneekula 969 Nearly a Posting Maven

Courier is the most common font to space all character equal.

Lingson commented: Nice and direct solution! +1
sneekula 969 Nearly a Posting Maven

Right now you simply have to use one of the many image view utilities to convert your jpg files to gif files.

sneekula 969 Nearly a Posting Maven

If the user of your program has to select from a fixed list of choices, the wx.SingleChoiceDialog is a good way to go:

# exploring the wx.SingleChoiceDialog
# fish_list from:
# http://allrecipes.com/Recipes/Seafood/Fish/Main.aspx
# snee

import wx

class MyFrame(wx.Frame):
    def __init__(self, fish_list):
        wx.Frame.__init__(self, None, -1, 'wx.SingleChoiceDialog',
            size=(350, 100))
        self.CreateStatusBar()
        label = wx.StaticText(self)
        
        dlg = wx.SingleChoiceDialog(None,
            "What's your favorite fish to eat?",
            'Select a Fish', fish_list)
        if dlg.ShowModal() == wx.ID_OK:
            answer = dlg.GetStringSelection()
            # show the selected choice different ways ...
            sf = 'Your choice was: %s' % answer
            label.SetLabel(sf)
            self.SetStatusText(sf)
            self.SetTitle(sf)
        dlg.Destroy()

fish_list = [
'Catfish',
'Cod',
'Flounder',
'Haddock',
'Halibut',
'Mahi Mahi',
'Salmon',
'Snapper',
'Swordfish',
'Tilapia',
'Trout',
'Tuna'
]

app = wx.App()
frame = MyFrame(fish_list)
frame.Center()
frame.Show()
app.MainLoop()
sneekula 969 Nearly a Posting Maven

Here is an example how to do something like this with PIL:

# create an empty image with PIL and put pixels inside

from PIL import Image

# use a (r, g, b) tuple to represent colors
red = (255,0,0)
white = (255,255,255)

# create a new 256x256 pixel image surface
# make the background white (default bg=black)
img = Image.new("RGB", [256,256], white)

# keep y fixed to create a horizontal line
y = 10
for x in range(10, 100):
    # put a red pixel at point (x, y)
    img.putpixel((x, y), red)

# save the image
img.save("test1.png")

# optionally look at the image you have created
img.show()
sneekula 969 Nearly a Posting Maven
sneekula 969 Nearly a Posting Maven

How about a blank icon as a spacer? Or maybe just a label with a few spaces?

Stefano Mtangoo commented: Blank icon? Great Idea! +7
sneekula 969 Nearly a Posting Maven

Something like ...

toolbar.AddSimpleTool(wx.ID_SAVE, self.getBMP(wx.ART_FILE_SAVE),
            "Save", " Save the text file")

... shows you the text "Save" as a popup hint

sneekula 969 Nearly a Posting Maven

I don't understand how you go from :
(4, 22, 51): 3
to:
4 22 7 51

sneekula 969 Nearly a Posting Maven

I don't understand what you are asking for. Could you explain, maybe give a short example?

sneekula 969 Nearly a Posting Maven

PMW has not been updated since 2007. Do you really want to go with this stale old thing?

sneekula 969 Nearly a Posting Maven

Is the directory there and do you have access to it?

sneekula 969 Nearly a Posting Maven

# optionally scroll to the bottom of the listbox
lines = listbox.size()
listbox.yview_scroll(lines, 'units')

sneekula 969 Nearly a Posting Maven

What is your problem? How does it manifest itself?

sneekula 969 Nearly a Posting Maven

Most likely maintenance time, those are scheduled most often on weekends.

sneekula 969 Nearly a Posting Maven

Just a note:
avoid using 'file' for an identifier, since it is a built-in Python function.

sneekula 969 Nearly a Posting Maven

If Sound Recorder has a command-line option, then you can send the arguments along to start it etc.

sneekula 969 Nearly a Posting Maven

Your carlist is a list of instances of the class carType. To compare the car's name you have to use the instance.name as shown here:

class carType:
   def __init__(self, name, brand, price):
      self.name = name
      self.brand = brand
      self.price = price
      
carlist = [
   carType("Viper", "Dodge", 80000),
   carType("Mustang", "Ford", 25000),
   carType("Silhouette", "Oldsmobile", 26000),
   carType("Croma", "Fiat", 15000),
   carType("RL", "Acura", 46000),
   carType("Axiom", "Isuzu", 24000)
   ]

print(carlist)  # shows a list of class instances

car_name = "Mustang"
for instance in carlist:
    print(instance.name)  # test
    if car_name == instance.name:
        print("%s is in the list" % car_name)

As you study some more about Python classes, it all will make sense to you.

sneekula 969 Nearly a Posting Maven

You post makes no sense to me!

sneekula 969 Nearly a Posting Maven

Hmm, this little test program works just fine:

# a small re and Tkinter program to display lines from
# a data file that contain the word "searchword"

from Tkinter import *
import re

# create a test data file
data = """\
this line has the searchword
this line does not
searchword is in this line too
"""
filename = "mytestdata.txt"
fout = open(filename, "w")
fout.write(data)
fout.close()


root = Tk()

text = Text(root, width=50, height=12, bg='yellow')
text.pack()

keyword = re.compile("searchword")

for line in file(filename):
    result = keyword.search (line)
    if result:
        text.insert(INSERT, '\n' + line)


root.mainloop()

BTW, don't use 'file' as a name for a variable, since there is a Python function named file()

sneekula 969 Nearly a Posting Maven

Like snippsat so wisely said,
"do not change a list that your are iterating over"
this will upset the indexing of the list during the iteration process.

snippsat also recommended to iterate over a copy of mylist:

mylist = ['bunnies', 'apples', 'animals', 'fruit', 'amsterdam']
mylist_copy = list(mylist)  # or mylist[:]
for x in mylist_copy:
    print '--------------'
    print x
    if x[0] == 'a':
        print "Removing ",x
        mylist.remove(x)

print mylist

"""
my output -->
--------------
bunnies
--------------
apples
Removing  apples
--------------
animals
Removing  animals
--------------
fruit
--------------
amsterdam
Removing  amsterdam
['bunnies', 'fruit']
"""
sneekula 969 Nearly a Posting Maven

How do you import Tkinter?

sneekula 969 Nearly a Posting Maven

kiddo might have to use a thread and a hook to the keyboard to get tis to go

sneekula 969 Nearly a Posting Maven

On the other hand 'in' would fetch:
'you love me!'
which would be a shame to miss!

sneekula 969 Nearly a Posting Maven

It is used when using formatted strings.
I could try explain, but a great book has been written and has a bit about it :)
http://diveintopython.org/getting_to_know_python/formatting_strings.html

Read and enjoy the best free book on python imho

hope that helps

The book is a little outdated IMHO.
However, aren't most of us a little outdated or at least fell like it at times?
Darn time simply does not stand still to catch up.

sneekula 969 Nearly a Posting Maven

A moderator would have to fiddle with it, I think it is best to leave it and refer interested folks to thread:
http://www.daniweb.com/forums/thread200291.html

sneekula 969 Nearly a Posting Maven

I guess the person who developed wxPython as a wrapper for wxWindows (written in C++) didn't do much about documentation, leaving that to his book he published later. The rub was that the editor of the book introduced a lot of errors and made the book not very friendly to use.

sneekula 969 Nearly a Posting Maven

On your last post --> Please do not double post, it is rude!

sneekula 969 Nearly a Posting Maven

Corrected your code a little and it works just fine:

''' TextFileDisp00.py
'''

import wx
import codecs

#-------------------
class TextFrame(wx.Frame):

    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, -1, mytitle, mysize)
        self.menubar = wx.MenuBar()
        self.file = wx.Menu()
        self.SetMenuBar(self.menubar)
        self.menubar.Append(self.file,'&File')
        self.openitem = self.file.Append(wx.ID_ANY,'&Open')
        self.Bind(wx.EVT_MENU,self.openevent,self.openitem)
        self.runitem = self.file.Append(wx.ID_ANY,'&Run')
        self.Bind(wx.EVT_MENU,self.runevent,self.runitem)
        self.exititem = self.file.Append(wx.ID_ANY,'E&xit')
        self.Bind(wx.EVT_MENU,self.exitevent,self.exititem)

        self.background = wx.Panel(self)
        self.background.SetBackgroundColour("white")
        self.vbox = wx.BoxSizer(wx.VERTICAL)
        self.vbox.Add(self.background, proportion=1, flag=wx.EXPAND)  #!!!!
        self.SetSizer(self.vbox)
        self.fileisopen = False
        self.Show()

    def openevent(self, event):
        filedialog = wx.FileDialog(self,
            message = 'Open text file',
            defaultDir = '.',
            defaultFile = 'TestTOC.txt',
            wildcard = 'Textfile (.txt .prn)|*.txt;*.prn|All (.*)|*.*', #!!!!
            style = wx.OPEN)
        if filedialog.ShowModal() == wx.ID_OK:
            self.path = filedialog.GetPath()
            self.fileisopen = True

    def runevent(self, event):
        if not self.fileisopen:
            msgbox = wx.MessageDialog(self.background,
                message="No file is open!", style=wx.OK)
            if msgbox.ShowModal() == wx.ID_OK:
                msgbox.Destroy()
        else:
            myOK = True
            linenr = 0
            InFile = codecs.open(self.path, 'r')
            textline = InFile.readline()
            while textline <> '' and myOK:
                linenr += 1
                msg = "Line " + repr(linenr) + ": " + textline
                msgbox = wx.MessageDialog(self.background,
                    message=msg, style=wx.OK+wx.CANCEL)
                if msgbox.ShowModal() == wx.ID_CANCEL:
                    myOK = False
                msgbox.Destroy()
                textline = InFile.readline()
            msg = "Finished, # lines = " + repr(linenr)
            msgbox = wx.MessageDialog(self.background,
                message=msg, style=wx.OK)
            if msgbox.ShowModal() == wx.ID_OK:
                msgbox.Destroy()
            InFile.close()
            self.Destroy()

    def exitevent(self, event):
        self.Destroy()

#-------------------
''' Main application
'''

app = wx.App(redirect = False)
mywidth = 300
myheight = 150
mytitle = "Text file display"
frame = TextFrame(None, mytitle, (mywidth,myheight))
app.MainLoop()

Line one of wx.AboutBox() has a larger font, maybe you can use that. See:
http://www.daniweb.com/forums/post901743-112.html

sneekula 969 Nearly a Posting Maven

I was doing a search on Daniweb for 'wx.AboutBox()', but it simply did not select a post, only the whole thread. So, this may be already somewhere. I am testing wxPython's fancy wx.AboutBox widget:

# testing the fancy wx.AboutBox() widget
# snee

import wx
from wx.lib.wordwrap import wordwrap

class MyFrame(wx.Frame):
    """
    create a frame, with a menu, statusbar and 2 about dialogs
    """
    def __init__(self):
        # create a frame/window, no parent, default to wxID_ANY
        wx.Frame.__init__(self, None, wx.ID_ANY, "wx.AboutBox test",
            pos=(300, 150), size=(300, 350))
        self.SetBackgroundColour("brown")

        # create a status bar at the bottom
        self.CreateStatusBar()
        self.SetStatusText("Click on File")

        menu = wx.Menu()
        # the optional & allows you to use alt/a
        # the last string argument shows in the status bar on mouse_over
        menu_about = menu.Append(wx.ID_ANY, "&About", "Ho-hum about box")
        menu_about2 = menu.Append(wx.ID_ANY, "About&2", "Fancy about box")
        menu.AppendSeparator()
        # the optional & allows you to use alt/x
        menu_exit = menu.Append(wx.ID_ANY, "E&xit", "Quit the program")

        # create a menu bar at the top
        menuBar = wx.MenuBar()
        # the & allows you to use alt/f
        menuBar.Append(menu, "&File")
        self.SetMenuBar(menuBar)

        # bind the menu events to an action/function/method
        self.Bind(wx.EVT_MENU, self.onMenuAbout, menu_about)
        self.Bind(wx.EVT_MENU, self.onMenuAbout2, menu_about2)
        self.Bind(wx.EVT_MENU, self.onMenuExit, menu_exit)

    def onMenuAbout(self, event):
        """a somewhat ho-hum about box"""
        dlg = wx.MessageDialog(self,
            "a simple application using wxFrame, wxMenu\n"
            "a statusbar, and this about message.",
            "About", wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()

    def onMenuAbout2(self, event):
        """use the much fancier wx.AboutBox()"""
        # first fill the info object
        info = wx.AboutDialogInfo()
        # Name and Version show in larger font
        info.Name = "Bratwurst7"
        info.Version = …
sneekula 969 Nearly a Posting Maven

There was also an effort that created a Tkinter GUI Builder:
http://sourceforge.net/projects/ptkgb/

It actually works.

sneekula 969 Nearly a Posting Maven

The maximum number of open files a process is allowed to have comes from the Operating System.
...

That is not all of it. In Python you have constructs like:

for line in file(filename):
    # do something with line

Here the closing of the file is left to the very eagle-eyed Python garbage collector. It is the garbage collector and its file closing algorithm that will feel overwhelmed after too many file opens.

sneekula 969 Nearly a Posting Maven

The contents of msvcrt.dll and its related dll's are used by Microsoft's C/C++ compilers for crt io. On Windows machines this dll is usually located in Windows/system32 and Python can access it.

If you are calling some of the msvcrt.dll C functions that pass arguments to and from Python you need to use module ctypes. Here is an example:

from ctypes import *

# declare the decorator with @ just before the function
# to make C functions in msvcrt.dll available
@cdecl(c_char_p, 'msvcrt', [c_char_p, c_int])
def strchr(string, c):
    """find a character in a string with C function strchr()"""
    return strchr._api_(string, c)

# ord() needed to converted from a single character Python string into a C char
print strchr('abcdefg', ord('d'))  # result --> defg

To get details on the C functions check this MS reference:
http://msdn.microsoft.com/en-us/library/b34ccac3(VS.80).aspx

sneekula 969 Nearly a Posting Maven

Microsoft's msvcrt.dll is a dynamic link library, look here for some of its contents:
http://msdn.microsoft.com/en-us/library/ms235446(VS.80).aspx

sneekula 969 Nearly a Posting Maven

If you use the Windows OS:

# get the character of a key pressed (no return key needed)
# works only in the command window and with Windows OS
# msvcrt.dll is the MS C library containing most standard C functions

from msvcrt import getch

print "press a char key (escape key to exit)"

while True:
    z = getch()
    # escape key to exit
    if ord(z) == 27:
        break
    print z,
sneekula 969 Nearly a Posting Maven

Python has a module numpy that will make things easier. However, you can use a Python list of lists for a matrix as shown in this example:

# create a 2D matrix of zeros and populate it

def make_list(size):
    """create a list of size number of zeros"""
    mylist = []
    for i in range(size):
        mylist.append(0)
    return mylist

def make_matrix(rows, cols):
    """
    create a 2D matrix as a list of rows number of lists
    where the lists are cols in size
    resulting matrix contains zeros
    """
    matrix = []
    for i in range(rows):
        matrix.append(make_list(cols))
    return matrix

rows = 5
cols = 10
# create the zero matrices first
mx1 = make_matrix(rows, cols)
mx2 = make_matrix(rows, cols)
mx3 = make_matrix(rows, cols)

# load matrix mx1 with multiples of x
x = 1
for row in range(rows):
    m = 1
    for col in range(cols):
        mx1[row][col] = x*m
        m += 1

# load matrix mx1 with squares of x
for row in range(rows):
    x = 1
    for col in range(cols):
        mx2[row][col] = x*x
        x += 1

# multiply mx1 with mx2
for row in range(rows):
    for col in range(cols):
        mx3[row][col] = mx1[row][col] * mx2[row][col]

# pretty show the different loaded matrix contents
for x in mx1:
    print(x)

print('-'*50)

for x in mx2:
    print(x)

print('-'*50)

for x in mx3:
    print(x)

"""
my result -->
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
--------------------------------------------------
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
--------------------------------------------------
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
"""
sneekula 969 Nearly a Posting Maven

Since a list is a mutable object, it would still behave global if it is used as a function parameter/argument. To wit:

def add_element(mylist2):
    mylist2.append(33)
    return mylist2

mylist = [1,2,3,4]
mylist3 = add_element(mylist)

print(mylist)   # [1, 2, 3, 4, 33]  oops!
print(mylist3)  # [1, 2, 3, 4, 33]

To prevent mutable parameter feedback use:

def add_element(mylist2):
    # make a copy to prevent feedback
    mylist2 = list(mylist)
    mylist2.append(33)
    return mylist2

mylist = [1,2,3,4]
mylist3 = add_element(mylist)

print(mylist)   # [1, 2, 3, 4]
print(mylist3)  # [1, 2, 3, 4, 33]
sneekula 969 Nearly a Posting Maven

To read in a list of integers with a loop you have to create an empty list and append to it with each input. For instance:

# create a list of integers
# note that input() gives a string in Python3

n_list = []
while True:
    n = int(input("Enter a positive integer (-1 to quit): "))
    n_list.append(n)
    if n < 0:
        break

print(n_list)

"""
my example output -->
[33, 12, 123, 567, -1]
"""

I left the end marker -1 in the list. If you break before the append then the -1 is omitted.

If you leave the -1 of the list or remove it, then you can just use:

low_number = min(n_list)
high_number = max(n_list)
total = sum(n_list)
average = float(total)/len(n_list)

However, your instructor, being rather tricky, most likely wants you to take care of the -1 as you do your calculations.

Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.

[code=python]
your Python code here

[/code]

sneekula 969 Nearly a Posting Maven

Are you using the Python Shell (>>> prompts), or an editor like the IDLE editor?

sneekula 969 Nearly a Posting Maven

Just in case you don't fine wxGlade or BoaConstructor to be quite what you need (or if you just can't get past how ugly they are), you can try QtDesigner for pyQT (comes with the pyQT package).

Beauty and henceforth ugly is in the eye of the beholder!

Actually, the QT_Designer is pretty good and gives XML code that can be converted to a seemingly complex looking Python code.

scru commented: not seemingly, it is complex. But people who use gui builders generally don't care about this sort of stuff. +6