ModuleNotFoundError: No module named 'breezypythongui' - python

I have created GUI program in python which converts C2F and F2C when I run my program I get an error though I imported module correctly. Can anyone please help me to solve an error
Code:
from breezypythongui import EasyFrame
#from tkinter import PhotoImage
from tkinter import *
class ProgDemo(EasyFrame):
def __init__(self):
EasyFrame.__init__(self,width="600", title = "Program")
self.addLabel(text = "Temp",row = 1, column = 0)
self.getinput = self.addFloatField(value = 0.0,row = 1,column = 1)
self.addLabel(text = "Output",row = 2, column = 0)
self.op = self.addFloatField(value = 0.0,row = 2,column = 1)
self.grp1 = self.addRadiobuttonGroup(row = 3,column = 0)
C_to_F = self.grp1.addRadiobutton(text = "C to F")
F_to_C = self.grp1.addRadiobutton(text = "F to C")
self.conBtn = self.addButton(text = "convert",row = 5, column = 0,command = self.tempc)
self.resetBtn = self.addButton(text = "reset",row = 5, column = 1,command = self.reseti)
def tempc(self):
ipval = self.getinput.getNumber()
if self.grp1.getSelectedButton()["value"] == "C to F":
op = 9.0/5.0 * ipval + 32
else:
op = (ipval - 32) * 5.0/9.0
self.op.setValue(op)
def reseti(self):
self.getinput.setValue(0);
self.op.setValue(0);
def main():
ProgDemo().mainloop()
if __name__ == "__main__":
main()
Screenshot:

It seems like, the module is missing and you need it.
So download and install it: http://home.wlu.edu/~lambertk/breezypythongui/

You need to have the module breezepythongui.py and your python code in the same folder. Not only having the folder but both modules must be in the same folder.
For example; My python code "myfirstguiproject.py" and "breezypythongui.py" are in the same folder.
I know when you extract the downloaded zip file named breezypythongui.zip, it will create a folder and in that folder there is the "breezypythongui.py" module. You need to get rid of the folder and only keep the module (breezypythongui.py).

Related

python: extract variables values from `json` and use in `jupyter` notebook for a function throwing an error

I have a par.json file were i stored the variable values. And fetched the values in .py file successfully. I'm trying to run all function of .py file in jupyter notebook (all is in same location) where .py file already getting values from json file but while running in jupyter notebook it is throwing an error called as 'b_threshold' is not defined
json file I have
{
"mul": 200,
"b_threshold": 2,
"a_threshold": 5,
}
the multi.py file snippet is below
def h_b_acc(data, har={}):
trr = data.tt.unique()
# global b_threshold, a_threshold, mul
for tr in trr:
temp_dict = {}
temp_df = data.loc[data['tt']==tr].copy()
temp_df['b_event'] = temp_df['aci'].apply(lambda x: 1 if x < b_threshold else 0)
temp_df['a_event'] = temp_df['aci'].apply(lambda x: 1 if x > a_threshold else 0)
total_d_dis = temp_df['dd'].max() - temp_df['dd'].min()
temp_dict['b_s'] = (2015* mul)/ total_d_dis
temp_dict['a_s']= (2016 * mul)/ total_d_dis
har['tr_' + str(tr)] = temp_dict
# print(temp_dict)
return har
if __name__ =='__main__':
try:
with open(r'path\par.json', "r") as prm_mp:
pp = json.load(prm_mp)
b_threshold = pp.get('b_threshold', 2)
a_threshold = pp.get('a_threshold', 5)
mul = pp.get(['mul'],200)
except:
print("Parameter mapping file not parsed")
loaded json file in following way in jupyter notebook
with open(r'path\par.json', "r") as prm_mp:
pp = json.load(prm_mp)
b_threshold = pp.get('b_threshold', 2)
a_threshold = pp.get('a_threshold', 5)
mul = pp.get(['mul'],200)
har_1 = multi.h_b_acc(tm)
har_1
showing following error .. how can I import it ? or may I wrong in writing function.
Your imported module multi and its function h_b_acc() do not have access to your variables a_threshold and b_threshold. I recommend that you modify multi.h_b_acc() to pass them as optional arguments, so you can use the function in the Jupyer Notebook, as well as use your global variables in multi.py when needed. (It's also probably a good idea to ALL-CAPS your global variables)
def h_b_acc(data, a_threshold=A_THRESHOLD, b_threshold=B_THRESHOLD, mul=MUL, har={}):
trr = data.tt.unique()
for tr in trr:
temp_dict = {}
temp_df = data.loc[data['tt']==tr].copy()
temp_df['b_event'] = temp_df['aci'].apply(lambda x: 1 if x < b_threshold else 0)
temp_df['a_event'] = temp_df['aci'].apply(lambda x: 1 if x > a_threshold else 0)
total_d_dis = temp_df['dd'].max() - temp_df['dd'].min()
temp_dict['b_s'] = (2015* mul)/ total_d_dis
temp_dict['a_s']= (2016 * mul)/ total_d_dis
har['tr_' + str(tr)] = temp_dict
# print(temp_dict)
return har
This, way, in your Jupyter Notebook, you can do the following:
with open(r'path\par.json', "r") as prm_mp:
pp = json.load(prm_mp)
b_threshold = pp.get('b_threshold', 2)
a_threshold = pp.get('a_threshold', 5)
mul = pp.get(['mul'],200)
har_1 = multi.h_b_acc(tm, a_threshold, b_threshold, mul)
har_1

I can't make reference to the checkbutton variable 2 times, in the second it says the name is not defined

Can anyone tell me why I can only refer to the Checkbutton variable once? the important part of code is bold.
The first time that I use the variable it run, but the second, the same variable dont work. I think I tried very much but dont work!
def botao_executar():
botão_executar = comand of Button
if (pag1 <= numero_quadros):
img1 = cv.imread('imagemfinal.jpg')
novo_y_1 = int(num_novos_y*1)
crop_image_1 = img1[0:novo_y_1]
status = cv.imwrite('Desktop\ORC/crop_image1.png', crop_image_1)
q = 590
a = (q+220)
z = (q-590)
p = (q+250)
#Dimensoes_1
crop_image_1_1_dimensoes = crop_image_1[q+60:a-20, z:p]
status_dimensoes = cv.imwrite('Desktop\ORC/crop_image1.1_dimensoes.png', crop_image_1_1_dimensoes)
img_1_1_dimensoes = PIL.Image.open('Desktop\ORC/crop_image1.1_dimensoes.png')
pytesseract.pytesseract.tesseract_cmd =r'C:\Users\joaoccfaria\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'
result_1_1_dimensoes = pytesseract.image_to_string(img_1_1_dimensoes, config='--psm 6 digits')
with open('abc.txt',mode ='w') as file:
file.write(result_1_1_dimensoes)
if v_dimensoes.get()> 0:
v_dimensoes.get= variable of checkbutton here it works!
print('dimensoes_1 = '+ result_1_1_dimensoes + ';')
sheet.write('A1', result_1_1_dimensoes)
else:
pass
pag2 = 2
if (pag2 <= numero_quadros):
img2 = cv.imread('imagemfinal.jpg')
novo_y_1 = int(num_novos_y*1)
crop_image_2 = img2[novo_y_1:novo_y_1*2]
status = cv.imwrite('Desktop\ORC/crop_image2.png', crop_image_2)
q = 590
a = (q+220)
z = (q-590)
p = (q+250)
#Dimensoes_2
crop_image_2_1_dimensoes = crop_image_2[q+60:a-20, z:p]
status_dimensoes = cv.imwrite('Desktop\ORC/crop_image2.1_dimensoes.png', crop_image_2_1_dimensoes)
img_2_1_dimensoes = PIL.Image.open('Desktop\ORC/crop_image2.1_dimensoes.png')
pytesseract.pytesseract.tesseract_cmd =r'C:\Users\joaoccfaria\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'
result_2_1_dimensoes = pytesseract.image_to_string(img_2_1_dimensoes, config='--psm 6 digits')
with open('abc.txt',mode ='w') as file:
file.write(result_2_1_dimensoes)
if v_dimensoes.get()> 0:
here the same variable, but says that the name is not defined
print('dimensoes_2 = '+ result_2_1_dimensoes + ';')
sheet.write('A21', result_2_1_dimensoes)
else:
pass
Thanks in advance, any suggestion. Compliments.

NameError: name 'packet' is not defined - RLBot

I'm trying to write a script to record player movement in Rocket League using the RLBot framework. I've got very minimal experience with code and I've been getting the error:
Traceback (most recent call last):
File "c:/Users/Julian/AppData/Local/RLBotGUIX/RLBotPackDeletable/RLBotPack-master/RLBotPack/CustomMutators/playerRecorder.py", line 27, in <module>
class playerRecorder(BaseScript):
File "c:/Users/Julian/AppData/Local/RLBotGUIX/RLBotPackDeletable/RLBotPack-master/RLBotPack/CustomMutators/playerRecorder.py", line 45, in playerRecorder
for car in packet.game_cars:
NameError: name 'packet' is not defined
Packet is defined within def run(self): but I'm still getting an error for it not being defined. Below is my full script from within VS Code. Any help is appreciated.
from typing import Optional
from rlbot.agents.base_agent import BaseAgent, GameTickPacket, SimpleControllerState
import os
import time
import math
from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
from rlbot.utils.structures.game_data_struct import GameTickPacket
from rlbot.utils.game_state_util import GameState, BallState, CarState, Physics, Vector3 as vector3, Rotator
import random
from rlbot.agents.base_script import BaseScript
from rlbot.utils.game_state_util import GameState
DIRECTORY_LOCATION = "C:\Logs\Recorder\log"
randNum = random.randint(0,9999999999)
# Extending the BaseScript class is purely optional. It's just convenient / abstracts you away from
# some strange classes like GameInterface
class playerRecorder(BaseScript):
def __init__(self):
super().__init__("playerRecorder")
packet = self.get_game_tick_packet()
self.writeFile = open(DIRECTORY_LOCATION+"\\"+"HumanLog"+str(car.team)+"-"+str(randNum), "w")
def run(self):
while True:
packet = self.get_game_tick_packet()
get_output(packet)
sleep(1 / 3)
print("test")
for car in packet.game_cars:
if not car.is_bot:
team = car.team
index = car.index
break
def get_output(self, game_tick_packet):
#***************************************************************
packet = self.get_game_tick_packet()
goodTeam = str(car.team)
goodLoc = packet.game_cars[car.index].physics.location
goodLocX = str(goodLoc.x)
goodLocY = str(goodLoc.y)
goodLocZ = str(goodLoc.z)
goodRot = packet.game_cars[car.index].physics.rotation
goodRotP = str(goodRot.pitch)
goodRotY = str(goodRot.yaw)
goodRotR = str(goodRot.roll)
goodVel = packet.game_cars[car.index].physics.velocity
goodVelX = str(goodVel.x)
goodVelY = str(goodVel.y)
goodVelZ = str(goodVel.z)
goodAngVel = packet.game_cars[car.index].physics.angular_velocity
goodAngVelX = str(goodAngVel.x)
goodAngVelY = str(goodAngVel.y)
goodAngVelZ = str(goodAngVel.z)
hasWC = str(packet.game_cars[car.index].has_wheel_contact)
isSS = str(packet.game_cars[car.index].is_super_sonic)
jumped = str(packet.game_cars[car.index].jumped)
dJumped = str(packet.game_cars[car.index].double_jumped)
bst = str(packet.game_cars[car.index].boost)
ballLoc = packet.game_ball.physics.location
ballLocX = str(ballLoc.x)
ballLocY = str(ballLoc.y)
ballLocZ = str(ballLoc.z)
ballVel = packet.game_ball.physics.velocity
ballVelX = str(ballVel.x)
ballVelY = str(ballVel.y)
ballVelZ = str(ballVel.z)
self.writeFile.write(goodTeam+";"+
goodLocX+","+goodLocY+","+goodLocZ+";"+
goodRotP+","+goodRotY+","+goodRotR+";"+
goodVelX+","+goodVelY+","+goodVelZ+";"+
goodAngVelX+","+goodAngVelY+","+goodAngVelZ+";"+
hasWC+";"+isSS+";"+jumped+";"+dJumped+";"+bst+";"+
ballLocX+","+ballLocY+","+ballLocZ+";"+
ballVelX+","+ballVelY+","+ballVelZ)
self.writeFile.write("\n")
## WRITE OPPONENT
badIndex = -1
for i in range(len(packet.game_cars)):
if i != car.index:
badIndex = i
break
assert badIndex != car.index
assert badIndex != -1
badTeam = str(packet.game_cars[badIndex].team)
badLoc = packet.game_cars[badIndex].physics.location
badLocX = str(badLoc.x)
badLocY = str(badLoc.y)
badLocZ = str(badLoc.z)
badRot = packet.game_cars[badIndex].physics.rotation
badRotP = str(badRot.pitch)
badRotY = str(badRot.yaw)
badRotR = str(badRot.roll)
badVel = packet.game_cars[badIndex].physics.velocity
badVelX = str(badVel.x)
badVelY = str(badVel.y)
badVelZ = str(badVel.z)
badAngVel = packet.game_cars[badIndex].physics.angular_velocity
badAngVelX = str(badAngVel.x)
badAngVelY = str(badAngVel.y)
badAngVelZ = str(badAngVel.z)
badhasWC = str(packet.game_cars[badIndex].has_wheel_contact)
badisSS = str(packet.game_cars[badIndex].is_super_sonic)
badjumped = str(packet.game_cars[badIndex].jumped)
baddJumped = str(packet.game_cars[badIndex].double_jumped)
badbst = str(packet.game_cars[badIndex].boost)
self.writeFile.write(badTeam+";"+
badLocX+","+badLocY+","+badLocZ+";"+
badRotP+","+badRotY+","+badRotR+";"+
badVelX+","+badVelY+","+badVelZ+";"+
badAngVelX+","+badAngVelY+","+badAngVelZ+";"+
badhasWC+";"+badisSS+";"+badjumped+";"+baddJumped+";"+badbst)
self.writeFile.write("\n")
## WRITE ACTION
self.writeFile.write(str(action.throttle)+";"+str(action.steer)+";"+str(action.pitch)+";"+str(action.yaw)+";"+str(action.action.roll)+";"+str(action.jump)+";"+str(action.boost))
self.writeFile.write("\n")
##*****************************************************
return action
In the run(...) function you should type self.get_output(packet) instead of get_output(). You have to pass a packet as a parameter to a function and also you should write self before the name of a function because it's inside a class. I think you also misspelled the parameter of the get_output function because you've named it game_tick_packet and in the function you are using variable named just a packet.

evaluate sqrt in text in graphics of python

Because of long codings, I put codings in this link:http://textuploader.com/5xofp
Here is the small codings:
from graphics import *
from math import *
def main():
win = GraphWin('Simple Calculator',400,600)
win.setBackground('slategray')
p1 = Point(10,70)
p2 = Point(390,10)
display_box = Rectangle(p1,p2)
display_box.draw(win)
text = Text(Point(190,30),"")
text.setStyle('italic')
text.setSize(15)
text.draw(win)
sqrt = Rectangle(Point(70,190),Point(120,140))
sqrt.draw(win)
sqrt1 = Text(Point(95,165),"√ ")
sqrt1.setStyle('italic')
sqrt1.setSize(36)
sqrt1.draw(win)
eq_sign = Rectangle(Point(170,510),Point(240,440))
eq_sign.draw(win)
eq = Text(Point(205,475),"=")
eq.setStyle('italic')
eq.setSize(36)
eq.draw(win)
num1 = Rectangle(Point(10,270),Point(80,200))
num1.draw(win)
num1_ = Text(Point(45,235),"1")
num1_.setStyle('italic')
num1_.setSize(36)
num1_.draw(win)
if 10<=mouse.x<=80 and 200<=mouse.y<=270:
text.setText(text.getText()+"1")
if 70<=mouse.x<=120 and 140<=mouse.y<=190:
text.setText(text.getText()+"sqrt(")
if 170<=mouse.x<=240 and 440<=mouse.y<=510:#=
try:
result = eval(text.getText())
except:
result = "ERROR"
text.setText(result)
main()
why when I enters sqrt(36), it gives error in the text? I have already made it as a string.
Is there any mistake in my codings?
sqrt = Rectangle(Point(70,190),Point(120,140))
sqrt.draw(win)
This overwrites the math module's sqrt function with a Rectangle object. Try changing the name of this variable to something else.
sqrt_button = Rectangle(Point(70,190),Point(120,140))
sqrt_button.draw(win)

Python - Change the textField after browsing - MAYA

I've got the most annoying problem with my GUI Exporter in Maya. I've made the textField etc. work, but I can't change the value of the textField after it's created, which is what I need to do.
What I want to do for example is, let's say the filepath is none from the beginning. The textField has now printed out: "None" in it, but after you press browse and select a directory, I want it to change None to the directory path etc.
That's the only problem I currently have and the error code received is this:
Error: RuntimeError: file C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\pmcmds.py line 134: Too many children in layout: rowLayout3 #
Code:
#Setup the window using the returned window
def setupWindow(self, new_window):
try:
frame_layout = pm.frameLayout(labelVisible = False, marginWidth = 5, marginHeight = 5)
pm.columnLayout(w = 350, h = 300)
pm.text(label = "Filepath: ")
self.textField = pm.textField("FieldNorm", text = "%s" % self.filePath, editable = False, w = 350, h = 20)
pm.button(label = "Browse", w = 100, h = 20, command = self.browse)
pm.rowLayout(numberOfColumns = 2, adjustableColumn = 1, w = 350, h = 25)
pm.button(label = "Export", w = 200, h = 25, command = self.export)
pm.button(label = "Close", w = 100, h = 25, command = pm.Callback(self.closeButton, new_window))
except:
print "<Setting up window failed>"
#Show the returned window
def showWindow(self, new_window):
if new_window is not None:
pm.showWindow(new_window)
else:
print "<Window does not exist!>"
#Browse Directory and Paste into textField
def browse(self, filePath):
self.filePath = pm.fileDialog2(dialogStyle = 2, returnFilter = 1, fileFilter = "*.obj")
if self.filePath is not None:
self.textField = pm.textField("FieldNorm", text = "%s" % self.filePath, editable = False, w = 350, h = 20)
else:
print "<No changes has been made!>"
Looks like you need the edit flag in the pm.textField line in browse()
pm.textField("FieldNorm", edit=True, text = "%s" % self.filePath)
The error means you are adding a new control, probably to the rowlayout at the end of the setupWindow function which holds the two buttons - Maya thinks you're adding a third
If you want to update the contents of self.textfield in the browse functions, you want
pm.textField(self.textField, e=True, text = "%s" % self.filePath, editable = False, w = 350, h = 20)
which will edit the already created field. The line in the example
self.textField = pm.textField("FieldNorm", text = "%s" % self.filePath, editable = False, w = 350, h = 20)
is trying to create a new one, as #julianMann points out

Categories