I embedded a checkbox in every row of my wx.Grid.
I used this page as an example: wx Python wiki
The problem is, my last checkbox value is never saved and I can't get quite my head around it.
Second problem: Just clicking the Cell and not the checkbox changes the cell value, but not the checkbox. Is there a solution for this? It's possible that the problems are related.
My whole unit can be found here (disregard the readout_main references).
I checked that the 1 or 0 value is really there.
Helping me would mean a lot! Thanks!
Related
To be more precise, I'm looking for a way to assign a function to a button to shift to another tab on the click of a button.
I've been looking everywhere for the python code and majority of them have posted its c++ code, its no where to be found
I was able to found a c++ code snippet of what i wanted to do, but had absolutely no idea what its python translation would be
following is the c++ code:
ui->tabWidget->setCurrentWidget(ui->tab);
and i have absolutely no idea what this means, all what I want is a PushButton, on click, would move to the next tab. Kindly help
Maybe this link could help understand my query better
https://forum.qt.io/topic/56408/solved-how-to-open-specific-tab-on-pushbutton-clicked-in-tabwidget/2
You will need to set the current tab index to the index of target tab and then reset the layout in order to update the main screen.
def next_Tab(self):
self.setCurrentIndex(1)
self.setLayout(layout)
This is a minor issue but I've been struggling with it most of the afternoon and getting nowhere, so here goes. I'm about to write a Python script that will require the use of the ScrolledListBox(). Never having used it before, I started with an experimental script where I could play with it and get familiar with it. I now have the script to where I can double click on an item and, in the handler, correctly print the selected item to stdout. However, I notice that when the item is selected, either with a single or double click, a rectangular border appears around the item in the list and remains there until another item is selected. I've been trying to see if there's a way to get rid of this border but so far have been unable to do so. Here's what I've tried:
1) Thanks to another post in this forum I found that the keys() method would give me a list of the available options for the widget. So, given a ScrolledListBox named slb1 I could do something like print(slb1.keys()) and I got the full list of everything I could configure on the widget. One of them was 'selectborderwidth' so I did: slb1.configure(selectborderwidth=0) thinking that this would remove the border. It didn't.
2) Next I dug through my copy of "Python and Tkinter" and discovered the selection_clear(first, last=None) method. The description states, "If any of the elements between first and last (inclusive) are selected, they are deselected." So I tried: slb1.selection_clear(0, None) in the handler but once again the rectangular border around the item remained.
I'm just getting started in Python and Tkinter so hopefully I'm missing something somebody with more experience knows about. Any ideas on how to get rid of the border?
Thanks,
Dave
The documentation by New Mexico Tech, which can be a good reference when working with Tkinter, lists the attributes for the Listbox widget, among which activestyle. This parameter refers to the box around the currently active (not necessarily selected) item, and can take the values underline, dotbox, and none.
If you set activestyle to none, the dotted border will go away.
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).
I have created a QTable view and connected it to a QSqlTableModel and i am displaying the resulted Query retrived from the database.In QTable view i have enabled sortEnabled option. All the expected results are printing but if i click the sort indicator
the whole data in the table is getting emptyed. Can any one suggest me how to overcome this issue
This is the snap shot of the results table.
This is the snap shot of the results table after pressing sort indicator.
Can any one suggest me how to overcome this issue
To figure out why QTableView's setSortingEnabled method wasn't working is, It turns out the sort method in QAbstractItemModel is not implemented. So you have to implement it yourself.
One solution would be creating a QAbstract view. below is a code snippet.
I'm not sure if this is the best way to implement the sort method, but I couldn't find anything else out there, and this seems to work for me.
I am currently using some wxPython's AuiNotebook in one of my projects and I have a problem that can't manage to solve. I think there should be a simple solution but can't manage to find it.
I have created a new class derived from wx.lib.agw.aui.AuiNotebook and I am trying to get the index of a tab at the moment it's clicked. I wrote something like that:
class NewNotebook(wx.lib.agw.aui.AuiNotebook):
# __init__ function an stuff...
def OnTabClicked(self, evt):
index = self.GetSelection()
print index
wx.lib.agw.aui.AuiNotebook.OnTabClicked(self, evt)
The aim was to capture the index of the tab clicked on and in some cases, have a special behavior, or just perform a regular click otherwise. However, I think that AuiNotebook.OnTabClicked actually changes the selection among different things. It would explain why index contains the value of the tab that was selected before the click.
I did not a find a way to get the selection of the new tab though. I looked for some information in the captured event but still could not find the one I wanted.
So, does someone know how I can get the selected tab before I call AuiNotebook.OnTabClicked?
There doesn't seem to be a builtin way to do this. The closest I found was something I helped with on the wxPython mailing list, but that had to do with double-clicking.
Here's one workaround that came to me though. When you first show the frame, set some kind of class property to the currently shown tab (i.e. self.currentTab = 0). Then catch the EVT_AUINOTEBOOK_PAGE_CHANGING or EVT_AUINOTEBOOK_PAGE_CHANGED event and update the property. For me, when I catch EVT_AUINOTEBOOK_PAGE_CHANGING, I always get the index of the tab I'm clicking on, at least on Windows.