Im posting a python program and need to convert it to C++ language.
import Tkinter
import Tkinter as tk
from Tkinter import *
import time
def current_iso8601():
"""Get current date and time in ISO8601"""
# https://en.wikipedia.org/wiki/ISO_8601
# https://xkcd.com/1179/
return time.strftime("%m.%d.%Y DATE %H:%M:%S
TIME")
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self,
master)
self.pack()
self.createWidgets()
def tstampIn(self):
clockFile =
open("clockTracker.txt","w")
print "You have
successfuly Clocked In \n"
clockIn =
time.strftime("%m.%d.%Y DATE %H:%M:%S TIME, CLOCK IN \n")
print clockIn
clockFile.write(clockIn)
clockFile.close
def tstampOut(self):
clockFile =
open("clockTracker.txt", "a")
print "You have
successfuly Clocked Out \n"
clockOut =
time.strftime("%m.%d.%Y DATE %H:%M:%S TIME, CLOCK OUT \n")
print clockOut
clockFile.write(clockOut)
clockFile.close
def LstampIn(self):
clockFile =
open("clockTracker.txt", "a")
print "You have
successfuly Clocked Out for LUNCH \n"
lunchIn =
time.strftime("%m.%d.%Y DATE %H:%M:%S TIME, LUNCH STARTED
\n")
print lunchIn
clockFile.write(lunchIn)
clockFile.close
def LstampOut(self):
clockFile =
open("clockTracker.txt", "a")
print "You have
successfuly Clocked In from LUNCH \n"
lunchOut =
time.strftime("%m.%d.%Y DATE %H:%M:%S TIME, LUNCH ENDED \n")
print lunchOut
clockFile.write(lunchOut)
clockFile.close
def createWidgets(self):
self.now =
tk.StringVar()
self.time =
tk.Label(self, font=('Helvetica', 24))
self.time.pack(side="top")
self.time["textvariable"] = self.now
self.t_stamp =
Button(self, fg="green")
self.t_stamp["text"] =
"CLOCK IN"
self.t_stamp["command"]
= self.tstampIn
self.t_stamp.pack(side="top")
self.t_stamp =
Button(self, fg="blue")
self.t_stamp["text"] =
"LUNCH BEGIN"
self.t_stamp["command"]
= self.LstampIn
self.t_stamp.pack(side="left")
self.t_stamp =
Button(self, fg="green")
self.t_stamp["text"] =
"LUNCH END"
self.t_stamp["command"]
= self.LstampOut
self.t_stamp.pack(side="right")
self.t_stamp =
Button(self, fg="blue")
self.t_stamp["text"] =
"CLOCK OUT"
self.t_stamp["command"]
= self.tstampOut
self.t_stamp.pack(side="bottom")
self.QUIT =
tk.Button(self, text="QUIT", fg="red",
command=root.destroy)
self.QUIT.pack(side="bottom")
# initial time
display
self.onUpdate()
def onUpdate(self):
# update displayed
time
self.now.set(current_iso8601())
# schedule timer to call
myself after 1 second
self.after(1000,
self.onUpdate)
root = tk.Tk()
app = Application(master=root)
root.mainloop()
This program is difficult to convert to C++ . The reasons are mentioned below.
1. TkInter is used in this Code. It is related to GUI
2. C++ don't have native GUI API library. Based on the Platform(Windows/Linux) there are some OS specific toolkits will be there like GTK etc. We have to use third party libraries like Qt or WxWidgets etc to program GUI. They are licenced. :(
Im posting a python program and need to convert it to C++ language. import Tkinter import...
Hi I am using python and I keep getting this error with my code. Traceback (most recent call last): ['1'] Traceback (most recent call last): File "/Users/isabellawelch/Python ish/shuffle.py", line 86, in <module> emp = Employee(emp_data[0], emp_data[1], emp_data[2], emp_data[3], emp_data[4]) IndexError: list index out of range What does it mean and how do i fix it?? from tkinter import Tk, Label, Button, Entry, END employees = [] class Employee: def __init__(self, empno, name, addr, hwage, hworked): self.empno = empno self.name =...
Here is my code for minesweeper in python and it has something
wrong. Could you please help me to fix it?
import tkinter as tk
import random
class Minesweeper:
def __init__(self):
self.main = tk.Tk()
self.main.title("mine sweeper")
self.define_widgets()
self.mines = random.sample( [(i,j) for i in range(25) for j in
range(50) ],self.CustomizeNumberOfMines())
print(self.mines)
self.main.mainloop()
self.CustomizeNumberOfMines()
def define_widgets(self):
""" Define a canvas object, populate it with squares and
possible texts """
self.canvas = tk.Canvas(self.main, width = 1002, height=502,
bg="#f0f0f0")
self.canvas.grid(row=0, column=0)
self.boxes =...
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...
Please convert the following python program to LINE BY LINE python pseudocode. Please convert LINE BY LINE (typed) class vector: def __init__(self,x,y): self.x = x # Assigning x to vector's x self.y = y # Assigning y to vector's y def __str__(self): return '('+str(self.x)+","+str(self.y)+')' # This returns the value of vector in bracket format def __add__(self,other): x = self.x+other.x # values of x of vector1 and vector2 are added forming new x value y = self.y+other.y # same is done...
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 =...
11q
Language is python need help
1) What is the output of the following code? Refer to the class defined here. Example: File 1: asset.py import asset class Asset: brains = asset.Asset( "Brains" ) strength = asset. Asset( "Strength" ) steel = asset.Asset( "Steel" ) wheelbarrow = asset. Asset( "Wheelbarrow" ) cloak = asset.Asset( "Cloak" ) def _init__( self, name): self.mName = name return def getName( self ): return self.mName al = strength + steel a2 = cloak + wheelbarrow...
11p
Python Language
Read the following code for oofraction. import oofraction class OOFraction: def main(): fl = oofraction.o0Fraction( 2, 5) f2 = oofraction.o0Fraction ( 1, 3) f3 = f1 + f2 print (str(3)) main() def __init__(self, Num, Den): self.mNum = Num self.mDen = Den return def_add_(self,other): num = self.mNumother.mDen + other.mNum*self.mDen den = self.mDen*other.mDen f = OOFraction(num,den) return f 1. Write the output below. def_str_(self): s = str( self.mNum )+"/" + str( self.mDen) returns 2. Write a class called wholeNum...
Python 3 Question: All I need is for someone to edit the program with comments that explains what the program is doing (for the entire program) def main(): developerInfo() #i left this part out retail = Retail_Item() test = Cash_Register() test.data(retail.get_item_number(), retail.get_description(), retail.get_unit_in_inventory(), retail.get_price()) answer = 'n' while answer == 'n' or answer == 'N': test.Menu() print() print() Number = int(input("Enter the menu number of the item " "you would like to purchase: ")) if Number == 8: test.show_items() else:...
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,...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...