Newbie 1st program

J

JDevine

Hey. I just finished my first python program. In fact it is my first
program program at all. I went from zero knowledge to the current
state in about 6 weeks. Check it out at
http://gobblewin.sourceforge.net I need help for the next stage of
development, I am also sure I could use a lot of advice on structure
etc. My #1 priority is adding a threaded status bar to track
downloads to this program. if you think you can help out let me know.

Thanks
 
P

Peter Hansen

JDevine said:
Hey. I just finished my first python program. In fact it is my first
program program at all. I went from zero knowledge to the current
state in about 6 weeks. Check it out at
http://gobblewin.sourceforge.net I need help for the next stage of
development, I am also sure I could use a lot of advice on structure
etc. My #1 priority is adding a threaded status bar to track
downloads to this program. if you think you can help out let me know.

More people would take the time to visit that link if you
took the time to describe something, *anything*, about what
the program actually does and why we should bother looking.

(Congratulations, though. After six weeks of programming I'm
quite sure I wasn't capable of writing anything that would
have been worth posting to Sourceforge, had it existed at
the time.)

-Peter
 
E

Ed Suominen

Peter said:
(Congratulations, though. After six weeks of programming I'm
quite sure I wasn't capable of writing anything that would
have been worth posting to Sourceforge, had it existed at
the time.)

Congratulation from me, too. After six weeks of programming, I'm also quite
sure I wasn't capable of writing anything that would have been worth
posting anywhere, had there been any means to do so other than saving it to
the tape drive. :)

Sadly, it took about 95% of my programming lifetime before object-oriented
programming came along and I (much later) truly realized what a wonder it
is.
 
N

Nick Jacobson

Hey. I just finished my first python program. In fact it is my first
program program at all. I went from zero knowledge to the current
state in about 6 weeks. Check it out at
http://gobblewin.sourceforge.net I need help for the next stage of
development, I am also sure I could use a lot of advice on structure
etc. My #1 priority is adding a threaded status bar to track
downloads to this program. if you think you can help out let me know.

Thanks

Great job! Here's something to clean up the code a bit:

You can change:

<<
if event.GetInt() == 0:
t2.Clear()
t2.SetValue("Restrict your search to a specific
site")
t2.SetEditable(True)

elif event.GetInt() == 1:
t2.Clear()
t2.SetValue("army.mil")
t2.SetEditable(False)

elif event.GetInt() == 2:
t2.Clear()
t2.SetValue("usmc.mil")
t2.SetEditable(False)

elif event.GetInt() == 3:
t2.Clear()
t2.SetValue("af.mil")
t2.SetEditable(False)

elif event.GetInt() == 4:
t2.Clear()
t2.SetValue("navy.mil")
t2.SetEditable(False)

elif event.GetInt() == 5:
t2.Clear()
t2.SetValue("uscg.mil")
t2.SetEditable(False)

elif event.GetInt() == 6:
t2.Clear()
t2.SetValue("SYColeman.com")
t2.SetEditable(False)

elif event.GetInt() == 7:
t2.Clear()
t2.SetValue("l3com.com")
t2.SetEditable(False)

elif event.GetInt() == 8:
t2.Clear()
t2.SetValue("fedbizopps.gov")
t2.SetEditable(False)

elif event.GetInt() == 9:
t2.Clear()
t2.SetValue("defenselink.mil")
t2.SetEditable(False)
to:

<<
ary = ["Restrict your search to a specific site",
"army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
"SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]
d = dict(zip(range(10), ary))
i = event.GetInt()
if i in range(10):
t2.Clear()
t2.SetValue(d)
t2.SetEditable(bool(i))
Also, instead of string.atoi(x), use int(x). I think the former is
deprecated.

--Nick
 
P

Peter Otten

Nick said:
d = dict(zip(range(10), ary))

Magic constants are evil. The above will not (automatically) remain correct
when new items are added to ary. Therefore:

d = dict(enumerate(ary))
i = event.GetInt()
if i in range(10):

Make the above line

if i in d:

instead. Faster and more robust against changes elsewhere (no need for
consecutive integer keys).

You wouldn't want to teach a newbie bad habits, would you :)

Peter
 
D

Duncan Booth

(e-mail address removed) (Nick Jacobson) wrote in
Great job! Here's something to clean up the code a bit:

You can change:

<<
to:

<<
ary = ["Restrict your search to a specific site",
"army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
"SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]
d = dict(zip(range(10), ary))
i = event.GetInt()
if i in range(10):
t2.Clear()
t2.SetValue(d)
t2.SetEditable(bool(i))

Converting the list to a dict seems pointless. Likewise the weird range
test seems a lot of effort to no gain, oh, and you got the sense of the
SetEditable backwards:

ary = ["Restrict your search to a specific site",
"army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
"SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]

i = event.GetInt()
if 0 <= i < len(ary):
t2.Clear()
t2.SetValue(ary)
t2.SetEditable(i != 0)
 
S

simo

Just a question: How did you make the installer package?

It's the old favourite py2exe plus InnoSetup.

Couple of hints:

1. make the image a GIF instead of BMP, it's better for portability
and size

2. is it platform-specific, or have you just not been able to test on
UNIX? you don't need the .pyw

3. to put the .ico into the .exe and get the WinXP look'n'feel, you
can use this as your setup.py for py2exe:


from distutils.core import setup
import py2exe

manifest = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="0.64.1.0"
processorArchitecture="x86"
name="Controls"
type="win32"
/>
<description>GobbleWin</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
"""

setup(
windows = [
{
"script": "Gobblewx.py",
"icon_resources": [(1, "Gobble.ico")],
"other_resources": [(24,1,manifest)]
}
],
)
 
N

Nick Jacobson

ary = ["Restrict your search to a specific site",
"army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
"SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]

i = event.GetInt()
if 0 <= i < len(ary):
t2.Clear()
t2.SetValue(ary)
t2.SetEditable(i != 0)


You're right, this is an improvement. Well, my main point was to
eliminate the code redundancy, even if I was a bit clumsy about it. :0

--Nick
 
N

Neuruss

Thanks for the information on Py2exe.
But I'm affraid I'm having trouble with it...

Traceback (most recent call last):
File "C:\Documents and
Settings\Usuario1\Escritorio\misApps\Grades\setup.py", line 30, in ?
setup(
File "C:\Python23\lib\distutils\core.py", line 137, in setup
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" %
msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
[cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied
I've seen the website and tried to follow the instructions, but
there's something I'm doing wrong...how exactly should I run the setup
script?
In my case, the program I want to convert to .exe is located in this
folder:
"C:\Documents and Settings\Usuario1\Escritorio\misApps\Grades", this
is a GUI application made with Pythoncard (wxpython) and there's a
file where a keep data of some serialized objects called
"grades.data".

With this info in mind, how should I do the script?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top