Button Transition - python

I am programming wxPython with GUI aid from pythonCard. The resource editor has made short work of my display so far.
The GUI has static boxes "cards" with information that the program outputs. I would like to transition to a different page on button click. So for example, clicking on ok should take me to page 2 (separate resource file).The complexity is I don't want to open up a new window for each click as I have 20 buttons.
I have 10 cards with same properties so on click i only want to change the particular and still be on main page however go to page two for particular card. Visually think of windows 8 tile and on click it flips to reveal more information.
Is this possible in wxPython? If so, how could i go about it?

It sounds to me like you want a Notebook or similar "book" control. The wxPython demo details the various book controls that wx supports. Or you might want to just swap panels, which is pretty easy to do as well. Here's a tutorial I wrote on the subject a while back:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
And here are a couple links on notebooks and similar controls:
http://wxpython.org/docs/api/wx.Notebook-class.html
http://wiki.wxpython.org/Simple%20wx.Notebook%20Example
http://www.blog.pythonlibrary.org/2012/07/18/wxpython-how-to-programmatically-change-wx-notebook-pages/

Related

Change the position of specific buttons at GtkHeaderBar?

I am creating a desktop recording program, I am designing the interface using Glade, and I am using GtkHeaderBar and client-side decoration.
This is what I have as an example: Example interface
My question is: How can I move the about button - for example - to be after the title text, so that I get 3 buttons before the title, and 1 after it, just like GNOME applications?
I Googled and got to gtk-decoration-layout, but couldn't find a real way to use it (Seems it will be system-wide if used).
gtk-decoration-layout is for the minimize/maximize/close buttons. You want pack_end() instead of pack_start(). If you're using glade, it'll be under the Packing tab when you select the given child.

Keep menu up after clicking in wxPython

I am using wxPython to write an app. I have a menu that pops up. I would like to know how to keep it on the screen after the user clicks an item on the menu. I only want it to go away after the click off it or if I tell it to in the programming. Does anyone know how to do this?
I am using RHEL 6 and wxPython 3.01.1
I don't think the regular wx.PopupMenu will work that way. However if you look at the wxPython demo, you will see a neat widget called wx.PopupWindow that claims it can be used as a menu and it appears to work the way you want. The wx.PopupTransientWindow might also work.

Python and Pygame inspiration and best practice

Sorry for not being very specific in this question, but I don't know where else to ask.
I have a Raspberry Pi which I will try to use in a car computer project. I have got the tip to use Pygame to write the interface.
I'm not really familiar to python or pygame but i have quite experience in PHP, HTML and C# and VB against winforms.
In this case I will have a menu to the right with lets say 5 "tabs". How would I think when doing this? Should I think PHP/HTML and have a file for every tab page and here then load header and background and stuff, and some how link to every *.py file (if that's even possible)? Should i think more of JS and ajax to use a surface (a "div") to display my pages in, depending on the selected menu?
I've spent an evening playing around and what I suppose i have to do is something like this:
//Set up the layout
//Add a surface for Tab 1 (tab1Layout.py)
//Add a surface for Tab 2 (tab2Layout.py) - set invisible
//Add a surface for Tab 3 (tab3Layout.py) - set invisible
//Add a surface for Tab 4 (tab4Layout.py) - set invisible
//Add a surface for Tab 5 (tab5Layout.py) - set invisible
//Add the menu to the right (menu.py)
//Start the pygame loop
//Listen for events in the menu (menuEvents.py)
//Listen for events in tab 1 (tab1Events.py)
//Listen for events in tab 2 (tab2Events.py)
//Listen for events in tab 3 (tab3Events.py)
//Listen for events in tab 4 (tab4Events.py)
//Listen for events in tab 5 (tab5Events.py)
Am i on the right track here?
Do you guys know any good tutorials or other libraries for doing this kind of stuff? I do not wanna load X or something like that.
Any good tips of tutorials or know any similar projects where I can study the code for this?
So, slightly hard to know exactly what you want. However I would like to champion simplicity here, if you make yourself this many files you'll just confused, and have a lot of redundant code.
From my person game making perspective, my screens are all methods of a single class. There are a few instance variables like the screen, but each method contain the main pygame loop, i.e.
while True:
for event in pygame.event.get():
#whatever
pass
and on button press one can move on to a separate method in your class.
I would recommend creating either a class for each tab button or a class for the whole set of tab buttons, this can be updated, drawn to screen and used in all separate methods for each of your tabs
The way this varies from things like php & html is the lack of predefined structure, as you will have to make all of this from scratch. I have a few code snippets available on my website that you can use for making buttons etc if that would help. Here is a link to it.
Also, If you choose the seperate file method, python's import works very intutively, you could import a class (say Layout3) from your file tabLayout3.py simply using:
from tabLayout3 import Layout3
(provided the path of tabLayout3.py is in my python path)

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 can I achieve layout similar to Google Image search in QT (PyQT)?

I'm new to QT. I'm using PyQT for GUI development in my project. I want to achieve this layout in my application. This application searches images from an image database. Google image search layout is ideal for my purpose.
I'm following the book "Rapid GUI Programming with Python and Qt" and I'm familiar with layouts. I guess I need to use a grid layout with each result image in each box of grid. & use vertical layout for (image,Qlabel,Qlabel) inside each grid box.
These are some problems I'm facing.
Importantly, I'm unable to display image. What control/widget do I need? I cannot find anything similar to PictureBox of .NET
How do I seperate these image result by fixed gap like in the image? I'm using Horizontal & vertical spacers but that isn't working?
How to set QLabel a clickable (like hyperlink). I don't want to a open a URL. Just the text should be clickable. So, that when user clicks on the link. I can show more information (like next set of results when he clicks on next page number or a new window with image in fullsize when user clicks on 'view') Do we have some new kind of control for this?
This is another important issue. I'll display the page numbers of results (like shown in figure) & assuming they are clickable. How do I load a new page of results? I mean what is the equivalent of page in QT?
As you can guess. This definitely wont be the first page of GUI. The first page will be exactly like http://google.com (a big logo & text box with button below it). when user clicks the search button. This page will be displayed. Again the same question comes up. How change the pages?
Please give a list of controls I'm going to need for this. Tell me if I'm unaware of something.
1/2.
For displaying the images and labels use a QListWidget with view mode set to QListView::IconMode. However, if you need to customize the display beyond what the QListWidget/QListWidgetItem api can provide you will need to create your own QAbstractListModel and use a standard QListView with it.
Make sure and read Qt's primer on model/view.
As for spacing the images, checkout the spacing property on the list view.
Here is an example from KDE's Dolphin file manager:
3. Use a regular QLabel, but set the contents to be an href.
Example:
edit: Oops I see from your tags you are using PyQt, the following is C++, but should be similar to what you would do in python.
QLabel *linkLabel = new QLabel;
linkLabel->setTextFormat( Qt::RichText )
linkLabel->setText( " Click me! " );
connect( linkLabel, SIGNAL( linkActivated ( const QString & link ) ), .... )
4.
Well, since you are using a Model/View, why bother having page numbers at all? The user will just be able to scroll the view and more pictures will be shown. This is by far the easiest solution as you don't have to do anything once you've got your M/V setup!
However, if you really want to show page numbers it will require more work in your model. For example, have a track the "current page" in the model and only allow access to images on the "current page". Then in your slot connected to the linkActivated() signal tell the model to change pages. I won't go into much more detail as this seriously violates the whole idea behind model/view. The "right way" of doing this would be to subclass QListView and add pagination support, but like I said why not use scroll bars? There isn't any performance hits to doing so.
5. Use a QStackedWidget, addWidget() all your "pages" to it, then call setCurrentIndex/Widget() as needed to switch the pages.
Thoughts:
It seems you are very committed to cloning the look, feel, and behavior of Google Image search, which is fine, but Google Image Search is a web application that uses interaction paradigms that are very different than a normal desktop application (links, pages, etc). You are presumably developing a desktop application, and by trying to emulate the behavior of a web app you will find it difficult as the API just isn't designed to support those sorts of interactions. By all means, it is doable, but you'll have your work cut out for you.
If you are extremely intent on sticking to the web based interaction style, why not code your app in javascript and HTML and toss it in a QWebView?
Try using QListWidget with viewMode set to IconMode. It should do all for you. BUT if you need to customize your data display use QListView with your own/standard model and own delegate for painting

Categories