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/
Related
I wrote a function that receives input as a string, modifies it, and outputs a string. I want to make it so that my non-computer savvy friends can use it, by adding a graphical user interface. I want something very simple: A box where they type in the text, a button that along with hitting "Enter," submits the text, and then a place where it displays the result after my function had modified it. I just want a way to receive input and to write output to a GUI in a way that a regular person can understand. I have no experience with GUIs.
Update
In the end I used XCode to create the GUI and PyObjC to pass the data from GUI to Python in a sort of "frontend-backend" setup.
You may be interested to get a look at http://zetcode.com/
there is a bunch of tutorial about wxPython, PyGTK and PyQt
It should guide you.
Jordi
Does your program have to be python? (as tagged) Your description sounds like a very straightforward task. In that case, have you considered JavaScript + HTML? Your users wouldn't need to download and install anything new, and most people have a good grasp of how to create/use web page forms.
If you're committed to a python implementation: There are a variety of different GUI toolkits (ways of creating the graphical user interface), but which one you choose will depend on how you want your program to look, what operating system you run on, ease of programming, and a variety of factors.
The widgets you describe are fairly simple (text box and button), and you might be able to accomplish your goals using Tk / Tkinter, python's "de facto standard GUI". The advantage of this GUI toolkit is that it's bundled with python on most operating systems, hence (so long as your friends have python installed) they're ready to go. If you don't have experience building complicated installers, then you'll find that users wander off when you require them to install a dozen modules on their own. The TK script would also run on any OS.
Convenience aside, the disadvantage of Tkinter is that Tk is a fairly old and limited framework in the form commonly found with python, and it can be painful to work with for more complicated programs. (some of the online tutorials have typos like mixed case or missing quotation marks) For your task, though, the basic layout and code are pretty simple: see the TkDocs site for a demo that you can adapt.
http://www.tkdocs.com/tutorial/firstexample.html
If you are familier with C# , than you can use IronPython,
just import the Form libraries, make simple form, by putting Lable, Textbox and Button, and refer to that textbox value on Button click. you can get the WOW Gui for Python, with IronPython
Ref : IronPython
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.
i have quite a lot of experience with python and gst-python, but no experience with plain gstreamer.
does anyone know (well, someone on earth probably does but...) how to create a custom element? i got as far as
class MyElement(Element):
by intuition, but i have no idea what next...
simply what i was hoping for was a "replace this function with the thing you want to happen to every unit that this element is passed", but i am pretty certain that it will be FAR more complicated than that....
If you're creating a source element, you probably want to subclass gst.BaseSrc. Then, IIRC, the main thing you need to do is implement the do_create() virtual method. Don't forget to gobject.type_register() your class; you may also need to set the time format using set_format().
I second the recommendation to look at the Pitivi source code; it contains several GStreamer elements implemented in Python.
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!).
Screenshot
I'm looking to recreate this in Python; I can't find a library that seems to have what I need. Are there any GUI libraries that might possibly have this? - I have scoured wxWidgets (which is my preferred gui library) but they have nothing similar.
I have a script already that uses a standard wxTreeCtrl but it has no provisions for adding additional icons at the tail end like this screen shot.
If no pre-existing gui library exists, any tips for my first steps in trying to create it myself?
you have few options
Use wx.lib.customtreectrl.CustomTreeCtrl
AppendItem of CustomTreeCtrl can take any wx widget, which is shown at end, so you can use that to affect e.g. tree.AppendItem(root, "item1", wnd=yourImageControl)
Use wx.gizmos.TreeListCtrl, you can have icons in separate columns and tree in first column
You can use wx.lib.mvctree , and supply your own Painter class or derive class from TreePainter, and override Paint method
Or most complex but most satisfying way is to write your own tree control, and if you have long term usage for such a control and you may need more custom changes, it will be best way and won't be much difficult. See mvtree for inspiration or customize that.
Instead of CustomTreeCtrl, I'd look into HyperTreeList. It is based on CustomTreeCtrl, but adds support for multiple columns. I'm not sure if it supports multiple icons in one column out of the box though.