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

Python Discussion :

Faire correspondre 2 programmes en Python.


Sujet :

Python

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    chomeur
    Inscrit en
    Avril 2017
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : chomeur

    Informations forums :
    Inscription : Avril 2017
    Messages : 31
    Par défaut Faire correspondre 2 programmes en Python.
    Bonjour,
    J'ai fait un programme de virtualisation de clavier avec XDOTOOL, j'aimerais l'introduire dans une variable se trouvant dans une Def d'un long programme( Maxchessdemo.py (5,9 Ko) mis en pièce jointe) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    def getboard():
        """ gets a text string from the board """
        ctxt = btxt
        return ctxt
    Le programme de virtualisation de clavier sur GPIO de raspberry est le suivant(ou lettresIII.py en pièce jointe) :

    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
    #!/usr/bin/python2
    from gpiozero import Button
    from gpiozero import LED
    from subprocess import check_call
    import time
     
    buttona = Button(3)
    buttonb = Button(2)
    red = LED(26)
     
    Clic = 0
    Clic2 = 0
    Clicb = 0
    Clicc = 0
    Clicd = 0
    Clice = 0
     
    red.off()
     
     
    #while True:
    while Clic2<1:
        if buttonb.is_pressed :
    	Clic2 = Clic2 + 1
            time.sleep(2)
        elif buttona.is_pressed:
             Clic = Clic + 1
    	 print(Clic)
             red.on()
             time.sleep(0.2)
             red.off()
             time.sleep(1)
    if Clic == 1:
       import subprocess
       subprocess.call(['setxkbmap', 'be'])
       subprocess.call(['xdotool', 'type', 'ma']) 
    elif Clic == 2:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'mb'])
    elif Clic == 3:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'mc'])
    elif Clic == 4:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'md'])
    elif Clic == 5:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'me'])
    elif Clic == 6:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'mf'])
    elif Clic == 7:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'mg'])
    elif Clic == 8:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'mh'])
    #while True:
    while Clic2<2:
        if buttonb.is_pressed :
    	 Clic2 = Clic2+1
    	 time.sleep(2)
        elif buttona.is_pressed:
               Clicb = Clicb + 1
    	   print(Clicb)
               red.on()
               time.sleep(0.2)
               red.off()
               time.sleep(1)
    if Clicb == 1:
       import subprocess
       subprocess.call(['setxkbmap', 'be'])
       subprocess.call(['xdotool', 'type', '1']) 
    elif Clicb == 2:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '2'])
    elif Clicb == 3:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '3'])
    elif Clicb == 4:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '4'])
    elif Clicb == 5:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '5'])
    elif Clicb == 6:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '6'])
    elif Clicb == 7:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '7'])
    elif Clicb == 8:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '8'])
    while Clic2<3:
        if buttonb.is_pressed :
    	 Clic2 = Clic2+1
    	 time.sleep(2)
        elif buttona.is_pressed:
               Clicc = Clicc + 1
    	   print(Clicc)
               red.on()
               time.sleep(0.2)
               red.off()
               time.sleep(1)
    if Clicc == 1:
       import subprocess
       subprocess.call(['setxkbmap', 'be'])
       subprocess.call(['xdotool', 'type', 'a']) 
    elif Clicc == 2:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'b'])
    elif Clicc == 3:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'c'])
    elif Clicc == 4:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'd'])
    elif Clicc == 5:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'e'])
    elif Clicc == 6:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'f'])
    elif Clicc == 7:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'g'])
    elif Clicc == 8:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', 'h'])
    while Clic2<4:
        if buttonb.is_pressed :
    	 Clic2 = Clic2+1
    	 time.sleep(2)
        elif buttona.is_pressed:
               Clicd = Clicd + 1
    	   print(Clicd)
               red.on()
               time.sleep(0.2)
               red.off()
               time.sleep(1)
    if Clicd == 1:
       import subprocess
       subprocess.call(['setxkbmap', 'be'])
       subprocess.call(['xdotool', 'type', '1']) 
    elif Clicd == 2:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '2'])
    elif Clicd == 3:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '3'])
    elif Clicd == 4:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '4'])
    elif Clicd == 5:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '5'])
    elif Clicd == 6:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '6'])
    elif Clicd == 7:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '7'])
    elif Clicd == 8:
         import subprocess
         subprocess.call(['setxkbmap', 'be'])
         subprocess.call(['xdotool', 'type', '8'])
    while Clice<3:
        if buttona.is_pressed:
           Clice = Clice + 1 
           import subprocess
           subprocess.call(['setxkbmap', 'be'])
           subprocess.call(['xdotool', 'key', 'Return'])
           red.on()
           time.sleep(0.2)
           red.off()
           time.sleep(1)
    Je serais ravi de connaître vos suggestions !
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. Faire communiquer sinatra avec mon programme en python
    Par echo55 dans le forum Réseau/Web
    Réponses: 3
    Dernier message: 08/07/2016, 22h02
  2. Programmation Système Pipe : Faire un mini shell en Python
    Par Mass062 dans le forum Général Python
    Réponses: 2
    Dernier message: 28/04/2014, 08h56
  3. Faire communiquer deux programmes python
    Par bestdomdom dans le forum Général Python
    Réponses: 5
    Dernier message: 26/10/2006, 09h30
  4. Comment faire patienter un programme ?
    Par JlouisI dans le forum Débuter
    Réponses: 4
    Dernier message: 03/03/2003, 11h11

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