Quick question: I have a python application with 3 tabs. Is it possible to read the state of a control on tab 2 from tab 1? That is, on tab 1 I have a run button. When clicking this I want to determine which checkboxes are checked on tab 2.
Should be quite simple, but I can't seem to suss it!
Many thanks
It should be possible, yes. All the controls are usually private members of the wxFrame class. I don't really understand what is the problem.
Related
So I made a fairly simply GUI, it has 3 tabs for organization - I can show pictures below.
As you can see there are 3 main tabs for general organization. However I was wondering if it was possible to add a Sub-Tab to one of the existing ones. For example in Non-Host would it be possible to add another tab called Combat that only shows once you click into the menu of Non-Host?
Sorry if my wording is bad, but essentially what I'm asking is if it's possible to add a tab within another tab, that's only accessible when the parent tab is already open.
I am trying to build a GUI which will:
Load a file with parameters which describe certain type of problem.
Based on the parameters of the file, show only certain tab in QTabwidget (of many predefined in Qt Designer .ui)
I plan to make a QTabwidget with, say 10 tabs, but only one should be visible based on the parameters loaded. Enabling certain tab is not an option since it takes to many space and the disabled tabs are grey. I do not want to see disabled tabs.
Removing tab could be an option but the index is not related to a specific tab so I have to take care of the shift in the indices. And furthermore if user loads another file with different parameters, a good tab should be added and the current one removed.
My questions are:
How to do this effectively?
Is it better to use any other type of widget?
In Qt designer, is it possible to define many widgets one over another and then just push the good one in front. If yes, how? And how to edit and change any of them?
If using RemoveTab, how to use pointers on tabs, rather than indices?
I use PyQt4
Use a QStackedWidget, which is exactly the same as a tab-widget, but without the tab-bar (which you don't need).
This widget is available in Qt Designer. The context menu has several commands for adding/removing pages and so forth. Note that the arrow buttons in the top-right corner are just there for convenience: they won't appear in your application.
Pages can be added/removed at runtime with addWidget/removeWidget:
index = self.stack.addWidget(self.page1)
self.stack.removeWidget(self.page1)
You can access the pages using either indexes or widget references.
I see that this thread is kinda old. But I hope this will still help.
You can use the remove() method to "hide" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvise it back. Give it a try!
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)
I have come across a problem while using wxPython lately: I want to grey out a whole wx.Menu and I can't find a way to do it. I could disable all the wx.MenuItem instances related to the wx.Menu, but I find it less efficient ergonomically speaking than greying out the menu itself.
The wx.Menu class has a method named Enable() which accepts the 'enable' argument, but its solely use is to enable/disable a related wx.MenuItem and not the wx.Menu itself. Actually, I'm not even sure that what I want can be done.
However, I would be glad to listen to your solutions if you have some.
Enable is just for the menu items. EnableTop should counter-intuitively disable the entire menu. See my old tutorial on menus about half-way down for more info. Here's how I did it:
self.menuBar.EnableTop(0, False)
Note that it's zero-based, so zero is the first menu, one is the second, etc.
I have 4 spinctrls in my app. When I click on them, I want all their
content to be selected instantly. And another thing is, I need to make
them tab traversal. Can you help me with some sort of code to do this
task?
Thanks in advance.
You need to catch EVT_SPIN or EVT_SPINCTRL and in your handler, you can select all the values by calling each of the control's GetValue method. In the wxPython demo, it seems to support tab traversal. I'm not sure what's going on with yours. Did you try the FloatSpin widget as an alternative?