Is it possible, and if so, how(links, tutorials) to use XRC to load aui-elements?
I want to create a somewhat advanced interface for a program, without wanting to do everything in-code.
Greetings
I don't think XRC supports AUI (either the C++ or the pure Python version found in wx.agw.aui). However, you should be able to mix XRC items with AUI. See http://wxpython-users.1045709.n5.nabble.com/xrc-aui-toolbar-problem-test-attached-td2344498.html
Basically you just create the frame and other items that ARE supported in XRC and then add the AUI code on top.
Related
I'm now practicing with Gtk by developing a file manager application similar to Thunar, and I simply can't figure out how to make the IconView items flow vertically instead of horizontally, like in Thunar or Nautilus' Compact View mode, as well as in Windows Explorer's List View Mode. Should I use TreeView istead?
I'm practicing in Haskell bindings, the Gtk2Hs, but I'm also familiar with native C library and Python bindings (PyGtk), so explanations using these languages are also acceptable.
It finally seems that IconView has not such a feature right now, as Thunar uses its own control from libexo, while Caja/Nautilus use their own controls from other libraries.
How I can write an OpenGl application using Enthought Framework? I created a TasksApplication and I am stuck on this tutorial, I don't know what I can use instead PythonEditor there. I need to create something where I will be able to render.
UPDATE:
I changed the code to
def create(self, parent):
widget = GLWidget(parent)
self.control = widget
Where GlWidget is implemented like in this example.
And I have a runtime crash. But I am able to run the GL script from the example above.
UPDATE2:
Log file
UPDATE4:
Code was updated according to #Robert Kern suggestions. Now it works.
Min Example
MinExample 7z
The control trait of a TaskPane is just the Qt widget object that you are using. In the example that you link, we happen to be getting it from another PyFace widget that wraps a Qt widget in a similar fashion, so we just grab the control attribute from it. You should just directly use a QGLWidget as the control of your pane. Please consult the Qt documentation for how to use it. You can use PyOpenGL in the paintGL(), etc. methods to do the actual rendering.
I am just starting to learn Glade with pyGTK. Since Glade makes XML files instead of actual python code, is there a good way to start a project with Glade and then hand code more or tweak it?
Are there times or reasons it would be preferrable to hand code all of it instead of starting with glade?
GUI's created with glade are accessible in the code in two way: libglade or gtkbuilder. I cannot comment much on the differences between the two, other than that gtkbuilder is newer; there are a lot of pages on google that show how to migrate from libglade to gtkbuilder.
Using gtkbuilder, you can create your GUI object by retrieving it from the the XML file using gtkbuilder. This creates the object with all of the settings you set in glade. You now have an GUI object which you can manipulate via it's regular interface.
builder = gtk.Builder()
builder.add_from_file(glade_path)
builder.connect_signals(self)
main_window = builder.get_object("main_window")
main_window.show()
text_box1 = builder.get_object("textbox1")
text_box1.set_text("enter your name")
Line 3 shows how signal handlers are attached when loaded from glade. Essentially, it looks for the function you specified for the signal in the glade interface and attached to it; if the function isn't provided, you'll see a warning on the command line.
How much do you know about glade and pygtk? Glade creates xml files but you load these using gtk.Builder in python. You can easily tweak any widgets you created with glade in python. Read these tutorials to understand how to do it better. You just need to learn more about pygtk and glade and it will be obvious.
I'm writing a simple OSX app using Python and PyObjC. I designed the settings dialog using Interface Builder and I use ibtool to compile it, then load it from Python. The problem is how to access the controls I have in this window from the Python code? I played around with iPhone development a bit before and I remember I need to have an IBOutlet in the controller class which will be connected to the UI control in the interface builder. It should look something like this in Python:
class MyClass(NSObject):
my_outlet = objc.IBOutlet('my_outlet')
But since I'm not working in XCode (all I have is a .py file and a .xib file), Interface Builder doesn't know about my outlets. How can I do the binding in this case? Or how else can I access the UI elements from the code?
First, the use of Xcode or not has nothing to do with NIB loading (beyond making it more convenient).
As Ole said, you can use IB to manually add the outlet's you need to file's owner or to the custom object instances that you have in the NIB file. By doing so, it will all "just work".
However, this statement is what prompted my relatively similar answer:
all I have is a .py file and a .xib
file
Are you trying to write a bit of UI code outside of a .app wrapper? If so, that is a wholly unsupported pattern, very difficult to get correct, and quite likely to break across software updates or major releases (as it has many times in the past).
The best way to solve your problem is to use an Xcode project and build a standard application. The templates are no longer shipped with the dev tools. Just download them separately.
If you need to run it from the command line, you can still do so.
I haven't tried this, but you can also define outlets directly in IB. Open the Library panel, select Classes in the segmented control at the top and select your custom class you want to define an outlet for. Let's say you have a NSWindow subclass called MyWindow. Select the NSWindow class in the list, click on the action button at the bottom left, select New Subclass... and name it MyWindow. Now switch to the Outlets tab and create a NSButton outlet for your window. Now you connect a button to the outlet.
I don't know how this will transfer to PyObjC but I'd love to see your results when you try it out.
I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to implement it all myself. If there aren't any tools to help with this advice would be greatly appreciated.
edit I am not trying to recreate explorer, that would be madness. I simply want to be able to take icons and lay them out in a scrollable window. Any number of them may be selected at once. It would be great if there was something that could select/deselect them in the same (appearing at least) way that Windows does. Then all I would need is a list of all the selected icons.
Python has extensions for accessing the Win32 API, but good luck trying to re-write explorer in that by yourself. Your best bet is to use a toolkit like Qt, but you'll still have to write the vast majority of the application from scratch.
Is there any way you can re-use explorer itself in your project?
Updated for edited question:
GTK+ has an icon grid widget that you could use. See a reference for PyGTK+: gtk.IconView
In wxPython there's a plethora of ready-made list and tree controls (CustomTreeCtrl, TreeListCtrl, and others), a mixture of which you can use to create a simple explorer in minutes. The wxPython demo even has a few relevant examples (see the demo of MVCTree).
I'll assume you're serious and suggest that you check out the many wonderful GUI libraries available for Python.