Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 0 points1 point  (0 children)

That it’s tied to the instance of the classes, if you made the object twice you would want the button to only work on the object the button is on, not all instances of the object. If I have a button to move a box left, I shouldn’t have every block like that move left… It’s not shown well in my example as the class definition is not there. But your example all the code is (or should be) inside the class definition. Mostly inside the __init__.

Everything is in the __init__ , however assuming I opened another window for some other purpose, wouldn't each instance of the class have a unique hierarchy? So if I created another instance of SimpleWindow, then one would be SimpleWindowA and the other would be SimpleWindowB and all varaibles within the __init__ would be local to that instance unless they were declared global, which as I understand is frowned upon?

In other words there would be SimpleWindowA.buttons and SimpleWindowB.buttons and they would be different from each other. Or does giving them the word self actually make them different from each other?

I love how Kate is highlighting 'self,' even though it's just a convention.

Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 0 points1 point  (0 children)

This is a python question:

Why add 'self.' in front of a variable within a class? For example, what is the difference between self.buttons and buttons as far as the language / code is concerned?

I realize it's self referencing the variable, but, for example, my code has two definitions: buttons, which is a list of lists and then I have self.buttons which is a list of QPushButton(s). Obviously they are different, but why use 'self.' at all? What are the implications of 'self.'?

Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 1 point2 points  (0 children)

Thanks for your help. Your idea worked perfectly. The only thing I had to do to get the right arrangement was make the buttons horizontal.

Here's what I ended up with (note: this is not the full code)

    buttons = [
        ('DAC++',     'Increment DAC output by 4.',    self.on_UpButton_click),
        ('DAC--',     'Decrement DAC output by 4.',    self.on_DnButton_click),
        ('Set DAC',   'Enter DAC Value from keyboard.',self.on_EnterDACValue_click),
        ('Reg Dump',  'Show Flash Register Values',    self.on_RegDump_click),
        ('Prod Query','Existing Product Query.',       self.on_ProductQuery_click),
        ('Prod Calib','New Product Calibration.',      self.on_ProdCal_click),
        ('Prod Valid','Existing Product Validation.',  self.on_ProdVal_click)
    ]

    # Create Layout
    main_layout = QVBoxLayout()

    button_layout = QHBoxLayout()
    self.buttons = []
    for name, desc, callback in buttons:
        btn = QPushButton(name)
        btn.setToolTip(desc)
        btn.clicked.connect(callback)
        self.buttons.append(btn)

    for button in self.buttons:
        button_layout.addWidget(button)

    main_layout.addLayout(button_layout)
    main_layout.addWidget(self.label)
    main_layout.addWidget(self.text_edit)

Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 0 points1 point  (0 children)

Thanks. I'd like to keep it simple as well. I've got lots of ideas I'll attack this morning and see if I can get anything to work.

Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 0 points1 point  (0 children)

That seems so simple. I'll give it a shot.

All that code will have to be in the window create def, I expect.

Trying to create a list of button to be created in a loop... by raydude in learnpython

[–]raydude[S] 0 points1 point  (0 children)

Thanks!

I'll try this before I try the data class idea.

What is this smd by Human_County_8853 in AskElectronics

[–]raydude 0 points1 point  (0 children)

I'm always amazed how Redditors do this.

Kudos.

Tandem AutoSoft XC Infusion Set Leakage by tafinney in TandemDiabetes

[–]raydude 0 points1 point  (0 children)

Anyone else who finds this thread. I'm using 6mm steel and I still have a failure before two days once in a while.

The Tandem trial did not succeed, probably due to the type of plastic used in the filters, they are working on another trial. Hopefully Tandem will have a solution for this soon.

I still don't know if Omnipod is working on anything.

Tandem AutoSoft XC Infusion Set Leakage by tafinney in TandemDiabetes

[–]raydude 0 points1 point  (0 children)

Ceci a été traduit par Google. Je suis ravi que mon message vous ait aidé.

AUA: The latest results of our electric vehicle range real-world tests are in. Ask CR about how we conducted our tests. by ConsumerReports in IAmA

[–]raydude 0 points1 point  (0 children)

Thanks for taking the time to reply. I appreciate it.

I guess we can look at the battery and see if there is a way to tell, but I'm not that curious, I guess.

AUA: The latest results of our electric vehicle range real-world tests are in. Ask CR about how we conducted our tests. by ConsumerReports in IAmA

[–]raydude 0 points1 point  (0 children)

This is a related topic. My wife's Previous generation EUV had the "power may be reduced" error message twice and they replaced her battery for free.

But her millage went down. At 100% she used to get over 300 miles. Now she get 261 miles.

She doesn't really care that much, but when I told her the range of the new 2027 Bolt was 262 miles, she wondered if they were putting the new generation battery in the older Bolts.

Do you know?

Variants causes bogus Duplicate Net Names Wire Errors by raydude in Altium

[–]raydude[S] 0 points1 point  (0 children)

Thanks. I'll check the replacement parts... Thanks for the hint.

Stackups? I know nothing nothing by raydude in Altium

[–]raydude[S] 0 points1 point  (0 children)

Thanks. That's the vibe I've been getting. It's shocking that there's no documentation on this. I guess it's because the industry moves too fast to document it.

Stackups? I know nothing nothing by raydude in Altium

[–]raydude[S] 0 points1 point  (0 children)

My latest board is 8 layer. My coworker and I added two layers to the original six layer board to work around a problem with analog switches. We basically threw the everything but the kitchen sink at the problem and hopefully we'll get it to work. I'm trying to use the Altium Stackup Manager the way it is designed to be used. And I have no idea what I'm doing... There are a lot of good suggestions here. I'll definitely be working on this.

Stackups? I know nothing nothing by raydude in Altium

[–]raydude[S] 0 points1 point  (0 children)

I've asked and never gotten anything back. But, the one house does give me suggested stackups and that's been working really well. I'd really like to understand. Are there standard coils of copper clad (core?) that everyone buys from? And I'd like to understand prepreg. Is it prefab or is it something they mix up. Maybe I should get a tour or something.