bumsfeld 413 Nearly a Posting Virtuoso

This might help:

import wx


class DemoFrame(wx.Frame):
    
    def __init__(self, parent, id):
        
        wx.Frame.__init__(self, parent, id, 'Demo', size=(600, 400), pos=(300,300))
        
        # make the widgets ...
        self.panel1=wx.Panel (self, -1)
        self.panel1.SetBackgroundColour ("white")

        # create splitter windows
        self.splitter = wx.SplitterWindow(self,
            style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
        self.splitter2 = wx.SplitterWindow(self.splitter, -1,
            style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
        self.mainpanel = wx.Panel(self.splitter, -1)
        self.leftpanel2 = wx.Panel(self.splitter2, -1, style=wx.WANTS_CHARS)
        self.mainpanel.SetBackgroundColour ("white")
        self.splitter2.SetBackgroundColour (wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))

        # create tree control
        self.tree = wx.TreeCtrl(self.mainpanel, -1, wx.Point(0, 0), wx.Size(160, 250),
            wx.TR_DEFAULT_STYLE | wx.NO_BORDER)
        self.root = self.tree.AddRoot("Root Demo Item")
        item1 = self.tree.AppendItem (self.root, "Item1",0)
        item2 = self.tree.AppendItem (self.root, "Item2",0)
        self.tree.Expand(self.root)

        # add other widgets
        self.help = wx.TextCtrl(self.splitter2, -1,
            style = wx.TE_MULTILINE|wx.TE_READONLY | wx.HSCROLL)
        self.staticboxstyles = wx.StaticBox(self.leftpanel2, -1, "Demo", size=(485, 240))
        
        self.DoLayout ()
        
        # bind tree action
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree)

    
    def DoLayout (self):
        
        # sizers
        mainsizer = wx.BoxSizer(wx.VERTICAL)
        panelsizer = wx.BoxSizer(wx.VERTICAL)
        sizer1 = wx.BoxSizer(wx.VERTICAL)
        sizer2 = wx.BoxSizer(wx.VERTICAL)
      
        # add widgets to sizers
        panelsizer.Add(self.splitter, 1, wx.EXPAND, 0)
        sizer1.Add(self.tree, 1, wx.EXPAND)
        sizer2.Add(self.staticboxstyles, 1, wx.BOTTOM|wx.EXPAND|wx.ALIGN_BOTTOM, 60 )
    
        # set sizers
        self.mainpanel.SetSizer(sizer1)
        self.leftpanel2.SetSizer(sizer2)
        self.SetSizer(panelsizer)
        mainsizer.Layout()
        self.Layout()

        # set splitters
        self.splitter.SplitVertically(self.mainpanel, self.splitter2, 300)
        self.splitter2.SplitHorizontally(self.leftpanel2, self.help, -160)
        self.splitter.SetSashPosition (200)


    def OnSelChanged(self, event):
        self.item = event.GetItem()
        select = self.tree.GetItemText(self.item)
        if self.item:
            # test (create your help string here)
            str1 = "Selected item = %s\n" % select
            self.help.SetValue(str1)
        if select == 'Item1':
            # test (create your check boxes instead)
            self.staticbox_check = wx.StaticBox(self.leftpanel2, -1, "Check",
                pos=(10, 20), size=(300, 100))
        if select == 'Item2':
            # test (create your radio buttons instead)
            self.staticbox_check = wx.StaticBox(self.leftpanel2, -1, "Radio",
                pos=(10, 20), size=(300, 100))
        

if __name__ == '__main__':
    app = wx.PySimpleApp() …
bumsfeld 413 Nearly a Posting Virtuoso

Try http://pyarticles.blogspot.com

Where is the meat?

bumsfeld 413 Nearly a Posting Virtuoso

I am scratching my head on this one! However, this modifiecation seems to work correctly ...

num = 32
b2 = 2
x = 1

def increasex3(num, b2, x):
    while num%(b2**x) < num:
        x = x+1
        increasex3(num, b2, x)
    #print x  # test
    return x

result = increasex3(num, b2, x)
print '-->', result
bumsfeld 413 Nearly a Posting Virtuoso

I think you are using wrong word here, list is like an array. You simply want each element of list displayed on separate line, right?

# for instance this is list
cards = ['4 c', '12 h', '2 s', '6 s', '8 s']
 
# one list item per line display
for card in cards:
    print card
 
"""
my output =
4 c
12 h
2 s
6 s
8 s
"""

Edit: changed php tags, don't work properly

bumsfeld 413 Nearly a Posting Virtuoso

There are number of ways, but this way I mostly use:

# sorting a list of lists by index

def sort_inner(inner):
    """
    inner is each inner list in the list of lists to be sorted
    (here item at index 1 of each inner list is to be sorted)
    """
    return inner[1]

serial = 123456
total = [[serial, 'john'], [serial, 'james']]

total.sort(key=sort_inner)
print total  # [[123456, 'james'], [123456, 'john']]
bumsfeld 413 Nearly a Posting Virtuoso

If you don't have any arguments to pass you can import the C function directly from msvcrt.dll:

# optional console wait for keypress, any key
# C:\Windows\System32\msvcrt.dll contains C functions
# works only with console (many IDEs have their own output)

from msvcrt import getch

print "Hello!"

getch()  # this is the C getch() function!

If you have to pass arguments you need the ctypes module (Python25 has the ctype module inclused), so you can convert Python argument types to C types:

# access the C function strchr()

from ctypes import *

libc = cdll.msvcrt  # accesses msvcrt.dll (the windows C function dll)
strchr = libc.strchr
strchr.restype = c_char_p # c_char_p is a pointer to a string
strchr.argtypes = [c_char_p, c_char]

print strchr("abcdef", "d")  # def

# optional console wait for keypress, any key
# C:\Windows\System32\msvcrt.dll contains C functions
# works only with console (many IDEs have their own output)
from msvcrt import getch
getch()
bumsfeld 413 Nearly a Posting Virtuoso

Something like this will work fine:

from Tkinter import *
    
root = Tk()
root.title('root win')
root.geometry("400x300+30+30")
# create child window
top = Toplevel()
top.title('top win')
top.geometry("200x100+100+130")
top.lift(aboveThis=root)
 
root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

It would be nice, if you could give us an actual example, so we don't have to guess too wildly!

bumsfeld 413 Nearly a Posting Virtuoso

We are talking PIL. 'n^2' ??? All I can think of is that you may want to average the color of one 4x4 area rather than one 2x2 area.

bumsfeld 413 Nearly a Posting Virtuoso

Don't use main the way it was written:

def main() :
    renamer(sys.argv[1])
    main()

It might call itself until the recursion limits are reached.

Use it like this:

def main() :
    renamer(sys.argv[1])

main()

Actually the best way to do this is as follows:

import os,shutil 
   
def renamer(target) :    
    os.chdir(target)
    for filename in os.listdir('.') :
        print filename
        newfilename = os.path.splitext(filename)[0] 
        print newfilename
        os.rename(filename, newfilename)
        print "Renamed " + filename + " to " + new_filename
    shutil.copy("copyme","newcopyme"

# test the function/module
if __name__ == __main__:
    renamer(sys.argv[1])

This test allows the program to be importable module or runnable program.

bumsfeld 413 Nearly a Posting Virtuoso

Yes, post your code again, in tags this time, you will get more help!

bumsfeld 413 Nearly a Posting Virtuoso

x to the power 0.16 would be x**0.16

To make your Python code readable, you neeed to preserve the indentations, see:
http://www.daniweb.com/techtalkforums/announcement114-3.html

bumsfeld 413 Nearly a Posting Virtuoso

You need to set gVar global in function setVar(), so it will be visible for function getVr():

gVar = None

def getVar():
    return gVar

def setVar(val):
    global gVar
    gVar = val
bumsfeld 413 Nearly a Posting Virtuoso

The DOS command window is kind of stupid, you have to tell it in detail where every file is.

bumsfeld 413 Nearly a Posting Virtuoso

You have to add one important line!

def OnPaint(self, evt):
        dc = wx.PaintDC(self.canvas)
        # added this to keep drawing from messing up on srolling
        self.canvas.PrepareDC(dc)   
        self.vykresli_graf(dc)
bumsfeld 413 Nearly a Posting Virtuoso

I added some needed lines to your code, now it works. Somehow you have to refresh your drawing as you scroll:

import wx

class Canvas(wx.ScrolledWindow):
    def __init__(self,parent):
        self.okno=parent
        self.radic = wx.FlexGridSizer(3,2,0,0)
        self.canvas = wx.ScrolledWindow(self.okno, -1)
        
        # EnableScrolling(bool x_scrolling, bool y_scrolling)
        self.canvas.EnableScrolling(True, True)
        
        # SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, 
        #      int noUnitsY, int xPos=0, int yPos=0, bool noRefresh=False)
        PAGE_WIDTH = 1000
        PAGE_HEIGHT = 1000 
        self.canvas.SetScrollbars(20, 20, PAGE_WIDTH/20, PAGE_HEIGHT/20)

        self.radic.Add(self.canvas, 1, wx.EXPAND)
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.Add((0,0))
        self.radic.AddGrowableRow(0, 1)
        self.radic.AddGrowableCol(0, 1)
        self.canvas.SetCursor(wx.CROSS_CURSOR)
        self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
        self.okno.SetSizer(self.radic)
        
    def vykresli_graf(self,dc):
        dc.BeginDrawing()
        lines=[(-500,-500,507,507)]
        dc.DrawLineList(lines)
        dc.EndDrawing()
        
    def OnPaint(self, evt):
        dc = wx.PaintDC(self.canvas)
        self.vykresli_graf(dc)
        
        
if __name__ == "__main__":
    okno = wx.App(0)
    parent=wx.MDIParentFrame(None,size=wx.Size(500,500))
    child=wx.MDIChildFrame(parent,title="Graf",id=-1)
    Canvas(child)
    child.Maximize()
    parent.Show()
    okno.MainLoop()
bumsfeld 413 Nearly a Posting Virtuoso

So this will not work?

str1 = """line1
line2
line3
"""
bumsfeld 413 Nearly a Posting Virtuoso

Must be something peculiar to the Mac OS, this code works fine on Windows:

import Tkinter as tk

def change(event):
    root.title(str(v_red.get()))

root = tk.Tk()

# width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (150, 120, 0, 0))

v_red = tk.IntVar()
red = tk.Scale(root, label="Red", variable=v_red, from_=0, to=255)
red.pack()
red.bind('<B1-Motion>', change)

root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

The other problem with Tkinter is that you are going back and forth between two languages, TCL and Python, so Python rules don't always apply.

bumsfeld 413 Nearly a Posting Virtuoso
from Tkinter import *
import inspect

# find out if Tkinter's PhotoImage is a class
print inspect.isclass(PhotoImage)  # True
bumsfeld 413 Nearly a Posting Virtuoso

There are some folks who might not know what graphics.h implies. It would be waste of time for them to explore this question. As for you, I am very glad you are so knowledgeable about Turbo C. I challenge you to supply a satsifactory answer!

bumsfeld 413 Nearly a Posting Virtuoso

Graphics.h? Let me guess, must be from the old Tubo C compiler (16bit), good luck to find anyone that uses this old bird!

bumsfeld 413 Nearly a Posting Virtuoso

Keyword variable image=object needs an object not a function call. You need to use
image1=PhotoImage(file="image.gif")
and then
self.Button = Button(self, image=image1)

bumsfeld 413 Nearly a Posting Virtuoso

This uses popen4(), but I think its similar:

# run an external program (cmd) and retrieve its output:
import os
cmd = "ls"
fin, fout = os.popen4(cmd)
result = fout.read()
print result
bumsfeld 413 Nearly a Posting Virtuoso

If you know in which windows dll the function SetCursorPos(x, y) is situated, then you can use module ctypes to get access to it.

bumsfeld 413 Nearly a Posting Virtuoso

RSC, thanks for the reference. Working with SWIG can be interesting, but their seems to be lots of pitfalls to avoid!

bumsfeld 413 Nearly a Posting Virtuoso

Sure Python has multidimensional arrays, they are called lists of lists or tuples of tuples etc.

mlist1 = [
[7, 12, 23],
[22, 31, 9],
[4, 17, 31]]

print mlist1  # [[7, 12, 23], [22, 31, 9], [4, 17, 31]]

# show list_item at index 1
print mlist1[1]  # [22, 31, 9]

# show item 2 in that sublist
print mlist1[1][2]  # 9

# change the value
mlist1[1][2] = 99

print mlist1  # [[7, 12, 23], [22, 31, 99], [4, 17, 31]]
mattyd commented: help with multi-d arrays +3
bumsfeld 413 Nearly a Posting Virtuoso

Here is the code from the pyame docs:

#/usr/bin/env python
"""
This simple example is used for the line-by-line tutorial
that comes with pygame. It is based on a 'popular' web banner.
Note there are comments here, but for the full explanation, 
follow along in the tutorial.
If you downloaded the Pygame Docs this file is in for instance
C:\Python24\Doc\Pygame-Docs\examples\chimp.py
images are in
C:\Python24\Doc\Pygame-Docs\examples\data\
"""


#Import Modules
import os, pygame
from pygame.locals import *

if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'


#functions to create our resources
def load_image(name, colorkey=None):
    fullname = os.path.join('data', name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error, message:
        print 'Cannot load image:', fullname
        raise SystemExit, message
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()

def load_sound(name):
    class NoneSound:
        def play(self): pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join('data', name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error, message:
        print 'Cannot load sound:', fullname
        raise SystemExit, message
    return sound
        

#classes for our game objects
class Fist(pygame.sprite.Sprite):
    """moves a clenched fist on the screen, following the mouse"""
    def __init__(self):
        pygame.sprite.Sprite.__init__(self) #call Sprite initializer
        self.image, self.rect = load_image('fist.bmp', -1)
        self.punching = 0

    def update(self):
        "move the fist based on the mouse position"
        pos = pygame.mouse.get_pos()
        self.rect.midtop = pos
        if self.punching:
            self.rect.move_ip(5, 10)

    def punch(self, target):
        "returns true if the fist collides with the target"
        if not self.punching:
            self.punching = 1
            hitbox = self.rect.inflate(-5, -5)
            return hitbox.colliderect(target.rect)

    def unpunch(self):
        "called …
bumsfeld 413 Nearly a Posting Virtuoso

For button1 use : self.myboxsizer.Add(self.button1,0,wx.EXPAND|wx.ALL,30) I works on Windows OS, Linux may behave differently.

bumsfeld 413 Nearly a Posting Virtuoso

Just short example how to build very simple pygame program (similar to vegaseat's Hello):

# module pygame free from: http://www.pygame.org
# "Hello World" with colour and nice font

import pygame as pg
    
# initialize pygame
pg.init()

# RGB colour tuple pygame uses
yellow = (255,255,0)

# create screen/surface of width=480 and height=80
screen = pg.display.set_mode((380, 60))
# add nice title
pg.display.set_caption('Hello World from DaniWeb!')

# create surface (canvas) in memory
surface = pg.Surface(screen.get_size())
# fill surface
surface.fill(yellow)

# display some text in given font
font = pg.font.SysFont('Comic Sans MS', 36)
text = font.render("Hello World!", 1, (10, 10, 10))
textpos = text.get_rect()
# have text center coincide with surface center position
textpos.centerx = surface.get_rect().centerx
# transfer text area to surface area (now centered)
surface.blit(text, textpos)

# transfer surface area to screen area at ulc x=0,y=0
screen.blit(surface, (0, 0))
# update to show it on the computer display
pg.display.flip()

# run event loop and provide exit conditions
while True:
    for event in pg.event.get():
        # the title 'x' click
        if event.type == pg.QUIT:
            raise SystemExit
bumsfeld 413 Nearly a Posting Virtuoso

Here is the code for a title-free Tkinter window.

import Tkinter as tk

root = tk.Tk()
# eliminate the titlebar
root.overrideredirect(1)

# your code here ...

root.mainloop()

You have to exit the program somehow and could create one exit/quit button that needs secret password to quit.

bumsfeld 413 Nearly a Posting Virtuoso

Here is way to do it:

def check_pin(pin):
    """check if pin number pin is between 1000 and 9000"""
    if 1000 <= pin <= 9000:
        return True
    return False

pin = int(raw_input("Enter pin number (between 1000 and 9000): "))
print check_pin(pin)
bumsfeld 413 Nearly a Posting Virtuoso

You have really butchered the original example code! I would suggest to reload the original code and it will work fine!

bumsfeld 413 Nearly a Posting Virtuoso

I don't know what window() does.

There is Windows API function, see thread:
http://www.daniweb.com/code/snippet217.html

bumsfeld 413 Nearly a Posting Virtuoso

I don't know about phthon but I know that can be done in C or C++ using sockets. Computers attached to a LAN (Local Area Network) do not require internet service provider but others do.

Here is your answer! Use C++! You may want to repost your request in the C/C++ section of the forum.

bumsfeld 413 Nearly a Posting Virtuoso

I think you can replace javascript with python code, but your webserver has to be python enabled.

bumsfeld 413 Nearly a Posting Virtuoso

Looks like someone at the office has been messing with the code field again, sorry!
Copy and pasting code is a mess now!!!!!!!!!!!

Gee, vegaseat you are old and blind. This is supposed to be improvement. See the little line 'Toggle Plain Text' just below the code, click on it, the line numbers are gone and now you can highlight, copy and paste as usual. Merry coding!
Your friend Henri

bumsfeld 413 Nearly a Posting Virtuoso

Looks like you really butchered vegseat's code. Let me rewrite it a little:

""" assume part of your list1.txt data file looks like this:
1846440556
1846440521
1846440491
1846440505
1846441137
1846441102
1846441080
1846441331
1846441323
1846441315
"""

# read the data file in as a list
fin = open( 'list1.txt', "r" )
data_list = fin.readlines()
fin.close()
# test first 5 list items ...
print data_list[:5]

print '-'*60

# remove list items from index 3 to 5 (inclusive)
del data_list[3:5+1]
# test first 5 list items ...
print data_list[:5]

# write the changed data (list) to a file
fout = open("list2.txt", "w")
fout.writelines(data_list)
fout.close()
bumsfeld 413 Nearly a Posting Virtuoso

Avoid all those globals, you are using Python! If the class variables are global within the class use the prefix 'self.' this way they are part of the class instance when you switch characters.

If your gif files are in the current folder's subfolder use:
grave=PhotoImage(file=r".\Images\TitleScreenGraves.gif")

When you call function in the class, also prefix with 'self.' since this function is method in the class.

Your present thread title is missleading and has nothing to do with grid! Like vegaseat and others recommend, start a new thread and call it "Can't get class to work!". I won't look here any further!

bumsfeld 413 Nearly a Posting Virtuoso

What is your error message?

bumsfeld 413 Nearly a Posting Virtuoso

Here are some well known approximations of pi:

# approximations of pi
# 3/14 is the official 'Pi Day'
# 3/14 is Albert Einstein's birthday (year 1879, born in Ulm)
# as of feb2007 the pi approximation record is 1,241,100,000,000 digits 
 
import math
 
# for your reference here is pi calculated to 77 decimals:
3.14159265358979323846264338327950288419716939937510582097494459230781640628620
 
# Chinese approximation, easy to remember
# take 113355 then split in half ...
p1 = 355/113.0
 
# Ramanujan1 or 'Chinese plus' (still 1, 3 or 5)
p2 = 355/113.0 * (1 - 0.0003/3533)
 
# deJerphanion, possibly easy to remember
p3 = math.log(23 + 1/22.0 + 2/21.0)
 
# Ramanujan2
p4 = 99*99/(2206*math.sqrt(2))
 
# Castellano
p5 = 1.09999901 * 1.19999911 * 1.39999931 * 1.69999961
 
# Kochansky
p6 = math.sqrt(40/3.0 - math.sqrt(12))
 
# Golden Ratio
p7 = 3/5.0 * (3 + math.sqrt(5))
 
print "math.pi =", math.pi # 3.14159265359
print "Ramanujan1 =", p2 # 3.14159265359
print "deJerphanion =", p3 # 3.14159265393
print "Ramanujan2 =", p4 # 3.14159273001
print "Chinese =", p1 # 3.14159292035
print "Castellano =", p5 # 3.14159257347
print "Kochansky =", p6 # 3.14153333871
print "Golden Ratio =", p7 # 3.1416407865

There is still room to invent one approximation for pi that is easy to remember! Go and find it!

bumsfeld 413 Nearly a Posting Virtuoso

I know printing primes isn't anything new, but (like always) I'd love to hear some feedback on how I can make my code more efficient and other constructive criticism.

def print_primes(r=10):
    primes = [ ]
    for i in range(2,r+1):
        prime = 1
        for divisor in range(2,i):
            if i % divisor == 0:
                prime = 0
                break
        if prime:
            primes.append(i)
    print "primes between 1 and %d:" % (r)
    for prime in primes:
        print prime,

print_primes()

Thanks.


EDIT: BAH! I CAN'T DELETE THIS! I just realized there's another prime thread and it has more advanced versions of this program. Sorry for the nuisance!

LaMouche, I am glad you posted this typical beginner's example! I improved your code a little bit and also showed the timing needed to follow positive progress. If you are interested, then see my code snippet at:
http://www.daniweb.com/code/snippet641.html

Mat has done much of interesting things too in his thread.

bumsfeld 413 Nearly a Posting Virtuoso

What's slicing

Also, what's the difference between xrange and range?

Here are some slicing examples (takes a while to get it, but very powerful):

# slicing operator seq[begin : end : step]
# step is optional
# defaults are index begin=0, index end=len(seq)-1, step=1
# -begin or -end --> count from the end backwards
# step = -1 reverses sequence
 
a = [0,1,2,3,4,5,6,7,8]
# if you get lost, put in the defaults in your mind
print a[3:6] # [3, 4, 5]
print a[:3] # [0, 1, 2]
print a[5:] # [5, 6, 7, 8]
print a[-3:] # [6, 7, 8]
print a[2:-2] # [2, 3, 4, 5, 6]
print a[1::2] # [1, 3, 5, 7]
print a[::-1] # [8, 7, 6, 5, 4, 3, 2, 1, 0]
 
# makes true copy of list a
b = a[:]
 
b[2:5] = [77, 88]
print b # [0, 1, 77, 88, 5, 6, 7, 8]

The function range() returns the whole list requested, xrange() returns only the next possible value each time as you iterate in the for loop. This saves time and memory with large list ranges.

bumsfeld 413 Nearly a Posting Virtuoso

... and old code will break frequently, since division will no longer yield integers. :eek:

Jeff

Pascal always had two different divisors, one for integers and one for floats. So I was used to using '//' when I wanted integer division. Lucky me!? In C this problem comes up with beginners a lot.

bumsfeld 413 Nearly a Posting Virtuoso

Makes my head spin too, so I used this short 'regular stuff' code ...

# extract numeric value from a data stream
# caveat --> only for one number per data line
 
data_raw = """
header
[23 ]
[ 43 ]
[4323]
[-$23.44 ]
[ 12.32 ]
footer
"""
 
data_list = data_raw.split('\n')
print data_list  # test
 
num_list = []
for x in data_list:
    s = ""
    for c in x:
        if c in '1234567890.-':
            s += c
    if s:
        num_list.append(s)
 
print num_list  # ['23', '43', '4323', '-23.44', '12.32']

... you should be able to figure that one out.

Thank you, I could understand that code! Have been bitten by the re bug a little too!

bumsfeld 413 Nearly a Posting Virtuoso

Python has full set of binary operators, but I don't think there is one way to send bitstring to USB chip. Ultimately that is how data would travel in the serial wire.

bumsfeld 413 Nearly a Posting Virtuoso

yea, ditch the printing and append it to a list and it'll be almost instant. :)

Even with ditching print and returning list of primes, this algorithm is not like speed demon. It takes 6,000ms for primes up to 10,000 compared to 4ms with standard sieve algorithm.

bumsfeld 413 Nearly a Posting Virtuoso

Just in case others may wonder, you put the event loop mainloop() in the wrong place:

from Tkinter import *

class Main:
    def __init__(self, master):
        self.master = master
        self.master.title('Role Playing Form V1.0')
        self.master.geometry('300x250+350+450')
        #self.master.mainloop()  #!!!!!!!!!!
        self.cmdCreate = Button(self.master, text='Create Character', command=self.create)
        self.cmdCreate.grid(row=0)
    def create(self):
        pass

root = Tk()
main=Main(root)
# put event loop here
root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

Obviously something wrong in your MainWin class.
Maybe the missing indents in reg()?
Do you get any traceback error?
Change line
app = wx.PySimpleApp(0)
to
app = wx.PySimpleApp(redirect = True)


I don't have MySQLdb installed, so I can't help you much.

bumsfeld 413 Nearly a Posting Virtuoso

Is this part of your doctorial theses in computer science?