473,416 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Python:how to create a set of buttons on top of a label in my main window

Brand new to Python. I am looking on advice on how to create a set of buttons on top of a label in my main window.

These 5-6 buttons will be chosen from 3 excel sheets based by the user values set in a QSpinBox (values 1-20) and a QSlider (values 1-3). Then the buttons will be generated by a QButton and each button can be closed after user interaction.

IE: A user setting of QSpinBox "1" will pull randomly from row 1 values and QSLider "1" will select the specific sheet one. Next when QButton is pressed the 5-6 buttons will populate. Clicking on the buttons will generate a note which then can be closed and that button disappears.

So far I have my main window and I can load a user image into a label which I want the random buttons to generate over

Expand|Select|Wrap|Line Numbers
  1. from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QLabel, QFileDialog
  2. from PyQt5 import uic
  3. from PyQt5.QtGui import QPixmap
  4. import sys
  5.  
  6. class UI(QMainWindow):
  7.     def __init__(self):
  8.         super(UI, self).__init__()
  9.  
  10.         # Load the ui file
  11.         uic.loadUi("TEST2.ui", self)
  12.  
  13.         # Define widgets
  14.         self.button = self.findChild(QPushButton, "pushButton")
  15.         self.label = self.findChild(QLabel, "label")
  16.  
  17.         # Click The Dropdown Box
  18.         self.button.clicked.connect(self.clicker)
  19.  
  20.         # Show The App
  21.         self.show()
  22.  
  23.     def clicker(self):
  24.         fname = QFileDialog.getOpenFileName(self, "Open File", "c:\\gui\\images", "All Files (*);;PNG Files (*.png);;Jpg Files (*.jpg)")
  25.  
  26.         # Open The Image
  27.         if fname:
  28.             self.pixmap = QPixmap(fname[0])
  29.             # Add Pic to label
  30.             self.label.setPixmap(self.pixmap)
  31.  
  32. # Initialize The App
  33. app = QApplication(sys.argv)
  34. UIWindow = UI()
  35. app.exec_()
  36.  
Aug 13 '22 #1
0 6665

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Roy Riddex | last post by:
Hi I'm wanting to create a cd-rom which boots automatically when it's inserted into the computer. What I hope to achieve is for a VB6 program to run automatically when the cd boots up. Can this...
1
by: Hung Jung Lu | last post by:
Hi, I have been looking into AOP (Aspect-Oriented Programming) for sometime, now. I frankly don't like the syntax of any of the approaches I have seen so far. I am kind playing around with some...
4
by: Marquisha | last post by:
If this is off-topic, please forgive me. But I thought this might be the perfect spot to get some advice about how to proceed with a project. Working on a Web site design for a nonprofit...
2
by: duncanblacksmithmath | last post by:
I know a lot of you have seen this before but I have worked on the program and have gotten it to work thus far but I need help getting these two functions to work and implementing them. Here is...
2
by: Steve K | last post by:
I got a bit of a problem I like some help on. I'm designing an online training module for people that work in food processing plants. This is my target audience. These workers have little or no...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
1
by: jmar | last post by:
I posted on this topic a while back and received some good responses. However, I have better insight into what I'm looking to do so I am tapping the wealth of experience here again hoping to find a...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
6
by: =?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Usually someone writes a program and guarantees its behaviour so long as people don't deliberately go and try to make it malfunction. For instance, let's say we have a "Proceed" button on the...
4
by: =?Utf-8?B?MjJQb20=?= | last post by:
Hi All, This is all new to me so please be patient with me. What I have is a very large 'Al-In-One' program, not yet complete, that has over 70 Forms/Modules/Classes in it and needs to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.