Hi all,
I need some help with my code, because I have a bit of trouble with using the cur.execute
in the loops.
When I try this:
for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
cur.execute('SELECT button_ids, button_width FROM buttons where button_ids=?', [prog_id))
if int(pos_X) == 375:
if int(prog_width) == 342:
self.getControl(int(prog_id)).setVisible(False)
It will work fine but I can't get self.getControl
to work unless if I have to fire the code twice.
So if I try this:
for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
#cur.execute('SELECT button_ids, button_width FROM buttons where button_ids=?', [prog_id))
if int(pos_X) == 375:
if int(prog_width) == 342:
self.getControl(int(prog_id)).setVisible(False)
It will work fine without have any problem.
Here is the full code:
for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
cur.execute('SELECT button_ids, button_width FROM buttons where button_ids=?', [prog_id])
buttons = cur.fetchall()
for ind, row in enumerate(buttons):
button_id = str(row[0])
button_width = str(row[1])
buttonList.append(button_id)
buttonWidthList.append(button_width)
buttons_id = map(str, buttonList)
buttons_width = map(str, buttonWidthList)
for program_id, program_width in zip(buttons_id, buttons_width):
for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
if int(pos_X) == 375:
if int(prog_width) == 342:
print program_id
I want to check in the elements pos_X
to see if I have the value 375
and I want to check in the elements prog_width
to see if it have the value 342
then I want to call the database to find for the matched elements of prog_id
then I want to pull the information from the database to get the width size before I use to call the object self.getControl
.
Can somebody please help me with this?