[xbmc] How to block the code from executed twice under the loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [xbmc] How to block the code from executed twice under the loop (/thread-626.html) |
RE: How to block the code from executed twice under the loop - Yoriz - Oct-25-2016 (Oct-24-2016, 11:50 PM)Yoriz Wrote: What gui are you using? While I ponder over this new code that has changed from before (have you added to it or you just failed to show the correct code to begin with) and looks even more overly complicated then it probably needs to be. Could you answer the unanswered questions I quoted. RE: How to block the code from executed twice under the loop - chris0147 - Oct-25-2016 I dont know what gui i am using. How i can find out what gui i am using? RE: How to block the code from executed twice under the loop - Yoriz - Oct-25-2016 What the ..... You are using some sort of gui framework, I use wxpython , there is tkinter, pyqt/pyside ect. what are you using RE: How to block the code from executed twice under the loop - micseydel - Oct-25-2016 Chris: Copy your code locally, on your own computer. Cull the copy so that it's as little code as possible while still reproducing your problem. Post that reduced code. It should be quite short. RE: How to block the code from executed twice under the loop - metulburr - Oct-25-2016 (Oct-25-2016, 06:13 PM)chris0147 Wrote: I dont know what gui i am using. Its usually in an import line somewhere at the top. At some point one of your modules will have it. IF you cant figure it out...then zip it up and attach the whole thing here. RE: How to block the code from executed twice under the loop - Yoriz - Oct-25-2016 If you don't even know what gui you are using what chance do you or anyone trying to help have Looks like it could be this You have loads of duplicated code, variables that are not used. ctrl is not defined if int(ctrl.getX()) != 375: # undefined variable ctrl continueIn this part if int(program_width) == 691: # width of button1 programs_width = 344 program_button_1.setWidth(int(programs_width)) # set button one width program_width = program_button_1.getWidth() # changed the width to 344 nextprogram_width = program_button_2.getWidth() print "catch this goright 1"You set button1 to width 344, then you ask the control what its width is that you already know as you just set it and change variable program_width to that width. In the next part you check for the value of program_width is inside your condition which it is because you just set it to be and then you change button1 width to the width of button2 elif int(program_width) >= 342 and int(program_width) <= 344: #print "you are working on 342 and 344 button" print "catch this goright 2" program_button_1.setLabel(nextprogram_label) program_button_1.setWidth(nextprogram_width) RE: How to block the code from executed twice under the loop - chris0147 - Oct-25-2016 (Oct-25-2016, 06:23 PM)Yoriz Wrote: What the ..... I use python version 2.6 to code for xbmc media application. I don't think it does make any difference what gui i'm using as long you can still help me to modify my code which is the main thing. RE: How to block the code from executed twice under the loop - metulburr - Oct-25-2016 Quote: I don't think it does make any difference what gui i'm using as long you can still help me to modify my code which is the main thingIt makes a lot of difference. Often times, people are unaware of a feature in a certain library that they are trying to recreate that. There may be a different or better method to carry out certain things, in one library or the other. RE: How to block the code from executed twice under the loop - Yoriz - Oct-25-2016 Of course it makes a difference, each gui framework has its own way of doing things , its own methods ect. Without knowing and your lack of showing enough useful code no one can have a clue whats going on. Your coding and explanations are terrible. Your lucky I'm wasting my time to even try and fathom out what the hell you are doing. RE: How to block the code from executed twice under the loop - chris0147 - Oct-25-2016 (Oct-25-2016, 06:44 PM)Yoriz Wrote: If you don't even know what gui you are using what chance do you or anyone trying to help have Yeah, but I have to create two different statement for the button when I change it which it can be done by using this: elif int(program_width) >= 342 and int(program_width) <= 344: #print "you are working on 342 and 344 button" print "catch this goright 2" program_button_1.setLabel(nextprogram_label) program_button_1.setWidth(nextprogram_width) program_button_2.setLabel(nextprogram1_label) program_button_2.setWidth(nextprogram1_width) program_button_3.setLabel(nextprogram2_label) program_button_3.setWidth(nextprogram2_width)I use the control of program_button_1 to set the width size to 344 that I get the width size from the program_button_2 control and I use to set the program_button_2 width size that I got from the program_button_3 control. When I run the code under the loop, I have got three button1 that need to set to the width size from 691 to 344, so the code will be executed and change the width size like three times which it should be only once time for each button. It would be easy if I can get one button id when I empty the list in each time when I change the button1 size without I have to run through the loop. |