What would be the best way of separating program logic to the GUI code?
I wanted different GUI (GTK, KDE, CLI) code using the same program logic.
I was thinking of using different python module (winecellar-common, winecellar-gtk, winecellar-cli) not sure how I would do this and if its the best way.
*EDITED*
Just to add to my question what would be the best way to organize the projects file structure and build platform with different modules. Keep in mind its mainly being used on Ubuntu.
If you're new to creating GUI's in Python the basic steps are to: Import the Tkinter module: import Tkinter, top = Tkinter.Tk() Create the GUI main window that will “house” your GUI and widgets. Add whatever widgets your GUI needs including buttons, labels, lists etc.
Creating a simple graphical user interface (GUI) that works across multiple platforms can be complicated. But it doesn't have to be that way. You can use Python and the PySimpleGUI package to create nice-looking user interfaces that you and your users will enjoy!
3–wxPythonwxPython is a cross-platform GUI toolkit you can use to create robust, functional GUIs in a simple and easy manner. The implementation is a set of Python extension modules that wrap the GUI components of the wxWidgets cross-platform library, which is written in C++.
Define functions or classes for your business logic in one module, and define your presentation in another, using those functions to get your presentation. You should almost entirely be using functions and classes from the main module in the GUI module. You should do the same thing for your CLI. That way, you can have different distributions with different interfaces, and not have to create a different "logic" file for each one.
Basically, you have the right idea. Just keep them as separate as possibility so that a.) you can support multiple interfaces easily and b.) you can easily make changes to the interfaces.
Maybe "Model-View-Controller" pattern will be useful for you. There is a nice tutorial with wxPython on implementing this architecture: http://wiki.wxpython.org/ModelViewController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With