I've been learning GTK3 on my own and I'm now stuck on Gtk.DrawingArea. As with most widgets and functions in GTK, there seems to be a lack of updated documentation and tutorials on this. For reference as to what I've found(hopefully this will help some other lost googlers), lazka's auto-generated documentation has been my best resource:
http://lazka.github.io/pgi-docs/Gtk-3.0/classes/index.html
However the drawing area page has no methods described.
http://lazka.github.io/pgi-docs/Gtk-3.0/classes/DrawingArea.html
This leads me to believe that I have a fundamental misunderstanding of GTK and this widget, but I can't find anything explaining how to work with it! The only tutorials I could find were these, but they are all for older versions;
1: http://www.pygtk.org/pygtk2tutorial/ch-DrawingArea.html
2: http://www.gtk.org/tutorial1.2/gtk_tut-23.html
3: http://www.pygtk.org/pygtk2tutorial/sec-DrawingMethods.html
3 is best of these tutorials, but I can't seem to get it to work in GTK3, and honestly its pretty advanced. Several things are also deprecated and the replacements seem to be pretty cryptic and are unclear how they work with DrawingArea:
http://lazka.github.io/pgi-docs/Gtk-3.0/classes/Widget.html#Gtk.Widget.set_style
The official tutorial doesn't have a section on it, and hasn't been significantly updated in a long time:
http://python-gtk-3-tutorial.readthedocs.org/en/latest/objects.html
https://github.com/sebp/PyGObject-Tutorial
My question now is whether someone could help me understand how to draw with Gtk.DrawingArea? Is there a gtk3 tutorial out there?
My goal at the moment is to automatically draw black points on a drawing area based on an algorithm's output, and display the results. I would show my code but I barely have anything.
You basically connect to the ::draw signal and draw in the handler using pycairo. And use queue_draw/queue_draw_area() if you want to redraw.
See http://zetcode.com/gfx/pycairo/basicdrawing/ for examples
Related
I have a Bokeh image made with patches onto a google map as background.
http://giove.units.it:5000
Is there a tool (or javascript code) to hide/unhide the background ? and is there way to save in png the background too ?
thanks
As of Bokeh 0.11.1 (and soon to be 0.12) there is no mechanism to hide the map portion. It seems like a reasonable feature though, an probably not terribly difficult to implement. I encourage you to submit a feature request on the project's GitHub issue tracker.
There might be some roundabout ways to do what you want currently, by setting map_options from a JS callback or something. But figuring that out would take discussion and experimentation and iteration, and StackOverflow is not very good for that kind of thing. I encourage you to bring the question to the project's public mailing list where more of a back-and-forth dialogue is possible.
I would like to create a "custom widget" in QtDesigner4 for matplotlib widgets.
I'm familiar with getting matplotlib widgets in QtDesigner3, and I have little problem manually coding the widget in Qt4. I'm not entirely sure how to do this the new way that QtDesigner handles custom widgets.
There appears to be some documentation, but I thought I'd ask if someone else has coded a solution before I attempt to do so myself.
I believe there is a matplotlib widget for qtdesigner4 (for windows) packaged with python(x,y).
I have never used it myself, but I found some discussion on how to use it here.
If you do have any luck with this, it would be great if you considered answering your own question with a detailed walkthrough!
HTH,
There is a solution in chapter 6 of "Matplotlib for Python Developers". Check out the book's supplemental code.
I'm looking to design a (very) basic GUI for a battleship game.
As suggested in another question, I was going to use Tk's check buttons and coordinates and pass the value and so forth.
I'm having a tough time finding a decent start-up tutorial for Tkinter. I've tried Google and went through several results to little to no avail. Though I'm pretty experienced with Python, I've never done any GUI (other than lightly with Xcode). If anyone knows any good resources, I'd really appreciate it.
"Programming Python" by Mark Lutz has a chapter on GUI's.
The tkinter page on the Python wiki has links to tutorials as well.
tkdocs.com has a tutorial that covers tkinter (as well as using tk with Ruby, Perl and Tcl).
For what you need I suggest you look at the canvas widget
There are several resources: e.g. - http://www.techrepublic.com/article/tkinter-canvas-freeform-guis-in-python/6310698 or http://effbot.org/tkinterbook/canvas.htm
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.