I am on a projet for school using kivy on Rasp pi 4 Model B.
When i use my mouse ( with vnc), function get call one time but when i use touchscreen, funtion get call twice.
I have already try some modification on my kivy config.ini but nothing works.
My python code :
class WindowAdminConfigLockerESPAdd(Screen):
global deviceLocalName
number = ''
def on_enter(self):
self.ids.TxtAdminConfigLockerESP.text= 'Ajouter des casiers à l ' + deviceLocalName
pass
def clearTxt(self):
self.ids.TxtPin.text=''
pass
def PressedButton(self,button):
print("Appel fonction")
self.ids.TxtPin.text = self.ids.TxtPin.text + str(button)
self.number = self.number + str(button)
pass
def Validate(self):
if(nlc.addNumberLockersConfig(deviceLocalName,self.number)):
nlc.saveNumberLockersConfigFile()
self.clearTxt()
pass
class FenetreManager(ScreenManager):
pass
kv = Builder.load_file("monkv.kv")
class MonApplicationPrincipale(App):
def build(self):
Window.clearcolor = (223/255,223/255,223/255,1)
return kv
if __name__=="__main__":
MonApplicationPrincipale().run()
My .kv part
<WindowAdminConfigLockerESPAdd>:
name: "adminConfigLockerESPAdd"
BoxLayout:
canvas :
Rectangle:
source:'helmo.jfif'
size: self.size
pos: self.pos
orientation: "vertical"
spacing:
20
padding:
20
size:
root.width, root.height
Label:
id : TxtAdminConfigLockerESP
halign : "center"
text:""
BoxLayout:
orientation: "horizontal"
spacing:
20
padding:
20
TextInput:
id: TxtPin
text:""
halign:"right"
font_size:35
size_hint:(1,1)
GridLayout:
cols:3
rows:4
size_hint:(1,4)
spacing : 2
Button:
size_hint:(.33,.25)
font_size:32
text:"1"
on_press:root.PressedButton(1)
Button:
size_hint:(.33,.25)
font_size:32
text:"2"
on_press:root.PressedButton(2)
Button:
size_hint:(.33,.25)
font_size:32
text:"3"
on_press:root.PressedButton(3)
Button:
size_hint:(.33,.25)
font_size:32
text:"4"
on_press:root.PressedButton(4)
Button:
size_hint:(.33,.25)
font_size:32
text:"5"
on_press:root.PressedButton(5)
Button:
size_hint:(.33,.25)
font_size:32
text:"6"
on_press:root.PressedButton(6)
Button:
size_hint:(.33,.25)
font_size:32
text:"7"
on_press:root.PressedButton(7)
Button:
size_hint:(.33,.25)
font_size:32
text:"8"
on_press:root.PressedButton(8)
Button:
size_hint:(.33,.25)
font_size:32
text:"9"
on_press:root.PressedButton(9)
Button:
size_hint:(.33,.25)
font_size:32
text:""
Button:
size_hint:(.33,.25)
font_size:32
text:"0"
on_press:root.PressedButton(0)
Button:
id: clearTxtPin
size_hint:(.33,.25)
font_size:32
text:"C"
background_color : (104/255,104/255,104/255,1)
on_press : root.clearTxt()
RoundedButton:
id : BtnValidatePin
text:"Valider"
on_release:
root.Validate()
root.manager.transition.direction = "left"
pos_hint:
{'center_x':0.5}
size_hint:
(0.9,0.9)
RoundedButton:
text:"Retour"
pos_hint:
{'center_x':0.5}
size_hint:
(0.9,0.9)
on_release:
#root.clear()
app.root.current = "adminChoice"
root.manager.transition.direction = "right"
My kivy config.ini
[kivy]
keyboard_repeat_delay = 300
keyboard_repeat_rate = 30
log_dir = logs
log_enable = 1
log_level = info
log_name = kivy_%y-%m-%d_%_.txt
window_icon =
keyboard_mode =
keyboard_layout = qwerty
desktop = 1
exit_on_escape = 1
pause_on_minimize = 0
kivy_clock = default
default_font = ['Roboto', 'data/fonts/Roboto-Regular.ttf', 'data/fonts/Roboto-Italic.ttf', 'data/fonts/Roboto-Bold.ttf', 'data/fonts/Roboto-BoldItalic.ttf']
log_maxfiles = 100
window_shape = data/images/defaultshape.png
config_version = 24
[graphics]
display = -1
fullscreen = 0
height = 600
left = 0
maxfps = 60
multisamples = 2
position = auto
rotation = 0
show_cursor = 1
top = 0
width = 800
resizable = 1
borderless = 0
window_state = visible
minimum_width = 0
minimum_height = 0
min_state_time = .035
allow_screensaver = 1
shaped = 0
vsync =
verify_gl_main_thread = 1
custom_titlebar = 0
custom_titlebar_border = 5
always_on_top = 0
show_taskbar_icon = 1
[input]
mouse = mouse
%(name)s = probesysfs
[postproc]
double_tap_distance = 20
double_tap_time = 250
ignore = []
jitter_distance = 0
jitter_ignore_devices = mouse,mactouch,
retain_distance = 50
retain_time = 0
triple_tap_distance = 20
triple_tap_time = 375
[widgets]
scroll_timeout = 250
scroll_distance = 20
scroll_friction = 1.
scroll_stoptime = 300
scroll_moves = 5
[modules]
[network]
useragent = curl
implementation = default
The function need to be call only once cause if u try to put "67" that put "6677".
If someone know,
Thanks,
My problem was this line in the KIVY config.
mouse = mouse
As i use sudo python3 and not python3 to execute the code, the KIVY config use was the admin one and not the usr one.
So with that commands, i change the admin KIVY config
sudo su
cd /root/.kivy
nano config.ini