How to modify panels individually in a wxPython wizard? - python

I am quite new to wxPython and want to build a wizzard. I used this guide as a base ("wxPython: How to Create a Generic Wizard"). I tried to add some widgets the panel, e.g. some radio buttons at the second page by inserting the following code at line 56 in add_page():
if(title=="Page 2"):
k1=wx.RadioButton(panel,-1,'Argument1',(35,60),(150,20), style = wx.RB_GROUP)
k2=wx.RadioButton(panel,-1,'Argument2',(35,80),(150,20))
But as soon as I try to add some sizer to the the second panel, all pages are affected. I tried quite a few variations of where to place the sizers, but without success. So my question is: is this the appropriate place to modify the individual pages and could someone give me a hint of how to write a minimalistic example of e.g inserting a boxSizer and a button in the first page and a boxSizer and a RadioButton in the second page?

Related

Grouping pages in Mezzanine

I'm new to Mezzanine, but I've got a project up and running and can generate customized Pages using my own model. I'd now like to group these pages into sections (and maybe subsections) like this:
Section1
Subsection1
Page1.1.1
Page1.1.2
Subsection2
Page1.2.1
...
Section2
Subsection1
Page2.1.1
Page2.1.2
...
and so on. How can I attach my Page objects to specific Section and Subsection categories (with an index page for each?) Do I need to create another Model to represent these categories and then a page_processor to generate the index or is there an easier way?
In Mezzanine, your categories of Section1, Subsection1, etc. need to be pages as well.
Say you wanted the following structure:
Movies
Comedies
Monty Python and the Holy Grail
You would first create a Mezannine Page (or RichTextPage or similar) with title "Movies", and enter some content (even if minimal), such as "These are the movies I watch too much". This page will automatically contain links to any subpages once you create them.
To create a subpage like "Comedies", you would go to "Pages" under "Content" in the admin, and click on the "Add" dropdown menu in the "Movies" row you just created (and not the "Add" dropdown at the top-right of the page).
Follow the same pattern to create a subpage under "Comedies", and on that page ("Monty Python...") you'll likely enter the bulk of the content you actually want.
If it suits your needs, you can consider the other hierarchical pages to be nothing more than placeholder pages in a way, but those pages are usually a place to put content related to what the category itself is about.
The overall page structure will be mirrored in things like navigation menu dropdown trees.
Changing the structure of existing pages:
The Mezzanine Admin > Content > Pages page supports drag & drop for this.
Click a page's row near the right side (where the small up/down arrows are), and drag it to where you want it to go. A dotted outline will appear indicating where the dropped page will go, as you move the mouse around.
If you want to move your existing page to be a subpage of another, you can position the dotted outline below the intended parent page, and then move the mouse right or left before dropping the page. You will see the dotted outline's position change from indented to de-dented. Dropping while the outline is indented will create a subpage.
Note that the right/left mouse adjustment to get the indent/dedent might be somewhat finicky, depending on the mouse's position.

Loading images and text in pyqt

Im not sure what this is called, so its hard to lookup. I want to get a set of images that have a unique identifier and the put some corresponding text information next to it, inside of an application. When more images are loading a scroll bar can go through them. I dont know which methods or how this is possible. For example, through other threads i found how to load images using a list widget and switching the items to an icon. However with this method I dont see how to put text next to it. Can this be done with a table, or a tree? I have been using qt Designer but I dont see anything like this available.
You can use QListWidget for that. Each item would represent an image (item's icon) and all text to the right of it. Define iconSize property of list widget to enlarge item icons. Use \n in item texts to add line breaks.

Python GTK (Glade) Notebook

I'm currently developing a small application in Python with the use of GTK+ (and Glade). Everything has been fairly simple to integrate so far, until I came up with the idea to add tabs instead of pop-ups. Note: Still using Python 2.7+
Is there any easy way to implement already existing pages inside a new tab(notebook) like structure? I'm having difficulties to find how to add content per separate tab created in glade.
Perhabs a more 'clear' question: What Notebook function will be required to call a specific V/HBox with every different tab? The current structure looks like (minus Menu / statusbar):
[ mainWindow ] --> (1) mainOverview (gtkVbox) --> (2A) mainContent (gtkHbox) ... other non-related content
The structure I was hoping for would look like:
[ mainWindow ] --> (1) mainOverview --> (2) noteBook --> (3) Tab1 --> (4) mainContent (gtkHbox) -- (3) Tab2 --> (4) secondaryContent (gtkHbox)
The application itself works fine (multithreaded, fully functioning) without the tabs, the mainContent(gtkHbox) contains a file/recursive directory analyzer, a few checkboxes and a general overview. I was hoping for an easy way to display this main window (the gtkHbox) ONLY when having Tab1 selected.
Having difficulties to find good reference pages that display a proper way to call content pages per notebook tab. Any reference-pages or useful links are very much appreciated! Thanks so far! My apologies if this is a rather newbish question, I'm not new to Python coding, but interfaces on the other hand... ;)
Not an answer, but it looks like "another.anon.coward" already answered this in a comment...
If you double click on the tab, then that page is selected for adding content in glade. You can go ahead and add content for that page. As for switching you can use set_current_page to switch to page whose content you want to display. Register for "switch-page" signal to find out which page has been switched to.
click on the notebook widget on the widget explorer(object inspector) on the left of glade. Then use your left and right keyboard arrow keys to move from tab to tab. You can also double click on the label of the tab as pyrotherm has said in his answer. But if you want to do it programatically get the notebook object from the ui using the get_object method of Gtk.builder class. Then do this to add a page
builder = Gtk.Builder()
builder.add_from_file("example.glade")
self.notebook = builder.get_object("notebook1") # set the id of the notebook in glade
self.page1 = Gtk.Box()
self.page1.add(Gtk.Label(label="Default Page!"))
self.notebook.append_page(self.page1, Gtk.Label(label="Plain Title"))
Now add the content you want to it. Now on to signals. Pyrotherm has already answered it. though there is no signal named switch-page. its named switch_page. You can look at the list of signals of notebook here

Using QFrame to display different panes of information?

I'm trying to get a QFrame to serve as a "display area" for a couple different kinds of information, eg: you click on something in a list view and an info pane shows up in the frame
to give you information about it, you click on a different item and a different pane shows up.
Having trouble swapping the different frames in and out of the QFrame though, is there a way to do this?
Using QStackedWidget is probably the most standard solution.

Equivalent of an HTML multiple SELECT box in wxPython

I'd like to create a ListBox in wxPython with the same semantics as a multiple select box in HTML. Specifically I'd like the following semantics
When the user clicks on an entry in the list, all other entries become de-selected and the clicked entry becomes selected. If the entry was already selected then it stays selected.
When the user holds down the Ctrl key while clicking on an entry, all other entries stay unchanged, but it toggles whether the clicked entry is selected.
When the user holds down shift and clicks on an entry, that entry and every entry between it and the last clicked entry become selected.
In Java I get this by using the JList class in Swing and setting the selection mode to MULTIPLE_INTERVAL_SELECTED. I assume that there's a way to do this with the wxPython toolkit, but I can't figure out how to get a ListBox or ListCtrl or any other class to do this short of doing an enormous amount of event-driven programming myself.
I think what you're looking for is the wxLB_EXTENDED list box style. Specify style = wx.LB_EXTENDED when you create the ListBox.
You can then use the GetSelections method to obtain a list of the selected items.

Categories

Resources