wxPython - Feedback while switching between panels - python

I have a splitter window with a list box on the left and a panel on the right. When I click on an item in the listbox, the panel changes to a panel that is specific to that item. Many of these panels look similar by design, and are all generated from the same class with settings taken from the item.
I would like to add some sort of feedback so the user can tell that something has changed. Something basic, like the panel switching to empty panel for a fraction of a second, and then switching to the new panel would suffice.
Do you have any suggestions on the best way to do this? Does wx have a feature that already handles this or something similar? Will I just have to do exactly what I outlined above, if so, if there a recommended time to display the blank panel? I could play around with timing to find what I feel is right, but I'm sure there has been studies into simple concepts like this. I may end up choosing a delay that is too quick and most users may miss it, but it may seem normal to me as I am the one testing it. I may prefer shorter delays so I can test more quickly, and my opinion will be biased.

Related

Why do people say "Don't use place()"?

I have been working on a note taking program for myself and it is going well however I have had a lot of problems with getting all my widgets placed where I want them using the .pack() or .grid() options.
After looking around I found that I could use the .place() option instead. Before I decided to use .place() I found countless forum post saying "don't use .place()!".
I was at a stand still with my other options so I decided to give .place() a try. It turns out .place() is exactly what I needed to fix my layout issues and I just don't understand why everyone is hating on .place() so much.
Is there something inherently wrong with .place()? Or do people just prefer to use .pack() and .grid() for some practical reason other than ease of use?
I'm not sure what evidence you have that says everyone says not to use place. I suspect if you're judging by stackoverflow posts, you're mostly reading my opinion a hundred times rather than a hundred different opinions.
I recommend against place mainly because it requires more work to make a UI that is responsive to changes in fonts, resolutions, and window sizes. While it's possible to write a GUI that uses place and is responsive to those things, it requires a lot of work to get right.
One advantage that both pack and grid have over place is that they allow tkinter to properly configure the size of the root and Toplevel windows. With place you must hard-code a size. Tkinter is remarkably good at making windows to be the exact right size without you having to decide on explicit sizes.
In addition, long term maintenance of applications that use place is difficult. If you want to add a new widget, you will almost certainly have to adjust every other widget. With grid and pack it's much easier to add and remove widgets without having to change the layout of all of the other widgets. If I've learned anything over years of using tk and tkinter is that my widget layout changes a lot during development.
place is mostly useful for edge cases. For example, if you want to center a single widget inside another widget, place is fantastic. Also, if you want to place a widget such that it is independent of other widgets, place is great for that too.
There's nothing really wrong with .place, although using grid and pack give you more maintainable code. If you want to add a feature then place would require you to alter loads of absolute placements to fit a button in, for example.
If you need to use it then use it, there's no real problem with it, it just isn't the most maintainable solution to many problems. As you say, it's a matter of preference and ease of use.
Edit: there's an excellent answer you can read about it here.

Alternative to wxStaticText in wxPython?

I have a problem in which I update StaticText fairly often(once every second) and every time it updates, it tears the frame. This is very bothersome on Windows but on Linux it never happened. I tried doing TextCtrl Readonly but I get ugly boxes around text I was wondering if there was a better option for updating text in wxPython frequently that wouldn't tear the screen. Thanks in advance!
I wish I understood better what you meant by "tearing" the frame - I don't seem to have problems with changing StaticText values after a window is created (though sometimes it's necessary to call Layout on a Panel or Dialog).
However, if you're really just looking for read-only TextCtrl's without the "ugly boxes" you should use TextCtrl(style = wx.NO_BORDER | wx.TE_READONLY). The combination will give you what you want - what appears to be a StaticText, but that can't be user-edited and doesn't display a border. You'll also be able to select its value (which may or may not be an advantage).

Place a button inside a grid

In a gui I have a grid. In this grid each row represents an order. To the right of each row, I would like to place a 'cancel button'to cancel the order. When new rows are added this should automatically come with a cancel button.
I did some seaching but apart from this FAQ-question which states that you have to design something yourself (did not help me much). Al other material was based on usage of Tkinter which I do not want to do.
So Two questions:
(1) Does anyone know of a way to place a button in a grid cell in wxpython?
(2) If not, does anyone know of a solution for my requirement?
Thanks,
Django
There isn't really a "built-in" way to do this. You would need to create a custom Renderer. According to Robin Dunn (creator of wxPython) in this thread, you could create a button using wx.RendererNative.DrawPushButton.
I would also recommend taking a look at the wxPython demo as it has some other examples of custom renderers too.

Swipe-Layout using PyGTK

I would like to implement a swipe or flipper view (widget) using PyGtk for my Quickly app. There should be a titlebar that contains the title of the currently showed content and the titles of the previous and next entry. To navigate threw the different entries you should be able to click the titles or swipe from left to right or vice versa.
But I do not know where to start.
Which Widget should I extend?
Would the Notebook widget the right choice?
How could I change the style of a Widget?
How do I implement the flip effect?
Do I have to combine different views (widgets) for the content pane and the titlebar?
For a better understanding of my problem view the screenshot below.
Thanks and best regards
Andreas
You might want to take a look at Clutter. Though I think, this kind of UI-Design could be very unintuitive on a desktop machine.

How to layout all children of a wxPanel?

I have a wxPython application which allows the users to select items from menus that then change what is visible on the screen. This often requires a recalculation of the layout of panels. I'd like to be able to call the layout of all the children of a panel (and the children of those children) in reverse order. That is, the items with no children have their Layout() function called first, then their parents, and so on.
Otherwise I have to keep all kinds of knowledge about the parents of panels in the codes. (i.e. how many parents will be affected by a change in this-or-that panel).
More in response to your comment to Jon Cage's answer, than to your
original question (which was perfectly answered by Jon):
The user might find it irritating, if the position of every element in
your dialog changes, when he makes a choice. Maybe it'll look better,
if only the "variable part" is updated. To achieve this, you could
make a panel for each set of additional controls. The minimum size of
each panel should be the minimum size of the largest of these
panels. Depending on the user's choice you can hide or show the
desired panel.
Alternatively, wxChoicebook might be what you need?
Have a look at wxSizers and some examples for a fluid way to layout forms.
You can specify heights, poportions etc. etc. and then let the layout code do the rest for you :)

Categories