Re: PyGTK + Glade = weird problem

2006-02-24 Thread gsteff
Sorry about that.  Your problem is that the show_hide_janela method is
setup to be called both on  a gtk signal ("destroy") and an
event("delete_event").  Callback methods for events take a slightly
different signature than signals; they take one extra argument, which
represents the triggering event.  When you close the window, the
delete_event is triggered, which calls show_hide_janella, but the call
fails, because show_hide_janella is called with 3 arguments, when its
only expecting 2.  So, to fix the code you have posted in the thread
you linked, replace the line

def show_hide_janela(self,obj):

with the line

def show_hide_janela(self,obj, event=None):

The modified code works on my machine.  Hope this helps,

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK + Glade = weird problem

2006-02-24 Thread gsteff
Oops- I didn't read your question carefully enough.  That's probably
not the problem.

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK + Glade = weird problem

2006-02-24 Thread gsteff
We'd need to see your "scc.glade" file to be sure, but basically,
calling the "show" method on the "w_cadcli" object only shows it, not
the objects it contains.  Again, to be clear, showing a container
object doesn't automatically show the objects it contains.  In glade,
use the "common" tab of the property editor to make sure that the
"visible" property is set to "Yes" for all of the widgets in the
windows you want to show.  In general, if you always do that, you'll be
able to show or hide the entire window by simply calling "show" or
"hide" on the window object, like you're trying to do.

But this is just a guess; post your "scc.glade" file if the above
advice doesn't work.

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


What is unique about Python?

2005-12-19 Thread gsteff
I'm a computer science student, and have recently been trying to
convince the professor who teaches the programming language design
course to consider mentioning scripting languages in the future.  Along
those lines, I've been trying to think of features of Python, and
scripting languages in general, that can't be found in older languages,
and have been having a surprising amount of trouble.  Dynamic typing
can be found in Smalltalk, the module concept can be found in Ada,
functional parameters and the dynamic creation of functions can be
found in Lisp.  The indentation-based syntax seems to be unique, but
that's not really what I'm looking for.  So I'm wondering, what is
innovative about Python, either in its design or implementation?  Or is
its magic really just in combining many useful features of prior
languages in an unusually pleasant way?

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread gsteff
I learned pygtk via the tutorial and reference manual, and found most
things to be pleasantly simple to do.  A message dialog, for example,
can be done via

dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL,
message_format="Test message here.")
response  = dialog.run()

All that can be found by looking up the MessageDialog class in the
reference manual,  noticing that there's not much there, and looking
and the documentation for its parent "Dialog" class.  That may be one
source of confusion you may have experiened while reading the reference
manual.

In general, I've found pygtk to be remarkably pythonic (for an
interface to a library that has been ported to many other languages as
well).  For example, when using tree views, you can access the tree
model underlying it using the normal python list syntax, which I think
is very cool.  If you have other examples of things that are confusing,
post them (here, or to the pygtk list).  

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do you use as symbols for Python ?

2005-11-11 Thread gsteff
I've seen the following style in some code (the formencode library
comes to mind):

opened = object()
closed = object()
error = object()

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python gui

2005-11-06 Thread gsteff
PyGTK is just easier to code with.  The api is much nicer.  However,
yeah, the windows/mac appearance probably does make it a non-starter,
unfortunately.  As near as I can tell, the solution that currently has
the most momentum is to just integrate the cheeseshop more tightly into
python, so that whatever gui toolkit you choose can be installed
easily.  Its probably the only politically feasible solution anyway.

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: formulaic 0.1

2005-10-22 Thread gsteff
I've been working on a form generation toolkit that integrates well
with FormEncode... its still under heavy development, of course, but
I've seen a lot of discussion of this topic on various mailing lists
over the past few days, and so wanted to get something out.  Release
early and all that.  So you can get it from

https://developer.berlios.de/project/showfiles.php?group_id=4967

There's a README with a tutorial in there, which is also provided as a
friendlier README.html.  It requires FormEncode (I developed with
FormEncode 0.22, but I expect it will work with older versions).
Current features include default values, intelligent detection and
rendering of "required" fields, extensive facilities for customization
of the output markup, etc.  Mainly, I've tried to make it easy to use.

I'm a Cherrypy guy, and so aimed it at use with that; it should be
perfectly usable with TurboGears too (although its largely orthagonal
to the (problematic) way that TurboGears currently encourages you to
use forms).  Really, its usable with any framework that lets you access
form submissions as a python dict.

For a really quick intro, I've pasted the contents of a sample script
that uses formulaic below, along with the output that script would
produce.

Its nowhere remotely near finished, of course, but hopefully is at a a
point that it can be useful for real world work.  Questions,
suggestions, etc. are extraordinarily welcome.

Greg

example.py
-
#!/usr/bin/python

from formencode import validators
from formencode.api import Invalid

from formulaic import forms
from formulaic import basicwidgets as widgets

form = forms.RequirementsForm()
form.attrs['id'] = 'myform'

form['age'] = widgets.TextInput(validators.Int(), 'Age')
form['age'].attrs = {'size':'4', 'maxlength':'3'}

colors = ['Red', 'Green', 'Blue']
form['favcolor'] = widgets.Select(validators.OneOf(colors), 'Favorite
color', options=colors)

form['pie'] = widgets.CheckboxInput(validators.Bool(), 'I like pie')

inputs = {'age':'ten', 'favcolor':'Green', 'pie':'checked'}

try:
data = form.schema.to_python(inputs)
print data
except Invalid, error:
print form.render(inputs, error.error_dict)

-

output:



Age

Please enter an integer value

Favorite color

Red
Green
Blue


I like pie






-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Execute C code through Python

2005-10-20 Thread gsteff
import subprocess
subprocess.call("cmd")

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread gsteff
Er, meant to say  "In addition GTK itself is in the top tier of free
software projects"

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread gsteff
I've used wxpython and pygtk, and have a strong preference for pygtk.
wxpython has some advantages: it has better OSX support (widgets look
native, and it doesn't require the installation of the Fink x server),
and better win32 support (a few gtk widgets, such as menus, don't look
quite native on gtk, and multithreading with pygtk on win32 is
problematic).  But pygtk has better documentation, a MUCH cleaner api,
integration with the Glade GUI designer (wxpython has wxglade, but its
not in the same league), and a richer widget set.  In addition, top
itself is in the top tier of free software projects; wxwidgets is not
as mature, and its development is not as active.

So, if you're trying to choose between those two, go with wxpython if
you need OSX support, or have specific issues with pygtk's win32
support.  In all other cases, I'd reccomend pygtk.

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: line

2005-10-10 Thread gsteff
Why do you want to know?  This list isn't a tool to get others to do
your homework.

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-29 Thread gsteff
I'm a CS student, and I've been following this thread with great
interest, because we've been discussing the virtues of private
visibility ("information hiding") in one of my courses recently.  Does
anyone know of academic papers that make the case against "private" in
languages?

Greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a database. Sugestions?

2005-09-15 Thread gsteff
SQLite rocks, its definitely the way to go.  Its binary is around 250K,
but it supports more of the SQL standard than MySQL.  It CAN be thread
safe, but you have to compile it with a threadsafe macro enabled..
check out www.sqlite.org for more info.  The windows binaries
apparently are compiled with this option, but the Linux binaries are
not, so if you're on Linux, you'll have to compile it yourself, which
isn't hard.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Process monitoring

2005-05-29 Thread gsteff
Thanks- subprocess was exactly what I needed.  For anyone else that
reads this, I just launched a new subprocess via subprocess.Popen, did
what I needed to do in a while look, while calling the poll method of
the Popen object to check whether it was finished, and if so, what its
error code was.  Pretty simple.

-- 
http://mail.python.org/mailman/listinfo/python-list


Process monitoring

2005-05-19 Thread gsteff
Hey, I'm working on a Python program that will launch some other
non-Python process using os.spawn (in the os.P_NOWAIT mode) and then
basically wait for it to finish (while doing some other stuff in the
interim).  Normally, the new process will signal that it's done by
writing to a file, but I'd like to also find out if the new process
died unexpectedly.  Anyone know any preferrable ways to do this?

Greg Steffensen

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI toolkit question

2005-03-15 Thread gsteff
If you may need to port to another language, you'll probably want to
use a toolkit that helps you store the interface description seperately
from the code.  The example I'm most familiar with is libglade for GTK,
although I believe Qt and wx have analagous facilities.  I don't do 3D
stuff myself, but I'd guess that your best bet for that will be OpenGL.
 wxwidgets 2.1.14 and higher has an OpenGL canvas included with the
stock distribution.  OpenGL widgets also exist for GTK, and the
Trolltech website says that OpenGL functionality is included with
QT/X11, though I have no experience with this.  Others can offer more
informed advice than I can, but I'd probably reccommend Qt.  Very good
documentation, Qt designer rocks, and I'd trust their OpenGl stuff more
than the others.

Greg Steffensen

-- 
http://mail.python.org/mailman/listinfo/python-list