473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 6672

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

Similar topics

21
7904
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 be done? if yes, then how? Also, how do I link a command button click to the opening of files within the cd, i.e. word, excel and access files? Thanks
1
2359
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 ideas, and maybe write up an article later. AOP is not just buzzword. It's not just callback, it's not just Ruby's MixIn, it's not just Python's metaclass, it's not just C++'s template. AOP can be implemented/considered as a subset of...
4
2300
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 organization, and I'm donating the work. Haven't done Web work in a while, and things have changed since I last did anything of this magnitude. I'm looking for a solution that will enable me to edit pages easily and in totally WYSIWYG fashion, while...
2
1590
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 what I have been trying to work out for these functions but can't get them to fully work out for me. information: A function to access an element of a list by its index called access i(LL, i). It traverses the list LL and returns the address of...
2
1982
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 computer knowledge at all! And they also have outdated, old browsers, slow modems, old computers, etc. So I need to keep this as simple as possible and as browser compatible as possible. The client wants a navigation bar at the bottom of each...
66
5337
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 occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of occurences. The second is to let you enter a word, with the program reporting how many times the...
1
1194
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 general consensus on how to proceed from here. Thank you in advance for anyone who takes the time to reply... I am upgrading a VB4.0 program for a client who distributes it to its reps worldwide. We are not at the point where we want to make...
232
13242
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 set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
6
1503
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 dialog box, but that this button is greyed out because the user hasn't entered their username yet. Now let's say the user writes some code that sends a message to the dialog box to enable the "Proceed" button even tho the programmer didn't design...
4
1573
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 broken up into smaller programs/modules that can be called from the main program. I understand that I would need to, via a Click Button to close one part down and open the new section, but how.
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.