How do I bring a PyGTK Button to the front? - python

I have a gtk.Table to which I've attached a number of gtk.Buttons, some of which overlap others. I can't figure out how to bring a specific button to the front, however. How do I do it?

I've struggled with an issue similar to this, and came to the conclusion that it wasn't possible in an officially documented manner... gtk.Table doesn't seem to have been designed to deal with the idea that things might overlap. Widgets seemed to be rendered in an order related to (but not exactly) the order they were added into the table.
What I ended up doing was determining which widgets were overlapping, and wrote code to toggle their visibility, depending on which one was appropriate for the current state. That was only possible because of the particular nature of my app, it might not work for you.
One avenue which I didn't research to far, but might be viable: intercepting the expose event on the gtk table, and propagating it to the children in a specific order (this got complicated quickly, but might work). My understanding of the gtk.Widget events is incomplete, there may be other events that need intercepting as well.

You could try to use the Clutter toolkit, I believe this is more suitable for putting widgets on surfaces that you can then animate and move around. It's also built on the same technology as GTK, so it won't be too unfamiliar.

Related

How to combine Python logic and Qt C++ GUI

I was presented with a Python logic and a GUI written in C++ Qt and asked to combine them. Before I choose the route of re-implementing the GUI in e.g. PySide, I would like to know which way would be the smoothest to achieve such a combination. Would I rather make the C++ GUI available to the Python logic (and a controlling layer) or the other way around?
I will gladly provide more information, if necessary. My problem is a lack of experience in that matter and that there are so many solutions of how to make code of one language accessible to the other, that I feel a bit smothered in options.
In this case, the Python logic is actually just a (too large, but that's another topic) class which provides some signal processing methods.
This is a crisp rephrasing of a prior question, which I somewhat clumsily posed, and therefore missed its aim.

How to properly create a multi-page gui in wxpython

I'm very new to wxpython, so this is probably an obvious question.
Let's say I wanted to create a program like an installation wizard which, when next is clicked, destroys the current set of widgets and creates a new set. However, the user must also be able to go back to a previous page.
Would I need classes for each page with their own __init__, could I just use a normal function, or is there a better way to do this?
There are a couple of valid approaches. The most obvious would be to just use wxPython's built-in wizard which can be found in wx.wizard. You might want to take a look at the documentation, the wiki or the wxPython demo for examples. You might also find this tutorial helpful:
http://www.blog.pythonlibrary.org/2011/01/27/wxpython-a-wizard-tutorial/
Of course the wizard is a bit limited, so if you needed something that gives you more flexibility, then you might want to look at rolling your own wizard. If you went with that approach, then yes, you would probably benefit from creating a base Page class that holds your assortment of widgets. Then as each page is shown, you can either Hide the previous page or Destroy it. Personally, I would just go with hiding it unless you had a lot of widgets per page.
This tutorial might help you get started down this path:
http://www.blog.pythonlibrary.org/2012/07/12/wxpython-how-to-create-a-generic-wizard/

How can I have a Macro like recording feature for PyQt

I have a Qt tablewidget and other Qt widgets adjoining it. What I am looking for a Automatic script generator that records all the actions that I would perform on the table or other Qt widgets. I had also worked with Enthought and they have a wonderful apptool enthought.scripting that helps me with the same but only for traits objects. I would like to do the same on PyQt widgets but dont know how.
This is one of those ideas that seems so natural, it makes you wonder why there isn't already a library out there that does it.
Well, it turns out that writing something that gets you 80% of the solution is pretty straightforward, especially if your app is small. But implementing a recording/playback system that works for a large app with a diverse array of widgets is quite a pain.
I wrote a library that does its best to solve this problem. It's full of hacks, and the code is still very immature (I just pushed the repo to github today), but you might get some ideas. Heck, if you're lucky, you might even be able to use it without any changes:
https://github.com/stuarteberg/eventcapture
There's no documentation yet. I plan to explain all the tricks to get this working, and probably clean up the code a bit. For now, you can at least get started by trying the demo as described in the Readme.
You could use the eventFilter method from your QApplication instance.

python GUI compared to Swing?

I wanted to say "best python GUI compared to Swing"... but was sternly told my question was "too subjective". I apologise to the deterministic ghost in the machine.
I'm currently using Jython... have been using it for maybe 6 months now following years of Java. I love Jython's ability to call on all the Java classes, and also to ease the transition from a Java way of doing things to a Python way.
But thinking about it I realise that by far the most common Java packages I'm using are the Swing ones. I have spent many years wrestling with Swing and finally think I have the beast under some kind of body-lock. I also think Swing is wonderful, by the way, and I have to say that I am something of a keyboard fanatic, for example, so wouldn't want to switch to a GUI where you don't have power akin to that lurking in ActionMap-InputMap, which maybe not many people care that much about. It would also be a shame really to turn my back on JTree and JTable, having spent so much time tearing out what was left of my hair about them. Seriously, they are fiendishly powerful...
But at the same time I'm fast becoming hooked on the Python way of doing things. I can and intend to stick with Jython. But I was just wondering what the various CPython GUIs are like... and specifically how their power and versatility compare with Swing?
added:
I have been asked to provide some specifics: OK, what about a tree GUI object sitting on a scroll pane where it is possible, if you want to, to control navigation and collapsing/expanding of nodes using the keyboard... where the scrolling happens automatically (if you want it to) and where you have control over look and feel, etc. Or tables where you have comprehensive control over resizing, over what happens when individual cells gain/lost focus. Where you can subclass renderers and editors. As I said in my comment, someone who is/was keen on, and a big user of, Swing but nonetheless made a transition to a CPython GUI and was happy/unhappy... might be the ideal person to answer this.
I never done much with Swing, but Qt (and its bython bindings, PySide or PyQt4), matches all of your criteria as far as I can understand them.
Qt focuses on doing things as it's customary on the underlying OS. So the most obvious thing to do is usually the “right” thing to do, but if you want control you can go and override the look or behavior.
As for the pythonic way of doing things... The bindings are getting there. They still feel somewhat C++-ey, to be honest.
Also read some other questions on comparison between the two.
I think Python has many toolkit for GUI.
Java has Swing. If you want to develop
cross-platform friendly GUI,I suggest
wxPython.

What are the existing open-source Python WxWidgets designers?

What are the usable tools?
I am aware of wxformbuilder and wxGlade, but none of them seems to be complete yet.
Here are a few of the most popular wxPython related GUI builders:
Boa Constructor (mostly dead)
wxGlade
wxFormBuilder
XRCed
wxDesigner (not FOSS)
Dabo - one of their videos shows a way to interactively design an app...
I personally just use a Python IDE to hand code my applications. My current favorite IDE is Wing.
I've been looking for them too and sadly I've come up empty handed. I used to like Boa Constructor and PythonCard back in the day but both projects seem to have stalled. There is an attempt to get PythonCard going again # http://trac.medianix.org/wiki/Pycard ; the site was down when I checked last but the mailing list seemed moderately active. Dabo's another actively-developed option.
afaik... none. I'll follow the answers to see if someone has one and try it of course but I'm not convinced this will be THAT useful. When using wxPython, you usually work with sizers (at least I think the results are better) so you don't really need to "place" the controls on the frame and I think a GUI "design" would be longer to do. The only part where I think it could have some interest is to fill atributes for the controls but a good auto-complete with wx (or a good cheat sheet or a "template class" with all the options you use) solves the problem in my opinion. I stopped seeking for a GUI designer for wx after trying Pydev that auto-completes wx very nicely (a lot better than everything I tried before... and that's a lot!).

Categories

Resources