Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SipAndPuff4Butiá
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Santiago Freire Lopez
SipAndPuff4Butiá
Commits
f93d1b87
Commit
f93d1b87
authored
3 years ago
by
Santiago Freire Lopez
Browse files
Options
Downloads
Patches
Plain Diff
added latin characters and fixed some bugs
parent
4ccc035b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dicts.py
+8
-0
8 additions, 0 deletions
dicts.py
principal.py
+48
-28
48 additions, 28 deletions
principal.py
with
56 additions
and
28 deletions
dicts.py
+
8
−
0
View file @
f93d1b87
...
...
@@ -13,6 +13,9 @@ keyTimeout = settings.get('keyTimeout')
mouseSpeed
=
settings
.
get
(
'
mouseSpeed
'
)
sipTimeout
=
settings
.
get
(
'
sipTimeout
'
)
#Caracteres especiales que deben ser ingresados pegándolos con ctrl-v
cEsp
=
{
'
Ñ
'
,
'"'
,
'
Á
'
,
'
É
'
,
'
Í
'
,
'
Ó
'
,
'
Ú
'
}
# obtenido parcialmente de https://github.com/grantwinney/52-Weeks-of-Pi/tree/master/02-Send-Morse-Code-Via-Button-Click
morse
=
{
...
...
@@ -44,6 +47,11 @@ morse = {
'
-..-
'
:
'
X
'
,
'
-.--
'
:
'
Y
'
,
'
--..
'
:
'
Z
'
,
'
.-.--
'
:
'
Á
'
,
'
.--..
'
:
'
É
'
,
'
.--.-
'
:
'
Í
'
,
'
.---.
'
:
'
Ó
'
,
'
-..--
'
:
'
Ú
'
,
#Números
'
.----
'
:
'
1
'
,
...
...
This diff is collapsed.
Click to expand it.
principal.py
+
48
−
28
View file @
f93d1b87
...
...
@@ -10,6 +10,7 @@ import time
import
json
import
subprocess
import
pyperclip
from
playsound
import
playsound
import
PySimpleGUI27
as
sg
###DICCIONARIOS###
...
...
@@ -29,7 +30,6 @@ robot = usb4butia.USB4Butia()
#Para poder mover el cursor a los bordes de la pantalla
pyautogui
.
FAILSAFE
=
False
#Chequeo inicial
if
robot
.
getButton
(
5
)
==
-
1
:
if
robot
.
getButton
(
4
)
==
-
1
:
...
...
@@ -118,7 +118,7 @@ def guardarAjustes(newSettings):
with
open
(
'
settings.json
'
,
'
w
'
)
as
setDict
:
json
.
dump
(
resSettings
,
setDict
)
def
keyboard
(
window
):
def
keyboard
(
window
,
salgo
):
cambiarTextoGUI
(
'
_OUTPUT_
'
,
window
,
dicts
.
texto
.
get
(
'
keyboardBig
'
))
...
...
@@ -133,7 +133,7 @@ def keyboard(window):
resCaracter
=
''
while
True
and
resCaracter
!=
'
EOM
'
and
resCaracter
!=
'
eom
'
:
while
resCaracter
!=
'
EOM
'
and
resCaracter
!=
'
eom
'
and
salgo
==
False
:
t_end
=
time
.
time
()
+
tiempoChar
...
...
@@ -154,6 +154,9 @@ def keyboard(window):
#Agrego a la secuencia Morse
resSecuencia
=
(
resSecuencia
+
'
-
'
)
#Feedback sonoro
# playsound('dash.wav')
#Actualizo el feedback
cambiarTextoGUI
(
'
_FEEDBACK_
'
,
window
,
resSecuencia
)
...
...
@@ -166,7 +169,10 @@ def keyboard(window):
#Agrego a la secuencia Morse
resSecuencia
=
(
resSecuencia
+
'
.
'
)
#Feedback sonoro
# playsound('dot.wav')
#Actualizo el feedback
cambiarTextoGUI
(
'
_FEEDBACK_
'
,
window
,
resSecuencia
)
...
...
@@ -194,11 +200,17 @@ def keyboard(window):
#Si no recibí ningún caracter especial, presiono la tecla.
if
resCaracter
!=
None
and
resCaracter
!=
'
EOM
'
and
resCaracter
!=
'
eom
'
and
resCaracter
!=
'
MAYUS
'
and
resCaracter
!=
'
mayus
'
:
# press(resCaracter)
pyperclip
.
copy
(
resCaracter
)
pyperclip
.
paste
()
# pyautogui.hotkey("ctrl", "v")
#Si los caracteres están en los que puede insertar pyautogui, presiono la tecla.
if
resCaracter
not
in
dicts
.
cEsp
:
press
(
resCaracter
)
else
:
#Si no, copio el caracter al portapapeles y lo pego.
#Lo que tiene esto es que no sirve para la terminal, por ejemplo, pues se pega con ctrl-shift-v.
#Sin embargo estos caracteres prácticamente no se usan normalmente en terminales así que no habría problema.
pyperclip
.
copy
(
resCaracter
)
pyautogui
.
hotkey
(
"
ctrl
"
,
"
v
"
)
#Si recibo una secuencia vacía o que no corresponde a ningún caracter
elif
resCaracter
==
None
:
cambiarTextoGUI
(
'
_TRANSLATION_
'
,
window
,
'
Nada
'
)
...
...
@@ -217,18 +229,22 @@ def keyboard(window):
else
:
cambiarTextoGUI
(
'
_TRANSLATION_
'
,
window
,
'
Cancelado
'
)
#Cuando se ingresa un EOM, vuelvo al módulo de mouse.
#Cuando se ingresa un EOM, vuelvo al módulo de mouse
saliendo del subprograma
.
sg
.
PopupAutoClose
(
'
Cambiando a mouse.
'
,
keep_on_top
=
True
)
mouse
(
textWindow
)
salgo
=
True
def
mouse
(
window
,
salgo
):
def
mouse
(
window
):
# print "entré."
#El error en X está entre estos dos prints, pues con el debug vemos que no pasa de acá
cambiarTextoGUI
(
'
_OUTPUT_
'
,
window
,
dicts
.
texto
.
get
(
'
mouseBig
'
))
#Elimino el feedback de la parte de teclado
cambiarTextoGUI
(
'
_FEEDBACK_
'
,
window
,
''
)
cambiarTextoGUI
(
'
_TRANSLATION_
'
,
window
,
''
)
# print "cambié texto en gui."
#Guardo el módulo que está ejecutándose actualmente
actual
=
'
mouse
'
...
...
@@ -254,43 +270,41 @@ def mouse(window):
etapa
=
0
event
,
values
=
window
.
Read
(
timeout
=
10
)
# print "volví a leer events and values."
#Mientras no reciba la orden de cambiar de módulo
while
cambio
!=
1
:
while
cambio
!=
1
and
salgo
==
False
:
soplido
=
robot
.
getButton
(
5
)
aspiro
=
robot
.
getButton
(
4
)
cambio
=
robot
.
getButton
(
2
)
#Mantengo el cursor quieto a menos que reciba orden de moverlo o hacer click
while
etapa
==
0
and
cambio
==
0
:
while
etapa
==
0
and
cambio
==
0
and
salgo
==
False
:
# print "entré al while."
#Será acá el error del X Window System?
#Si no recibo nada fuera de lo normal, no hago nada.
while
aspiro
==
0
and
soplido
==
0
and
cambio
==
0
and
event
!=
'
Guardar
'
and
event
!=
'
Ajustes
'
and
event
!=
'
Salir
'
and
event
!=
'
Guia Morse
'
:
event
,
values
=
window
.
Read
(
timeout
=
10
)
while
aspiro
==
0
and
soplido
==
0
and
cambio
==
0
and
salgo
==
False
and
event
!=
'
Guardar
'
and
event
!=
'
Ajustes
'
and
event
!=
'
Salir
'
and
event
!=
'
Guia Morse
'
:
event
,
values
=
window
.
Read
(
timeout
=
10
)
# print "leí otra vez events and values."
soplido
=
robot
.
getButton
(
5
)
aspiro
=
robot
.
getButton
(
4
)
cambio
=
robot
.
getButton
(
2
)
if
event
==
'
Guardar
'
:
event
=
''
newValues
=
window
.
read
()
#Tiene formato JSON
guardarAjustes
(
newV
alues
[
1
]
)
sg
.
PopupAutoClose
(
'
Ajustes guardados.
'
,
keep_on_top
=
True
)
guardarAjustes
(
v
alues
)
sg
.
PopupAutoClose
(
'
Ajustes guardados.
Reinicie el programa para que tengan efecto.
'
,
keep_on_top
=
True
)
if
event
==
'
Guia Morse
'
:
event
=
''
#Abrir la guía almacenada en el archivo guide.jpg con el visor de imágenes predeterminado
subprocess
.
call
([
'
xdg-open
'
,
'
guide.jpg
'
])
# if event == 'Ajustes':
# event = ''
# ajustes(actual,window)
if
event
==
'
Salir
'
:
# sg.PopupYesNo('Esta seguro de que desea salir?')
event
=
''
quit
()
...
...
@@ -320,7 +334,8 @@ def mouse(window):
#Para no ingresar caracteres accidentalmente por seguir aspirando
sg
.
PopupAutoClose
(
'
Puede dejar de aspirar.
'
,
keep_on_top
=
True
)
keyboard
(
textWindow
)
# keyboard(textWindow)
salgo
=
True
#Paso a la siguiente etapa
if
soplido
==
1
:
...
...
@@ -396,7 +411,7 @@ def mouse(window):
soplido
=
robot
.
getButton
(
5
)
#Cambio de módulo, de mouse a teclado.
keyboard
(
textWindow
)
#
keyboard(textWindow)
#Cambio el texto del elemento identificado por 'key' en la ventana 'window' por 'text'
def
cambiarTextoGUI
(
key
,
window
,
text
):
...
...
@@ -460,8 +475,13 @@ textWindow = sg.Window('Sip&Puff4Butia', combinedLayout)
event
,
values
=
textWindow
.
Read
(
timeout
=
10
)
#Arranco con la función mouse
mouse
(
textWindow
)
#Ejecuto una función otra tras otra
#Quizás pueda poner un solo salgo fuera del while, pues sería una variable global y no importaría qué pasase con ella dentro de los subprogramas.
while
True
:
salgo
=
False
mouse
(
textWindow
,
salgo
)
salgo
=
False
keyboard
(
textWindow
,
salgo
)
#Cierro la ventana al finalizar
textWindow
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment