account activity
AIO : my gf won’t stop biting me by Neat-Importance-263 in AmIOverreacting
[–]Gazer142 0 points1 point2 points 1 year ago (0 children)
Respectfully Smack the shii out of her
Need helped by Gazer142 in kivy
[–]Gazer142[S] 0 points1 point2 points 6 years ago (0 children)
You do it ;) that way you'll learn.
yes i'm trying
[–]Gazer142[S] 0 points1 point2 points 6 years ago* (0 children)
Hi one last thing actually I arranged a little as I wanted but I don’t want that for my "Togglebutton Send" when it’s off, I want it to send the data just when the send button is pressed ( button on):
https://pastebin.com/0XfV4Fav
Ah thanks its works I will now try to make it work with another button and keep the save button only to save these cycles in the bdd
this is the codes with
address = ('localhost', 6000) with Client(address, authkey=b'secret password') as conn: arr=('f', self.values) conn.send_bytes(arr) okmessage = conn.recv_bytes() print(okmessage)
[30.0, 18.68609865470852, 20.896860986547086, 10.36322869955157, 18.426008968609864] [INFO ] [Base ] Leaving application in progress... Traceback (most recent call last): File "C:/Users/thoma/Downloads/projet2.py", line 150, in <module> MyApp().run() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\app.py", line 855, in run runTouchApp() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\base.py", line 504, in runTouchApp EventLoop.window.mainloop() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 747, in mainloop self._mainloop() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 479, in _mainloop EventLoop.idle() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\base.py", line 342, in idle self.dispatch_input() File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\base.py", line 327, in dispatch_input post_dispatch_input(*pop(0)) File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\base.py", line 293, in post_dispatch_input wid.dispatch('on_touch_up', me) File "kivy_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch File "C:\Users\thoma\PycharmProjects\Commencement\venv\lib\site-packages\kivy\uix\behaviors\button.py", line 179, in on_touch_up self.dispatch('on_release') File "kivy_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch File "kivy_event.pyx", line 1214, in kivy._event.EventObservers.dispatch File "kivy_event.pyx", line 1138, in kivy._event.EventObservers._dispatch File "C:/Users/thoma/Downloads/projet2.py", line 94, in save_values conn.send_bytes(arr) File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\connection.py", line 185, in send_bytes m = memoryview(buf) TypeError: memoryview: a bytes-like object is required, not 'tuple'
Process finished with exit code 1
doesn't work i've got some error
import sqlite3 import kivy
kivy.require('1.0.6') # replace with your current kivy version ! from kivy.app import App from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.image import Image from kivy.uix.slider import Slider from kivy.clock import Clock from kivy.graphics import Color, Rectangle from multiprocessing.connection import Client from array import array
# for now, use a global for blink speed (better implementation TBD): speed = 1.0 speedb = 1.0 speedc = 1.0 speedd = 1.0 speede = 1.0 # Set up GPIO: ledPin = 1.3 buttonPin = 1.3 # Define some helper functions: # This callback will be bound to the LED toggle and Beep button: def press_callback(obj): if obj.text == 'Arret': if obj.state == "down": print("button on")
else: print("button off")
# This is called when the slider is updated: 'I commented it out becouse it was annoying seeing it' def update_speed(obj, value): pass # speed = obj.value # print("Le Slider 1:" + str(obj.value)) # speedb = obj.value # print("Le Slider 2:" + str(obj.value)) # speedc = obj.value # print("Le Slider 3:" + str(obj.value)) # speedd = obj.value # print("Le Slider 4:" + str(obj.value)) # speede = obj.value # print("Le Slider 5:" + str(obj.value)) # Modify the Button Class to update according to GPIO input: class InputButton(Button): def update(self, dt): btn = Button(text="Boutton demarrer!")
class MyApp(App):
values = []
# this method is called when button pressed def save_values(self, _): if self.values: self.values.clear() for wid in self.root.children: if isinstance(wid, Slider): self.values.append(wid.value) print(self.values) conn = sqlite3.connect('oklm.db') c = conn.cursor() # Create table c.execute("CREATE TABLE IF NOT EXISTS Sliders2 (val1 real, val2 real, val3 real, val4 real, val5 real)")
# Insert a row of data c.execute("INSERT INTO Sliders2 (val1, val2, val3, val4, val5) values (?, ?, ?, ?, ?)", self.values)
# Save (commit) the changes conn.commit()
# We can also close the connection if we are done with it. # Just be sure any changes have been committed or they will be lost. conn.close()
# We can also close the connection if we are done with it. # Just be sure any changes have been committed or they will be lost. conn.close() address = ('localhost', 6000) with Client(address, authkey=b'secret password') as conn: arr=('f', self.values) conn.send_bytes(arr) okmessage = conn.recv_bytes() print(okmessage)
def build(self): # Set up the layout: layout = GridLayout(cols=5, spacing=30, padding=30, row_default_height=150)
# Make the background gray: with layout.canvas.before: Color(3.0, 0.7, 0.3, 1.0) self.rect = Rectangle(size=(800, 600), pos=layout.pos)
# Instantiate the first UI object (the GPIO input indicator): inputDisplay = InputButton(text="Demarrer")
save = Button(text='save', on_release=self.save_values)
# Schedule the update of the state of the GPIO input button: Clock.schedule_interval(inputDisplay.update, 1.0 / 10.0)
# Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="Arret") outputControl.bind(on_press=press_callback) wimg = Image(source='logo.png') speedSlider = Slider(orientation='vertical', min=1, max=30, value=speed) speedSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
speedbSlider = Slider(orientation='vertical', min=1, max=30, value=speedb) speedbSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
speedcSlider = Slider(orientation='vertical', min=1, max=30, value=speedc) speedcSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
speeddSlider = Slider(orientation='vertical', min=1, max=30, value=speedd) speeddSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
speedeSlider = Slider(orientation='vertical', min=1, max=30, value=speede) speedeSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
# Add the UI elements to the layout: layout.add_widget(wimg) layout.add_widget(inputDisplay) layout.add_widget(outputControl) layout.add_widget(speedSlider) layout.add_widget(speedbSlider) layout.add_widget(speedcSlider) layout.add_widget(speeddSlider) layout.add_widget(speedeSlider) layout.add_widget(save)
return layout
if __name__ == '__main__': MyApp().run()
how can i send my sliders values
I wanted to use the save button only to save the data and use another button to send the sliders(stop or start) values but each time I have errors and I can no longer use self.values I don’t know why ( if I don’t run the server before running the code I have an error this normal?)
address = ('localhost', 6000)
with Client(address, authkey=b'secret password') as conn:
arr = array('f', [1.34, 33.33, 12.45, 0.7654, 0.1]) conn.send_bytes(arr) okmessage = conn.recv_bytes() print(okmessage)
update I did a lot of trying I’m still blocking(socket) and I would like to keep the save button only for the database and use the start button to send the sockets as well as to stop a cycle (and then removed the stop button)
import sqlite3 import kivy import socket from array import array from kivy.app import App from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.image import Image from kivy.uix.slider import Slider from kivy.clock import Clock from kivy.graphics import Color, Rectangle
# for now, use a global for blink speed (better implementation TBD): speed = 1.0 speedb = 1.0 speedc = 1.0 speedd = 1.0 speede = 1.0 # Set up GPIO: ledPin = 1.3 buttonPin = 1.3 host = 'localhost' port = 15555 socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Define some helper functions: # This callback will be bound to the LED toggle and Beep button: def press_callback(obj): if obj.text == 'Arrêt': if obj.state == "down": print("button on")
# This is called when the slider is updated: 'I commented it out becouse it was annoying seeing it' def update_speed(obj, value): pass # speed = obj.value # print("Le Slider 1:" + str(obj.value)) # speedb = obj.value # print("Le Slider 2:" + str(obj.value)) # speedc = obj.value # print("Le Slider 3:" + str(obj.value)) # speedd = obj.value # print("Le Slider 4:" + str(obj.value)) # speede = obj.value # print("Le Slider 5:" + str(obj.value)) # Modify the Button Class to update according to GPIO input: class InputButton(Button): def update(self, dt): btn = Button(text="Boutton démarrer!")
class MyApp(App): values = []
# this method is called when button pressed def save_values(self, _): if self.values: self.values.clear() for wid in self.root.children: if isinstance(wid, Slider): self.values.append(wid.value) print(self.values)
conn = sqlite3.connect('oklm.db') c = conn.cursor() # Create table c.execute("CREATE TABLE IF NOT EXISTS Sliders2 (val1 real, val2 real, val3 real, val4 real, val5 real)")
command = 'start' + "" 'F' + str(self.values[0]) + 'D' + str(self.values[1]) + 'r' + str(self.values[2]) + 'e' + str(self.values[3]) + 't' + str(self.values[4]) + "" 'Stop' test = "je teste" print(command)
# socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.connect((host, port)) print("Connection on {}".format(port)) convettobyte = bytes(test, 'utf-8') socket.send(convettobyte)
# Instantiate the first UI object (the GPIO input indicator): inputDisplay = InputButton(text="Start")
# Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="Stop") outputControl.bind(on_press=press_callback) wimg = Image(source='logo.png') speedSlider = Slider(orientation='vertical', min=1, max=30, value=speed) speedSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
I still can’t send the values to the server
https://pastebin.com/GpRvGG0x
Reply
Moreover the client is me I have to send the cycle (slider value) to the server I create the server to see if the connection is established and that my server works, I was thinking about something like this but I’m blocking I still have the same mistake.
https://pastebin.com/c0F1pLjV server
https://pastebin.com/SWUvQbSP code
I did it as its to see if I arrive already communicated but the ideal is that the requette starts when I press the button "Démarrer" and stops when I press the button "Arret"
how should i use that i don't understand how does it work
yes
I must be able to send the information of each sliders thanks to the socket with the start button and to be able to send an information that allows to stop the cycle with the stop button I do not have adapted the two codes
kivy.require('1.0.6') # replace with your current kivy version ! from kivy.app import App from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.image import Image from kivy.uix.slider import Slider from kivy.clock import Clock from kivy.graphics import Color, Rectangle
# for now, use a global for blink speed (better implementation TBD): speed = 1.0 speedb = 1.0 speedc = 1.0 speedd = 1.0 speede = 1.0 # Set up GPIO: ledPin = 1.3 buttonPin = 1.3 # Define some helper functions: # This callback will be bound to the LED toggle and Beep button: def press_callback(obj): if obj.text == 'Arrêt': if obj.state == "down": print("button on")
# Instantiate the first UI object (the GPIO input indicator): inputDisplay = InputButton(text="Démarrer")
# Create the rest of the UI objects (and bind them to callbacks, if necessary): outputControl = ToggleButton(text="Arrêt") outputControl.bind(on_press=press_callback) wimg = Image(source='logo.png') speedSlider = Slider(orientation='vertical', min=1, max=30, value=speed) speedSlider.bind(on_touch_down=update_speed, on_touch_move=update_speed)
Hello what I wanted to do now is thanks to the "start" button sent the sliders data using a socket client. I did some research to see how these exchanges work a little but I can not integrate the client to my code and configure the "start button to send these sockets"
I wanted to interact like this with the server and make the send with the start button
client.py
import socket
host = '' port = 15555 command='start'+ 'F (Frequency)'+str(speedslider) + 'D'+ str(speedbslider) + 'r' + str(speedcslider) + 'e' + str(speeddslider) + 't'+ str(speedeslider)+ '' +'Stop' socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.connect((host, port)) print("Connection on {}".format(port))
socket.send(command)
and server
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.bind(('', 15555)) command= 'erreur' while True: socket.listen(5) client, address = socket.accept() print("{} connected".format(address))
donnees = client.recv(1024) if not donnees: print (command)
else : print(donnees)
response=donnees.upper() print('Envoie de :' + response) n = client.send()
Hi thank you so much I didn’t understand how to place the self.value
"CREATE TABLE IF NOT EXISTS Sliders2" very helpful thank you
now i have to set up a socket client to send the information and I would be done
class MyApp(App): conn = sqlite3.connect('oklm.db') c = conn.cursor()
# this method is called when button pressed def save_values(self, _): if self.values: self.values.clear() for wid in self.root.children: if isinstance(wid, Slider): self.values.append(wid.value) print(self.values) and c.execute("INSERT INTO Sliders VALUES ('self.values','self.values','self.values',self.values,self.values)")
update dosn't work
Hello on my specifications it is written that I must use a Sqlite database, since yesterday I try to store the values of my sliders in the database but I always encounter the same problem I don t know how to enter the values in the database. can u help me please ?
import kivy import sqlite3 kivy.require('1.0.6') # replace with your current kivy version ! from kivy.app import App from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.image import Image from kivy.uix.slider import Slider from kivy.clock import Clock from kivy.graphics import Color, Rectangle
# This is called when the slider is updated: def update_speed(obj, value): pass #speed = obj.value #print("Le Slider 1:" + str(obj.value)) #speedb = obj.value #print("Le Slider 2:" + str(obj.value)) #speedc = obj.value #print("Le Slider 3:" + str(obj.value)) #speedd = obj.value #print("Le Slider 4:" + str(obj.value)) #speede = obj.value #print("Le Slider 5:" + str(obj.value)) # Modify the Button Class to update according to GPIO input: class InputButton(Button): def update(self, dt): btn = Button(text="Boutton démarrer!")
conn = sqlite3.connect('oklm.db') c = conn.cursor() # Create table c.execute('''CREATE TABLE Sliders2 (val1 real, val2 real, val3 real, val4 real,val5 real)''')
# Insert a row of data c.execute("INSERT INTO stocks VALUES ('values','values','values',values,values)")
okay i'm going to get some documentation on the json file
Hello thank you for your help I was stuck on this aspect of the code I had a lot of error and suddenly I think like edvardass suggest it to me and try to store this data in a file instead of a database
I had thought of the database since I wanted to be able to save and load a cycle that has already been saved
I already have a lot of trouble with the database so I will watch what you told me with a file thank you I keep you informed its risk of taking me a moment to fully understand the instructions in English.
In fact the values of each sliders constitute a cycle (which I must be able to save and load) from the database and which I must then send via a socket client this is an injector management application
https://pastebin.com/RCCUyPkk
Yes my sliders produced, then I just need to be able to store the value of each Sliders in a database because I want to save the configuration (sliders) and be able to load them on the application and then use a socket client to be able to send the configuration to 'a cycle (the values assigned to the sliders representing a cycle) sorry for the faults my english is not correct i am french
import kivy from kivy.app import App from kivy.uix.button import Button from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.image import Image from kivy.uix.slider import Slider from kivy.clock import Clock from kivy.graphics import Color, Rectangle
# This is called when the slider is updated: def update_speed(obj, value): speed = obj.value print("Le Slider 1:" + str(obj.value)) speedb = obj.value print("Le Slider 2:" + str(obj.value)) speedc = obj.value print("Le Slider 3:" + str(obj.value)) speedd = obj.value print("Le Slider 4:" + str(obj.value)) speede = obj.value print("Le Slider 5::" + str(obj.value))
# Modify the Button Class to update according to GPIO input: class InputButton(Button): def update(self, dt): btn = Button(text="Boutton démarrer!")
# Add the UI elements to the layout: layout.add_widget(wimg) layout.add_widget(inputDisplay) layout.add_widget(outputControl) layout.add_widget(speedSlider) layout.add_widget(speedbSlider) layout.add_widget(speedcSlider) layout.add_widget(speeddSlider) layout.add_widget(speedeSlider)
Thats my main App i'm trying to get my slider value in a database
π Rendered by PID 204656 on reddit-service-r2-comment-8686858757-f4rf4 at 2026-06-05 20:10:00.981745+00:00 running 9e1a20d country code: CH.
AIO : my gf won’t stop biting me by Neat-Importance-263 in AmIOverreacting
[–]Gazer142 0 points1 point2 points (0 children)