Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code:
#All modules are built into Python so there is no need for any installation
import tkinter
from tkinter import Label
from tkinter import Entry
def calculatewages():
hours=float(nhours.get())
nsal=float(nwage.get())
wage=nsal*hours
labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" %
wage).grid(row=7,column=2)
return
Tk = tkinter.Tk()
myGUI=Tk
myGUI.geometry('400x200+100+200')
myGUI.title('Pay Calculator')
nwage=float()
nhours=float()
label1=Label(myGUI,text='Enter the number of hours worked for
the week').grid(row=1, column=0)
label2=Label(myGUI,text='Enter the pay rate').grid(row=2,
column=0)
mywage=Entry(myGUI,textvariable=nwage).grid(row=1,column=2)
myhours=Entry(myGUI,textvariable=nhours).grid(row=2,column=2)
myGUI.mainloop()
Problem is, when I type in the hours worked field, it fills in the wage rate field also. How do I make it so I can type in separate values in the fields and have it calculate the weekly pay by clicking a Calculate Pay button at the bottom?
Thanks for the question, here is the updated code. Now the values wont get copied to the other Entry box.
=============================================================================
import tkinter
from tkinter import Label
from tkinter import Entry
def calculatewages():
hours=float(myhours.get())
nsal=float(mywage.get())
wage=nsal*hours
labelresult=Label(myGUI,text="Weekly
Pay: $ %.2f" % wage).grid(row=7,column=2)
return
Tk = tkinter.Tk()
myGUI=Tk
myGUI.geometry('400x200+100+200')
myGUI.title('Pay Calculator')
label1=Label(myGUI,text='Enter the number of hours worked
for the week').grid(row=1, column=0)
label2=Label(myGUI,text='Enter the pay
rate').grid(row=2, column=0)
mywage=Entry(myGUI).grid(row=1,column=2)
myhours=Entry(myGUI).grid(row=2,column=2)
myGUI.mainloop()
=========================================================================
Help with Python code. Right now I'm creating a code in Python to create a GUI....
The Gui has all the right buttons, but from there i get lost. I need to know whats wrong with my assignment can someone please help. The code I have so far is listed below, could you please show me the errors in my code. PYTHON Create the GUI(Graphical User Interface). Use tkinter to produce a form that looks much like the following. It should have these widgets. Temperature Converter GUI Enter a temperature (Entry box) Convert to Fahrenheit...
Demonstrate this result for the parallel calculation. CODE: from Tkinter import * # MODIFY THIS TO HANDLE THREE RESISTORS __author__ = "robincarr" """ GUI version of Resistor Calculator finds the equivalent resistance for two resistors connected either in series or parallel. Features entry widgets and buttons.""" def series_calculation(): r1 = float(resistor1.get()) r2 = float(resistor2.get()) req = r1 + r2 equivalent_resistance.delete(0, END) # Clear the previous result. equivalent_resistance.insert(0, req) print("Resistor 1: %s\nResistor 2: %s" % (r1, r2)) print "The equivalent series...
Need help with Intro to Comp Sci 2 (Python) problem:
This is what is provided:
(Copy/Paste version):
from tkinter import Tk, Label, Entry, Button
from random import *
class Craps(Tk):
#set up the main window
def __init__(self, parent=None):
Tk.__init__(self, parent)
self.title('Play Craps')
self.new_game()
self.make_widgets()
#when a new game is started, the firstRoll will start at 0
def new_game(self):
self.firstRoll = 0
#create and place the widgets in the window
def make_widgets(self):
Label(self, text="Die 1").grid(row=0, column=0, columnspan=1)
Label(self, text="Die 2").grid(row=0,...
Python
Consider the GUI below (3 Labels and 3 Radiobuttons) which has
been produced with a Python program using the Tkinter
library.
You are required to write a Python program to produce this
interactive GUI.
Your GUI must replicate the example above as closely as
possible, including the same widgets displayed in the sample
positions on the GUI, using the same colours, shapes and relative
sizes. (Note that the GUI border in the sample output does not need
to be...
Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window,...
########### Homework 20 ################################## ################################################### #### Rewrite this code in 'class mode' : define the class and so on.... #### If you can - try make a clicked button 'blue'. #### (Only if you can.) from tkinter import * abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def callback(x): label.configure(text = 'Button {} clicked'. format(abc[x])) root = Tk() label = Label() label.grid(row = 1, column = 0, columnspan = 26) buttons = [0]*26 ##create a list to hold 26 buttons for i in range(26): buttons[i]...
Python 3 I am trying to get my GUI Celsius to Fahrenheit calculator to work, why won't this run? let me know what to change specifically import tkinter import tkinter.messagebox class GUI: def __int__(self): self.main_window=tkinter.Tk() self.frame1=tkinter.Frame(self.main_window) self.frame2=tkinter.Frame(self.main_window) self.frame3=tkinter.Frame(self.main_window) self.label1=tkinter.Label(self.frame1,text="Enter Celsius value: ") self.entry1=tkinter.Entry(self.frame1,width=10) self.label1.pack(side='left') self.entry1.pack(side='left') self.far=tkinter.StringVar() self.res=tkinter.Label(self.frame2,text='The Fahrenheit value is:') self.result=tkinter.Label(self.frame2,textvariable= self.far) self.res.pack(side='left') self.result.pack(side='left') self.calc=tkinter.Button(self.frame3,text='Calculate Fahrenheit',command=self.calfahr) self.quit_button=tkinter.Button(self.frame3,text='Quit',command=self.main_window.destroy) self.calc.pack(side='left') self.quit_button.pack(side='left') self.frame1.pack() self.frame2.pack() self.frame3.pack() tkinter.mainloop() def calfahr(self): self.test1=float(self.entry1.get()) self.thisanswer=float((1.8*(self.test1))+32) self.far.set(self.thisanswer) g=GUI()
Python 3 Code does not save the data into excel properly # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) # arraging barcode.grid(row=0, column=1) product.grid(row=1, column=1) money.grid(row=2, column=1) cal =...
Using Python GUI
from tkinter import *
from tkinter.ttk import *
def main():
window = Tk()
window.mainloop()
main()
Create a basic integer calculator program that uses two entries, a combo box, two labels, and a button to do basic calculations, as shown in the images below. The combo box should have the options for addition, subtraction, and multiplication, displayed as', andrespectively. Row 0 of the layout grid must contain an entry, the combo box and another entry in columns 0...