Python Forum
[PyQt] No reaction and no error message when clicking button
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] No reaction and no error message when clicking button
#3
Many thanks for fixing the code. I have some questions about your changes:

1. Does your explanation mean that every window instantiated after the main window always needs to be an attribute of another object?


'show_concentration_test_window' method before your fixes:
    def show_concentration_test_window(self):
        concentration_test = ConcentrationTest(self.COLORS, self.get_designated_color())
        concentration_test_window = ConcentrationTestWindow(concentration_test, self.get_switch_time())
        concentration_test_window.show()
        concentration_test_window.change_screen_color()
'show_concentration_test_window' method after your fixes:
    def show_concentration_test_window(self):
        self.concentration_test = ConcentrationTest(self.COLORS, self.get_designated_color())
        self.concentration_test_window = ConcentrationTestWindow(self.concentration_test, self.get_switch_time())
        self.concentration_test_window.show()
        self.concentration_test_window.change_screen_color()


'__init__' method of 'MainWindow' class before your fixes:
class MainWindow(QMainWindow):
    COLORS = {"Black": QtCore.Qt.black,
              "Blue": QtCore.Qt.blue,
              "Cyan": QtCore.Qt.cyan,
              "Green": QtCore.Qt.green,
              "Magenta": QtCore.Qt.magenta,
              "Red": QtCore.Qt.red,
              "Yellow": QtCore.Qt.yellow}

    def __init__(self, concentration_test, parent=None):
        super().__init__(parent)
        loadUi("mainwindow.ui", self)
        self.concentration_test = concentration_test
        self.comboBox_designated_color.addItems(self.COLORS)
        self.pushButton_start_test.clicked.connect(self.show_concentration_test_window)
The declaration of 'concentration_test' seems to be a relic from last refactoring.

'__init__' method of 'MainWindow' class after your fixes:
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super().__init__()
        loadUi("mainwindow.ui", self)
        self.COLORS = {"Black": QtCore.Qt.black,
                       "Blue": QtCore.Qt.blue,
                       "Cyan": QtCore.Qt.cyan,
                       "Green": QtCore.Qt.green,
                       "Magenta": QtCore.Qt.magenta,
                       "Red": QtCore.Qt.red,
                       "Yellow": QtCore.Qt.yellow}
        self.comboBox_designated_color.addItems(self.COLORS)
        self.pushButton_start_test.clicked.connect(self.show_concentration_test_window)


2. What's the reason for changing the (constant) class variable 'COLORS' to an object variable 'self.COLORS'?
Reply


Messages In This Thread
RE: No reaction and no error message when clicking button - by Atalanttore - Nov-22-2018, 03:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] error message the_wolf_dz 4 2,067 Oct-24-2022, 07:24 PM
Last Post: deanhystad
  [Tkinter] Clicking on the button crashes the TK window ODOshmockenberg 1 2,258 Mar-10-2022, 05:18 PM
Last Post: deanhystad
  [Tkinter] Button error Tyrel 2 2,018 Jun-20-2021, 07:21 AM
Last Post: Tyrel
  Error message box and quit app Kumarkv 1 2,259 May-19-2020, 07:05 PM
Last Post: Larz60+
  [Tkinter] How to make message box error stay on top of window scratchmyhead 1 8,327 May-10-2020, 10:21 PM
Last Post: scratchmyhead
  Need tkinter help with clicking buttons pythonprogrammer 2 2,486 Jan-03-2020, 04:43 AM
Last Post: joe_momma
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,044 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] RE: status bar to return to the centre after 1 minute of clicking a button ? chano 6 4,733 May-27-2019, 04:24 PM
Last Post: Yoriz
  tkinter- adding a new window after clicking a button built on the gui ShashankDS 2 6,647 Apr-18-2019, 12:48 PM
Last Post: ShashankDS
  [Tkinter] Adding New TAB to NoteBook Widget by Clicking Vicolas 0 2,632 Feb-15-2019, 06:03 PM
Last Post: Vicolas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020