database and gui help

Hi all
Im building a simple database app and Im running into some simple but
annoying problems.ive attached the relevant code here, along with a
sample database.
Here are the problems -
1. when you select a machine you can enter new values in the text
control widgets and then press save to save the values in the
database. However this happens only once.The second time, if i select
another machine and enter new values in the text control boxes the
update doesnt happen.
2. the second time I enter data into the text control boxes, when i
click on the txtcontrol widgets the previous value I had entered is
shown.
3. theres another button called new machine. this is to enter a new
row of data in the database. It works fine.But I want it to immedietly
update so that when i click ok and come out into the main panel page,
i get the new machines id also in the choice box. Right now when i
have to close the app and then reopen it to get the values in the
choice widget

Ok thats it!
any help would be appreciated
thanks
Harsha

database.rar (3.05 KB)

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Harsha,

Hi all
Im building a simple database app and Im running into some simple but
annoying problems.ive attached the relevant code here, along with a
sample database.
Here are the problems -
1. when you select a machine you can enter new values in the text
control widgets and then press save to save the values in the
database. However this happens only once.The second time, if i select
another machine and enter new values in the text control boxes the
update doesnt happen.
2. the second time I enter data into the text control boxes, when i
click on the txtcontrol widgets the previous value I had entered is
shown.
3. theres another button called new machine. this is to enter a new
row of data in the database. It works fine.But I want it to immedietly
update so that when i click ok and come out into the main panel page,
i get the new machines id also in the choice box. Right now when i
have to close the app and then reopen it to get the values in the
choice widget

Ok thats it!
any help would be appreciated
   

The things I changed.

- database connection is only created once on start up (pretty expensive operation and normally you don't want to open/close this all the time)
- widgets should only be created once and then use Set/GetValue to update the values in the widget. You created them again and again on the choice selection, this was your real problem.
- switched to use sqlite3 which is included as of Python 2.5 in the standard lib

Changed stuff attached in harsha.zip.

I also included a db sample application I did some time ago using sqlalchemy. It depends on sqlalchemy (0.5.8 http://www.sqlalchemy.org/, should work with 0.6. but not sure) and objectlistview (ObjectListView — ObjectListView v1.2 documentation), maybe that gives you some ideas.

You should probably also look at Dabo which is a framework based on wxPython which provides database enabled widgets.

Werner

harsha.zip (3.26 KB)

dbsampleSAnew.zip (262 KB)

···

On 16/05/2010 10:02, harsha sunder wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Werner
thanks for the reply.Ive changed the things youve mentioned. I havent
got all the modules needed to run your demo. Apart from the two you
mentioned sqlalchemy and objectlistview, do i need anything else to
run the demo?

Cheers
Harsha

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

···

On 16/05/2010 13:12, harsha wrote:

Hi Werner
thanks for the reply.Ive changed the things youve mentioned. I havent
got all the modules needed to run your demo. Apart from the two you
mentioned sqlalchemy and objectlistview, do i need anything else to
run the demo?
   

No, that should be it.

What error do you get when you try to run it?

Werner

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I get
   import pkg_resources
ImportError: No module named pkg_resources

which means no sqlalchemy..
another question - i want to create a table for each day. So if i have
a variable called day, is it possible to directly pass that variable
into create table (variable) .. ?

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I get
    import pkg_resources
ImportError: No module named pkg_resources

which means no sqlalchemy..
   

Oops, I install SA in multi version so I need that, if you installed it as a single version then you can just comment lines 4 - 6 in model.py and it should work.

another question - i want to create a table for each day. So if i have
a variable called day, is it possible to directly pass that variable
into create table (variable) .. ?
   

A table for each day!? I would think that this should be a column within your table, unless you have huge amount of data per day (millions of rows!).

Werner

···

On 16/05/2010 18:28, harsha wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en