Feb-17-2022, 04:40 PM
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.
Feb-17-2022, 06:32 PM
thanks again menator I studied the code from all our work and got it going. hopefully, it helps me win at the OLG.ca casino :)
Feb-17-2022, 06:48 PM
Here is the final code on the Ultimate Roulette picker if anyone is interested

Python is a great language. with the stuff I just learned I will make an automatic dice roller :)
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('Ultimate Roulette') label2 = QLabel('Side Bets and More') 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,'))} {rnd.choice(('1st,', '2nd,', '3rd,'))} {rnd.choice(('top 1/2', 'Bottom 1/2'))}") #self.listbox.addItem(f"{rnd.choice(('1st', '2nd', '3rd'))}") #self.listbox.addItem(f"{rnd.choice(('top 1/2', 'Bottom 1/2'))}") def numpick(self): spots = 3 picks = [] while len(picks) < spots: pick = rnd.randint(0, 37) if pick not in picks: picks.append(f'{pick}') nums = ', '.join(picks) self.listbox.addItem(nums) def clear(self): self.listbox.clear() def main(): app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_()) main()

Python is a great language. with the stuff I just learned I will make an automatic dice roller :)
Feb-18-2022, 08:52 PM
I did a version of your number gen. Still will be tweaking on it a little. eg(on the roulette have red text for red picks)
#! /usr/bin/env python3 # Do the imports import random as rnd import sys from PyQt6.QtWidgets import (QMainWindow, QApplication, QWidget, QGridLayout, QPushButton, QLabel, QListWidget, QListWidgetItem, QFrame, QHBoxLayout, QSpinBox) from PyQt6.QtCore import Qt from PyQt6.QtGui import (QFont, QColor) # Create the Gamble class class Gamble: # Define the lottery, choose which lottery we are playing # Powerball ends with 69 while mega millions ends with 70 def lottery(self, game, listbox): self.numbers = [] if game == 'powerball': end_number = 69 bonus_end_number = 26 elif game == 'mega millions': end_number = 70 bonus_end_number = 25 while len(self.numbers) < 6: number = rnd.randint(0, end_number) if str(number) not in self.numbers: self.numbers.append(f'{number:02d}') # Get the bonus number self.bonus = rnd.randint(0, bonus_end_number) item = QListWidgetItem(f'{game.title()} Numbers') font = QFont() font.setBold(True) item.setFont(font) item.setForeground(QColor('blue')) item2 = QListWidgetItem(f'{", ".join(self.numbers)} - Bonus Number: {self.bonus}') listbox.insertItem(0, item) listbox.insertItem(1, item2) listbox.insertItem(2, QListWidgetItem('')) # Define the pick # lotto # rng depends on which playing 3 for pick3, 4 for pick4, and so on def pick(self, rng, listbox, game): self.numbers = [] for i in range(rng): number = rnd.randint(0,9) self.numbers.append(f'{number}') item = QListWidgetItem(f'{game.title()} Numbers') font = QFont() font.setBold(True) item.setFont(font) item.setForeground(QColor('blue')) item2 = QListWidgetItem(f'{", ".join(self.numbers)}') listbox.insertItem(0, item) listbox.insertItem(1, item2) listbox.insertItem(2, QListWidgetItem('')) # Define keno def keno(self, spots, listbox, game): self.numbers = [] while len(self.numbers) < int(spots.value()): number = rnd.randint(1, 80) if str(number) not in self.numbers: self.numbers.append(f'{number}') item = QListWidgetItem(f'{game.title()} Numbers') font = QFont() font.setBold(True) item.setFont(font) item.setForeground(QColor('blue')) item2 = QListWidgetItem(f'{", ".join(self.numbers)}') listbox.insertItem(0, item) listbox.insertItem(1, item2) listbox.insertItem(2, QListWidgetItem('')) # Define rouleere def roulette(self, listbox, game): black = ('black', ['28','26', '11', '20', '17', '22', '15', '24', '13', '10', '29', '8', '31', '6', '33', '4', '35', '2']) red = ('red', ['9', '30', '7', '32', '5', '34', '3', '36', '1', '27', '25', '12', '19', '18', '21', '16', '23', '14']) green = ('green',['0', '00']) numbs = rnd.choice([black,red,green]) choices = { 'odd even':['odd', 'even'], 'column':['1st', '2nd', '3rd'], 'dozen':['1-12', '13-24', '25-36'], 'color':['black', 'red'], 'low high':['Low 1-18', 'High 19-36'] } picks = [] picks.append(f'{numbs[0]} {rnd.choice(numbs[1])}') for key, val in choices.items(): picks.append(f'{key}: {rnd.choice(val)}') # return picks item = QListWidgetItem(f'{game.title()} Numbers') font = QFont() font.setBold(True) item.setFont(font) item.setForeground(QColor('blue')) item2 = QListWidgetItem(f'{", ".join(picks)}') listbox.insertItem(0, item) listbox.insertItem(1, item2) listbox.insertItem(2, QListWidgetItem('')) class Window(QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('Number Generator') self.setMinimumWidth(500) gamble = Gamble() button = { 'powerball': lambda: gamble.lottery('powerball', self.listbox), 'mega millions': lambda: gamble.lottery('mega millions', self.listbox), 'pick5': lambda: gamble.pick(5, self.listbox, 'pick5'), 'pick4': lambda: gamble.pick(4, self.listbox, 'pick4'), 'pick3': lambda: gamble.pick(3, self.listbox, 'pick3'), 'keno': lambda: gamble.keno(spinner, self.listbox, 'keno'), 'roulette': lambda: gamble.roulette(self.listbox, 'roulette'), 'clear': lambda: self.listbox.clear() } # Create a container for widgets container = QGridLayout() hbox = QHBoxLayout() spinner = QSpinBox() spinner.setRange(1, 12) #Create the header header = QLabel('Number Generator') header.setAlignment(Qt.AlignmentFlag.AlignCenter) header.setFrameStyle(1) header.setFrameShadow(QFrame.Shadow.Sunken) header.setStyleSheet('font-size: 18px; font-weight:bold;') container.addWidget(header, 0, 0,1, 4,) # Create the buttons col = 0 row = 1 for btn, cmd in button.items(): button = QPushButton(btn.title()) button.pressed.connect(cmd) if btn == 'keno': hbox.addWidget(button) hbox.addWidget(QLabel('Spots:')) hbox.addWidget(spinner) container.addLayout(hbox, row, col, 1, 1) else: container.addWidget(button, row, col, 1, 1) if col >= 3: row += 1 col = 0 else: col += 1 self.listbox = QListWidget() container.addWidget(self.listbox, 3, 0, 1, 4) widget = QWidget() widget.setLayout(container) self.setCentralWidget(widget) def main(): app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec()) if __name__ == '__main__': main()
Feb-21-2022, 12:15 AM
With the tweaks
#! /usr/bin/env python3 import sys import random as rnd from PyQt6.QtWidgets import(QGridLayout, QHBoxLayout, QMainWindow, QApplication, QPushButton, QSpinBox, QFrame, QLabel, QWidget, QGraphicsDropShadowEffect, QGraphicsView, QGraphicsScene, QTextEdit) from PyQt6.QtGui import (QLinearGradient, QCursor, QColor, QFont, QTextCursor) from PyQt6.QtCore import (Qt, QPointF) # Create the Gamble class class Gamble: # Define the lottery, choose which lottery we are playing # Powerball ends with 69 while mega millions ends with 70 def lottery(self, game, textbox): self.numbers = [] if game == 'powerball': end_number = 69 bonus_end_number = 26 elif game == 'mega millions': end_number = 70 bonus_end_number = 25 while len(self.numbers) < 6: number = rnd.randint(0, end_number) if str(number) not in self.numbers: self.numbers.append(f'{number:02d}') # Get the bonus number self.bonus = rnd.randint(0, bonus_end_number) cursor = QTextCursor(textbox.document()) cursor.insertHtml(f"<b><font color='blue'>{game.title()} Numbers</font></b>: {', '.join(self.numbers)} - \ <b><font color='blue'>Bonus Number</font></b>: {self.bonus}<br><br>") # Define the pick # lotto # rng depends on which playing 3 for pick3, 4 for pick4, and so on def pick(self, rng, textbox, game): self.numbers = [] for i in range(rng): number = rnd.randint(0,9) self.numbers.append(f'{number}') cursor = QTextCursor(textbox.document()) cursor.insertHtml(f'<b><font color="blue">{game.title()} Numbers: </font></b> {", ".join(self.numbers)} \ <br><br>') # Define keno def keno(self, spots, textbox, game): self.numbers = [] while len(self.numbers) < int(spots.value()): number = rnd.randint(1, 80) if str(number) not in self.numbers: self.numbers.append(f'{number}') cursor = QTextCursor(textbox.document()) cursor.insertHtml(f'<b><font color="blue">{game.title()} Numbers:</font></b> {", ".join(self.numbers)} \ <br><br>') # Define rouleere def roulette(self, textbox, game): black = ('black', ['28','26', '11', '20', '17', '22', '15', '24', '13', '10', '29', '8', '31', '6', '33', '4', '35', '2']) red = ('red', ['9', '30', '7', '32', '5', '34', '3', '36', '1', '27', '25', '12', '19', '18', '21', '16', '23', '14']) green = ('green',['0', '00']) numbs = rnd.choice([black,red,green]) choices = { 'odd even':['odd', 'even'], 'column':['1st', '2nd', '3rd'], 'dozen':['1-12', '13-24', '25-36'], 'color':['black', 'red'], 'low high':['Low 1-18', 'High 19-36'] } picks = [] picks.append(f'{numbs[0]} {rnd.choice(numbs[1])}') for key, val in choices.items(): picks.append(f'{key}: {rnd.choice(val)}') cursor = QTextCursor(textbox.document()) cursor.insertHtml(f'<b><font color="blue">{game.title()}</font></b><br>') cursor.insertHtml(f' <b><font color="purple">Possible Bets</font></b>:<br>') colors = ['red', 'green'] for data in picks: if colors[0] in data: color = 'red' elif colors[1] in data: color = 'green' else: color = 'black' cursor.insertHtml(f'{" "*8}<font color="{color}">{data}</font><br>') cursor.insertHtml('<br>') class Window(QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('Number Generator') self.setMinimumWidth(500) gamble = Gamble() button = { 'powerball': lambda: gamble.lottery('powerball', self.textbox), 'mega millions': lambda: gamble.lottery('mega millions', self.textbox), 'pick5': lambda: gamble.pick(5, self.textbox, 'pick5'), 'pick4': lambda: gamble.pick(4, self.textbox, 'pick4'), 'pick3': lambda: gamble.pick(3, self.textbox, 'pick3'), 'keno': lambda: gamble.keno(spinner, self.textbox, 'keno'), 'roulette': lambda: gamble.roulette(self.textbox, 'roulette'), 'clear': lambda: self.textbox.clear() } # Create a container for widgets container = QGridLayout() container.addWidget(self.header(), 0, 0, 1, 4) hbox = QHBoxLayout() spinner = QSpinBox() spinner.setRange(1, 12) # Create the buttons col = 0 row = 1 for btn, cmd in button.items(): button = QPushButton(btn.title()) button.pressed.connect(cmd) if btn == 'keno': hbox.addWidget(button) hbox.addWidget(QLabel('Spots:')) hbox.addWidget(spinner) container.addLayout(hbox, row, col, 1, 1) else: container.addWidget(button, row, col, 1, 1) if col >= 3: row += 1 col = 0 else: col += 1 self.textbox = QTextEdit() self.textbox.setReadOnly(True) container.addWidget(self.textbox, 3, 0, 1, 4) widget = QWidget() widget.setLayout(container) self.setCentralWidget(widget) def header(self): shadow = QGraphicsDropShadowEffect() shadow.setBlurRadius(3) shadow.setOffset(2, 2) scene = QGraphicsScene() view = QGraphicsView() view.setScene(scene) view.setMaximumHeight(70) gradient = QLinearGradient(QPointF(0,0), QPointF(300,300)) gradient.setColorAt(0, QColor(200,200,200)) gradient.setColorAt(1, QColor(250,250,250)) scene.setBackgroundBrush(gradient) font = QFont('comic sans ms', 30) font.setBold(True) text = scene.addText('Number Generator') text.setFont(font) text.setDefaultTextColor(QColor(250,150,105)) text.setGraphicsEffect(shadow) return view def main(): app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec()) if __name__ == '__main__': main()
Feb-21-2022, 11:15 AM
great job looks great.
Jan-24-2023, 12:19 PM
Creating a graphical user interface (GUI) for point cloud visualization can be done using various programming languages and libraries. Some popular options include:
Python and the library VTK (Visualization Toolkit) can be used to create a GUI for point cloud visualization. VTK provides a wide range of visualization tools and can be easily integrated with other libraries such as NumPy and SciPy.
C++ and the library PCL (Point Cloud Library) can also be used to create a GUI for point cloud visualization. PCL provides a set of algorithms for point cloud processing and can be integrated with libraries such as OpenCV for image processing.
JavaScript and WebGL can be used to create a web-based GUI for point cloud visualization. WebGL is a JavaScript API for rendering interactive 3D graphics and can be used in combination with libraries such as Three.js to create a browser-based point cloud visualization.
Unity, Unreal Engine, and other game engines can be used to create a GUI for point cloud visualization with interactive elements and augmented reality features.
It's important to note that creating a GUI for point cloud visualization can be complex and requires a good understanding of programming and 3D graphics.
Python and the library VTK (Visualization Toolkit) can be used to create a GUI for point cloud visualization. VTK provides a wide range of visualization tools and can be easily integrated with other libraries such as NumPy and SciPy.
C++ and the library PCL (Point Cloud Library) can also be used to create a GUI for point cloud visualization. PCL provides a set of algorithms for point cloud processing and can be integrated with libraries such as OpenCV for image processing.
JavaScript and WebGL can be used to create a web-based GUI for point cloud visualization. WebGL is a JavaScript API for rendering interactive 3D graphics and can be used in combination with libraries such as Three.js to create a browser-based point cloud visualization.
Unity, Unreal Engine, and other game engines can be used to create a GUI for point cloud visualization with interactive elements and augmented reality features.
It's important to note that creating a GUI for point cloud visualization can be complex and requires a good understanding of programming and 3D graphics.