Python Forum
help needed running a simple function in pyqt5
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help needed running a simple function in pyqt5
#1
Hi

I am new to python and would like to get a small function to accept 2 variables and then execute a small function in a pyqt5 window. I have read two books and still can't do it. Here is the code I am trying to run. It is for a lotto quick picker using the Random library.

import random
print('Bills Lucky Quick Picker')
print('how many numbers')
x = int(input())
print('how many spots')
y = int(input())
for i in range(x):
    print(random.randint(1,y))
I would like a pyqt5 window to accept the two variables x and y and then run the for loop to print out the results within the window. I can get a window to run that function but it displays in the idle, not the GUI.

The program takes in input x and uses it to create the range of how many numbers the program picks and then the y variable (both integers) is the maximum number to select up to. so 6 and 49 would mean six numbers out of 49 total, a common lottery. If it's possible and easy adding in some code to not pick the same number twice would be nice as well. I have had success with this program online in casinos so I am really keen on making it run in its own GUI
Larz60+ write Jan-30-2022, 02:08 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBcode tags on funture posts.
Reply


Messages In This Thread
help needed running a simple function in pyqt5 - by diodes - Jan-30-2022, 02:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How To Make A PyQt5 Progress Bar Run While Executing A Function rcwildabeast 1 155 Yesterday, 02:18 AM
Last Post: menator01
  simple tkinter question function call not opening image gr3yali3n 5 3,467 Aug-02-2022, 09:13 PM
Last Post: woooee
  Tkinter won't run my simple function AthertonH 6 3,911 May-03-2022, 02:33 PM
Last Post: deanhystad
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 5,052 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  A Simple PyQt5 Class zoro 15 5,795 Mar-02-2020, 07:25 PM
Last Post: micseydel
  Refresh image in label after every 1s using simple function jenkins43 1 5,509 Jul-28-2019, 02:49 PM
Last Post: Larz60+
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,842 Apr-06-2019, 11:15 PM
Last Post: ZenWoR

Forum Jump:

User Panel Messages

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