Похожие чаты

# disclaimer: i'm completly new to python ### imports ### class MyWindow(Gtk.Window):

def __init__(self):
### irrelevant initialization of gtk ###

self.sio = socketio.Client()
self.sio.connect('http://localhost:3500')
Process(target=self.sio.wait).start()

### irrelevant initialization of gtk ###

### irrelevant functions for event handlers of gtk ###

# here's the issue. I want to hook up event listeners to the socket
# but i can't access the socket object(?) to put it in the decorator.
# how can i access `self.sio` in here to use it in the decorators?
@sio.on('connect')
def on_connect(self):
print('connection established')

@sio.on('logged in')
def on_message(self, data):
print(data)
print('user id: ', data['user']['id'])

@sio.on('disconnect')
def on_disconnect(self):
print('disconnected from server')

### irrelevant initialization of gtk ###

4 ответов

5 просмотров

It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.

void (lider de ANTIFA)- Автор вопроса

ping

is your question simply how to use the socketio decorator from the class ?

Похожие вопросы

Обсуждают сегодня

Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
10
А чем вам питонисты не угодили?😂
.
79
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
52
Asus, норм фирма для ноутов?
Артем Записной
20
А дальше что?.. Записать в файл, потом в Код?.. И потом разбирать как-то?..
Хаскель Моисеевич Гопник
14
доброго времени. db, dw и прочие исполняются при трансляции или при выполнении программы?
lutayyy
10
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
И ещё - определить, имеет ли он доступ к интернету очень просто - смотрим всех пользователей сети. И да, как оно без сети передаст данные в куда то?
BytePixel 🐧
15
Ясн. Но я всеравно к кедам отношусь с опасением. Чисто субьективное кедосозерцание. Что касаемо "восторга изяшности кед" так и не вкурил, хотя много слышал, пока не поставил с...
Артем Записной
30
Hi guys which one is better ?
A
12
Карта сайта