473,836 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enthought python - Traits

Ash
Hello everyone !

I am trying to find some sort of a cookbook or more examples for using
Enthought Traits to build GUI's. I tried to follow the documentations
present at the enthought site, but couldnt get too far - especially on
how to handle a control event ?

Also while i am on the topic:

say i have a list "control" that create using the following two lines:

class Project(HasTrai ts):
coordinate_syst em=Enum('Cartes ian','Cylindric al')

I added the following line to get the option selected by the user:

def _coordinate_sys tem_changed(sel f,old,new):
print 'System changed from %s to %s ' %(old,new)

but it does not return what the user select. It should return either 0
or 1 based on the two choices, but i can't seem to find a way to trap
that.
I am relatively new to this GUI programming in Python and really could
use some tips/hints.

Thanks,

-Ash

Oct 12 '06 #1
2 3692
Ash wrote:
Hello everyone !

I am trying to find some sort of a cookbook or more examples for using
Enthought Traits to build GUI's. I tried to follow the documentations
present at the enthought site, but couldnt get too far - especially on
how to handle a control event ?
The traits manual is in the lib/site-packages/enthought/traits/doc
directory, named Traits2_UM.doc/.pdf. The traits UI manual/user guide
is also in there. However, what is not so obvious is that there is
also an excellent, massive set of powerpoint slides (121 pages) that
Dave Morrill put together that talks about the architecture of Traits
UI, and how to build GUIs using it. (Er, how to build them *well*,
i.e. adhering to the M-V-C pattern and maximizing code reuse.) Those
slides are in traits_ui.ppt.
say i have a list "control" that create using the following two lines:

class Project(HasTrai ts):
coordinate_syst em=Enum('Cartes ian','Cylindric al')

I added the following line to get the option selected by the user:

def _coordinate_sys tem_changed(sel f,old,new):
print 'System changed from %s to %s ' %(old,new)

but it does not return what the user select. It should return either 0
or 1 based on the two choices, but i can't seem to find a way to trap
that.
The way that this works is that _coordinate_sys tem_changed() gets
called with the old value and the new value of self.coordinate _system.
Thus, it doesn't "return" anything; your method is a "handler" method
that gets called when the value of a particular trait gets changed.

Why do you say it should return 0 or 1? Do you mean that you want to
get the index into the list of enumeration choices? The Enum trait
type is not quite like C in this regard. In C/C++, enums are really
ints; in traits, enums are lists of values of possibly mixed type.
I am relatively new to this GUI programming in Python and really could
use some tips/hints.
No problem, hope the above helped. You might want to email your
questions to en**********@en thought.com (and subscribe to it!). That
is the primary mailing list for several enthought libraries (including
traits) and you'll get very speedy, in-depth answers to your questions
there.
-Peter

Oct 12 '06 #2
Ash
Thanks Peter .. I will check out the mailing list. In the meanwhile - i
have made some progress. Now working out - how to get a button_fired
event to actually return the values ..

It's a process (as always..)

Cheers,

-A
Peter Wang wrote:
Ash wrote:
Hello everyone !

I am trying to find some sort of a cookbook or more examples for using
Enthought Traits to build GUI's. I tried to follow the documentations
present at the enthought site, but couldnt get too far - especially on
how to handle a control event ?

The traits manual is in the lib/site-packages/enthought/traits/doc
directory, named Traits2_UM.doc/.pdf. The traits UI manual/user guide
is also in there. However, what is not so obvious is that there is
also an excellent, massive set of powerpoint slides (121 pages) that
Dave Morrill put together that talks about the architecture of Traits
UI, and how to build GUIs using it. (Er, how to build them *well*,
i.e. adhering to the M-V-C pattern and maximizing code reuse.) Those
slides are in traits_ui.ppt.
say i have a list "control" that create using the following two lines:

class Project(HasTrai ts):
coordinate_syst em=Enum('Cartes ian','Cylindric al')

I added the following line to get the option selected by the user:

def _coordinate_sys tem_changed(sel f,old,new):
print 'System changed from %s to %s ' %(old,new)

but it does not return what the user select. It should return either 0
or 1 based on the two choices, but i can't seem to find a way to trap
that.

The way that this works is that _coordinate_sys tem_changed() gets
called with the old value and the new value of self.coordinate _system.
Thus, it doesn't "return" anything; your method is a "handler" method
that gets called when the value of a particular trait gets changed.

Why do you say it should return 0 or 1? Do you mean that you want to
get the index into the list of enumeration choices? The Enum trait
type is not quite like C in this regard. In C/C++, enums are really
ints; in traits, enums are lists of values of possibly mixed type.
I am relatively new to this GUI programming in Python and really could
use some tips/hints.

No problem, hope the above helped. You might want to email your
questions to en**********@en thought.com (and subscribe to it!). That
is the primary mailing list for several enthought libraries (including
traits) and you'll get very speedy, in-depth answers to your questions
there.
-Peter
Oct 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1700
by: Donald 'Paddy' McCarthy | last post by:
Hi, I am having a few problems with a GUI. I am new to traits and wxGlade. I have used wxGlade to create a Form with an embedded space for a CustomWidget. I have the traits demo and would like to edit the traits and have the traits form appear instead of the space left for my CustomWidget. wxGlade produces code with the following hook (last line):
3
7372
by: RMJ | last post by:
After installing Enthought's python and typing 'python' from within cygwin the program hangs with no output. I do not remember this being the case with earlier versions of Enthought python. Is this version not compatible with cygwin? Or, is there some configuration file that needs changing? It does run successfully with 'python somecode.py' -but without printing out intermediate results. Thanks! -Roger Jones
1
1561
by: Oh Kyu Yoon | last post by:
Hi! I have been using the python 2.3.3 distribution from Enthought Inc because it has most of the libraries I use included. Does anyone know when Enthought will release the python 2.4 distribution? Thanks. Ohkyu
0
3754
by: skscpp | last post by:
What's wrong with the following code? Compiler error is at the bottom. The compiler I am using is gcc version 2.95. ============================= // traits.h ============================= #include <vector> #include <list> #include <set> #include <functional>
12
2448
by: Mark A. Gibbs | last post by:
Good day, What is the safest way to get a non-end of file value? char_traits<char_type>::eof() will get me eof, but how can I safely and consistently generate a value that is not eof? should i use ~char_traits<char_type>::eof()? char_traits<char_type>::int_type()? char_traits<char_type>::eof() + 1? while(!char_traits<char_type>::not_eof(char_traits<char_type>::int_type(rand())))? mark
18
2763
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning from the experts. I feel there's a tradeoff between clear, easily readdable and extensible code on one side, and safe code providing early errors and useful tracebacks on the other. I want both! How do you guys do it? What's the pythonic way? Are...
6
3285
by: jadamwilson2 | last post by:
Hello, I have recently become interested in using python for scientific computing, and came across both sage and enthought. I am curious if anyone can tell me what the differences are between the two, since there seems to be a lot of overlap (from what I have seen). If my goal is to replace matlab (we do signal processing and stats on physiological data, with a lot of visualization), would sage or enthought get me going quicker? I realize...
0
1447
by: Christopher Brewster | last post by:
I have always thought this idea very good, but if I download it and install it (on my MacBook pro) will any conflicts occur with existing bits and pieces of Python and its libraries? Thank you, Christopher Brewster ***************************************************** Department of Computer Science, University of Sheffield
0
1411
by: Guido van Rossum | last post by:
Hey Travis, Congratulations with this release! Are you guys thinking of Python 2.6 yet, now that it's been released? --Guido On Tue, Oct 21, 2008 at 2:53 PM, Travis Vaught <travis@enthought.comwrote:
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9656
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10819
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10526
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9349
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7771
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5811
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.