Re: GUIs - A Modest Proposal

2010-06-07 Thread Simon Hibbs
On 6 June, 23:55, ant  wrote:

>If we are to make progress, I can see two obvious approaches:
>1) Improve Tkinter to the point where it is supportable and supported
>by a good fraction of Python programmers
>or
>2) Drop Tkinter as the default and use something else.

IIRC Guido has ruled out officialy adopting a full-bore GUI toolkit
such as WxPython or PyQT, or even a supercharged verison of Tkinter,
into the standard library. There are two main reasons. One is that
doing so would more than double the standard Python distribution's
disk footprint, to no advantage for non-graphical target systems or
developers wanting to use native GUI APIs. Another is that it wouldn't
make any of the other options go away, so e.g. if PyQT were chosen,
anyone wanting to use WxPython would have to install it as well,
creating even more bloat.

GUI toolkits are major projects with their own development cycles and
roadmaps that may not match with that of the standard library. They
are also still rapidly evolving. The standard library should only
contain stable, mature code bases. Furthermore the core Python dev
team have limited resources. Increasing the officialy maintained code
base by 2x or more just isn't supportable.

Tkinter is perfectly adequate for basic GUIs. If you want something
more sophisticated there are plently of high quality, well documented
alternatives to match your platform or functionality requirements.

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


Re: Generic spreadsheet interface

2010-02-12 Thread Simon Hibbs

Hi Bro, I don't know of anything like that. The spreadsheet sites I do
know of are application-specific.

http://www.python-excel.org/

http://wiki.services.openoffice.org/wiki/Python
http://lucasmanual.com/mywiki/OpenOffice

Note that the OO.o bindings for Python are only for Python 2.3 which
is a little archaic, but it's the version I started with and should be
more than good enough for spreadsheet work. A port to 2.5 is well
underway.

You'd probably need to write your own application-specific wrapper
modules with a common API and then use those, but it's probably not as
much work as it sounds and could be developed incrementaly.
Alternatively you just write your code against one spreadsheet module,
and then write a wrapper module for the other spreadsheet API  so it
looks the same.

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


Re: Problem with win32ui

2009-12-23 Thread Simon Hibbs
On 23 Dec, 11:10, Marc Grondin  wrote:
> On 22/12/2009 1:05 PM, Gabriel Genellina wrote:
>
> > En Tue, 22 Dec 2009 12:31:37 -0300, Marc Grondin 
> > escribi :
>
> >> Hello everyone,
> >> So i have been building an app with python(and learning as i go along) my
> >> knowledge of python is still kinda limited but the app work on my pc.
> >> I have
> >> also compiled it to an exe using py2exe and it also works fine this
> >> way on
> >> my pc(where python is installed) if however i try to run it from a pc
> >> where
> >> python is not installed i get this message:
>
> >> Traceback (most recent call last):
> >> File "printorders.py", line 2, in 
> >> File "win32ui.pyc", line 12, in 
> >> File "win32ui.pyc", line 10, in __load
> >> ImportError: DLL load failed: The specified module could not be found.
>
> > There is a missing DLL. Dependency Walker is a useful tool to solve this
> > kind of problems:
> >http://technet.microsoft.com/en-us/library/cc738370(WS.10).aspx
> > Once you know which DLL is missing, add it to your setup.py
>
> ok so that got me a little further. The app now works on win2k and
> windows 7 but on winXP i get this:
>
>   File "printorders.py", line 2, in 
>    File "win32ui.pyc", line 12, in 
>    File "win32ui.pyc", line 10, in __load
> ImportError: DLL load failed: This application has failed to start
> because the a
> pplication configuration is incorrect. Reinstalling the application may
> fix this
>   problem.
>
> Dependencie walker does not find any major issues. what am i missing here.
>
> thank you in advance for your help.

You could try and find out what the __load statement in line 10 in
win32ui.py does.

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


Re: python gui builders

2009-11-20 Thread Simon Hibbs
On 18 Nov, 22:11, Stef Mientki  wrote:
> Simon Hibbs wrote:
> > On 18 Nov, 07:51, sturlamolden  wrote:
>
> >> GPL
>
> > PyQT is GPL for now, but Qt itself is available under the LGPL as is
> > PySide. Eventualy PySide, which tracks the PyQT API, will supplant it
> > and the issue will be moot. For now it can be a problem, but PyQT
> > developer licenses are very afordable at only a few hundred dollars.
> > If a commercial project can't aford that, it's got problems.
>
> > Only you can know enough to make an informed decision. Wx does look
> > more usable than last time I used it for a project and is a fine
> > option too, for me though QT is the gold standard against all others
> > are measured, and generaly found wanting.
>
> > Simon Hibbs
>
> Wouldn't it be nice
> if each fan of some form of GUI-package,
> would post it's code (and resulting images) for generating one or two
> standard GUI-forms ?
>
> Then everyone can judge the differences,
> and see what's simple and not  so simple !!

I don't think a list like this is a great way to do that. There are
plenty of examples and tutorials available for each option.

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


Re: is there any FIX message handle modules in Python?

2009-11-19 Thread Simon Hibbs
On 19 Nov, 05:25, alex23  wrote:
> On Nov 19, 3:21 pm, "Stephen.Wu" <54wut...@gmail.com> wrote:
>
> > FIX message is the "Financial information Exchange" protocol
> > messages...
> > any 3rd libs we have?
>
> You mean like this one that was the first result when I googled
> 'python "financial information exchange"'?
>
> http://www.quickfixengine.org/

There are no prebuilt Python modules available based on quickfix, at
least that I'm aware of. It has Python bindings available, but you
have to complie it with them yourself from the C++ source.

Simon Hibbs


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


Re: python gui builders

2009-11-18 Thread Simon Hibbs
On 17 Nov, 23:25, Kevin Walzer  wrote:
> On 11/17/09 4:25 PM, Tim Daneliuk wrote:
>
> > +1 Tkinter for the simple stuff
>
> You can actually use Tkinter to do quite sophisticated GUI's that rival
> anything found in Qt or wx...

Neither Tkinteror Wx have anything that come close to QGraphicsView,
the Model-View-Delegate framework, the Phonon multimedia framework
integration, QtSQL, QtXML, QtSVG, and the many other first grade
components in Qt. You can substitute components from other frameworks,
e.g. for database access, but then you lose the integration QtSQL has
with the model-view-delegate features in other parts of the Qt world.

Qt is much more than just a GUI framework, it's more of a rival to
something like the MacOS development libraries, or the .NET framework
in terms of the library facilities it offers. I think that's why Nokia
bought into it. Qt provides them with a platform with the potential to
rival the iPhone dev environment.

Of course to take full advantage of it you need to invest in learning
it all, which is non-trivial. It comes at a cost in time and potential
lock-in. But the point is you can't just say Qt is just like Wx.

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


Re: python gui builders

2009-11-18 Thread Simon Hibbs
On 18 Nov, 07:51, sturlamolden  wrote:

>
> GPL

PyQT is GPL for now, but Qt itself is available under the LGPL as is
PySide. Eventualy PySide, which tracks the PyQT API, will supplant it
and the issue will be moot. For now it can be a problem, but PyQT
developer licenses are very afordable at only a few hundred dollars.
If a commercial project can't aford that, it's got problems.

Only you can know enough to make an informed decision. Wx does look
more usable than last time I used it for a project and is a fine
option too, for me though QT is the gold standard against all others
are measured, and generaly found wanting.

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


Re: python gui builders

2009-11-17 Thread Simon Hibbs
On 16 Nov, 10:06, me  wrote:

> What Python gui builder is well supported, does not require me
> to learn another framework/library, and can crank out stuff for
> multiple platforms ?

You're looking for a framework/library that doesn't require you to
learn it. OK

I've had this problem for a few years. I've tried PythonCard,
WxWidgets with WxDesigner, BoaConstructor, etc. None of them come
anywhere close to PyQT/QTDesigner.

Dion't get Blackadder It hasn't been updated for several years and is
a dead project. In any case it uses QTDesigner for GUI layout anyway.
You're better off using Eric or Wing if you want a decent IDE.

QT does have a learning curve of course, but you get a lot of power
back in return for the investment. I'm just coming to grips with it's
MVC framework and the book "Rapid GUI Programming with Python and Qt"
is very helpful with that.

I wouldn't completely dismiss Tkinter. It's too simple for complex
GUIs but I still think it has it's place for basic utilities.

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


Re: Choosing GUI Module for Python

2009-11-10 Thread Simon Hibbs
On 10 Nov, 10:40, Lorenzo Gatti  wrote:

> I also would like to use PySide, but unlike PyQt and Qt itself it
> doesn't seem likely to support Windows in the foreseeable future. A
> pity, to put it mildly.

It's not been ruled out. They don't officialy support the Mac either,
but according to posts on the mailing list a independent developer has
got it working in MacOS X at some level. Since QT runs on Windows,
porting to the Windows version of QT shouldn't be hard.

PySide is for the future, not the present, but it gives me a lot more
confidence in using and recomending PyQT to know that there is so much
work being put in to make sure it has a great future.

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


Re: Choosing GUI Module for Python

2009-11-09 Thread Simon Hibbs
Having tried most of the options out there, personaly I've settled on
two.

I use Tkinter for ver simple GUIs such as single dialog boxes or
results displays. The advantage of it being built-in to Python
outweighs it's limitations.

For anything more complex, I go for PyQT every time. QTDesigner is a
full drag-and-drop GUI builder that rivals Visual Studio, and PyQT
comes with a script to convert QTDesigner XML files into Python code,
which you then subclass in your own script and attach your own code to
the GUI widgets. There's a longer learning curve than Tkinter, but
it's very much worth it for access to QTs mature and rich framework,
with excellent professional-class documentation. Sorry, but wxWidgets
which I have used doesn't come anywhere close.

The main objection to using PyQT untill now was that for commercial
development you needed to buy a license (it was free for GPL
projects). That's rapidly becoming a non-issue as the core QT
framework is now LGPL and Nokia have a project underway to produce
PyQT compatible LGPL python bindings under the PySide project.

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


Re: Command parsing... best module to use?

2009-11-03 Thread Simon Hibbs
On 3 Nov, 01:14, Collin D  wrote:
> Thanks for the replies. Pyparsing looks just like what I need.

The cmd module in the standard library is fine for simple command
interpreters. Depending on your needs you might find it does what you
want. Doug Hellmann has covered it in his "Python module of the week"
series of articles.

http://www.doughellmann.com/PyMOTW/cmd/index.html

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


Re: how to modify row content of file in python?

2009-10-27 Thread Simon Hibbs
On 27 Oct, 07:55, holmes86  wrote:
> hi,everyone
>
> Is there function of modify row content in python? just like 'sed' in
> shell,thanks

You would do something like this, which acepts a CSV file from stdin
and sends the first column to stdout (prints it), which you could
redirect to a file or pipe to another command.

import sys

with infile = sys.stdin.readlines():
for line in infile.readlines():
columns = line.split(',')
print columns[0]


This code is not tested as Windows Explorer just crashed on my box
(effing windows - I'm at work so no Mac. *sob*).

One thing to look out for is that 'columns' is being created each time
through the loop, which works fine. If you modified the code to append
to it instead, you would need to create it before entering the loop as
you can't append to something that doesn't exist.


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


Re: Converting a PIL image object to a buffer

2009-04-02 Thread Simon Hibbs
On 2 Apr, 08:28, "Diez B. Roggisch"  wrote:
> Simon Hibbs schrieb:
>
>
>
> > On 1 Apr, 21:43, Gary Herron  wrote:
> >> Simon Hibbs wrote:
> >>> I'm trying to dump a snapshot of my application window to the
> >>> clipboard. I can use ImageGrab in PIL to get the screen data into a
> >>> PIL image object, which i have converted to a bitmap using ImageWin,
> >>> but when I try to pass this to the clipboard using -
> >>> win32clipboard.SetClipboardData(win32clipboard.CF_BITMAP, img)
> >>> It fails, telling be that "The object must support the buffer
> >>> interface".
> >>> How can I convert a PIL image into a buffer object? I can't find any
> >>> clues.
> >> PIL images have a tostring method that returns a string containing all
> >> the pixel data.  Would that help you to either create the needed
> >> buffer?  Or perhaps you could by-pass the need for a buffer, and just
> >> use the byte string.
>
> > If I use tostring I get a string which I can put on the clipboard, but
> > it isn't any kind of image. I can make a PIL image from the string but
> > them I'm back to square one again.
>
> Did you actually try that? Strings support the buffer interface, and the
> type of the binary data you set should be defined by the first argument.
>
> Alternatively (if the string is not of the proper format), maybe storing
> the image to a (c)StringIO-object as BMP and retrieving it's value would
> help.
>
> However, I think your concerns about "wasting memory" when using a file
> are moot - creating an extra memory buffer isn't less memory consuming,
> and if the file is living only a few seconds it might not even actually
> hit the disk at all. In the end, the important thing is the working
> clipboard.

Yes I did try this, the code to dump the sting version to the
clipboard worked, but pasting it back out wasn't possible although I
could print them to the console.

I don't mean wasting memory, just that actualy hitting the file system
and creating a file seems as though it shouldn't be necessery. Is
there any good reason why you can't just create an empty buffer object
or file object directly? It seems like an unecessery restriction,
unless there's some underlying reason such as that it's hard to
implement in c, which seems implausible. Sorry, that's a rhetorical
question.

I've not had a chance to work on this today, if I find an elegant way
round it I'll post the results for future googling.

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


Re: Converting a PIL image object to a buffer

2009-04-01 Thread Simon Hibbs
On 1 Apr, 21:43, Gary Herron  wrote:
> Simon Hibbs wrote:
> > I'm trying to dump a snapshot of my application window to the
> > clipboard. I can use ImageGrab in PIL to get the screen data into a
> > PIL image object, which i have converted to a bitmap using ImageWin,
> > but when I try to pass this to the clipboard using -
>
> > win32clipboard.SetClipboardData(win32clipboard.CF_BITMAP, img)
>
> > It fails, telling be that "The object must support the buffer
> > interface".
>
> > How can I convert a PIL image into a buffer object? I can't find any
> > clues.
>
> PIL images have a tostring method that returns a string containing all
> the pixel data.  Would that help you to either create the needed
> buffer?  Or perhaps you could by-pass the need for a buffer, and just
> use the byte string.

If I use tostring I get a string which I can put on the clipboard, but
it isn't any kind of image. I can make a PIL image from the string but
them I'm back to square one again.

I suppse I could save the image object to a real file and then send
that to the clipboard, but that seems wasteful and I'd have to worry
about what to call it and where to put it. Much neater if I could just
create it in memory somehow.

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


Converting a PIL image object to a buffer

2009-04-01 Thread Simon Hibbs
I'm trying to dump a snapshot of my application window to the
clipboard. I can use ImageGrab in PIL to get the screen data into a
PIL image object, which i have converted to a bitmap using ImageWin,
but when I try to pass this to the clipboard using -

win32clipboard.SetClipboardData(win32clipboard.CF_BITMAP, img)

It fails, telling be that "The object must support the buffer
interface".

How can I convert a PIL image into a buffer object? I can't find any
clues.

Help appreciated,

Simon Hibbs


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


Re: A little bit else I would like to discuss

2009-02-13 Thread Simon Hibbs
On 13 Feb, 02:53, azrael  wrote:

> All I hear when I talk to people who own or eork in SW companies is
> "Python? Isn't that that small scripting language. This will never
> bring a real application." I am tired of hearing this. Even Microsoft
> implemented Python. Only because the GUI building I am thinking about
> of moving to IronPython. But this great comunity holds me bac on
> CPython.

I don't agree at all that Python can't compete with Visual Studio for
GUI development. There are Python modules for Eclipse if you need an
enterprise class IDE. For GUI design the PyQT GUI toolkit includes QT
Designer - a fully featured graphical GUI builder every bit as capable
as the one in Visual Studio. In fact I much prefer working in QT
Designer for GUI layout, the Signals/Slots model for hooking up to the
application  logic is just so much more elegant and robust.

If Eclipse is a bit heavyweight for you, and you're after a Pyhton
equivalent to VB, I can't recommend Eric enough. It's a Python IDE
written in Python using the PyQT toolkit, and integrates directly with
QTDesigner. IMHO it's far superior to anything Microsoft has to offer,
with full native support for MacOS X, Linux and Windows.

The only fly in the ointment in licensing. The QT toolkit will be
fully GPL and LGPL from version 4.4, but PyQT itself has a dual GPL/
commercial licensing structure. Still, it's relatively cheap and well
worth it if you're goingt to do commercial development.

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


Re: Python OOP advice

2008-09-17 Thread Simon Hibbs
Great contributions, thanks both of you. I'm self-tought when it comes
to Python and OOP and I haven't yet grown an intuitive feel for how to
do things sensibly.

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


Python OOP advice

2008-09-17 Thread Simon Hibbs
I'm rewriting a design application for a science fiction game. in it
you design your own starships. Each component has a mass and cost, but
the mass can either be fixed or it can be expressed as a percentage of
the tonnage of the overall ship.

Orriginaly I thought I'd need to have a hull object which contains
component objects, but the component objects need access to members of
the hull object (e.g. the hull size) so that looks messy to implement.

I have defined a base class Component with a class member variable
'hull_size' so that all components can see the hull size. I've then
got two child classes called Fixed_Component and Percent _Component
that implement their mass, mass_percent and cost properties
appropriately for their type. I've also defined a Hull class which
also inherits from Component and provides methods for access to the
hull_size class variable.

I'm not sure where to go from here. One possibility is to have a Ship
object containing a list of components, but I'd need to have a way to
ensure there's only ever one hull object so maybe that shouldn't go in
the list?

I think the fact that the hull_size is a class member also means I
can't ever have an application that loads two designs at the same
time, because they'd share the same hull_size class variable. Is that
so, and is there a way round that? I suspect the inheritance model
will work fine at first, but is too rigid in the long run.

Is there a way to cleanly implement a parent-child relationship
between objects that gives child objects limited access to members of
the parent?

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


Re: creating color gradients using PIL

2007-11-23 Thread Simon Hibbs
On 21 Nov, 06:30, Ramdas <[EMAIL PROTECTED]> wrote:
> Any ideas how we can create a color gradient using Python Imaging
> Library. Has any got some sample code that can give me some idea. I
> need to create a horizontal and vertical color gradient for a college
> project
>
> Thanks

I use these functions for building PIL images from numpy arrays

# Convert a 2-d array with typecode 'b' to an image with mode 'P'
def numpy2pil(arr):
rows = arr.shape[0]
cols = arr.shape[1]
m = arr.tostring()
out = Image.new('L', (cols, rows), 999 )
#out.fromstring(m)
out.fromstring(m, 'raw', 'L', 0, -1)
return out

def pil2numpy(im, typecode='b'):
# tostring does something funny with '1' images (packs em
tight).
# For 'P' images, the image data is not pased through the
palette.
if im.mode != 'L' and im.mode != 'P':
print 'im.mode must be "L" or "P"'
raise 'terminate'
xsize = im.size[0]
ysize = im.size[1]
m = im.tostring()
t = fromstring(m, 'b')
tt = asarray(t, typecode)
# Note that ysize is first:
return reshape(tt, (ysize, xsize))

im = numpy2pil(myarray)
im.putpalette(palette_list)
im.save('myimage.png')

You'll need to import numpy and Image. You'll need to generate the
palette (juust a list) and image array (a numpy array) of course.

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


Re: python safe scripting

2007-11-23 Thread Simon Hibbs

> > 2007/11/21, Vladimir Rusinov <[EMAIL PROTECTED]>:

> Yes, but apache, nginx and others does not uses logger.
> I wanna write an application which would handle all my (Linux) logs:
> rotating, compressing, analysing and so on (logrotate replacement), it would
> require some nontrivial configuration, something like "If size of this log
> bigger then 2Mb or today is sunday. If size of this log bigger then 30 Mb,
> and today is not sunday, then rotate it, and make alert".
> Is there any module to parse such configuration files?

I don't think there's a module for this. Those kinds of tests are
fairly easy though.

import datetime, os

filename = 'myfile.log'
if (datetime.date.today().weekday() == 0) or (os.stat(filename)[6] >
200):
do.whatever()

The individual tests would be better wrapped in utility functions of
course.

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


Re: Using python to create windows apps that everyone can use?

2007-09-19 Thread Simon Hibbs
 On 9/18/07, Thomas Harding <[EMAIL PROTECTED]> wrote:

 > Hi guys, sorry to post another topic on this, as I am aware that it
has
 > already been posted a few times, but not with specifically what I
am looking
 > for. I want an app that makes a gui interface for python (similar
to
 > Microsoft visual studio or qt designer, not a code based one) and/
or an app
 > that can make this into a .exe that can be opened by any person on
any
 > computer without python installed.

For windows only, there's always Iron Python. This allows you to use
Visual Studio, the commercial or the express version, to create the
GUI in VB or C# and from that call Python code that does all the heavy
lifting.

I'd second the recommendation for QtDesigner if you want cross-
platform capability.

Simon Hibbs

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


Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Simon Hibbs

Sorry, here's the tutorial link:

http://hetland.org/writing/instant-python.html


Simon Hibbs

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


Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Simon Hibbs
Chris,

I can fully relate to your post. I trained as a programmer in the 80s
when OOP was an accademic novelty, and didn't learn OOP untill around
2002. However now I find myself naturaly thinking in OOP terms,
although I'm by no means an expert - I'm a sysadmin that writes the
occasional utility. I found learning OOP with Python very easy because
it has such a stripped-down and convenient syntax.

The advantages of OOP aren't in performance or memory, they're in the
fact that OOP simplifies the ways in which we can think about and
solve a problem. OOP packages up the functionality of a program into
logical units (objects) which can be written, debugged and maintained
independently of the rest of the programme almost as if they were
completely seperate programmes of their own, with their own data and
'user inteface' in the form of callable functions (actualy methods).

Here's a realy excellent tutorial on Python that's fun to follow.
Downloading and installing python, and following this tutorial will
probably take about as long as it took to write your post in the first
place. At the end of it you'll have a good idea how OOP works, and how
Python works. Learning OOp this way is easy and painless, and what you
learn about the theory and principles of OOP in Python will be
transferable to C++ if you end up going in that direction.

I hope this was helpful.

Simon Hibbs


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


Re: Creating a distro of python... What would you include in it?

2007-05-30 Thread Simon Hibbs
On 30 May, 16:25, [EMAIL PROTECTED] wrote:
> I am creating a distro of Python to be licensed as GPL am
> wondering, what would anyone suggest as to 3rd party modules being put
> into it (non-commercial of course!)? I know I'd put MySQLdb into it at
> the very least. Any suggestions?

What you put in it will depend on what it's for.

Which platforms will you support? Many Linux distros already provide
comprehensive package management systems, so developers on those would
probably be better off using the native package manager unless you're
offering something distinctive.

Does your distro target a particular developer community, such as web
developers, database developers or desktop developers? These
communities have very different requirements, but then again if you
target web developers do you include Turbo Gears, or Django or both?
Do you include an ORM and if so which one?

If you can clarify what you are trying to achieve, or what
defiiciencies in the existing distros that you're finding limiting
then that would realy help. Super-distros can definitely have a place.
In fact that's exactly what TurboGears is, but it has a very clear
mission statement and adds significant value of it's own. It also acts
as an add-on to the standard distro rather than an alternative and I
recommend you consider that strategy.


Simon Hibbs

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


Re: I need some tips to begin a simple project

2006-09-19 Thread Simon Hibbs
> PyGame is in it, right?

Python comes with a basic GUI toolkit called Tk with basic stuff such
as buttons, text and graphics widgets, menus, etc.

PyGame is a seperate package that you can download that makes it fairly
easy to create games. There are also additional libraries that make
PyGame programing even easier.

Having said all that, Python isn't magic. I'd recommend doing something
simple first, such as a calculator or a text editor. These are very
easy to do, but will cover the basics of creating a user interface,
manipulating data and accessing files.

Simon Hibbs

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


Re: python vs java

2006-09-06 Thread Simon Hibbs

Aravind wrote:
> hi,
>
> some of my friends told that python and java are similar in the idea of
> platform independency. Can anyone give me an idea as i'm a newbie to java
> and python but used to C++. My idea is to develop an app which can run both
> in windows and linux.

That's true to an extent. Both Java and Python come with extensive
standard libraries, providing a useful toolkit for the programmer.
Python does have a number of cross-platform GUI toolkits abailable too,
including one in the standard library, although WxWidgets (formerly
WxWindows) is also popular.

I'd say that Python is easier to learn and more productive as a
language, but Java has a much larger selection of add-ons and libraries
available. I can't give you much more help without knowing what the app
will do, and therefore what language features or library/framework
support would be helpful.

Simon Hibbs

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


Re: Make Object Oriented?

2006-08-10 Thread Simon Hibbs
I can't even vaguely concieve of how such a think could work, even at a
trivial, hypothetical level. The code converter would ahve to actualy
understand at a general level what the program does and how it does it,
then come up with an orriginal way to solve the same problem using a
different methodology.

As to the simple case, even here, the converter would have to make
inteligent decisions. Which methods and properties should it move to
the base class, and which should it keep local? What criteria might it
use for making such a choice? How could you be sure that the decisions
it made would be useful or appropriate?


Simon Hibbs

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


Re: Borg vs. Module

2006-08-01 Thread Simon Hibbs

Jordan R McCoy wrote:

> For example, the Twisted framework uses this technique to allow global
> access to the installed reactor via import syntax, which works well
> within the framework. It did, however, throw me a bit when I first
> encountered it, and drove me to pour over the source to find out what
> was happening.

It sounds to me like this was a case of poor code commenting in Twisted
(Iv'e not looked at it myself). It seems to me this is a useful trick,
but like any unusual or clever bit of coding it's use should be
carefully commented to make sure it's clear to anyone coming across it.

Simon Hibbs

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


Re: Pickle vs XML for file I/O

2006-08-01 Thread Simon Hibbs

I've recently gone through a similar evaluation of my options for
persisting data. Object serialization to pickles or XML is a very easy,
quick way of persisting data but it does have drawbacks. I'm not a
professional developer, so if there are errors in my analysis, I'd love
to be corrected.

Suppose you make some changes to the object format - adding some new
attributes or properties. Suddenly your existing test data is useless.
At least with XML you can edit the files by hand to add dummy data, but
with pickles that's not an option and even with XML it's a painful and
error prone process.

Idealy you need to be able to browse and edit your saved data outside
the main program, to scan for errors, fix them manualy and easily
update your data structure as the application data model grows and
changes.

There are good reasons why relational databases are the default data
store for many professional applications because you can parse and edit
the data very easily using external tools. Personaly I'd go with
SQLite. It's soon to be a part of the Python standard library with 2.5
and is very compact. It can be a lot more work than just serializing
automaticaly, but there are toolkits such as SQLObject and SQL Alchemy
that can automate this as well.

Best regards,

Simon Hibbs

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


Re: Paste text across multiple text boxes

2006-07-25 Thread Simon Hibbs
This link seems to have some relevent code.

http://lists.wxwidgets.org/archive/wxPython-users/msg07340.html

Simon Hibbs

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


Re: About Embedding PyWin or wxPython

2006-07-25 Thread Simon Hibbs

Have you considered IronPython?

This is of course only an option if you're prepared to code in VB.NET
or C# instead of VB6 or Delphi, but it would provide seamless
integratioon between your Python code and the rest of your app and
would not require an external graphics library - although you would
need to distribute the .NET and IronPython runtimes.

Multiple-language and library integration is after all what .NET is all
about.


Simon Hibbs

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


Re: dicts vs classes

2006-07-25 Thread Simon Hibbs
I'm wondering about whether to use objects in this way or dictionaries
for a program I'm writing at the moment. It seems to me that unless you
need some of the functionality supplied with dictionaries (len(a),
has_key, etc) then simple objects are a syntacticaly cleaner and more
natural way to express yourself.

Any objctions to this, or pitfalls?

Simon Hibbs

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


Re: Project organisation

2006-07-19 Thread Simon Hibbs
If a particular project requires slightly different functionality from
the classes in Utils.Py one way would be to import Utils.py and then
either monkey-patch or subclass the classes you need to extend or
modify for that project.

That way you will have no effect whatever on the other projects.

Simon Hibbs

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


Re: TextCtrl focus events in wxWidgets

2006-07-19 Thread Simon Hibbs

Frank Millman wrote:

> Try self.PlantCtrl.Bind(wx.EVT_KILL_FOCUS, self.OnUpdatePlantCtrl)

And Voila! It works. Many, many thanks.

Any idea what is going on?

Simon

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


Re: TextCtrl focus events in wxWidgets

2006-07-19 Thread Simon Hibbs

Simon Hibbs wrote:
> rony steelandt wrote:
> > Since the event handler of a textctrl inherits from wxCommandEvent,
> > I would guess that the binding should be to EVT_COMMAND_KILL_FOCUS
>
> Still not working :(

I can trap EVT_TEXT_ENTER events successfuly, without using
EVT_COMMAND_ENTER. This almost gets me where I want to be. The user
must press 'enter' after modifying each value though. If they forget
the UI isn't updated, so I'd need some way of visualy distinguishing
between modified values that have been ENTER'd and those that haven't
which is a pain, and not very user friendly at all.

There must be some way of doing this, but blowed if I can figure it
out.

Simon

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


Re: TextCtrl focus events in wxWidgets

2006-07-19 Thread Simon Hibbs

rony steelandt wrote:
> Since the event handler of a textctrl inherits from wxCommandEvent,
> I would guess that the binding should be to EVT_COMMAND_KILL_FOCUS

Still not working :(

Simon

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


Re: TextCtrl focus events in wxWidgets

2006-07-19 Thread Simon Hibbs

Steve Holden wrote:

> It should be quite simple: you need to handle EVT_SET_FOCUS and/or
> EVT_KILL_FOCUS events (documented in the wxPython docs) to know when to
> recaclulate the values. Sounds like that should be enough of a hint to you.

I've tried that, but it doesn't work. Here is the test code:

self.PlantCtrl = wx.TextCtrl(self, -1, "")

self.Bind(wx.EVT_KILL_FOCUS, self.OnUpdatePlantCtrl,
self.PlantCtrl)

def OnUpdatePlantCtrl(self, event):
print "set Plant"

When the control loses focus, I don't get the message in the console.
I'm trapping other events successfuly elsewhere using similar code.

Simon Hibbs
.

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


TextCtrl focus events in wxWidgets

2006-07-19 Thread Simon Hibbs
I have a simple form with some input values and some calculated values
in TextCtrl widgets.

What I would like to do is have the display update automaticaly when
the user changes one of the input fields, without having to click on a
'Calculate' button. I was thinking of having an update triggered when
one of the text Controlls loses focus, indicating that the user has
finished changing it's value.

I don't want to do an update on every character entry, as this would
create a lot of bogus/meaningless updates. There doesn't seem to be
such an event. Any ideas how I could implement this, or a similarly
user friendly behaviour?

Best regards,

Simon Hibbs

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


Re: New SourceForge project: Diet Python!!!

2006-07-19 Thread Simon Hibbs
I was reading an article about the One Laptop Per Child initiative the
other day, and being a Python fan I wondered if there are any plans to
put Python on it, or at least make it available. A cut-down version of
python, preferably with bindings to the Sugar GUI framework they are
developing, would be a Very Good Thing.

They're planning on manufacturing 100 million of these things!

Simon Hibbs

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


Re: Newbie

2006-07-13 Thread simon . hibbs

So far I've mostly used it for writing short text file re-formatting
scripts. Previously I would have used Perl, but I find Python much more
readable and maintainable for this sort of thing, and only very
slightly more verbose.

I'm currently writing a play-by-mail game turn processing engine using
Python, SQLite and wxPython. It's easily my most ambitious project so
far.

Simon Hibbs

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


Re: Data access from multiple code modules

2006-07-13 Thread simon . hibbs

Bruno Desthuilliers wrote:

> Separating operations on data (model/controler) from GUI code (view).
> The controler(s) have a reference on the model. The views have a
> reference on the controler(s), and call on the controller to get data to
> display or act on data.

So I instantiate a Model object that handles all IO to the database.
Next I instantiate a Controller object, passing it a reference to the
Data/IO model object. Next I instantiate the display panel objects for
the GUI, passing them references to the Controller object.

The Controller object contains the logic for all the transformations I
want to perform on the data.

Simon Hibbs

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


Re: Data access from multiple code modules

2006-07-13 Thread simon . hibbs

Bruno Desthuilliers wrote:

> Do you mean the code effectively doing these operations is in the gui ?
> If yes, it would be better to factor it out IMHO.

The GUI has to be able to acces the data object, otherwise how does the
user affect any changes to the application data? If I modify a value in
a text box and hit Apply, that change must be propagated to the data
model somehow. Similarly, the GUI must access the data to display it.

Actualy this has nothing to do with code modules. The problem is is you
have one object that contains your data, and your app consists of
several objects that need to interact with it, how do these other
objects access it? I'm fairly new to OOP and Python so I don't know
it's scoping rules very well.

Simple example:

One way would be to use the database as the point of contact for all
the object. Every object that wants to read or write to the database
instantiates an object to interact with the database and performs
whatever actions it needs. That way each top-level objecyt will contain
it's own instanced database IO object. Their only point of contact with
each other is the database itself. This could lead to synchronisation
problems though.

Another way would be to create one instance of the database IO object
and then pass it as a parameter to the other application objects when
they are created. The point of contact between the application objects
would be the single database IO object, with the  database behind it.
This seems to me to be the superior approach.

Are there any other architectural options that anyone could suggest?

Simon Hibbs

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


Re: Data access from multiple code modules

2006-07-12 Thread simon . hibbs

Jeremy Jones wrote:

> What does main.py do?  Are you creating an instance of the gui thingy?
> If so, you could just pass DataObject into your gui thingy either into
> the constructor or to a setter once you create an instance of it.

It's a wxPython app. I created the GUI initialy using wxGlade which
gave me a small myapp.py script, a file containing the main application
frame (containing a listbook controll) and several files containing
panel classes. Each panel class contains controlls for performing
various operations on the data set (adding records, deleting them,
running various transformations). I can't say I understand how it all
works at a deep level, although I've been hacking it about quite
successfuly so far.

Presumably if I pass DataObject through to the Frame object, and from
there through to the Panel objects then presumably this will solve the
probelm? I guess it would be passed by reference so all the panels
would be working on the same data object?

Doh! How simple. Why didn't I think of that? I'm too used to procedural
scripts where you'd just put everything in a global data structure. I
know this is bad, but it's hard to get out of that mentality.

Many thanks,

Simon Hibbs

P.S. Regular reader of your blog on Oreillynet.

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


Data access from multiple code modules

2006-07-12 Thread simon . hibbs
Lets say that I have an application consisting of 3 files. A main.py
file, gui.py and a data.py which handles persistent data storage.
Suppose data.py defines a class 'MyDB' which reads in data from a
database, and main.py creates an instance of this object. How does code
in gui.py access this object? Here's simplified pseudocode:

MAIN.PY
import gui, data
DataObject = data.MyDB(blah)

How do I write code in gui.py that can access DataObject? Is this
entirely the wrong way to approach this sort of problem?

Actualy the problem is more complex because the GUI consists of a main
GUI form, and panels defined as seperate objects in seperate files.
Various panels will contain controlls for manipulating data in the
DataObject, or wherever data storage end up.


Best regards,

Simon Hibbs
(who strugles to get his head round this OOP stuff sometimes).

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


Re: listener program in Python

2006-05-12 Thread simon . hibbs
[EMAIL PROTECTED] wrote:

> I basically want to remotely shut down windows from linux and write
> such a program in python.

You probably don't need to write a service in windows for this. All you
need is to write your Linux python program with an SNMP library and
configure the Windows box to accept SNMP calls to shut down. Frankly
I'm not 100% sure how to do this. You'd have to enable the SNMP Agent
on Windows, and probably the "Force shutdown from a remote system"
system policy would have to be changed.

The O'Reilly book "Python programming on Win32" explains how to write
Windows services and do basic networking. This article explains one
way: http://tinyurl.com/ezjx7

Simon Hibbs

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