Thanks for all the help on this little program. I am now trying to adapt it to run this roulette code for playing odd or even and red or black.
import random print('Bill does Odd or Even') print('and Red and Black') x = (random.randint(0,1)) if x == 0: print('odd') if x == 1: print('even') y = (random.randint(2,3)) if y == 2: print('red') if y == 3: print('black')This is my GUI interface but not sure how to accomplished that basic code.
import random as rnd import sys from PyQt5.QtWidgets import (QMainWindow, QApplication, QWidget, QPushButton, QGridLayout, QLabel, QLineEdit, QListWidget, QMessageBox) class Window(QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Container container = QGridLayout() label = QLabel('Odd or Even') label2 = QLabel('Red or Black?') button = QPushButton('Spin') button2 = QPushButton('clear') button.clicked.connect(lambda: self.picker) button2.clicked.connect(self.clear) self.listbox = QListWidget() container.addWidget(label, 0, 0, 1, 1) container.addWidget(label2, 0, 1, 1, 1) container.addWidget(button, 1, 0, 1, 1) container.addWidget(button2, 1, 1, 1, 2) container.addWidget(self.listbox, 2, 0 ,1 ,2) widget = QWidget() widget.setLayout(container) self.setCentralWidget(widget) def clear(self): self.listbox.clear() def picker(self): x = (rnd.randint(0, 1)) if x == 0: print('Odd') if x == 1: print('even') y = (rnd.randint(2,3)) if y == 2: print('red') if y == 3: print('black') nums = ', ' self.listbox.addItem(nums) def main(): app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_()) main()Is it possible to run that with like a while function. not sure how to get it to execute.