GridSizer is not placing my elements correctly - python-3.x

what im trying to do is make a 4X3 Gridsizer and attach my object on each spot but when I run it , it appears to run fine but everything is smooshed to the left side. I don't see what im doing wrong Below is the code for that section of my program
class F_WaferMaps ( wx.Frame ):
def __init__( self, parent, dateBegin , dateEnd):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 800,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
gSizer1 = wx.GridSizer( 4, 3, 3,3 )
waferDesign = WaferInfo(die_size = (.3,.45),center_xy= (10 ,6.5), dia= 6.0 , edge_excl= 0.0 )
waferInfo = pd.read_excel("file.xlsx", index_col= None, na_values=['NA'] , usecols=[18,4,5,21,2])
df2 = waferInfo[(waferInfo.FILE_FINISH_TS >= dateBegin) & (waferInfo.FILE_FINISH_TS <= dateEnd) ]
waferSubSet = df2[['X', 'Y' , 'HB', 'TIME' , 'LOT']]
df3 = waferSubSet[~(waferSubSet[['X_COORD', 'Y_COORD', 'LOT_WF']].duplicated(keep = 'last'))]
a = 0
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
self.vbox = wx.BoxSizer(wx.VERTICAL)
waferNum = 0
for lotID, wafNum in df3.groupby(['LOT_WF']):
df4 = wafNum[['X_COORD', 'Y_COORD', 'HB_NUM']]
print(wafNum)
print("\n")
my_list = df4.transform(tuple, axis=1).tolist()
self.panels = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower())
gSizer1.Add(self.panels,1)
waferNum += 1
self.SetSizer( gSizer1 )
self.Layout()
self.Centre( wx.BOTH )
so I want my output to look like
A B C
D E F
G H I
J K M
but instead im getting something like
A
B
C
D
E
etc
Below is the class of the WaferMapApp like requested in the comments
def _init_ui(self):
"""Create the UI Elements and bind various events."""
# Create items to add to our layout
self.canvas = FloatCanvas.FloatCanvas(self,
BackgroundColor="BLACK",
)
# Initialize the FloatCanvas. Needs to come before adding items!
self.canvas.InitAll()
# Create the legend
self._create_legend()
# Draw the die and wafer objects (outline, crosshairs, etc) on the canvas
self.draw_die()
if self.plot_die_centers:
self.draw_die_center()
self.draw_wafer_objects()
# Bind events to the canvas
self._bind_events()
# Create layout manager and add items
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
self.hbox.Add(self.legend, 0, wx.EXPAND)
self.hbox.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(self.hbox)
im not sure if is the layout of this that is causing the issue

Related

How to pass arguments to lambda function in yscrollcommand in tkinter Listbox?

6 Listbox objects are generated in a for loop in app class.
And its yscrollcommand, 6 functions are hard coded.
(def function for 0, def function for 1...)
It seems if I can pass the index argument to lambda function,
6 functions for list scroll can be compressed to 1 for loop.
But the funtion in a class, it has argument 'self'.
It make me confusing.
How can I pass index argument to lambda function in yscrollcommand?
class app(tk.Frame):
def __init__(self):
self.root = tk.Tk()
self.root.title('title something')
# showing data frame
self.data_frame = tk.LabelFrame(self.root, text='')
self.data_frame.pack(fill='x')
self.scrollbar = tk.Scrollbar(self.data_frame)
self.scrollbar.pack(side='right', fill='y')
self.listboxes = []
self.listboxes_column = 6 # This can be vary.
# listboxes are in a list.
for i in range(self.listboxes_column):
self.listboxes.append(tk.Listbox(self.data_frame, selectmode='extended', height=20, width=0, yscrollcommand = self.scrollbar.set))
self.listboxes[i].pack(side='left')
# when self.listboxes_column == 3
# self.list_indexes == [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]
self.list_indexes = []
for i in range(self.listboxes_column):
indexes = [j for j in range(self.listboxes_column)]
indexes.remove(i)
self.list_indexes.append(indexes)
# a listbox can scroll the others
# with lambda function and argument passing,
# I want to make these 6 lines be in a for loop.
# The from like this
# for i in range(6):
# self.listboxes[index_argument].config(yscrollcommand = lambda ????? : self.list_scrolls_all(index_argument ????? ))
self.listboxes[0].config(yscrollcommand = self.list0_scrolls_all)
self.listboxes[1].config(yscrollcommand = self.list1_scrolls_all)
self.listboxes[2].config(yscrollcommand = self.list2_scrolls_all)
self.listboxes[3].config(yscrollcommand = self.list3_scrolls_all)
self.listboxes[4].config(yscrollcommand = self.list4_scrolls_all)
self.listboxes[5].config(yscrollcommand = self.list4_scrolls_all)
self.scrollbar.config(command=self.bar_scrolls_all)
self.root.mainloop()
# functions for lists scroll from 0 to 5.
# I don't know how to pass argument via yscrollcommand in Listbox.
# I want a form like this.
#
# def list_scrolls_all(self, index, *args):
# for i in self.list_indexes[index] :
# self.listboxes[i].yview_moveto(args[0])
# self.scrollbar.set(*args)
def list0_scrolls_all(self, *args):
for i in self.list_indexes[0] :
self.listboxes[i].yview_moveto(args[0])
self.scrollbar.set(*args)
def list1_scrolls_all(self, *args):
for i in self.list_indexes[1] :
self.listboxes[i].yview_moveto(args[0])
self.scrollbar.set(*args)
# scroll bar
def bar_scrolls_all(self,*args):
for i in range(self.listboxes_column):
self.listboxes[i].yview(*args)
I just happen to be working on a multi listbox program so I've made a few modifications to your code.
I've included flexx function so all objects for totally flexible, although I had to replace pack the grid.
import tkinter as tk
def flexx(m, r = 0, c = 0, rw = 1, cw = 1):
if r != None:
m.rowconfigure(r, weight = rw)
if c != None:
m.columnconfigure(c, weight = cw)
class app:
def __init__(self):
self.root = tk.Tk()
self.root.title('title something')
# make root flexible
flexx(self.root)
# showing data frame
self.data_frame = tk.LabelFrame(self.root, text='Multiple Linked Listboxes')
self.data_frame.grid(row = 0, column = 0, sticky = tk.NSEW)
self.listboxes = []
self.listboxes_column = 6 # This can be vary.
self.scrollbar = tk.Scrollbar(self.data_frame)
self.scrollbar.grid(row = 0, column = self.listboxes_column, sticky = tk.NS)
# listboxes are in a list.
for i in range(self.listboxes_column):
self.listboxes.append(tk.Listbox(
self.data_frame, selectmode='extended',
height=20, width=0))
self.listboxes[i].grid(row = 0, column = i, sticky = tk.NSEW)
# make data_frame flexible
flexx(self.data_frame, c = i)
# populate listbox with some data for testing purposes
for b in dir(self):
self.listboxes[i].insert("end", b)
# connect yscollcommand to all listboxes
for a in self.listboxes:
a["yscrollcommand"] = self.move_to
if False: # Not sure waht this does
# when self.listboxes_column == 3
# self.list_indexes == [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]
self.list_indexes = []
for i in range(self.listboxes_column):
indexes = [j for j in range(self.listboxes_column)]
indexes.remove(i)
self.list_indexes.append(indexes)
# connect scrollbar command to all y_views
self.scrollbar.config(command = self.y_view)
def y_view(self, *args):
for a in self.listboxes:
a.yview(*args)
def move_to(self, *args):
self.scrollbar.set(*args)
self.y_view("moveto", args[0])
if __name__ == "__main__":
demo = app()
demo.root.mainloop()

Python GUI Calculator backspace and clear

I'm making a simple calculator using tkinter. I have managed to get everything to work except for my backsapce and clear buttons.The error message I get is: 'TypeError: backspace() takes 0 positional arguments but 1 was given' for backspace and 'TypeError: clear() takes 0 positional arguments but 1 was given' for clear. I have looked around online tutorials but most of the tutorial I've found don't seem to have this problem.
from tkinter import *
root = Tk()
root.geometry("275x300")
root.title("Calculator")
def calculatorTitle():
labelTitle=Label(root, text="Calculator", bg = "black", fg = "white")
labelTitle.config(font = ("Verdana", 12, "bold"))
labelTitle.grid(row=0, column=0, columnspan=4, padx=55, pady=5)
e=Entry(root,width=20,font="Arial 12",justify='right', bg='yellow', fg = 'blue')
e.grid(row=1,column=0,columnspan=4, pady = 5)
def addEntry(ch):
e.insert(20, ch)
def CalculateEntry(expression):
expression = e.get()
expression = eval(expression)
e.delete(0, END)
e.insert(20, expression)
def clear():
e.delete(0, END)
return
def backspace():
current = e.get()
lenght = len(current)-1
e.delete(lenght, END)
def calculatorBoard():
b1=Button(root,text='1',width=5,command=lambda:addEntry(1))
b2=Button(root,text='2',width=5,command=lambda:addEntry(2))
b3=Button(root,text='3',width=5,command=lambda:addEntry(3))
bAddition=Button(root,text='+',width=5,command=lambda:addEntry('+'))
b4=Button(root,text='1',width=5,command=lambda:addEntry(4))
b5=Button(root,text='5',width=5,command=lambda:addEntry(5))
b6=Button(root,text='6',width=5,command=lambda:addEntry(6))
bSubtract=Button(root,text='-',width=5,command=lambda:addEntry('-'))
b7=Button(root,text='7',width=5,command=lambda:addEntry(7))
b8=Button(root,text='8',width=5,command=lambda:addEntry(8))
b9=Button(root,text='9',width=5,command=lambda:addEntry(9))
bMultiply=Button(root,text='*',width=5,command=lambda:addEntry('*'))
bClear=Button(root,text='CE',width=5,command=lambda:clear('CE'))
b0=Button(root,text='0',width=5,command=lambda:addEntry(0))
bBackspace=Button(root,text='<-',width=5,command=lambda:backspace('<-'))
bDivide=Button(root,text='/',width=5,command=lambda:addEntry('/'))
bEqual=Button(root,text='=',width=27,command=lambda:CalculateEntry('='))
b1.grid(row=2,column=0,pady = 10 )
b2.grid(row=2,column=1,pady = 10 )
b3.grid(row=2,column=2,pady = 10 )
bAddition.grid(row=2,column=3,pady = 10 )
b4.grid(row=3,column=0,pady = 10 )
b5.grid(row=3,column=1,pady = 10 )
b6.grid(row=3,column=2,pady = 10 )
bSubtract.grid(row=3,column=3,pady = 10 )
b7.grid(row=4,column=0,pady = 10 )
b8.grid(row=4,column=1,pady = 10 )
b9.grid(row=4,column=2,pady = 10 )
bMultiply.grid(row=4,column=3,pady = 10 )
bClear.grid(row=5,column=0,pady = 10 )
b0.grid(row=5,column=1,pady = 10 )
bBackspace.grid(row=5,column=2,pady = 10 )
bDivide.grid(row=5,column=3,pady = 10 )
bEqual.grid(row= 6, column= 0, columnspan= 4, pady= 10)
calculatorTitle()
calculatorBoard()
root.mainloop()
Edit: This part if an assignment where I have to follow some instructions.
def clear() and def backspace(): you define the functions with zero arguments.
clear('CE') and backspace('<-'): You call the functions with one argument
To fix the problem, either redefine the functions to take an argument,
def clear(arg):
# do whatever
def backspace(arg):
# do whatever
or change the call to not pass any.
bClear=Button(root,text='CE',width=5,command=clear)
bBackspace=Button(root,text='<-',width=5,command=backspace)
Be sure not to do both -- you'll run into the opposite problem.

why am i getting got an unexpected keyword argument 'calculate_hit_box'

Im trying to make a card game and for some reason i keep on getting got an unexpected keyword argument 'calculate_hit_box' error everytime i run my code
import arcade
# Screen title and size
SCREEN_WIDTH = 1024
SCREEN_HEIGHT = 768
SCREEN_TITLE = "Bahraini Deal"
# Constants for sizing
CARD_SCALE = 0.6
# How big are the cards?
CARD_WIDTH = 140 * CARD_SCALE
CARD_HEIGHT = 190 * CARD_SCALE
# How big is the mat we'll place the card on?
MAT_PERCENT_OVERSIZE = 1.25
MAT_HEIGHT = int(CARD_HEIGHT * MAT_PERCENT_OVERSIZE)
MAT_WIDTH = int(CARD_WIDTH * MAT_PERCENT_OVERSIZE)
# How much space do we leave as a gap between the mats?
# Done as a percent of the mat size.
VERTICAL_MARGIN_PERCENT = 0.10
HORIZONTAL_MARGIN_PERCENT = 0.10
# The Y of the bottom row (2 piles)
BOTTOM_Y = MAT_HEIGHT / 2 + MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
# The X of where to start putting things on the left side
START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
# Card constants
CARDS_NAMES = ["City_Center_1" , "Clock_Roundabout_1", "Extra_Play_1", "Its_Friday_1","Just_Say_No_1", "Pay_Me_Rent_BlackGray_1", "Pay_Me_Rent_BrownBlue_1","Pay_Me_Rent_GreenPurple_1",
"Pay_Me_Rent_PinkOrange_1","Pay_Me_Rent_RedYellow_1","Pay_Me_Rent_Mix_1", "Shake_Pockets_1", "Social_Housing_1",
"Two_More_Cards_1","World_Trade_Center_1", "Zallaq_Sofitel_1"]
CARDS_VALUE = {"City_Center_1" : 4, "Clock_Roundabout_1" : 3, "Extra_Play_1" : 2, "Its_Friday_1":2,"Just_Say_No_1":4, "Pay_Me_Rent_BlackGray_1":1, "Pay_Me_Rent_BrownBlue_1":1,"Pay_Me_Rent_GreenPurple_1":1,
"Pay_Me_Rent_PinkOrange_1":1,"Pay_Me_Rent_RedYellow_1":1,"Pay_Me_Rent_Mix_1":3, "Shake_Pockets_1":3, "Social_Housing_1":2,
"Two_More_Cards_1":1,"World_Trade_Center_1":4, "Zallaq_Sofitel_1":5}
class Card(arcade.Sprite):
""" Card sprite """
def __init__(self, name, scale=1):
""" Card constructor """
# Attributes for suit and value
self.name = name
# Image to use for the sprite when face up
self.image_file_name = f":CardsFinal:images/{self.name}.png"
# Call the parent
super().__init__(self.image_file_name, scale,calculate_hit_box=False)
class MyGame(arcade.Window):
""" Main application class. """
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
self.card_list = None
arcade.set_background_color(arcade.color.FRENCH_SKY_BLUE)
def setup(self):
""" Set up the game here. Call this function to restart the game. """
self.card_list = arcade.SpriteList()
# Create every card
for card_name in CARDS_NAMES:
for card_value in CARDS_VALUE:
card = Card(card_name, card_value, CARD_SCALE)
card.position = START_X, BOTTOM_Y
self.card_list.append(card)
def on_draw(self):
""" Render the screen. """
# Clear the screen
arcade.start_render()
# Draw the cards
self.card_list.draw()
def on_mouse_press(self, x, y, button, key_modifiers):
""" Called when the user presses a mouse button. """
pass
def on_mouse_release(self, x: float, y: float, button: int,
modifiers: int):
""" Called when the user presses a mouse button. """
pass
def on_mouse_motion(self, x: float, y: float, dx: float, dy: float):
""" User moves mouse """
pass
def main():
""" Main method """
window = MyGame()
window.setup()
arcade.run()
if __name__ == "__main__":
main()
I've tried multiple ways to fix the problem but while fixing it i end up messing it up more and more every time, its clear that the issue is with the calculate_hit_box but what i dont get is why? every soultion i try ends up mesing it up more and more
From looking at the arcade.Sprite source code, it doesn't look like calculate_hit_box is one of Sprite's __init__ parameters:
class Sprite:
def __init__(self,
filename: str = None,
scale: float = 1,
image_x: float = 0, image_y: float = 0,
image_width: float = 0, image_height: float = 0,
center_x: float = 0, center_y: float = 0,
repeat_count_x: int = 1, repeat_count_y: int = 1,
flipped_horizontally: bool = False,
flipped_vertically: bool = False,
flipped_diagonally: bool = False,
mirrored: bool = None,
hit_box_algorithm: str = "Simple",
hit_box_detail: float = 4.5):
# ...
Maybe it used to be in an older version of Arcade, which would explain the confusion if you're following an old tutorial.
Remove calculate_hit_box=False from here:
super().__init__(self.image_file_name, scale,calculate_hit_box=False)
Seems that there is an error in "Solitaire" tutorial. I've created an issue for arcade lib.

pygame sets position of all instances of class to the same value for some reason?

I'm making a snake game in pygame and i've run into a problem. Whenever the snake eats food, the player gains a point. From that point on a tail is created behind the snake whenever it moves. Only the tails the number of player points away from the snake head will be drawn while the rest are deleted. The problem arises when i'm creating the tails. Whenever i create an instance of the tail, i have to get the position of the snake head and subtract away a value equal to the snake size in the opposite direction. That's where the tail will be drawn. However the position of all the tails are set to the same value for some reason and i cant't figure out why that is. I'm using my own library so i cant post it in here but iv'e determined it's not the cause.
import pygame as pg
from random import randrange
import widget
# disp -> display properties
disp = widget.get_json("config", ["display"])
food = widget.Surface(image="../images/food.png", pos=[0, 0])
def set_food_pos(snake):
while True:
pos = [randrange(0, disp["size"][_], disp["cell"]) for _ in range(2)]
safe = 0
for tail in snake.tails:
if tail.pos != pos: safe += 1
if safe == len(snake.tails):
food.pos = pos
food.rect.topleft = food.pos
break
class Snake(widget.Sprite):
""" Snake: main playable sprite """
SIZE = [disp["cell"]] * 2
KEYS = [[276, 275], [273, 274]]
def __init__(self):
self.image = pg.image.load("../images/snake_head.png")
self.pos = widget.VEC(0, 0)
super().__init__(pg.sprite.GroupSingle)
self.axis, self.orient, self.do_move = 0, 1, False
self.past, self.delay = pg.time.get_ticks(), 150
self.speed, self.vel = disp["cell"], [-1, 1]
self.alive, self.points = True, 0
self.tails = [self]
def control(self, key):
axis = [0 if key in Snake.KEYS[0] else 1][0]
if axis != self.axis:
if self.do_move:
self.axis = axis
self.orient = Snake.KEYS[axis].index(key)
self.do_move = False
def time_base_movement(self):
now = pg.time.get_ticks()
if now - self.past >= self.delay:
self.do_move = True
self.pos[self.axis] += self.vel[self.orient] * self.speed
self.past = pg.time.get_ticks()
def eat_food(self):
if food.rect.contains(self.rect):
set_food_pos(self)
self.points += 1
def create_tail(self):
if self.points:
if self.do_move:
pos = [_ for _ in self.rect.topleft]
pos[self.axis] += self.vel[::-1][self.orient] * 20
tail = widget.Sprite(image="../images/snake_head.png", pos=pos)
self.tails.insert(0, tail)
def render_tails(self, surface):
if self.points > 0:
tails = self.tails[:-1]
for tail in tails[0:self.points]: tail.group.draw(surface)
[self.tails.remove(tail) for tail in tails[self.points:]]
def check_boundary_collision(self):
for _ in range(2):
if self.pos[_] > disp["size"][_] - Snake.SIZE[_]:self.alive = False
elif self.pos[_] < 0: self.alive = False
for tail in self.tails[:-1]:
if tail.rect.contains(self.rect): self.alive = False
def reset_properties(self):
if self.alive == False:
print([tail.pos for tail in self.tails[:-1]])
self.tails = [self]
self.do_move = False
self.pos = widget.VEC([0, 0])
self.rect.topleft = self.pos
self.axis, self.orient = 0, 1
self.points, self.alive = 0, True
set_food_pos(self)
def update(self):
if self.alive:
self.time_base_movement()
self.check_boundary_collision()
self.reset_properties()
self.rect.topleft = self.pos
I figured it out, it seems python doesn't create a new copy of an attribute each time it is assigned to a different attribue. Instead the new attribute points to the assigned attribute. The fix for this is the "deepcopy" method in the built in module "copy".
Exe: new_value = copy.deepcopy(old_value)

can't multiply sequence by non-int of type 'float' error with tkinter Entry

I'm creating a game : The canon-man. You have to touch a target, specifying the angle and the velocity. The game is separated in 3 phases :
1- You choose "play", "options" or "quit"
2- You choose the difficulty "easy", "medium" or "hard"
3- The game appears and you can choose the parameters.
My game is separated in two classes, the first one(Canon) which handle the first and second phases and the second one(Man) which handle the third phase.
I can access the first two phases but when I click on "easy" "medium" or "hard"
I get this error :
" can't multiply sequence by non-int of type 'float' "
and the third window appears like this (Tkinter's Entrys are not here) :
third window
here is my class Man (a part of it) :
def base(self):
self.height_c = 300
self.width_c = 700
self.choix = 0
self.lang = 0
self.flag = 0
bool(self.flag)
self.t = 0
self.x = 130
self.y = 225
self.root = Tk()
self.root.title("ShotDown")
self.can = Canvas(self.root, width=self.width_c, height=self.height_c)
self.can.grid(row=0, column=4, rowspan=4)
self.cible = PhotoImage(file="\image\\cible.png")
self.canon = PhotoImage(file="\image\\canon.png")
self.canontete = PhotoImage(file="\image\\canontete.png")
self.photo = PhotoImage(file="\image\\paysage_700.png")
self.hc45 = PhotoImage(file="\image\hc45.png")
self.Play = PhotoImage(file="\image\\Play.gif")
self.angle = Entry(self.root, textvariable="hey")
# initialisation:
#
# choix du fond
if self.lang == "0000":
self.photo = PhotoImage(file="\image\\paysage_700.png")
elif self.lang == "0001":
self.photo = PhotoImage(file="\image\\mer.png")
elif self.lang == "0010":
self.photo = PhotoImage(file="\image\\interstellar.png")
self.y_cible = random.randint(60, 240)
self.can.create_image(0, 0, anchor=NW, image=self.photo)
self.image = self.can.create_image(-50, -50, image=self.hc45)
# Creation des differents boutons
#
bou1 = Button(self.root, text='Quitter', width=8, command=self.root.quit)
bou1.grid(row=0, column=2)
bou2 = Button(self.root, text='Demarrer', width=8, command=Man.start_it(self))
bou2.grid(row=0, column=3)
bou3 = Button(self.root, text='Arreter', width=8, command=Man.stop_it)
# bou3.grid(row=2, column=1)
New_angle = StringVar()
New_angle.set("Saisir Nouvel Angle")
text_angle = Label(self.root, text="Angle :")
text_angle.grid(row=1, column=2)
self.angle = Entry(self.root, textvariable=New_angle)
self.angle.grid(row=1, column=3)
New_vitesse = StringVar()
New_vitesse.set("Saisir Nouvelle Vitesse")
text_vitesse = Label(self.root, text="Vitesse :")
self.in_vitesse = Entry(self.root, textvariable=New_vitesse)
text_vitesse.grid(row=2, column=2)
self.in_vitesse.grid(row=2, column=3)
bou_tir = Button(self.root, text='Tirer', width=8, command=Man.start_it(self))
bou_tir.grid(row=0, column=3)
if self.flag == 0:
self.base = self.can.create_image(50, 260, image=self.canontete)
self.can.create_image(self.width_c - 50, self.y_cible, image=self.cible)
# demarrage de la boucle principale
#
self.root.mainloop()
If you don't understand something, feel free to ask ^^.
Thanks.
EDIT :
#calico_ " - Without seeing all of your code ". Sorry, I didn't show where the error was:
self.can.update()
b = float(self.angle.get() * pi / 180)
Vo = float(self.in_vitesse.get())
self.t += 0.025
self.x += (Vo * cos(b) * self.t)
self.y -= ((-0.5 * 9.81 * (self.t ** 2)) + (Vo * sin(b) * self.t))
print(self.x, self.y)
Without seeing all of your code, or the complete exception, it is hard to tell you exactly whats wrong. But, here is an explanation of the error and likely why you're seeing it:
Sequences can be multiplied in Python. Here we create a list (a type of sequence), and then multiply it by 3:
>>> x = [1,2,3]
>>> y = x*3
The result is not the product of each item by the factor. Rather, it is the original sequence three times:
>>> y
[1, 2, 3, 1, 2, 3, 1, 2, 3]
Another piece of the puzzle - When you divide two numbers, the resulting value is usually a float, not an int:
>>> x = 6/3
>>> type(x)
<class 'float'>
And you cannot multiply a sequence by a float, only an integer. Exactly what the exception says..
So, look for a part of your code where you're multiplying sequences. The complete Traceback will help you find the lines causing the error. Just guessing, but what you probably want is list comprehension:
>>> y = [val*3 for val in x]
>>> y
[3, 6, 9]

Resources