[PySide] Question from a newbie

Vojtěch Polášek krecoun at gmail.com
Sun Dec 22 18:15:41 CET 2013


Greetings,
my name is Vojtěch Polášek and I am a blind student from czech Republic.
I am creating an application in Pyside with Python 3.2. I would like to
create a sudoku game accessible for blind and visually impaired people.
I have created a main window, added a widget which contains 81 buttons
in a grid layout. Now my idea is, that after pressing a button, that
button would disappear and would be replaced by some other controll
which would allow you to change the value. I chose QSpinBox for now.
This step works well, although I had to implement my own eventfilter,
because QT in Linux uses arrows to browse available elements on the
screen. Never mind.
Now this is the way in which I replace a button with a spinbox. This
function is connected to the QPushButton.clicked signal:
    def editValue(self):
        print ('editing')
        senderpos =
self.grid.getItemPosition(self.grid.indexOf(self.sender()))
        self.grid.addWidget(self.spinbox, senderpos[0], senderpos[1])
        print ('added')
        self.spinbox.setValue(int(self.sender().text()))
        print ('value set')
        self.spinbox.show()
        print('showed')
        self.spinbox.setFocus()
        print('focused')
        self.spinbox.editingFinished.connect(self.storeValue)
        print('connected')

Don't mind those print statements, they are there for debugging
purposes, because I haven't found a way of debugging Pyside with PDB.
The problem is, that this signal is also called after I press a button
and this function is executed. I don't manipulate with spinbox in any
manner. Only thing that is set is its accepted range of input.
What could be the problem?
I am attaching the source code.
Thank you very much,
Vojtěch Polášek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: layout.py
Type: text/x-python
Size: 2601 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20131222/fcfa7787/attachment.py>


More information about the PySide mailing list