wxPython : change colour of a DataViewListCtrl item - python

I'm pretty new to building UIs, so I apologize if my question seems dumb in any way.
I'm currently building a small interface which aims at displaying a report depending on several entry parameters.
At first, I wanted the report to be shown through a wxListCtrl (LC_REPORT) but the problem I encountered is that I can't set the background or the font colour of a "Cell", I can only do it for the complete row. Maybe I'm mistaken tho.
Secondly, I found that I could show a report in a wxDataViewListCtrl, but I must admit I'm kind of lost within wxPython documentation (wxDataViewItem, wxDataViewItemAttr, etc).
Is there a way, once I built the report, to change some cells settings specifically?

You can definitely do what you want using the UltimateListCtrl widget. The wxPython demo even has an example of setting a single cell's background color to yellow. It looks like the items are of the following type: UltimateListItem. These have a _colour property that can be set.
The ObjectListView also might be a solution that is worth looking at: https://objectlistview-python-edition.readthedocs.io/en/latest/recipes.html#how-can-i-change-the-colours-of-a-row

Related

VTK Render Mouse Interaction (Python)

I want to visualize one or more STL file(s) using a vtk render viewport inside my application. I was able to get it all running with this example here: https://kitware.github.io/vtk-examples/site/Python/IO/ReadSTL/
My question is as follows: I have a mouse to control it and it is just unbelievable how bad default the controls of the camera are. It is almost impossible to get the model rotated intentionally or focus on a certain part. I am confused as I could not find any topic here or elsewhere discussing this. Normally I would read through other threads to find an answer, but there doesn't seem to be any. So, maybe you can point me to an approach or even certain functions of how I can change these settings, that would be really great! Basically I want to mimic the camera behavior of say, Paraview or a common CAD tool. Like zooming with mouse wheel, rotating with RMB and holding down the wheel to pan.
Some background on my project: I have written a python program and created a quite ok UI using tkinter. However, recently I was thinking of rewriting some basic parts of it and also upgrading everything visually and in terms of handling. So, I want to move to Qt widgets and, there shall be a VTK rendering viewport inside my application to show some of the stuff that can be interacted with.
I was able to find a solution in the tutorials. By explicitly defining the vtkInteractorStyle with
style = vtk.vtkInteractorStyleTrackballCamera()
The handling is just as I wanted it to be.

wxPython: control navigation within wx.Lisbook wx.Panels

world!
I'd like to ask you one question, a simple solution (I guess) for a nerve-wracking problem I'm encountering using a wx.Lisbook component of wxPython.
In fact, I want to switch from a wx.Panel to another fluently, withou requiring a user input. I've already tried the SetFocus(), Show()/ShowWithEffect() + Hide()/HideWithEffect() methods, without great results.
Show()/Hide() gives the better results, but the selected Thumbnail remains the previous displayed panel...
Any idea of the method or good practice to manipulate wx.Listbook?
Thanks very much by advance for your answers!
Patrice
You want to be able to switch between panels? You should check out the various "Book" controls in wxPython, such as the Toolbook, Notebook, AUINotebook, etc. I also wrote a tutorial that's just on switching panels using the menu:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
You could use a wx.Timer to do the switching too if you didn't want any user involvement.

tkinter forced indent

I am looking for help - I am updating my Tkinter wiki (http://sourceforge.net/projects/infolder/) trying to add to it some folding/outline capabilities.
For it to work I need to place in the text widget (the main window where all the action happens) some un-deletable symbol indicating folding (e.g. a small triangle image indicating hidden text lines).
Unfortunately I noticed from these Q&A's that undeletable stuff is not easy to create in Tkinter:
How can you mark a portion of a text widget as readonly?
unremovable text in tkinter
As a 2nd option, I could try to show folding levels by a forced indent, so that e.g. if I'm at a one-level deep, the start-of-line is not at column 1 but at column 5...
This is it possible in Tkinter, without too much work?
thanks for any help...
Your question says that undeleteable regions are "not easy", but you also show they are possible by linking to an answer that shows how. So, what question are you asking?
As for "forced indent", look at the lmargin1 and lmargin2 tag attributes.

Can I add a label to a single tool in a wxPython toolbar?

Does anyone know if it's possible to add a label to a single tool in a wx.ToolBar? I've found a global setting but no option to set it for a single tool.
I have a feeling that's a limitation of the native widget. It's an all or nothing affair. You could make the label a part of the image on the tool item though. Or you might be able to do it with FlatMenu which has a Toolbar widget equivalent that's written in pure Python, so you can hack it. See the wxPython demo for an example of its API.

How would you draw cell borders in a wxPython FlexGridSizer?

I'm new to Python, but I can't really find much decent documentation on the web, so I'm hoping somebody will know the answer or where the answer is...
I have a wxPython FlexGridSizer bound to a panel that contains other FlexGridSizers, I'd like to display some cell borders on the main FlexGridSizer, so each section looks encapsulated but I can't find any documentation to do it.
I tried using a panel to add to my main FlexGridView, with the panel's border on, but the panel's border doesn't always fill up the entire FlexGridView cell, so it looks choppy and uneven.
Does anybody know how to properly simulate this?
Sizers are used just to organize widgets spatially, as a matter of a fact they are 'invisible'.
I think you're on the right track with putting a panel inside each cell and turning on it's borders. Try adding it with wx.EXPAND flag, it has a chance to help.
Concerning documentation:
wxPython is essentially a wrapper (well, with few extras) for the wxWidgets C++ library, so virtually everything you need can be found in wxwidgets documentation.
I find this documentation browser useful. And here are some notes on interpreting C++ documentation for wxPython users, but usually everything is obvious enough.
Also for borders you might be interested in wx.StaticBox or wx.StaticBoxSizer (that etched-line box around a group of controls, often with a label)

Categories

Resources