I'm trying to create a Python implementation of Dawkins' biomorphs as described in his book, The Blind Watchmaker.
It works like this: A parent organism is displayed, as well as its offspring which are just mutated versions of the parent. Then the user clicks on a descendant it wants to breed, and all the offspring will "evolve" based on cumulative selection.
What I'm unsure of is how to get started in Python. I've already created genetic algorithm and l-system programs that are supposed to be used. The l-system program evolves trees given certain parameters (which is my goal in this biomorph implementation), and the genetic algorithm program evolves the genotypes that are created in the l-system program.
What library would be good to use (turtle, pygame, etc)?
I am familiar with turtle, but the documentation says, "To use multiple turtles an a screen one has to use the object-oriented interface." I'm not sure what that means. The reason I thought of using multiple turtles on a screen is to have the the parent and its descendants displayed on one screen, as they are in online apps. Then the user can click on the organism it wants to breed by using mouse events. Is this a good idea, or is there better way to do it?
Thanks in advance.
Depending on graphical requirements, I would say that for a lightweight app you could get away with PyQt or PyGame. For more demanding real-time graphical requirements you could use something like PyOgre or PyOpenGL.
You may need to also research graph-layout/data-visualisation algorithms or libraries (e.g. dot) depending on your UI goals.
Related
I have recently started learning python and decided that a fun way to learn would be to use pygame.
The following is some code that sets up the the window.
screen = pygame.display.set_mode((1200,800))
Would pygame be a file in which the file display is located?
I assume display refers to a file in which the method set_mode() is located.
If you already have a basic understanding of Object-Oriented Programming but are learning python through pygame, then Have a read through this tutorial: pygame - Setting Display Modes
Setting the display mode in pygame creates a visible image surface on the monitor. This surface can either cover the full screen or be windowed on platforms that support a window manager. The display surface is nothing more than a standard pygame surface object.
If you are starting to learn python and or programming from scratch, you might find more value in learning some basic programming and problem-solving concepts first, then come back to pygame.
I'm not affiliated but find the Hacker Rank 30-day challenge as a great learning tool, it is unique in tutorial sites as it is language agnostic and allows you to learn multiple languages at the same time if you wish to do so! It is also a good environment to learn in as there are fewer IDE features, forcing you to understand more before you can move on.
The average desktop IDE is not a great place to learn how to program because it will often have features like Intellisense, Autocomplete and other smart refactoring tools that allow us to write code quickly, but they allow you to "cheat" and skip over vital underlying mechanics that you need to understand if want to take advantage of abstract knowledge resources you may find around the web, like solutions in Stack Overflow!
Once you have a better understanding of syntax and how to use your chosen IDE, then go back to your pygame learning, walk before you run.
I need to create some program that will calculate some thermodynamics properties. I write on macos, python 3 because python has the necessary library.
So i have the problem with GUI. I learn and try to create simple grid for my application, but the actual behavior of the elements is very different from the one conceived (or doesn't work). I don't understand how to create right grid for my app. When i studied bootstrap, i needed one evening for understanding, and after that i could to create grid very easy, but here is hell.
Please help me. I want to understand how i need to create right grid system for my app
my Application layout:
I have made a pygame physics simulation--'a projectile motion' but it lacks interactivity like accepting angle of launch,speed etc. I am wanting to add input boxes with increase decrease arrows but don't know how to go about it. Thanks for the help.
Maybe you can try PGU (Phil's pyGame Utilities).
In addition to other tools, it has a library for creating GUIs.
This PGU demo shows probably something similar to that you are looking for:
Try Some of these:
http://wiki.wxpython.org/IntegratingPyGame
http://www.pygame.org/project-Pygame+embedded+in+wxPython-1580-2788.html
Good luck!
I don't think trying to add wx-Elements is a very pygame way of implementing a GUI, a better (in sense of portable) way would be to use some all-in-python-GUI-extention for pygame. But the issue of GUI in pygame is anoying, since I could not find any library that offeres such a thing.
I know of two interesting approches, first there is Albow (a little bit of widgetry for pygame), which has a nice implementation of styles. The newest Version (which is not very new, I'm afraid) can be found at http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/
Then there is OcempGUI http://ocemp.sourceforge.net/gui.html -- which has documentation and an some good concepts of event handling.
The sad thing is, both projects seem to be dead. I know of no other pygame-GUI that is worth looking at (correct my on that one, please!). For my own project I started to build something inspired by both of them (just don't expect that to ever become useable), since I'm not really content with either of the two. But they might by just the thing if you don't want to put too much time into it and want to have a good collection of GUI elements from labels and buttons up to file browsing dialogs or scrollable text fields.
I have a project where I have to show some sort of changing bar graph with results from a function. This bar graph should be in colour and 3d. I want it to look good since it's an open source educational program where it teaches the user about different voting systems and how they effect the outcome of an election. I would like to use python but I have no idea about using GUI frameworks since all my work in python has been command line based. Your help will be appreciated.
For 3D graphics, you might want to use OpenGL with a game framework, such as PyGame or Pyglet. Use matplotlib as TJD suggested in the other answer.
As for GUI frameworks, they generally won't help much with 3D graphics:
PyQt is one choice; I see you already have it in the question tags. PySide is very similar to PyQt, but with a nicer licence.
Then there's tkinter (in the standard library), wxPython, and pyGTK – I hear all of them are good, though I don't know them personally.
Pick one and stay with it. It'll take some time to learn if you're not experienced, so don't expect results too soon.
You might want to look at matplotlib, which is probably the most widely used library for doing graphs, including 3-D.
I am attempting to create my first OS-level GUI using wxPython. I have the book wxPython in Action and have looked at the code demos. I have no experience with event-driven programming (aside from some Javascript), sizers, and all of the typical GUI elements. The book is organized a little strangely and assumes I know far more about OS GUI programming than I actually do. I'm fairly recent to object-oriented programming, as well. I'm aware that I am clearly out of my depth.
My application, on the GUI side, is simple: mostly a set of reminder screens ("Turn on the scanner," "Turn on the printer," etc) and background actions in Python either in the filesystem or from hitting a web service, but it is just complex enough that the Wizard class does not quite seem to cover it. I have to change the names on the "Back" and "Next" buttons, disable them at times, and so forth.
What is the standard process for an application such as mine?
1) Create a single wxFrame, then put all of my wxPanels inside of it, hiding all but one, then performing a sequence of hides and shows as the "Next" button (or the current equivalent) are triggered?
2) Create multiple wxFrames, with one wxPanel in each, then switch between them?
3) Some non-obvious fashion of changing the names of the buttons in wxWizard and disabling them?
4) Something I have not anticipated in the three categories above.
I don't have a good understanding of your application, but trying to force wxWizard to suit your needs sounds like a bad idea.
I suggest checking out the Demos available from the wxPython website. Go through each demo and I bet you'll find one that suits your needs.
I've personally never used wxWizard as I find it too cumbersome. Instead, I create a sequence of dialogs that do what I need.