simple wxpython mysql example

hi ,
i'm looking for a wxpython mysql working example can any body send me alink to a working tutorial or send me a working example
thanks in advance
regards
hatem gamal

There is no real connection between wxPython and MySQL. wxPython is the GUI. It is really the connection between Python and MySQL that you want to understand.

If you Google “python mysql” you should find plenty of examples. Then, getting information displayed in or out of the GUI is just a matter of using methods like .SetValue() or .GetValue() with, for example, a wxTextControl.

If you want to follow best practices, apparently the way to go is to use MVC (model, view, controller) design, but i haven’t bothered with that so far.

-Che

···

On Sat, Apr 16, 2011 at 2:11 PM, hatem elzanaty shang5000@gmail.com wrote:

hi ,

i’m looking for a wxpython mysql working example can any body send me alink to a working tutorial or send me a working example

thanks in advance

Hi,

hi ,
i'm looking for a wxpython mysql working example can any body send me alink to a working tutorial or send me a working example
thanks in advance

wxPython is not having any db support out of the box, so you need some other stuff.

- Python dbapi module for your database
- then you need to "enable" the different wxPython widgets to work with the db. I used a validator approach which in turn uses widget.Change/SetValue and widget.GetValue or similar (e.g. a bit different for listctrls, comboboxs etc.

I would strongly suggest to also look at/use SQLAlchemy. When using its ORM you can write your code independent to the actually database used, so by just changing the connection string you can switch to a different database backend.

http://www.sqlalchemy.org/docs/07/

http://wiki.wxpython.org/FrontPage?action=fullsearch&context=180&value=data+aware&titlesearch=Titles

You might also want to look at Dabo - http://www.dabodev.com/

I don't have sample code for mySql, as I think there are better db's out there (Firebird SQL, PostGresSQL) but I guess it depends what you want to do. I'll send you off list my sample/test code using SQLAlchemy 0.6 which works with SQLITE (included with Python 2.5+?) or Firebird SQL.

Werner

···

On 04/16/2011 08:11 PM, hatem elzanaty wrote:

1 Like

I had the same question and was wondering if you’ve found anything along those lines?

The way I’m reading your question, you are describing a use case with MySQL and WxPython, with no expectation that WxPython has any built in support.

wxPython does not have direct support for any database. That said, the link provided by Werner is helpful. You can write your own using the data_aware link. Or you should take a look at dabo. I have used Dabo for many years and it works just fine. Dabo now supports wxPython 4.x.x and python 3.x. Should you choose to use Dabo and have any issues - just contact me. To download the latest use


then switch your branch to ‘dabo3’
Johnf