(PyQt5)
I have my first gui program that is in the VERY rough stages. Here's what it looks like just for reference:
Screen Shot 2016-06-29 at 13.48.50.jpg
Here's some heavily abridged code it runs on:
def __init__(self):
super().__init__()
self.main_screen()
def main_screen(self):
self.button_1 = RightSideButton("Enter")
# RSB is my own class, to normalize the size of the buttons to 1 inch square on screen, extending QPushButton
# sets everything else up
self.reset()
self.showMaximized()
def reset(self):
# does stuff
self.button_1.clicked.connect(self.run_main)
self.main_input.returnPressed.connect(self.button_1.click)
def run_main(self):
# does stuff
self.button_1.clicked.connect(self.run_next) # this line doens't seem to do anything
def run_next(self):
# does stuff
self.reset()
class MyWidget(QWidget):
def __init__(self):
super().__init__()
self.main_screen()
def main_screen(self):
self.button_1 = RightSideButton("Enter")
# RSB is my own class, to normalize the size of the buttons to 1 inch square on screen, extending QPushButton
self.main_input = QLineEdit()
# sets everything else up
self.reset()
self.showMaximized()
def reset(self):
# does stuff
self.button_1.clicked.connect(self.run_main)
self.main_input.returnPressed.connect(self.button_1.click)
def run_main(self):
# does stuff
self.button_1.clicked.connect(self.run_next) # this line doens't seem to do anything
def run_next(self):
# does stuff
self.reset()
To copy to clipboard, switch view to plain text mode
In this, button_1 is the one on the bottom right. I'm trying to have the program run through different "modes" as it were, where in each mode it does different things when you type something in the main input and hit enter or the button on the lower right.
It works at first, going through run_main() as it should, but when it gets to the end (line 21) and tries to "change modes" by changing the slot of the button signal, it doesn't work and it just goes back through run_main() if I hit enter in the main input OR click the button. Is there even a way to change the slot of a signal once it's been set?
Bookmarks