Feb-17-2022, 06:17 PM
I have been fine tunning the program for roulette and I could use a little help getting a second button to pick 3 numbers from 0 to 37
I have it almost working. and I added some more options for choosing around the whole roulette table.
I have it almost working. and I added some more options for choosing around the whole roulette table.
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.odd_even()) button2.clicked.connect(self.clear) spinbtn = QPushButton('Numbers') spinbtn.clicked.connect(lambda: self.numpick()) 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) container.addWidget(spinbtn, 4, 0, 1, 2) widget = QWidget() widget.setLayout(container) self.setCentralWidget(widget) def odd_even(self): for i in range(1): self.listbox.addItem(f"{rnd.choice(('odd', 'even'))} {rnd.choice(('red', 'black'))}") self.listbox.addItem(f"{rnd.choice(('1st', '2nd', '3rd'))}") self.listbox.addItem(f"{rnd.choice(('top 1/2', 'Bottom 1/2'))}") # def numpick(self): # for i in range(3): def clear(self): self.listbox.clear() def main(): app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_()) main()I made the button call a function called numpick, however I am not sure on how to run the number picker.