IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PyQt Python Discussion :

Qthread et instanciation de classe


Sujet :

PyQt Python

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2020
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2020
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Qthread et instanciation de classe
    Bonjour j'ai deux classes , un pour gérer les événement IHM (IHM_application)et un autre pour les surveiller des entrées à l'aide d'Qthread (GPIO_Thread)

    j'aimerais récupérer l’état d'un appui bouton de mon IHM dans mon Qthread.
    J'instancie ma classe IHM dans mon Qthread (ligne 818 du code) mais ça ne fonctionne pas


    quelqu'un à une piste?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
     
    ##!/usr/bin/env python
    """
    ================================================
    ABElectronics IO Pi | - IO Interrupts Demo
    Requires python smbus to be installed
    For Python 2 install with: sudo apt-get install python-smbus
    For Python 3 install with: sudo apt-get install python3-smbus
    run with: python demo_iointerruptsthreading.py
    ================================================  threading
    on the IO port.
    The interrupts will be enabled and set so that pin 1 will trigger INT A and B.
    Internal pull-up resistors will be used so grounding
    one of the pins will trigger the interrupt
    using the read_interrupt_capture or reset_interrupts methods
    will reset the interrupts.
    """
    ###################################################
    #Address of iobus_out                             #
    ###################################################
    #Pin 1: X40 position Open                         #
    #Pin 2: X40 position Close                        #
    #Pin 3: X80 position Open                         #
    #Pin 4: X80 position Close                        #
    #Pin 5: X160 position Open                        #
    #Pin 6: X160 position Close                       #
    #Pin 7: X320 position Open                        #
    #Pin 8: X320 position Close                       #
    #Pin 9: X400 position Open                        #
    #Pin 10: X400 position Close                      #
    #Pin 11: R1 position Open                         #
    #Pin 12: R1 position Close                        #
    #Pin 13: R2 position Open                         #
    #Pin 14: R2 position Close                        #
    #Pin 15: Perte 230V (0 = On and 1 = Off)          #
    #Pin 16: Contact 230V (0 =  On and 1 = Off)       #
    ###################################################
     
    ###################################################
    #Address of iobus_in                              #
    ###################################################
    #Pin 1: CF X40                                    #
    #Pin 2: CO X40                                    #
    #Pin 3: CF X80                                    #
    #Pin 4: CO X80                                    #
    #Pin 5: CF X160                                   #
    #Pin 6: CO X160                                   #
    #Pin 7: CF X320                                   #
    #Pin 8: C0 X320                                   #
    #Pin 9: CF X400                                   #
    #Pin 10: CO X400                                  #
    #Pin 11: CF R1                                    #
    #Pin 12: C0 R1                                    #
    #Pin 13: CF R2                                    #
    #Pin 14: C0 R2                                    #
    #Pin 15: Contact command 230V                     #
    ###################################################
     
     
    from __future__ import absolute_import, division, print_function, \
        unicode_literals
     
    import threading
    import time
     
    try:
        from IOPi import IOPi
    except ImportError:
        print("Failed to import IOPi from python system path")
        print("Importing from parent folder instead")
        try:
            import sys
            sys.path.append('..')
            from IOPi import IOPi
        except ImportError:
            raise ImportError(
                "Failed to import library from parent folder")
     
    import sys
    from PyQt5 import QtCore
    from PyQt5.QtCore import QCoreApplication, QThread, pyqtSignal
    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    from PyQt5 import QtWidgets
    from TRA_IHM import Ui_TabWidget
     
    # Create an instance of the IOPi class with an I2C address of 0x27 and 0x28
    iobus_in = IOPi(0x20)
    iobus_out = IOPi(0x21)
     
    # Set all pins on the IO bus to be inputs with internal pull-ups enabled.
    iobus_in.set_port_pullups(0, 0xFF)
    iobus_in.set_port_pullups(1, 0xFF)
    iobus_in.set_port_direction(0, 0xFF)
    iobus_in.set_port_direction(1, 0xFF)
     
    # Set port 0 on iobus_out to be outputs and set the port to be off
    iobus_out.set_port_direction(0, 0x00)
    iobus_out.set_port_direction(1, 0x00)
     
    # Set Self position init (X80 is closed, X40, X160, X320 are open)
    iobus_out.write_port(0, 0x59)
    # Set Self position Init (R1 and R2 are closed, Perte 230V is Off and Contact 230V is Off)
    iobus_out.write_port(1, 0xE9)
     
    # invert the ports so pulling a pin to ground will show as 1 instead of 0
    #iobus_in.invert_port(0, 0xFF)
    #iobus_in.invert_port(1, 0xFF)
     
    # Set the interrupt polarity to be active high and mirroring enabled, so
    # pin 1 will trigger both INT A and INT B when a pin is grounded
    #iobus_in.set_interrupt_polarity(1)
    #iobus_in.mirror_interrupts(1)
     
    # Set the interrupts default value to 0
    #iobus_in.set_interrupt_defaults(0, 0x00)
    #iobus_in.set_interrupt_defaults(1, 0x00)
     
    # Set the interrupt type to be 1 for ports A and B so an interrupt is
    # fired when a state change occurs
    #iobus_in.set_interrupt_type(0, 0x00)
    #iobus_in.set_interrupt_type(1, 0x00)
     
    # Enable interrupts for pin 1 to 8
    #iobus_in.set_interrupt_on_port(0, 0xFF)
    #iobus_in.set_interrupt_on_port(1, 0xFF)
     
    class IHM_Application(QtWidgets.QTabWidget):
     
     
        def __init__(self, parent=None):
            super (IHM_Application, self).__init__(parent)
            self.createWidgets()
            self.init_image_var()
            self.thread = GPIO_Thread()
            self.thread.start()
            self.Connect_Signal()
     
        def Connect_Signal(self):
            self.thread.X40_Close.connect(self.Send_X40_Close_Image)
            self.thread.X40_Open.connect(self.Send_X40_Open_Image)
            self.thread.X80_Close.connect(self.Send_X80_Close_Image)
            self.thread.X80_Open.connect(self.Send_X80_Open_Image)
            self.thread.X160_Close.connect(self.Send_X160_Close_Image)
            self.thread.X160_Open.connect(self.Send_X160_Open_Image)
            self.thread.X320_Close.connect(self.Send_X320_Close_Image)
            self.thread.X320_Open.connect(self.Send_X320_Open_Image)
            self.thread.X400_Close.connect(self.Send_X400_Close_Image)
            self.thread.X400_Open.connect(self.Send_X400_Open_Image)
            self.thread.R1_Close.connect(self.Send_R1_Close_Image)
            self.thread.R1_Open.connect(self.Send_R1_Open_Image)
            self.thread.R2_Close.connect(self.Send_R2_Close_Image)
            self.thread.R2_Open.connect(self.Send_R2_Open_Image)
            self.ui.Exit.clicked.connect(self.close)
            self.ui.X40.clicked.connect(self.Open_Close_X40)
            self.ui.X80.clicked.connect(self.Open_Close_X80)
            self.ui.X160.clicked.connect(self.Open_Close_X160)
            self.ui.X320.clicked.connect(self.Open_Close_X320)
            self.ui.X400.clicked.connect(self.Open_Close_X400)
            self.ui.R1.clicked.connect(self.Open_Close_R1)
            self.ui.R2.clicked.connect(self.Open_Close_R2)
            self.ui.IC_Slide.sliderPressed.connect(self.Slide_Bar_Moved)
            self.ui.IC_Slide.valueChanged.connect(self.Slide_Bar_Changed)
            self.ui.X40.clicked.connect(self.NRP_IC)
     
        def createWidgets(self):
            self.ui = Ui_TabWidget()
            self.ui.setupUi(self)
     
        #Configure images for 80A
        def init_image_var(self):
            self.ui.X40.setChecked(False)
            self.ui.X80.setChecked(True)
            self.ui.X160.setChecked(False)
            self.ui.X320.setChecked(False)
            self.ui.X400.setChecked(False)
            self.ui.R1.setChecked(True)
            self.ui.R2.setChecked(True)
            self.ui.IC_LCD.display(80)
            self.Slide_start = 80
     
        def NRP_IC(self):
            NRP = self.ui.X40.isChecked()
            return(NRP)          
     
    #Functions for IC Slide Bar
        def Slide_Bar_Moved(self):
            self.Slide_start = self.ui.IC_Slide.sliderPosition()
     
        def Slide_Bar_Changed(self):
            Direction = self.ui.IC_Slide.sliderPosition() - self.Slide_start
     
            if self.ui.IC_Slide.sliderPosition() > 80 and self.ui.IC_Slide.sliderPosition() < 120 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(120)
                self.ui.IC_LCD.display(120)
                iobus_out.write_port(0, 0x5A)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
     
            elif self.ui.IC_Slide.sliderPosition() > 80 and self.ui.IC_Slide.sliderPosition() < 120 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(80)
                self.ui.IC_LCD.display(80)
                iobus_out.write_port(0, 0x59)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 120 and self.ui.IC_Slide.sliderPosition() < 160 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(160)
                self.ui.IC_LCD.display(160)
                iobus_out.write_port(0, 0x65)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 120 and self.ui.IC_Slide.sliderPosition() < 160 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(120)
                self.ui.IC_LCD.display(120)
                iobus_out.write_port(0, 0x5A)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 160 and self.ui.IC_Slide.sliderPosition() < 200 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(200)
                self.ui.IC_LCD.display(200)
                iobus_out.write_port(0, 0x66)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 160 and self.ui.IC_Slide.sliderPosition() < 200 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(160)
                self.ui.IC_LCD.display(160)
                iobus_out.write_port(0, 0x65)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 200 and self.ui.IC_Slide.sliderPosition() < 240 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(240)
                self.ui.IC_LCD.display(240)
                iobus_out.write_port(0, 0x69)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 200 and self.ui.IC_Slide.sliderPosition() < 240 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(200)
                self.ui.IC_LCD.display(200)
                iobus_out.write_port(0, 0x66)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 240 and self.ui.IC_Slide.sliderPosition() < 280 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(280)
                self.ui.IC_LCD.display(280)
                iobus_out.write_port(0, 0x6A)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 240 and self.ui.IC_Slide.sliderPosition() < 280 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(240)
                self.ui.IC_LCD.display(240)
                iobus_out.write_port(0, 0x69)
                iobus_out.write_port(1, 0xE9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 280 and self.ui.IC_Slide.sliderPosition() < 320 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(320)
                self.ui.IC_LCD.display(320)
                iobus_out.write_port(0, 0x95)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
     
            elif self.ui.IC_Slide.sliderPosition() > 280 and self.ui.IC_Slide.sliderPosition() < 320 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(280)
                self.ui.IC_LCD.display(280)
                iobus_out.write_port(0, 0x6A)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(False)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 320 and self.ui.IC_Slide.sliderPosition() < 360 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(360)
                self.ui.IC_LCD.display(360)
                iobus_out.write_port(0, 0x96)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 320 and self.ui.IC_Slide.sliderPosition() < 360 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(320)
                self.ui.IC_LCD.display(320)
                iobus_out.write_port(0, 0x95)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 360 and self.ui.IC_Slide.sliderPosition() < 400 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(400)
                self.ui.IC_LCD.display(400)
                iobus_out.write_port(0, 0x99)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 360 and self.ui.IC_Slide.sliderPosition() < 400 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(360)
                self.ui.IC_LCD.display(360)
                iobus_out.write_port(0, 0x96)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
            elif self.ui.IC_Slide.sliderPosition() > 400 and self.ui.IC_Slide.sliderPosition() < 440 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(440)
                self.ui.IC_LCD.display(440)
                iobus_out.write_port(0, 0x9A)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 400 and self.ui.IC_Slide.sliderPosition() < 440 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(400)
                self.ui.IC_LCD.display(400)
                iobus_out.write_port(0, 0x99)
                iobus_out.write_port(1, 0xE5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(True)
     
     
            elif self.ui.IC_Slide.sliderPosition() > 440 and self.ui.IC_Slide.sliderPosition() < 480 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(480)
                self.ui.IC_LCD.display(480)
                iobus_out.write_port(0, 0xA5)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 440 and self.ui.IC_Slide.sliderPosition() < 480 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(440)
                self.ui.IC_LCD.display(440)
                iobus_out.write_port(0, 0x9A)
                iobus_out.write_port(1, 0xD9)
                iobus_out.write_port(0, 0xA5)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(False)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 480 and self.ui.IC_Slide.sliderPosition() < 520 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(520)
                self.ui.IC_LCD.display(520)
                iobus_out.write_port(0, 0xA6)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 480 and self.ui.IC_Slide.sliderPosition() < 520 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(480)
                self.ui.IC_LCD.display(480)
                iobus_out.write_port(0, 0xA5)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 520 and self.ui.IC_Slide.sliderPosition() < 560 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(560)
                self.ui.IC_LCD.display(560)
                iobus_out.write_port(0, 0xA9)
                iobus_out.write_port(1, 0xD5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 520 and self.ui.IC_Slide.sliderPosition() < 560 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(520)
                self.ui.IC_LCD.display(520)
                iobus_out.write_port(0, 0xA6)
                iobus_out.write_port(1, 0xD9)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(False)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(True)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 560 and self.ui.IC_Slide.sliderPosition() < 600 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(600)
                self.ui.IC_LCD.display(600)
                iobus_out.write_port(0, 0xAA)
                iobus_out.write_port(1, 0xD5)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 560 and self.ui.IC_Slide.sliderPosition() < 600 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(560)
                self.ui.IC_LCD.display(560)
                iobus_out.write_port(0, 0xA9)
                iobus_out.write_port(1, 0xD5)
                self.ui.X40.setChecked(False)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 600 and self.ui.IC_Slide.sliderPosition() < 640 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(640)
                self.ui.IC_LCD.display(640)
     
            elif self.ui.IC_Slide.sliderPosition() > 600 and self.ui.IC_Slide.sliderPosition() < 640 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(600)
                self.ui.IC_LCD.display(600)
                self.ui.X40.setChecked(True)
                self.ui.X80.setChecked(True)
                self.ui.X160.setChecked(True)
                self.ui.X320.setChecked(True)
                self.ui.X400.setChecked(False)
                self.ui.R1.setChecked(False)
                self.ui.R2.setChecked(False)
     
            elif self.ui.IC_Slide.sliderPosition() > 640 and self.ui.IC_Slide.sliderPosition() < 680 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(680)
                self.ui.IC_LCD.display(680)
     
            elif self.ui.IC_Slide.sliderPosition() > 640 and self.ui.IC_Slide.sliderPosition() < 680 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(640)
                self.ui.IC_LCD.display(640)
     
            elif self.ui.IC_Slide.sliderPosition() > 680 and self.ui.IC_Slide.sliderPosition() < 720 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(720)
                self.ui.IC_LCD.display(720)
     
            elif self.ui.IC_Slide.sliderPosition() > 680 and self.ui.IC_Slide.sliderPosition() < 720 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(680)
                self.ui.IC_LCD.display(680)
     
            elif self.ui.IC_Slide.sliderPosition() > 720 and self.ui.IC_Slide.sliderPosition() < 760 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(760)
                self.ui.IC_LCD.display(760)
     
            elif self.ui.IC_Slide.sliderPosition() > 720 and self.ui.IC_Slide.sliderPosition() < 760 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(720)
                self.ui.IC_LCD.display(720)
     
            elif self.ui.IC_Slide.sliderPosition() > 760 and self.ui.IC_Slide.sliderPosition() < 800 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(800)
                self.ui.IC_LCD.display(800)
     
            elif self.ui.IC_Slide.sliderPosition() > 760 and self.ui.IC_Slide.sliderPosition() < 800 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(760)
                self.ui.IC_LCD.display(760)
     
            elif self.ui.IC_Slide.sliderPosition() > 800 and self.ui.IC_Slide.sliderPosition() < 840 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(840)
                self.ui.IC_LCD.display(840)
     
            elif self.ui.IC_Slide.sliderPosition() > 800 and self.ui.IC_Slide.sliderPosition() < 840 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(800)
                self.ui.IC_LCD.display(800)
     
            elif self.ui.IC_Slide.sliderPosition() > 840 and self.ui.IC_Slide.sliderPosition() < 880 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(880)
                self.ui.IC_LCD.display(880)
     
            elif self.ui.IC_Slide.sliderPosition() > 840 and self.ui.IC_Slide.sliderPosition() < 880 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(840)
                self.ui.IC_LCD.display(840)
     
            elif self.ui.IC_Slide.sliderPosition() > 880 and self.ui.IC_Slide.sliderPosition() < 920 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(920)
                self.ui.IC_LCD.display(920)
     
            elif self.ui.IC_Slide.sliderPosition() > 880 and self.ui.IC_Slide.sliderPosition() < 920 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(880)
                self.ui.IC_LCD.display(880)
     
            elif self.ui.IC_Slide.sliderPosition() > 920 and self.ui.IC_Slide.sliderPosition() < 960 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(960)
                self.ui.IC_LCD.display(960)
     
            elif self.ui.IC_Slide.sliderPosition() > 920 and self.ui.IC_Slide.sliderPosition() < 960 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(920)
                self.ui.IC_LCD.display(920)
     
            elif self.ui.IC_Slide.sliderPosition() > 960 and self.ui.IC_Slide.sliderPosition() < 1000 and Direction > 0:
                self.ui.IC_Slide.setSliderPosition(1000)
                self.ui.IC_LCD.display(1000)
     
            elif self.ui.IC_Slide.sliderPosition() > 960 and self.ui.IC_Slide.sliderPosition() < 1000 and Direction < 0:
                self.ui.IC_Slide.setSliderPosition(960)
                self.ui.IC_LCD.display(960)
     
    #Exit Function for quit application
        def Close(self):
            QCoreApplication.instance().quit
     
    #Functions for changing position manually
        def Open_Close_X40(self):
            if self.ui.X40.isChecked() == True:
                iobus_out.write_pin(1, 0)
                iobus_out.write_pin(2, 1)
     
            else:
                iobus_out.write_pin(2, 0)
                iobus_out.write_pin(1, 1)
     
        def Open_Close_X80(self):
            if self.ui.X80.isChecked() == True:
                iobus_out.write_pin(3, 0)
                iobus_out.write_pin(4, 1)
            else:
                iobus_out.write_pin(4, 0)
                iobus_out.write_pin(3, 1)
     
        def Open_Close_X160(self):
            if self.ui.X160.isChecked() == True:
                iobus_out.write_pin(5, 0)
                iobus_out.write_pin(6, 1)
            else:
                iobus_out.write_pin(6, 0)
                iobus_out.write_pin(5, 1)
     
        def Open_Close_X320(self):
            if self.ui.X320.isChecked() == True:
                iobus_out.write_pin(7, 0)
                iobus_out.write_pin(8, 1)
            else:
                iobus_out.write_pin(8, 0)
                iobus_out.write_pin(7, 1)
     
        def Open_Close_X400(self):
            if self.ui.X400.isChecked() == True:
                iobus_out.write_pin(9, 0)
                iobus_out.write_pin(10, 1)
            else:
                iobus_out.write_pin(10, 0)
                iobus_out.write_pin(9, 1)
     
        def Open_Close_R1(self):
            if self.ui.R1.isChecked() == True:
                iobus_out.write_pin(11, 0)
                iobus_out.write_pin(12, 1)
            else:
                iobus_out.write_pin(12, 0)
                iobus_out.write_pin(11, 1)
     
        def Open_Close_R2(self):
            if self.ui.R2.isChecked() == True:
                iobus_out.write_pin(13, 0)
                iobus_out.write_pin(14, 1)
            else:
                iobus_out.write_pin(14, 0)
                iobus_out.write_pin(13, 1)
     
    #Function for update Slide_Bar
        def Update_Slide_Bar(self):
            if iobus_out.read_port(0) == 89:
                self.ui.IC_Slide.setSliderPosition(80)
                self.ui.IC_LCD.display(80)
     
            elif iobus_out.read_port(0) == 90:
                self.ui.IC_Slide.setSliderPosition(120)
                self.ui.IC_LCD.display(120)
     
            elif iobus_out.read_port(0) == 101:
                self.ui.IC_Slide.setSliderPosition(160)
                self.ui.IC_LCD.display(160)
     
            elif iobus_out.read_port(0) == 102:
                self.ui.IC_Slide.setSliderPosition(200)
                self.ui.IC_LCD.display(200)
     
            elif iobus_out.read_port(0) == 105:
                self.ui.IC_Slide.setSliderPosition(240)
                self.ui.IC_LCD.display(240)
     
            elif iobus_out.read_port(0) == 106:
                self.ui.IC_Slide.setSliderPosition(280)
                self.ui.IC_LCD.display(280)
     
            elif iobus_out.read_port(0) == 149:
                self.ui.IC_Slide.setSliderPosition(320)
                self.ui.IC_LCD.display(320)
     
            elif iobus_out.read_port(0) == 150:
                self.ui.IC_Slide.setSliderPosition(360)
                self.ui.IC_LCD.display(360)
     
            elif iobus_out.read_port(0) == 153:
                self.ui.IC_Slide.setSliderPosition(400)
                self.ui.IC_LCD.display(400)
     
            elif iobus_out.read_port(0) == 154:
                self.ui.IC_Slide.setSliderPosition(440)
                self.ui.IC_LCD.display(440)
     
            elif iobus_out.read_port(0) == 165:
                self.ui.IC_Slide.setSliderPosition(480)
                self.ui.IC_LCD.display(480)
     
            elif iobus_out.read_port(0) == 166:
                self.ui.IC_Slide.setSliderPosition(520)
                self.ui.IC_LCD.display(520)
     
            elif iobus_out.read_port(0) == 169:
                self.ui.IC_Slide.setSliderPosition(560)
                self.ui.IC_LCD.display(560)
     
            elif iobus_out.read_port(0) == 170:
                self.ui.IC_Slide.setSliderPosition(600)
                self.ui.IC_LCD.display(600)
     
    #Functions for changing images on IHM
        def Send_X40_Close_Image(self):
            self.ui.X40.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_X40_Open_Image(self):
            self.ui.X40.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_X80_Close_Image(self):
            self.ui.X80.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_X80_Open_Image(self):
            self.ui.X80.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_X160_Close_Image(self):
            self.ui.X160.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_X160_Open_Image(self):
            self.ui.X160.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_X320_Close_Image(self):
            self.ui.X320.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_X320_Open_Image(self):
            self.ui.X320.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_X400_Close_Image(self):
            self.ui.X400.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_X400_Open_Image(self):
            self.ui.X400.setChecked(False)
     
        def Send_R1_Open_Image(self):
            self.ui.R1.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_R1_Close_Image(self):
            self.ui.R1.setChecked(True)
            self.Update_Slide_Bar()
     
        def Send_R2_Open_Image(self):
            self.ui.R2.setChecked(False)
            self.Update_Slide_Bar()
     
        def Send_R2_Close_Image(self):
            self.ui.R2.setChecked(True)
            self.Update_Slide_Bar()
     
    class GPIO_Thread(QtCore.QThread):
     
        X40_Close = pyqtSignal(int)
        X40_Open = pyqtSignal(int)
        X80_Close = pyqtSignal(int)
        X80_Open = pyqtSignal(int)
        X160_Close = pyqtSignal(int)
        X160_Open = pyqtSignal(int)
        X320_Close = pyqtSignal(int)
        X320_Open = pyqtSignal(int)
        X400_Close = pyqtSignal(int)
        X400_Open = pyqtSignal(int)
        R1_Close = pyqtSignal(int)
        R1_Open = pyqtSignal(int)
        R2_Close = pyqtSignal(int)
        R2_Open = pyqtSignal(int)
     
        def __init__(self):
            super(GPIO_Thread, self).__init__()
            self.IHM = IHM_Application() 
     
     
        def run(self):
     
            while True:
     
                if iobus_in.read_pin(15) == 1:
                    iobus_out.write_pin(16, 0)
                else:
                    iobus_out.write_pin(16, 1)
     
    #X40 CF command
                if iobus_in.read_pin(1) == 1:
                    iobus_out.write_pin(1, 0)
                    iobus_out.write_pin(2, 1)
                    self.X40_Close.emit(int)
     
    #X40 CO command
                if iobus_in.read_pin(2) == 1:
                    iobus_out.write_pin(2, 0)
                    iobus_out.write_pin(1, 1)
                    self.X40_Open.emit(int)
     
    #X80 CF command
                if iobus_in.read_pin(3) == 1:
                    iobus_out.write_pin(3, 0)
                    iobus_out.write_pin(4, 1)
                    self.X80_Close.emit(int)
     
    #X80 CO command
                if iobus_in.read_pin(4) == 1:
                    iobus_out.write_pin(4, 0)
                    iobus_out.write_pin(3, 1)
                    self.X80_Open.emit(int)
     
    #X160 CF command
                if iobus_in.read_pin(5) == 1:
                    iobus_out.write_pin(5, 0)
                    iobus_out.write_pin(6, 1)
                    self.X160_Close.emit(int)
     
    #X160 CO command
                if iobus_in.read_pin(6) == 1:
                    iobus_out.write_pin(6, 0)
                    iobus_out.write_pin(5, 1)
                    self.X160_Open.emit(int)
     
    #X320 CF command
                if iobus_in.read_pin(7) == 1:
                    iobus_out.write_pin(7, 0)
                    iobus_out.write_pin(8, 1)
                    self.X320_Close.emit(int)
     
    #X320 CO command
                if iobus_in.read_pin(8) == 1:
                    iobus_out.write_pin(8, 0)
                    iobus_out.write_pin(7, 1)
                    self.X320_Open.emit(int)
     
    #X400 CF command
                if iobus_in.read_pin(9) == 1:
                    iobus_out.write_pin(9, 0)
                    iobus_out.write_pin(10, 1)
                    self.X400_Close.emit(int)
     
    #X400 CO command
                if iobus_in.read_pin(10) == 1:
                    iobus_out.write_pin(10, 0)
                    iobus_out.write_pin(9, 1)
                    self.X400_Open.emit(int)
     
    #R1 CF command
                if iobus_in.read_pin(11) == 1:
                    iobus_out.write_pin(11, 0)
                    iobus_out.write_pin(12, 1)
                    self.R1_Close.emit(int)
     
    #R1 CO command
                if iobus_in.read_pin(12) == 1:
                    iobus_out.write_pin(12, 0)
                    iobus_out.write_pin(11, 1)
                    self.R1_Open.emit(int)
     
    #R2 CF command
                if iobus_in.read_pin(13) == 1:
                    iobus_out.write_pin(13, 0)
                    iobus_out.write_pin(14, 1)
                    self.R2_Close.emit(int)
     
    #R2 CO command
                if iobus_in.read_pin(14) == 1:
                    iobus_out.write_pin(14, 0)
                    iobus_out.write_pin(13, 1)
                    self.R2_Open.emit(int)
     
                time.sleep(0.01)
     
     
    if __name__ == "__main__":
        app = QtWidgets.QApplication(sys.argv)
        myapp = IHM_Application()
        myapp.show()
        sys.exit(app.exec_())
     
     
     
     
     
    #

  2. #2
    Expert éminent
    Avatar de tyrtamos
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2007
    Messages
    4 480
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2007
    Messages : 4 480
    Points : 9 277
    Points
    9 277
    Billets dans le blog
    6
    Par défaut
    Bonjour,

    L'instanciation de l'IHM dans le QThread ne peut pas marcher, puisque le QThread ne doit pas toucher au graphique!

    Il y a plusieurs solutions possibles, en voici une:
    1- on crée une variable dans la classe QThread qui représentera l'état du bouton de l'IHM
    2- on crée une méthode dans la classe QThread dont l'exécution mettra à jour la valeur de la variable ci-dessus
    3- l'appui sur le bouton de l'IHM appellera une méthode de l'IHM (qui devrait déjà exister pour d'autre raisons!) qui appellera la méthode du QThread pour mettre à jour la variable du QThread.

    Pour savoir si c'est une méthode adaptée, il faudrait savoir sous quelle forme cette variable du QThread sera utilisée par le QThread (désolé, mais je ne lirai pas un code de 900 lignes...).

    En ce qui me concerne, c'est comme ça que je traite souvent la demande par l'IHM d'arrêt d'un thread, quand son exécution se fait dans une boucle (genre "while self.encore:"), et dans ce cas, la méthode du thread "stop()" met la variable "self.encore" à False, ce qui stoppe la boucle suivante et termine le thread.

    Il y a d'autres solutions, comme par exemple une variable globale partagée (mais protégée par un verrou pour éviter les accès simultanés) ou une communication par signaux.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2020
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2020
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Bonjour et merci pour votre réponse.
    La variable à mettre à jour est de type booléen (elle est liée à l'appui d'Qpush bouton)

    Ci dessous l'appel de la méthode pour mettre à jour ma variable dans l'IHM:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    self.ui.X40.clicked.connect(self.NRP_IC)
     
    def NRP_IC(self):
            self.thread.Update_NRP_IC(self.ui.X40.isChecked())
    Ci dessous la méthode dans mon QThread:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     def __init__(self, parent=None):
            super(GPIO_Thread, self).__init__(parent)
            self.NRPIC = False
     
        def Update_NRP_IC(self, value):
            self.NRPIC = value
    et je vois bien la mise à jour dans mon run, je vais faire pareil pour pour stopper le Qthread. Merci beaucoup car je voulais éviter l’utilisation de variables globales!

Discussions similaires

  1. [JAR]Instancier une classe d'un jar
    Par Foub dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 16/08/2005, 15h10
  2. Réponses: 3
    Dernier message: 13/08/2005, 15h18
  3. [MFC] où instancier mes classes?
    Par giova_fr dans le forum MFC
    Réponses: 3
    Dernier message: 26/07/2005, 13h15
  4. [Débutant(e)]Instancier une classe connaissant son nom (String)
    Par Invité dans le forum API standards et tierces
    Réponses: 5
    Dernier message: 17/06/2005, 11h05
  5. [Débutant(e)]servlet qui instancie une classe personelle
    Par NiBicUs dans le forum Servlets/JSP
    Réponses: 5
    Dernier message: 08/02/2005, 12h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo